diff options
| author | James Smith <js5@sanger.ac.uk> | 2022-12-09 00:29:56 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-09 00:29:56 +0000 |
| commit | 0a90986281b28beb73de5b63f935dd6ee9670d73 (patch) | |
| tree | ed296ab2fb455aedeaf83bb6cb9e5faf749c6af0 /challenge-194/eric-cheung/python/ch-1.py | |
| parent | e0dd4b5e72551ca1412554f0b9d11c62a3b08af0 (diff) | |
| parent | 14e3c6a41685893e9a7a830d98fabe069bc4d0b5 (diff) | |
| download | perlweeklychallenge-club-0a90986281b28beb73de5b63f935dd6ee9670d73.tar.gz perlweeklychallenge-club-0a90986281b28beb73de5b63f935dd6ee9670d73.tar.bz2 perlweeklychallenge-club-0a90986281b28beb73de5b63f935dd6ee9670d73.zip | |
Merge branch 'manwar:master' into master
Diffstat (limited to 'challenge-194/eric-cheung/python/ch-1.py')
| -rwxr-xr-x | challenge-194/eric-cheung/python/ch-1.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-194/eric-cheung/python/ch-1.py b/challenge-194/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..c8df0f3507 --- /dev/null +++ b/challenge-194/eric-cheung/python/ch-1.py @@ -0,0 +1,34 @@ +
+## strTimeInput = "?5:00" ## Example 1
+## strTimeInput = "?3:00" ## Example 2
+## strTimeInput = "1?:00" ## Example 3
+## strTimeInput = "2?:00" ## Example 4
+## strTimeInput = "12:?5" ## Example 5
+strTimeInput = "12:5?" ## Example 6
+
+nPos = strTimeInput.find("?")
+
+if nPos == 0:
+ for nLoop in [2, 1]:
+ nHour = int(str(nLoop) + strTimeInput[1])
+ if nHour <= 23:
+ print (str(nLoop))
+ break
+elif nPos == 1:
+ for nLoop in [9, 8, 7, 6, 5, 4, 3, 2, 1]:
+ nHour = int(strTimeInput[0] + str(nLoop))
+ if nHour <= 23:
+ print (str(nLoop))
+ break
+elif nPos == 3:
+ for nLoop in [5, 4, 3, 2, 1]:
+ nMin = int(str(nLoop) + strTimeInput[4])
+ if nMin <= 59:
+ print (str(nLoop))
+ break
+elif nPos == 4:
+ for nLoop in [9, 8, 7, 6, 5, 4, 3, 2, 1]:
+ nMin = int(strTimeInput[3] + str(nLoop))
+ if nMin <= 59:
+ print (str(nLoop))
+ break
|
