diff options
author | Aleteoryx <alyx@aleteoryx.me> | 2024-12-09 20:42:52 -0500 |
---|---|---|
committer | Aleteoryx <alyx@aleteoryx.me> | 2024-12-09 20:42:52 -0500 |
commit | 2807186474128e9d0fb52149630dc675b169cbfa (patch) | |
tree | 2d299fa9ae2db353b368b3be313e7fadd786bfc5 /2024/tcl/lib.tcl | |
parent | b16625cf6797da68f9c3c82a48509c7697d01040 (diff) | |
download | adventofcode-2807186474128e9d0fb52149630dc675b169cbfa.tar.gz adventofcode-2807186474128e9d0fb52149630dc675b169cbfa.tar.bz2 adventofcode-2807186474128e9d0fb52149630dc675b169cbfa.zip |
grid mode in tcl helper
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) + } } } |