aboutsummaryrefslogtreecommitdiff
path: root/problems/aweirdclock.py
diff options
context:
space:
mode:
authorRaghuram Subramani <raghus2247@gmail.com>2024-09-30 16:08:27 +0530
committerRaghuram Subramani <raghus2247@gmail.com>2024-09-30 16:08:27 +0530
commit3496b0ed08c51e37e135e686b1632fd86f930c2c (patch)
tree1da44792489607070f3b4ca14d82af05b73e362b /problems/aweirdclock.py
(init): Initialize repository.
Diffstat (limited to 'problems/aweirdclock.py')
-rw-r--r--problems/aweirdclock.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/problems/aweirdclock.py b/problems/aweirdclock.py
new file mode 100644
index 0000000..5175306
--- /dev/null
+++ b/problems/aweirdclock.py
@@ -0,0 +1,30 @@
+def transform_time(readable_text):
+ mapping = {
+ 'O': '0', '0': '0',
+ 'i': '1', '1': '1',
+ '2': '2',
+ 'E': '3',
+ 'h': '4',
+ 'S': '5', '5': '5',
+ '9': '6',
+ 'L': '7',
+ '8': '8',
+ '6': '9'
+ }
+
+ reversed_text = readable_text[::-1]
+ reversed_hours, reversed_minutes = reversed_text.split(":")
+
+ hours = int("".join(mapping[c] for c in reversed_hours))
+ minutes = int("".join(mapping[c] for c in reversed_minutes))
+
+ if hours >= 24:
+ print(f"Error {hours} hours")
+ if minutes >= 60:
+ print(f"Error {minutes} minutes")
+
+ if hours < 24 and minutes < 60:
+ print(f"{hours}:{minutes:02d}")
+
+readable_text = input()
+transform_time(readable_text)