Added partial solution to K

This commit is contained in:
Claudio Maggioni 2019-04-22 18:40:44 +02:00
parent 6f4006e49a
commit c3c1d42acf
3 changed files with 81 additions and 2 deletions

View file

@ -73,7 +73,9 @@ def count_genes(G):
CI.append(last)
else:
last = last - 1
CI.append(last + 1)
CI.append(last)
print(CI)
m = CI[0]
p = I[0][0]
@ -82,7 +84,7 @@ def count_genes(G):
m = CI[i]
p = I[i][0]
return (p, m)
return (p + 1, m)
if __name__ == "__main__":
n = int(input())

71
getting_digits.py Executable file
View file

@ -0,0 +1,71 @@
def get_digits(s):
S = ["ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN",
"EIGHT", "NINE"]
L = {
'A': [],
'B': [],
'C': [],
'D': [],
'E': [0,1,3,5,7,8,9], #3*2 7*2
'F': [4,5],
'G': [8],
'H': [3,8],
'I': [5,6,8,9],
'J': [],
'K': [],
'L': [],
'M': [],
'N': [1,7,9], #9*2
'O': [0,1,2,4],
'P': [],
'Q': [],
'R': [0,3,4],
'S': [6,7],
'T': [2,3,8],
'U': [4],
'V': [5,7],
'W': [2],
'X': [6],
'Y': [],
'Z': [0]
}
dgts = [0] * 10
O = []
N = []
for string in S:
O.append(list(string))
N.append(list(string))
removed = []
for c in s:
print(c)
for n in L[c]:
try:
N[n].remove(c)
removed.append([n, c])
except ValueError:
"fregacazzi"
print(N)
for i in range(10):
if len(N[i]) == 0:
print("BINGO "+ str(i))
dgts[i] = dgts[i] + 1
for log in reversed(removed):
if log[1] in O[i]:
N[log[0]].append(log[1])
del log
print(N)
print(dgts)
print(N)
o = ""
for i in range(10):
while dgts[i] > 0:
o = o + str(i)
dgts[i] = dgts[i] - 1
return o
if __name__ == "__main__":
n = int(input())
for i in range(1, n + 1):
print("Case #" + str(i) + ": " + get_digits(input()))

6
getting_digits.txt Normal file
View file

@ -0,0 +1,6 @@
1
ZEROONETWOTHREEFOURFIVESIXSEVENEIGHTNINE
OZONETOWER
WEIGHFOXTOURIST
OURNEONFOE
ETHER