diff options
| author | Abigail <abigail@abigail.freedom.nl> | 2022-01-04 21:00:42 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.freedom.nl> | 2022-01-04 21:00:42 +0100 |
| commit | 04d7fd7e6e3c5c56b809efb18e7c1a5dbb12d6b1 (patch) | |
| tree | 454f464c43c54bdf869186bbaea553f75acf958d | |
| parent | 90913122376d0d23610f4eea69d956f6c26ed38b (diff) | |
| download | perlweeklychallenge-club-04d7fd7e6e3c5c56b809efb18e7c1a5dbb12d6b1.tar.gz perlweeklychallenge-club-04d7fd7e6e3c5c56b809efb18e7c1a5dbb12d6b1.tar.bz2 perlweeklychallenge-club-04d7fd7e6e3c5c56b809efb18e7c1a5dbb12d6b1.zip | |
Week 1: Tcl solutions
| -rw-r--r-- | challenge-001/abigail/README.md | 2 | ||||
| -rw-r--r-- | challenge-001/abigail/tcl/ch-1.tcl | 21 | ||||
| -rw-r--r-- | challenge-001/abigail/tcl/ch-2.tcl | 27 |
3 files changed, 50 insertions, 0 deletions
diff --git a/challenge-001/abigail/README.md b/challenge-001/abigail/README.md index 5ea37b3c0d..3965e2b75b 100644 --- a/challenge-001/abigail/README.md +++ b/challenge-001/abigail/README.md @@ -25,6 +25,7 @@ count the number of time we encountered an 'e'. * [Python](python/ch-1.py) * [R](r/ch-1.r) * [Ruby](ruby/ch-1.rb) +* [Tcl](tcl/ch-1.tcl) ## [Challenge #2](https://perlweeklychallenge.org/blog/perl-weekly-challenge-001/#challenge-2) @@ -54,3 +55,4 @@ upper bound from STDIN. * [Python](python/ch-2.py) * [R](r/ch-2.r) * [Ruby](ruby/ch-2.rb) +* [Tcl](tcl/ch-2.tcl) diff --git a/challenge-001/abigail/tcl/ch-1.tcl b/challenge-001/abigail/tcl/ch-1.tcl new file mode 100644 index 0000000000..6597b18b52 --- /dev/null +++ b/challenge-001/abigail/tcl/ch-1.tcl @@ -0,0 +1,21 @@ +#!/usr/local/opt/tcl-tk/bin/tclsh + +# +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-001 +# + +# +# Run as: tclsh ch-1.tcl < input-file +# + +while {[gets stdin line] >= 0} { + set count 0 + set index [string first e $line] + while {$index >= 0} { + incr count + set line [string replace $line $index $index E] + set index [string first e $line] + } + puts $line + puts $count +} diff --git a/challenge-001/abigail/tcl/ch-2.tcl b/challenge-001/abigail/tcl/ch-2.tcl new file mode 100644 index 0000000000..da334033a1 --- /dev/null +++ b/challenge-001/abigail/tcl/ch-2.tcl @@ -0,0 +1,27 @@ +#!/usr/local/opt/tcl-tk/bin/tclsh + +# +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-001 +# + +# +# Run as: tclsh ch-2.tcl < input-file +# + +while {[gets stdin max] >= 0} { + for {set i 1} {$i <= $max} {incr i} { + if {$i % 15 == 0} { + puts "fizzbuzz" + continue + } + if {$i % 5 == 0} { + puts "buzz" + continue + } + if {$i % 3 == 0} { + puts "fizz" + continue + } + puts $i + } +} |
