diff --git a/bigrandom/answer.py b/bigrandom/answer.py index cb5fee4..994347d 100644 --- a/bigrandom/answer.py +++ b/bigrandom/answer.py @@ -1,16 +1,31 @@ class BigRandom: def __init__(self): self.data = "data.txt" - # add attributes if you need more def answer(self): - noh = 0 # variable to store number of hashtag - # ommiting line number's hashtag - suc = 0 # variable to store sum of character's code in ascii, - # ommiting line number and its hashtag - - # your algorithm + noh = 0 + suc = 0 + text = open(self.data,"r") + jmlhline=0 + for x in text : #mengakses per line + jmlhline +=1 + t=0 + tmp=0 + for y in x: #mengakses per kata + t+=1 + for z in y: #mengaskes per huruf + if (t == 1 and z != "#"): + tmp += ord(z) + if (z=="#"): + noh +=1 + else : + suc += ord(z) + suc -=tmp + + text.close() + noh -= jmlhline return (noh,suc) - # add methods if you need more \ No newline at end of file +b= BigRandom() +print (b.answer()) diff --git a/caesar/answer.py b/caesar/answer.py index 0d85db4..b318df6 100644 --- a/caesar/answer.py +++ b/caesar/answer.py @@ -1,13 +1,19 @@ class Caesar: def __init__(self): self.ciphertext = "ciphertext.txt" - # add attributes if you need more def answer(self): - key = 0 # variable to store the key - - # your algorithm - + key = 0 + a = open(self.ciphertext,"r") + x ="" + for i in a: #mengakes perkata + for y in i: #mengakses perhuruf + tmp = ord(str(y))-key + if (tmp<0): + tmp += 127 + x += chr(tmp) + print (x) return (key) - # add methods if you need more \ No newline at end of file +b= Caesar() +print (b.answer()) \ No newline at end of file