summaryrefslogtreecommitdiffstats
path: root/2024/tcl/02.tcl
diff options
context:
space:
mode:
Diffstat (limited to '2024/tcl/02.tcl')
-rwxr-xr-x2024/tcl/02.tcl4
1 files changed, 1 insertions, 3 deletions
diff --git a/2024/tcl/02.tcl b/2024/tcl/02.tcl
index dac290e..8cc14f3 100755
--- a/2024/tcl/02.tcl
+++ b/2024/tcl/02.tcl
@@ -22,7 +22,7 @@ proc row_errs {row} {
return $row_errs
}
-while {[gets $input report] != -1} {
+foreach report $input {
if ![row_errs $report] { incr safe_count; continue }
# naive, but handles a case like [1 4 2 3] where removing 2 makes it
# safe but an iterative approach only trips on [2]. backtracking
@@ -37,8 +37,6 @@ while {[gets $input report] != -1} {
incr dampened_safe_count $safe_count
-close $input
-
puts "Safe sequence count: $safe_count"
puts ""