diff options
| author | dms061 <dms7225@psu.edu> | 2021-05-16 18:47:40 -0400 |
|---|---|---|
| committer | dms061 <dms7225@psu.edu> | 2021-05-16 18:47:40 -0400 |
| commit | 0602d0d635835efc141bf1a89f604cd3156ecd3e (patch) | |
| tree | a3cf4fbbe6f6378b1e7f0180ab722010493d6c7d /challenge-112/abigail/python | |
| parent | 111673b82066733c69a62c8f1030da605767aaf8 (diff) | |
| parent | fa969a62c402d6220e260e0f302c80e9b6133c90 (diff) | |
| download | perlweeklychallenge-club-0602d0d635835efc141bf1a89f604cd3156ecd3e.tar.gz perlweeklychallenge-club-0602d0d635835efc141bf1a89f604cd3156ecd3e.tar.bz2 perlweeklychallenge-club-0602d0d635835efc141bf1a89f604cd3156ecd3e.zip | |
Merge branch 'manwar:master' into challenge112
Diffstat (limited to 'challenge-112/abigail/python')
| -rw-r--r-- | challenge-112/abigail/python/ch-1.py | 24 | ||||
| -rw-r--r-- | challenge-112/abigail/python/ch-2.py | 18 |
2 files changed, 42 insertions, 0 deletions
diff --git a/challenge-112/abigail/python/ch-1.py b/challenge-112/abigail/python/ch-1.py new file mode 100644 index 0000000000..bf52e6d83c --- /dev/null +++ b/challenge-112/abigail/python/ch-1.py @@ -0,0 +1,24 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-1.py < input-file +# + +import fileinput + +for line in fileinput . input (): + parts = line . rstrip () . split ("/") # Split input on / + parts2 = [] + for part in parts: + if part == "" or part == ".": # Skip empty parts, + continue # and current directory. + if part == "..": # Pop parent directory + if len (parts2): + parts2 . pop () + continue + parts2 . append (part) # Else, append. + print ("/" + "/" . join (parts2)) # Print result. diff --git a/challenge-112/abigail/python/ch-2.py b/challenge-112/abigail/python/ch-2.py new file mode 100644 index 0000000000..da542b06f2 --- /dev/null +++ b/challenge-112/abigail/python/ch-2.py @@ -0,0 +1,18 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-2.py < input-file +# + +import fileinput +from math import sqrt + +SQRT5 = sqrt (5) +PHI = (1 + SQRT5) / 2 + +for line in fileinput . input (): + print (round (pow (PHI, int (line) + 1) / SQRT5)) |
