Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions bigrandom/answer.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
class BigRandom:
def __init__(self):
self.data = "data.txt"
# add attributes if you need more
self.data = "data.txt"

def answer(self):

noh = 0 # variable to store number of hashtag
# ommiting line number's hashtag
# ommiting line number's hashtag
suc = 0 # variable to store sum of character's code in ascii,
# ommiting line number and its hashtag
# ommiting line number and its hashtag

# your algorithm

self.data = open("data.txt", "r")
noh, suc = 0, 0
for line in self.data.readlines():
noh = noh + len([x for x in line if x == '#']) #______ count of '#'
suc = suc + sum([ord(x) for x in line]) #_____________ sum of asciis of all chars


numbs = ''.join([str(x) for x in range(10000)]) # 1234567891011121314...999910000

self.data.close() # close data stream

return (noh,suc)
# ord('#') * 10000 _________________ sum of asciis of first '#' in each row
# sum([ord(x) for x in nomor]) _____ sum of asciis of numbs
return (noh - 10000, suc - (ord('#') * 10000 + sum([ord(x) for x in numbs])))

# add methods if you need more
# instantiation
big = BigRandom()
a, b = big.answer()
print(a, b)
11 changes: 8 additions & 3 deletions caesar/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ def __init__(self):
# add attributes if you need more

def answer(self):
key = 0 # variable to store the key
key = 0

# your algorithm

self.ciphertext = open("ciphertext.txt", "r+")
msg = ''.join([chr(ord(x) - key) for x in str(self.ciphertext.readlines())]) # ____ decripting @return decripted string
print("Hasil decrypt dengan key %d adalah \n %s" % (key, msg)) # __________________ printing out
self.ciphertext.close() # _________________________________________________________ close data stream
return (key)

# add methods if you need more
# instantiation
csr = Caesar()
print(csr.answer());