11697 - Playfair Cipher

All about problems in Volume 116. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
kier.guevara
New poster
Posts: 30
Joined: Thu Jul 19, 2012 11:24 pm

11697 - Playfair Cipher

Post by kier.guevara » Wed Feb 20, 2013 11:08 am

[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
Last edited by kier.guevara on Tue Feb 26, 2013 9:48 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11697 - Playfair Cipher

Post by brianfry713 » Thu Feb 21, 2013 12:52 am

Your code is throwing a RE on the sample input, see:
https://ideone.com/7Xy8vU
Check input and AC output for thousands of problems on uDebug!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11697 - Playfair Cipher

Post by brianfry713 » Thu Feb 21, 2013 10:03 pm

row and col are size 1 and you're accessing row[1] and col[1]
Check input and AC output for thousands of problems on uDebug!

kier.guevara
New poster
Posts: 30
Joined: Thu Jul 19, 2012 11:24 pm

Re: 11697 - Playfair Cipher

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

Code: Select all

AC
}
I fixed the size of my row and col but still WA..Why? Are there special cases?
Last edited by kier.guevara on Tue Feb 26, 2013 9:48 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11697 - Playfair Cipher

Post by brianfry713 » Fri Feb 22, 2013 9:33 pm

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.
Check input and AC output for thousands of problems on uDebug!

kier.guevara
New poster
Posts: 30
Joined: Thu Jul 19, 2012 11:24 pm

Re: 11697 - Playfair Cipher

Post by kier.guevara » Tue Feb 26, 2013 9:48 am

Thanks brianfry for the input and output! A logic error :)
Got AC now! Thanks again for the help!

Post Reply

Return to “Volume 116 (11600-11699)”