#!/usr/bin/env tclsh set y 0 while {[gets stdin line] >= 0} { if {$line eq {}} continue set x 0 foreach c [split $line {}] { set grid($x,$y) $c incr x } set width $x incr y } set height $y set x 0 set y 1 set trees 0 while {$y < $height} { set x [expr {($x+3) % $width}] if {$grid($x,$y) eq "#"} {incr trees} incr y } puts $trees