Page 1 of 1

11697 - Playfair Cipher

Posted: Wed Feb 20, 2013 11:08 am
by kier.guevara
[codeAC
[/code]

This is my code for the playfair cipher. It matches with the sample I/O. Can you guys give me more I/O? I don't know whats wrong with my code

Re: 11697 - Playfair Cipher

Posted: Thu Feb 21, 2013 12:52 am
by brianfry713
Your code is throwing a RE on the sample input, see:
https://ideone.com/7Xy8vU

Re: 11697 - Playfair Cipher

Posted: Thu Feb 21, 2013 10:03 pm
by brianfry713
row and col are size 1 and you're accessing row[1] and col[1]

Re: 11697 - Playfair Cipher

Posted: Fri Feb 22, 2013 7:55 am
by kier.guevara

Code: Select all

AC
}
I fixed the size of my row and col but still WA..Why? Are there special cases?

Re: 11697 - Playfair Cipher

Posted: Fri Feb 22, 2013 9:33 pm
by brianfry713
Try input:

Code: Select all

1
z y x w v u t s r p o n m l k j i h g f e d c b a
the playfair cipher is a manual symmetric encryption techniue and was the first digraph substitution cipher  the scheme was invented in eighteen hundred fiftyfour by charles wheatstone  but bears the name of lord playfair who promoted the use of the cipher  the playfair cipher uses a five by five table containing each letter in the english alphabet exactly once  except  which is missing   the table constitutes the encryption key  to more easily remember the table  it is typically generated from a key phrase  first fill in the spaces in an empty table with the letters of the key phrase  dropping spaces and duplicate letters   then fill the remaining spaces with the rest of the letters of the alphabet in order  the key phrase is written in the top rows of the table  from left to right  for instance  if the key phrase is playfair example  the encryption key becomes
AC output:

Code: Select all

SIAUKBVIDFSBFTJCTGPCKCOTBKTXHSOCSPHDDOBSVTNDNMUDXCIDOZDKBYCPSIAJGTRSYDBLVKCMRERSDNTSJNMDFTJCPSJCMXJCOCVBTHKYDOUDYDODHFISCZDOJSIYUBAIHJNTJKTPDWXCBPOBRXJCDPRSNMDATSADBPRSJCKDOCKJKNTBRKDVAVGTXGKUULLNUDYNJCTRZJIPJCDHSFBUSIAUKBVIDFSBFTJCPTUCPCJHZADWJHZAPDWGDBNMPDDIDIJBEBGMDUUDTGINJCDOBGHTFCKRFCADUDVCDSNWNMBDCZBDUSXGHDGHMHHTTHLISIDUEAOBEMMTNDSTUDRSJCDOBSVTNDNMOATNNLLUCZDETHNWUBOCLCBUSIDUEAOBDNHTNTTFBEMWNWJBODPBUDAIULKCOAVTGSCPAJGTRSJHMWNGINJCRUEBCUDIDKCOUSTNEAOBYGSISIBODUUDPRKJSIAODZSFPBUCBTKUTFLIRUEBCUDKCYETRKHDDPBODUUDPRSIDOJHMWNRJCUBKCDIDIHRKVBDRXDNISJCUBRSKJSIBODUUDPRKJSIDEKRFCADNDMNTBBUSIAODZSFPBUCHTRLDNUDIDINJCUNUPLZUMIPJCPDWGAJULLKAJSYUNTGFGPILUDIRSDKBDHJSIAODZSFPBUCHTRKDVAVGTCZCKRKDUJCDOBSVTNDNMOAWDDBNLCU
The text to encrypt should be all on one line.

From the problem statement:
The text to encrypt will not contain two 'x's following each other, or an 'x' as the last character, as this might cause the first rule above to repeat itself indefinitely.

Re: 11697 - Playfair Cipher

Posted: Tue Feb 26, 2013 9:48 am
by kier.guevara
Thanks brianfry for the input and output! A logic error :)
Got AC now! Thanks again for the help!