aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-12-20 01:06:47 +0000
committerGitHub <noreply@github.com>2021-12-20 01:06:47 +0000
commit901dbda540db79d7750c5afa59898c54d29b1f13 (patch)
tree98c7f6514fab0eaf0f2d61e7c2fc439761a9aade
parent0caa5757fda342fcbf6356cbdfc07777640b2ad3 (diff)
parent13ebea25187e04a08fb804ce8496c67dc373000b (diff)
downloadperlweeklychallenge-club-901dbda540db79d7750c5afa59898c54d29b1f13.tar.gz
perlweeklychallenge-club-901dbda540db79d7750c5afa59898c54d29b1f13.tar.bz2
perlweeklychallenge-club-901dbda540db79d7750c5afa59898c54d29b1f13.zip
Merge pull request #5388 from Abigail/abigail/week-143
Abigail/week 143
-rw-r--r--challenge-143/abigail/README.md12
-rw-r--r--challenge-143/abigail/bash/ch-1.sh1
-rw-r--r--challenge-143/abigail/bc/ch-1.bc1
-rw-r--r--challenge-143/abigail/lua/ch-1.lua13
-rw-r--r--challenge-143/abigail/node/ch-1.js10
-rw-r--r--challenge-143/abigail/perl/ch-1.pl1
-rw-r--r--challenge-143/abigail/perl/ch-2.pl33
-rw-r--r--challenge-143/abigail/python/ch-1.py13
-rw-r--r--challenge-143/abigail/r/ch-1.r16
-rw-r--r--challenge-143/abigail/ruby/ch-1.rb7
-rw-r--r--challenge-143/abigail/t/ctest.ini8
-rw-r--r--challenge-143/abigail/t/input-1-12
-rw-r--r--challenge-143/abigail/t/input-2-13
-rw-r--r--challenge-143/abigail/t/output-1-1.exp2
-rw-r--r--challenge-143/abigail/t/output-2-1.exp3
-rw-r--r--challenge-143/abigail/tcl/ch-1.tcl5
16 files changed, 130 insertions, 0 deletions
diff --git a/challenge-143/abigail/README.md b/challenge-143/abigail/README.md
index d589af7261..48a5093c46 100644
--- a/challenge-143/abigail/README.md
+++ b/challenge-143/abigail/README.md
@@ -2,4 +2,16 @@
## Part 1
+* [Bash](bash/ch-1.sh)
+* [Bc](bc/ch-1.bc)
+* [Lua](lua/ch-1.lua)
+* [Node.js](node/ch-1.js)
* [Perl](perl/ch-1.pl)
+* [Python](python/ch-1.py)
+* [R](r/ch-1.r)
+* [Ruby](ruby/ch-1.rb)
+* [Tcl](tcl/ch-1.tcl)
+
+## Part 2
+
+* [Perl](perl/ch-2.pl)
diff --git a/challenge-143/abigail/bash/ch-1.sh b/challenge-143/abigail/bash/ch-1.sh
new file mode 100644
index 0000000000..db6e8363a1
--- /dev/null
+++ b/challenge-143/abigail/bash/ch-1.sh
@@ -0,0 +1 @@
+while read l;do echo $(($l));done
diff --git a/challenge-143/abigail/bc/ch-1.bc b/challenge-143/abigail/bc/ch-1.bc
new file mode 100644
index 0000000000..dc63c2a8f4
--- /dev/null
+++ b/challenge-143/abigail/bc/ch-1.bc
@@ -0,0 +1 @@
+bc < input-file
diff --git a/challenge-143/abigail/lua/ch-1.lua b/challenge-143/abigail/lua/ch-1.lua
new file mode 100644
index 0000000000..524751df03
--- /dev/null
+++ b/challenge-143/abigail/lua/ch-1.lua
@@ -0,0 +1,13 @@
+#!/opt/local/bin/lua
+
+--
+-- See ../README.md
+--
+
+--
+-- Run as: lua ch-1.lua < input-file
+--
+
+for line in io . lines () do
+ (load ("print (" .. line .. ")")) ()
+end
diff --git a/challenge-143/abigail/node/ch-1.js b/challenge-143/abigail/node/ch-1.js
new file mode 100644
index 0000000000..33be42296f
--- /dev/null
+++ b/challenge-143/abigail/node/ch-1.js
@@ -0,0 +1,10 @@
+#!/usr/local/bin/node
+
+//
+// Run as: node ch-1.js < input-file
+//
+
+ require ('readline')
+. createInterface ({input: process . stdin})
+. on ('line', line => {console . log (eval (line))})
+
diff --git a/challenge-143/abigail/perl/ch-1.pl b/challenge-143/abigail/perl/ch-1.pl
new file mode 100644
index 0000000000..8ae1d21ccb
--- /dev/null
+++ b/challenge-143/abigail/perl/ch-1.pl
@@ -0,0 +1 @@
+use 5.01;say eval for <> # Maybe a challenge for language without eval. Not Perl
diff --git a/challenge-143/abigail/perl/ch-2.pl b/challenge-143/abigail/perl/ch-2.pl
new file mode 100644
index 0000000000..2109647bf2
--- /dev/null
+++ b/challenge-143/abigail/perl/ch-2.pl
@@ -0,0 +1,33 @@
+#!/opt/perl/bin/perl
+
+use 5.032;
+
+use strict;
+use warnings;
+no warnings 'syntax';
+
+use experimental 'signatures';
+use experimental 'lexical_subs';
+
+#
+# Run as: perl ch-2.pl < input-file
+#
+
+#
+# And for the fourth week in succession we're solving need the
+# majority of the problem by getting the divisors of a number.
+#
+# Perhaps it is time to say:
+# "I'm completely out of ideas, let's skip this week".
+#
+# Big Yawn
+#
+
+use Math::Prime::Util qw [divisors];
+
+while (my $n = <>) {
+ # Put sum of divisor pairs in hash.
+ my %s = map {$_ + $n / $_ => 1} divisors 0 + $n;
+ # Any difference of 1?
+ say grep ({$s {$_ - 1}} keys %s) ? 1 : 0;
+}
diff --git a/challenge-143/abigail/python/ch-1.py b/challenge-143/abigail/python/ch-1.py
new file mode 100644
index 0000000000..3b67604548
--- /dev/null
+++ b/challenge-143/abigail/python/ch-1.py
@@ -0,0 +1,13 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+import fileinput
+
+for line in fileinput . input (): print (eval (line))
diff --git a/challenge-143/abigail/r/ch-1.r b/challenge-143/abigail/r/ch-1.r
new file mode 100644
index 0000000000..238fc25f08
--- /dev/null
+++ b/challenge-143/abigail/r/ch-1.r
@@ -0,0 +1,16 @@
+#
+# See ../README.md
+#
+
+#
+# Run as: Rscript ch-1.r < input-file
+#
+
+stdin <- file ('stdin', 'r')
+repeat {
+ n <- readLines (stdin, n = 1)
+ if (length (n) == 0) {
+ break
+ }
+ print (eval (parse (text = n)))
+}
diff --git a/challenge-143/abigail/ruby/ch-1.rb b/challenge-143/abigail/ruby/ch-1.rb
new file mode 100644
index 0000000000..314b69797c
--- /dev/null
+++ b/challenge-143/abigail/ruby/ch-1.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/ruby
+
+#
+# Run as: ruby ch-1.rb < input-file
+#
+
+ARGF . each_line do |_| puts (eval _) end
diff --git a/challenge-143/abigail/t/ctest.ini b/challenge-143/abigail/t/ctest.ini
new file mode 100644
index 0000000000..575704342b
--- /dev/null
+++ b/challenge-143/abigail/t/ctest.ini
@@ -0,0 +1,8 @@
+#
+# Configuration file for running tests, using ctest.
+# See https://github.com/Abigail/Misc/blob/master/ctest
+#
+
+[names]
+1-1 = Given Examples
+2-1 = Given Examples
diff --git a/challenge-143/abigail/t/input-1-1 b/challenge-143/abigail/t/input-1-1
new file mode 100644
index 0000000000..01dd3f8720
--- /dev/null
+++ b/challenge-143/abigail/t/input-1-1
@@ -0,0 +1,2 @@
+10 + 20 - 5
+(10 + 20 - 5) * 2
diff --git a/challenge-143/abigail/t/input-2-1 b/challenge-143/abigail/t/input-2-1
new file mode 100644
index 0000000000..024f0e0086
--- /dev/null
+++ b/challenge-143/abigail/t/input-2-1
@@ -0,0 +1,3 @@
+36
+12
+6
diff --git a/challenge-143/abigail/t/output-1-1.exp b/challenge-143/abigail/t/output-1-1.exp
new file mode 100644
index 0000000000..e573c227f4
--- /dev/null
+++ b/challenge-143/abigail/t/output-1-1.exp
@@ -0,0 +1,2 @@
+25
+50
diff --git a/challenge-143/abigail/t/output-2-1.exp b/challenge-143/abigail/t/output-2-1.exp
new file mode 100644
index 0000000000..2f1465d159
--- /dev/null
+++ b/challenge-143/abigail/t/output-2-1.exp
@@ -0,0 +1,3 @@
+1
+1
+0
diff --git a/challenge-143/abigail/tcl/ch-1.tcl b/challenge-143/abigail/tcl/ch-1.tcl
new file mode 100644
index 0000000000..3796f3ae1c
--- /dev/null
+++ b/challenge-143/abigail/tcl/ch-1.tcl
@@ -0,0 +1,5 @@
+#
+# Run as: tclsh ch-1.tcl < input-file
+#
+
+while {[gets stdin line] >= 0} {puts [expr $line]}