aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-047/lubos-kolouch/python/ch-1.py31
-rw-r--r--challenge-047/lubos-kolouch/python/ch-2.py9
2 files changed, 40 insertions, 0 deletions
diff --git a/challenge-047/lubos-kolouch/python/ch-1.py b/challenge-047/lubos-kolouch/python/ch-1.py
new file mode 100644
index 0000000000..873c78af2a
--- /dev/null
+++ b/challenge-047/lubos-kolouch/python/ch-1.py
@@ -0,0 +1,31 @@
+#! python3
+from roman import toRoman, fromRoman
+import sys
+
+
+class RomanConvertor:
+
+ def roman_magic(self, v1, op, v2):
+
+ rom_v1 = str(fromRoman(v1))
+ rom_v2 = str(fromRoman(v2))
+
+ operation = rom_v1+op+rom_v2
+
+ return toRoman(eval(operation))
+
+ def main(self, v1, op, v2):
+
+ return self.roman_magic(v1.upper(), op, v2.upper())
+
+
+if __name__ == '__main__':
+ v1, op, v2 = sys.argv[1:]
+ rom_conv = RomanConvertor()
+ print(rom_conv.main(v1, op, v2))
+
+# tests
+
+rom_conv = RomanConvertor()
+assert rom_conv.main('I', '+', 'II') == 'III'
+assert rom_conv.main('II', '-', 'I') == 'I'
diff --git a/challenge-047/lubos-kolouch/python/ch-2.py b/challenge-047/lubos-kolouch/python/ch-2.py
new file mode 100644
index 0000000000..bfaa3f97f2
--- /dev/null
+++ b/challenge-047/lubos-kolouch/python/ch-2.py
@@ -0,0 +1,9 @@
+#!python3
+
+count = 0
+for i in range(100, 10001):
+ if i % int(str(i)[0]+str(i)[2]) == 0:
+ print(i)
+ count += 1
+ if count == 20:
+ break