aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-137/abigail/tcl/ch-1.tcl26
-rw-r--r--challenge-137/abigail/tcl/ch-2.tcl27
2 files changed, 53 insertions, 0 deletions
diff --git a/challenge-137/abigail/tcl/ch-1.tcl b/challenge-137/abigail/tcl/ch-1.tcl
new file mode 100644
index 0000000000..b4b6db3ab5
--- /dev/null
+++ b/challenge-137/abigail/tcl/ch-1.tcl
@@ -0,0 +1,26 @@
+#
+# See ../README.md
+#
+
+#
+# Run as: tclsh ch-1.tcl
+#
+
+set start_years [list 1600 2000]
+set long_year_offsets [list \
+ 4 9 15 20 26 32 37 43 48 54 60 65 71 76 82 \
+ 88 93 99 105 111 116 122 128 133 139 144 150 \
+ 156 161 167 172 178 184 189 195 201 207 212 218 \
+ 224 229 235 240 246 252 257 263 268 274 280 285 291 296 \
+ 303 308 314 320 325 331 336 342 348 353 359 364 370 \
+ 376 381 387 392 398 ]
+
+
+foreach start_year $start_years {
+ foreach offset $long_year_offsets {
+ set year [expr $start_year + $offset]
+ if {1900 <= $year && $year <= 2100} {
+ puts $year
+ }
+ }
+}
diff --git a/challenge-137/abigail/tcl/ch-2.tcl b/challenge-137/abigail/tcl/ch-2.tcl
new file mode 100644
index 0000000000..0c5c9ecfd8
--- /dev/null
+++ b/challenge-137/abigail/tcl/ch-2.tcl
@@ -0,0 +1,27 @@
+#
+# See ../README.md
+#
+
+#
+# Run as: tclsh ch-2.tcl < input-file
+#
+
+proc reverse num {
+ set rev 0
+ while {$num > 0} {
+ set rev [expr $rev * 10]
+ set rev [expr $rev + [expr $num % 10]]
+ set num [expr $num / 10]
+ }
+ return $rev
+}
+
+proc ly n {
+ if {$n >= 10000000} {return 1}
+ if {$n == [reverse $n]} {return 0}
+ return [ly [expr $n + [reverse $n]]]
+}
+
+while {[gets stdin num] >= 0} {
+ puts [ly $num]
+}