summaryrefslogtreecommitdiffstats
path: root/2024/tcl/03.tcl
diff options
context:
space:
mode:
Diffstat (limited to '2024/tcl/03.tcl')
-rwxr-xr-x2024/tcl/03.tcl6
1 files changed, 2 insertions, 4 deletions
diff --git a/2024/tcl/03.tcl b/2024/tcl/03.tcl
index d1ff7c9..7f29b9a 100755
--- a/2024/tcl/03.tcl
+++ b/2024/tcl/03.tcl
@@ -1,14 +1,14 @@
#!/bin/env tclsh
source lib.tcl
-setup 3
+setup 3 data
puts {Part 1: Sum of mul(x,y) calls...}
set mulsum 0
set mulsum_cf 0
set cf 1
-foreach {inst a b} [regexp -all -inline {do\(\)|don't\(\)|mul\((\d+),(\d+)\)} [read $input]] {
+foreach {inst a b} [regexp -all -inline {do\(\)|don't\(\)|mul\((\d+),(\d+)\)} $input] {
switch -- [string range $inst 0 2] {
mul {
set inc [expr {$a * $b}]
@@ -26,8 +26,6 @@ foreach {inst a b} [regexp -all -inline {do\(\)|don't\(\)|mul\((\d+),(\d+)\)} [r
}
}
-close $input
-
puts "Sum: $mulsum"
puts ""