diff options
Diffstat (limited to '2024/tcl/lib.tcl')
-rw-r--r-- | 2024/tcl/lib.tcl | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/2024/tcl/lib.tcl b/2024/tcl/lib.tcl index 048bce5..588a5e8 100644 --- a/2024/tcl/lib.tcl +++ b/2024/tcl/lib.tcl @@ -5,7 +5,7 @@ proc setup {n {mode lines}} { set n [string range 0$n end-1 end] upvar input input - set fd [open input.$n.txt] + set fd [open ../input.$n.txt] switch -- $mode { lines { @@ -19,6 +19,17 @@ proc setup {n {mode lines}} { fd { set input $fd } + grid { + set input(raw) [string trim [read $fd]] + set input(lines) [split $input(raw) "\r\n"] + set input(grid) {} + foreach line $input(lines) { + lappend input(grid) [split $line ""] + } + set input(h) [llength $input(grid)] + set input(w) [llength [lindex $input(grid) 0]] + set input(debug) $input(grid) + } } } |