aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrxfork <ph.bricout@gmail.com>2022-07-11 18:04:45 +0200
committerbrxfork <ph.bricout@gmail.com>2022-07-11 18:04:45 +0200
commit9fd0c36e3e3f0303bc53dc8bf86802e025307b9e (patch)
tree9a7cea17e8d3ad3d93921d86c4b8de5e90901e06
parent753d19e9546dfd295e36874df9fb823c0e87a45c (diff)
downloadperlweeklychallenge-club-9fd0c36e3e3f0303bc53dc8bf86802e025307b9e.tar.gz
perlweeklychallenge-club-9fd0c36e3e3f0303bc53dc8bf86802e025307b9e.tar.bz2
perlweeklychallenge-club-9fd0c36e3e3f0303bc53dc8bf86802e025307b9e.zip
simple one-liner showing the first wrong digits
-rwxr-xr-xchallenge-173/brxfork/perl/ch-1.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/challenge-173/brxfork/perl/ch-1.sh b/challenge-173/brxfork/perl/ch-1.sh
new file mode 100755
index 0000000000..b3ebcf288b
--- /dev/null
+++ b/challenge-173/brxfork/perl/ch-1.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+perl -nle 'if (/0[^1]|1[^02]|2[^13]|3[^24]|4[^35]|5[^46]|6[^57]|7[^68]|8[^79]|9[^8]/) {$a=$_;s/$&/[$&]/;print "$a is *not* an esthetic number ($_)"} else {print "$_ is an esthetic number" }'
+
+
+#echo -e "123\n120\n5456\n987678\n123321" | perl -nle 'if (/0[^1]|1[^02]|2[^13]|3[^24]|4[^35]|5[^46]|6[^57]|7[^68]|8[^79]|9[^8]/) {$a=$_;s/$&/[$&]/;print "$a is *not* an esthetic number ($_)"} else {print "$_ is an esthetic number" }'
+#123 is an esthetic number
+#120 is *not* an esthetic number (1[20])
+#5456 is an esthetic number
+#987678 is an esthetic number
+#123321 is *not* an esthetic number (12[33]21)