diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-01-30 12:33:55 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-01-30 12:33:55 +0000 |
| commit | 456fb3efcfc1882e5afbea14280d60599371f85a (patch) | |
| tree | 5918a596d15e776010d156a661fd06745f0c04c4 /challenge-045 | |
| parent | 7b71ad854b8588d9342aa8a1c62ec9c5d67a8b64 (diff) | |
| download | perlweeklychallenge-club-456fb3efcfc1882e5afbea14280d60599371f85a.tar.gz perlweeklychallenge-club-456fb3efcfc1882e5afbea14280d60599371f85a.tar.bz2 perlweeklychallenge-club-456fb3efcfc1882e5afbea14280d60599371f85a.zip | |
- Added Python solutions by Orestis Zekai.
Diffstat (limited to 'challenge-045')
| -rw-r--r-- | challenge-045/orestis-zekai/python/ch-1.py | 31 | ||||
| -rw-r--r-- | challenge-045/orestis-zekai/python/ch-2.py | 5 |
2 files changed, 36 insertions, 0 deletions
diff --git a/challenge-045/orestis-zekai/python/ch-1.py b/challenge-045/orestis-zekai/python/ch-1.py new file mode 100644 index 0000000000..9d01f88da7 --- /dev/null +++ b/challenge-045/orestis-zekai/python/ch-1.py @@ -0,0 +1,31 @@ +# Define string, make it a list, count and remove spaces
+string = 'The quick brown fox jumps over the lazy dog'
+f = [char.lower() for char in string]
+spaces = 0
+for char in f:
+ if (char == ' '):
+ f.remove(char)
+ spaces += 1
+
+# Code new string
+coded = []
+j = 0
+while True:
+ i = j
+
+ if (len(coded) == len(f) + spaces):
+ break
+
+ while (i < len(f)):
+ coded.append(f[i])
+ i += 8
+
+ coded.append(' ')
+ j += 1
+
+# Convert to string
+new_string = ''
+for letter in coded:
+ new_string += letter
+
+print(new_string)
\ No newline at end of file diff --git a/challenge-045/orestis-zekai/python/ch-2.py b/challenge-045/orestis-zekai/python/ch-2.py new file mode 100644 index 0000000000..574ce3331c --- /dev/null +++ b/challenge-045/orestis-zekai/python/ch-2.py @@ -0,0 +1,5 @@ +# Open file
+f = open('sourceDumper.py')
+
+# Read contents and print
+print(f.read())
\ No newline at end of file |
