advent-of-code

advent of code attempts
git clone git://bvnf.space/advent-of-code.git
Log | Files | Refs

a.tcl (367B)


      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
set txt [read -nonewline stdin]
set lines [split $txt "\n"]
set m {one o1e two t2o three t3e four f4r five f5e six s6x seven s7n eight e8t nine n9e}

set tot 0
foreach line $lines {
	set line [string map $m $line]
	set line [string map $m $line]
	regsub -all {[^0-9]} $line {} line
	set code [string index $line 0][string index $line end]
	incr tot $code
}
puts $tot