aboutsummaryrefslogtreecommitdiff
path: root/challenge-150/abigail/tcl
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.freedom.nl>2022-01-31 15:50:18 +0100
committerAbigail <abigail@abigail.freedom.nl>2022-01-31 19:47:29 +0100
commit8487fe3f219c99dc720f99e2d53197c211deaf5b (patch)
tree97a4990ae8dfa3601c30efc7863baa5e5b4d4e37 /challenge-150/abigail/tcl
parentd52aa060e5c7663353b4d1a0186b608ef520dc9e (diff)
downloadperlweeklychallenge-club-8487fe3f219c99dc720f99e2d53197c211deaf5b.tar.gz
perlweeklychallenge-club-8487fe3f219c99dc720f99e2d53197c211deaf5b.tar.bz2
perlweeklychallenge-club-8487fe3f219c99dc720f99e2d53197c211deaf5b.zip
Week 150: Solutions
Diffstat (limited to 'challenge-150/abigail/tcl')
-rw-r--r--challenge-150/abigail/tcl/ch-1.tcl17
-rw-r--r--challenge-150/abigail/tcl/ch-2.tcl25
2 files changed, 42 insertions, 0 deletions
diff --git a/challenge-150/abigail/tcl/ch-1.tcl b/challenge-150/abigail/tcl/ch-1.tcl
new file mode 100644
index 0000000000..139521c54e
--- /dev/null
+++ b/challenge-150/abigail/tcl/ch-1.tcl
@@ -0,0 +1,17 @@
+#!/usr/local/opt/tcl-tk/bin/tclsh
+
+#
+# See https://theweeklychallenge.org/blog/perl-weekly-challenge-150
+#
+
+#
+# Run as: tclsh ch-1.tcl < input-file
+#
+
+while {[gets stdin line] >= 0} {
+ lassign [split $line " "] fib_prev fib_last
+ while {[string length $fib_last] < 51} {
+ lassign "$fib_last $fib_prev$fib_last" fib_prev fib_last
+ }
+ puts [string index $fib_last 50]
+}
diff --git a/challenge-150/abigail/tcl/ch-2.tcl b/challenge-150/abigail/tcl/ch-2.tcl
new file mode 100644
index 0000000000..404637f772
--- /dev/null
+++ b/challenge-150/abigail/tcl/ch-2.tcl
@@ -0,0 +1,25 @@
+#!/usr/local/opt/tcl-tk/bin/tclsh
+
+#
+# See https://theweeklychallenge.org/blog/perl-weekly-challenge-150
+#
+
+#
+# Run as: tclsh ch-2.tcl
+#
+
+set primes [list 2 3 5 7 11 13 17 19]
+
+for {set n 1} {$n <= 500} {incr n} {
+ set has_square 0
+ foreach p $primes {
+ if {$n % ($p * $p) == 0} {
+ set has_square 1
+ }
+ }
+ if {$has_square == 0} {
+ puts -nonewline "${n} "
+ }
+}
+
+puts ""