aboutsummaryrefslogtreecommitdiff
path: root/challenge-194/robert-dicicco/python/ch-1.py
diff options
context:
space:
mode:
authorJames Smith <js5@sanger.ac.uk>2022-12-09 00:29:56 +0000
committerGitHub <noreply@github.com>2022-12-09 00:29:56 +0000
commit0a90986281b28beb73de5b63f935dd6ee9670d73 (patch)
treeed296ab2fb455aedeaf83bb6cb9e5faf749c6af0 /challenge-194/robert-dicicco/python/ch-1.py
parente0dd4b5e72551ca1412554f0b9d11c62a3b08af0 (diff)
parent14e3c6a41685893e9a7a830d98fabe069bc4d0b5 (diff)
downloadperlweeklychallenge-club-0a90986281b28beb73de5b63f935dd6ee9670d73.tar.gz
perlweeklychallenge-club-0a90986281b28beb73de5b63f935dd6ee9670d73.tar.bz2
perlweeklychallenge-club-0a90986281b28beb73de5b63f935dd6ee9670d73.zip
Merge branch 'manwar:master' into master
Diffstat (limited to 'challenge-194/robert-dicicco/python/ch-1.py')
-rw-r--r--challenge-194/robert-dicicco/python/ch-1.py97
1 files changed, 97 insertions, 0 deletions
diff --git a/challenge-194/robert-dicicco/python/ch-1.py b/challenge-194/robert-dicicco/python/ch-1.py
new file mode 100644
index 0000000000..74bb343b88
--- /dev/null
+++ b/challenge-194/robert-dicicco/python/ch-1.py
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+
+'''
+
+AUTHOR: Robert DiCicco
+
+DATE: 2022-12-05
+
+Challenge 194 Digital Clock ( Python )
+
+-------------------------------------------
+
+SAMPLE OUTPUT
+
+python .\DigitalClock.py
+
+Input: $time = '?5:00'
+
+Output: 1
+
+
+Input: $time = '?3:00'
+
+Output: 2
+
+
+Input: $time = '1?:00'
+
+Output: 9
+
+
+Input: $time = '2?:00'
+
+Output: 3
+
+
+Input: $time = '12:?5'
+
+Output: 5
+
+
+Input: $time = '12:5?'
+
+Output: 9
+
+'''
+
+
+templates = ["?5:00", "?3:00", "1?:00", "2?:00", "12:?5","12:5?"]
+
+
+def GetDigit(tp, n) :
+
+ print(f"Input: $time = '{tp}'")
+
+ print("Output: ", end = " ")
+
+ if (( n == 0 ) and (tp[1] < '4')) :
+
+ print("2\n")
+
+ elif (( n == 0 ) and (tp[1] >= '4' )) :
+
+ print("1\n")
+
+ elif (( n == 1 ) and (tp[0] <= '1')) :
+
+ print("9\n")
+
+ elif (( n == 1 ) and (tp[0] == '2')) :
+
+ print("3\n")
+
+ elif ( n == 3) :
+
+ print("5\n")
+
+ elif ( n == 4) :
+
+ print("9\n")
+
+ else :
+
+ print("Error!")
+
+
+for tp in templates :
+
+ GetDigit(tp,tp.index('?'))