aboutsummaryrefslogtreecommitdiff
path: root/challenge-004/abigail/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-004/abigail/python')
-rw-r--r--challenge-004/abigail/python/ch-1.py76
-rw-r--r--challenge-004/abigail/python/ch-2.py40
2 files changed, 116 insertions, 0 deletions
diff --git a/challenge-004/abigail/python/ch-1.py b/challenge-004/abigail/python/ch-1.py
new file mode 100644
index 0000000000..0f7f8bf725
--- /dev/null
+++ b/challenge-004/abigail/python/ch-1.py
@@ -0,0 +1,76 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as python ch-1.py
+#
+
+import sys
+
+pi = "%(uP7+Y`ME)gy(7')v?;%s^qc(Mj1}16idp'ONGs'2m.o,1HLY'}~P61@@Y-" + \
+ "*O/.v,Jc~D+ttA'&EPjR(zXxD$dr,M$P=-f*YQqe,GIZ`0x5oL1(mpl17en`" + \
+ ")Q$ge,L6_5.I;hj%yy6n,L_t')dtyy)[ugS&-3(c&lC:a&~8SP#+iis+WR&8" + \
+ "*Y;V3/+JD@-J>7u0$Nh<#2&:@+#=`/*YtP-0t8uf+tf/V&yjx>+]S=&%d}7z" + \
+ "0YXa9$SOyt$*mzv1&X(W(.{0G-Vya`0a}KI0pQD2,nV0:,WE0+#?F[>(iMb}" + \
+ "%k(tB/UO0m.8R'x%Vys_-|IgL.y-n6(v[*#+<w,K&ph2o.LfLw.'YJB%SI/r" + \
+ "-RGB[0/yKw);ml1+SlKv.UDG6&jY3_#=Nry$t6Ng/YXEe%A)of.>/-J1#[`]" + \
+ "&*M<M1Uqt]#f=#g-a$q{$Gn<,#CLb7((C*0,D]yd&c4OS#Ql2h%gd7>#'1wg" + \
+ "-}+B}*jWDi)/2&k,h|/)+eu-3)9{mU-`:]M/YF$a.O0SF0{~2C.EjkZ&>|lD" + \
+ "#%UmL+w)$V&14Ty0arq+%xnAo/XX/y0_=Bl/)f*}'Gc88'GV;X1RG~<+gJ8p" + \
+ "&^E~A'/3N=*R2|j&Sg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e0``3L%.JF[+Z?8b(tj7C" + \
+ "'S/z}#vS|i)S9[=*/nCG)PMaY-{pML);vN?%kRcr#*.Tg,x;42'(1w.0dA)S" + \
+ ")-us%.#1$R-rkwf%m%B-(ctK8+4Sn^%*C1Y-wqsr%eNg11%$De&&07q+%1>-" + \
+ "+mCl2%)V#w%#y:[,?t*D$64`9.U+{`-SBX-+gi/o)0B$q#V$tW+#lmM)';EH" + \
+ "%yFPZ/Gy(~,dl@h)A&ju-Co2,-du++)[Awk&wE}p*H;._.[]4W+Eb7K#iiKB";
+
+
+in_size = 5
+out_size = 9
+first_ord = ord ("#")
+skip_ord = ord ("\\")
+last_ord = ord ("~")
+ord_range = last_ord - first_ord
+format = "{:0" + str (out_size) + "d}"
+
+
+sys . stdout . write ("3.")
+
+for i in range (0, len (pi), in_size):
+ out = 0
+ for j in range (i, i + in_size, 1):
+ out = out * ord_range
+ n = ord (pi [j])
+ if n >= skip_ord:
+ n = n - 1
+ out = out + n - first_ord
+ sys . stdout . write (format . format (out))
+
+sys . stdout . write ("\n")
+
+#
+# FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER
+# FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER
+# FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER
+# FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER?
+# FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER
+# FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER
+# FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER FODDER!
+#
diff --git a/challenge-004/abigail/python/ch-2.py b/challenge-004/abigail/python/ch-2.py
new file mode 100644
index 0000000000..4e94f7fe7d
--- /dev/null
+++ b/challenge-004/abigail/python/ch-2.py
@@ -0,0 +1,40 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as python ch-2.py < input-file
+#
+
+import fileinput
+import getopt
+import sys
+
+#
+# Parse options
+#
+opts, args = getopt . getopt (sys . argv [1:], 'f:')
+for opt, val in opts:
+ if opt == "-f":
+ filename = val
+
+
+#
+# Find the words in 'filename' which can be constructed
+# from the letters in 'letters'.
+#
+def find_words (filename, letters):
+ letters = list (letters . lower () . strip ())
+ for word in open (filename):
+ word = word . strip ()
+ copy = word . lower ()
+ for letter in letters:
+ copy = copy . replace (letter, "", 1)
+ if copy == "":
+ print (word)
+
+
+for line in fileinput . input ('-'):
+ find_words (filename, line . strip ())