From 2807186474128e9d0fb52149630dc675b169cbfa Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Mon, 9 Dec 2024 20:42:52 -0500 Subject: grid mode in tcl helper --- 2024/tcl/lib.tcl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to '2024/tcl/lib.tcl') 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) + } } } -- cgit v1.2.3-70-g09d2