From c3c1d42acf93c9a4bfb7d0d4dd915aadecf51966 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Mon, 22 Apr 2019 18:40:44 +0200 Subject: [PATCH] Added partial solution to K --- circular_dna.py | 6 ++-- getting_digits.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++ getting_digits.txt | 6 ++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100755 getting_digits.py create mode 100644 getting_digits.txt diff --git a/circular_dna.py b/circular_dna.py index 86b2c57..d05e702 100644 --- a/circular_dna.py +++ b/circular_dna.py @@ -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()) diff --git a/getting_digits.py b/getting_digits.py new file mode 100755 index 0000000..1e0fcff --- /dev/null +++ b/getting_digits.py @@ -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())) diff --git a/getting_digits.txt b/getting_digits.txt new file mode 100644 index 0000000..6207233 --- /dev/null +++ b/getting_digits.txt @@ -0,0 +1,6 @@ +1 +ZEROONETWOTHREEFOURFIVESIXSEVENEIGHTNINE +OZONETOWER +WEIGHFOXTOURIST +OURNEONFOE +ETHER