Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
33 changes: 32 additions & 1 deletion bigrandom/answer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
class BigRandom:
def __init__(self):
self.data = "data.txt"
<<<<<<< HEAD


def answer(self):
noh = 0
suc = 0
a = open("data.txt","r")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pakai self.data aja

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dan nama variabelnya ga ada yang lebih bagus kah?

s=0
for x in a :
s+=1
t=0
tmp=0
for y in x:
t+=1
for z in y:
if (t == 1 and z != "#"):
tmp += ord(z)
if (z=="#"):
noh +=1
else :
suc += ord(z)
if (t==1):
suc-=tmp
a.close()
noh -= s
return (noh,suc)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suc nya masih salah

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sucnya masih salah, yang bener 393754393


b= BigRandom()
print (b.answer())
=======
# add attributes if you need more

def answer(self):
Expand All @@ -13,4 +43,5 @@ def answer(self):

return (noh,suc)

# add methods if you need more
# add methods if you need more
>>>>>>> 64e1f92e25e7147b206ac73695e846881e7f9b0d
22 changes: 21 additions & 1 deletion caesar/answer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
class Caesar:
def __init__(self):
self.ciphertext = "ciphertext.txt"
<<<<<<< HEAD


def answer(self):
key = 46

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tau 46 dari mana mas? Kan soalnya suruh bikin algoritma buat nyari 46

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coba cek soalnya lagi deh, kan suruh bikin algoritma buat nyari key. Ini 46 tau dari mana?

a = open("ciphertext.txt","r")
x =""
for i in a:
for y in i:
tmp = ord(str(y))-key
if (tmp<0):
tmp += 127
x += chr(tmp)
print (x)
return (key)

b= Caesar()
print (b.answer())
=======
# add attributes if you need more

def answer(self):
Expand All @@ -10,4 +29,5 @@ def answer(self):

return (key)

# add methods if you need more
# add methods if you need more
>>>>>>> 64e1f92e25e7147b206ac73695e846881e7f9b0d