Hi every one i recently registered for the code jam 2020, so i was trying my
hands on some past problem like the Cryptopanagram
but when i post my solution, the online judge keep showing sample failed RE. am
using python3 and i ran those samples locally and it worked.
i have been checking for bugs for long now but could not find one.Any
assistance will be greatly appreciated. i used sympy module before but the
error pesist.so i removed it and wrote a simple prime factorisation
function(the factor function).please i really need help on this,because it is
really energy sapping
here's my code:
from math import *
def factor(q):
m = floor(sqrt(q))
y = []
for k in range(2,m):
if q % k == 0:
y.append(k)
break
y.append(q//k)
return y
def reppt(li):
nlist = []
for k in li:
if k in nlist:
continue
else:
nlist.append(k)
return nlist
def decrypt(n):
n = [int(x) for x in n.split()]
z = []
y = factor(n[0])
if n[1] % y[0] == 0:
a = y[0]
z.append(y[-1])
else:
a = y[-1]
z.append(y[0])
for k in n[1:]:
z.append(a)
a = k//a
z.append(a)
m = reppt(z)
m.sort()
alpha =
['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
plaintext = ''
for l in z:
r = m.index(l)
plaintext += alpha[r]
return plaintext
def main():
T = int(input())
for k in range(1,T+1):
x,y = [int(a) for a in input().split()]
n = input()
print(f'Case #{1}: {decrypt(n)}')
main()
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/9021d1b6-48cc-46f3-8a4d-ba9d40300171%40googlegroups.com.