Barrel cypher

Discuss about the puzzles, but without giving the solutions please !!!

Barrel cypher

Postby admin » Fri Oct 07, 2011 7:27 am

The goal of this puzzle is to write a barrel cypher decoder with the smallest code size possible.


The cypher works with a key and a message. The key is a suite of numbers between 1 and 9, the message a space separated list of lower case words. To encrypt a message, we repeatedly travel through the numbers of the key from left to right and then from right to left and shift the letter in the alphabet by the corresponding number.


Example



  • key 1595

  • message hello world


We start processing the words and using the digits from the key from left to right:


h+1=i, e+5=j, l+9=u, l+5=q


Now that we used all the digits, we do it again from right to left:


o+5=t, the space is discarded, w+9=f, o+5=t, r+1=s


And finally we repeat the process, starting from left to right:


l+1=m, d+5=i


The encrypted message is: ijuqt ftsmi


User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Barrel cypher

Postby Radu Cruceru » Sat Oct 22, 2011 2:19 pm

Something is not right:

[sample input]
123
xgofqnf vr fqeftfkcsuu

[output]
welcome to codercharts

x (ascii 120) + 1 -> y (ascii 121)

in your case, you substract the value.
From the problem description, i understood that you have to right-shift the letters. Please clarify this for me.

Thanks
User avatar
Radu Cruceru
 
Posts: 3
Joined: Tue Jul 12, 2011 9:11 am

Re: Barrel cypher

Postby admin » Sat Oct 22, 2011 4:13 pm

Hello Radu,

the description explains how to encode a message A and obtain a resulting message B.
The goal of the puzzle is to decode a message B and find the original message A.

Hope that clarifies
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Barrel cypher

Postby bknarendra » Sat Oct 22, 2011 8:56 pm

What is maximum size of the key?
User avatar
bknarendra
 
Posts: 4
Joined: Thu Sep 22, 2011 6:30 pm

Re: Barrel cypher

Postby admin » Sun Oct 23, 2011 3:15 pm

bknarendra wrote:What is maximum size of the key?


As long as the text to be encrypted. The key is never longer than the text.
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Barrel cypher

Postby octalc0de » Mon Oct 24, 2011 12:37 am

"The first 30 spaces, tabs and newlines are ignored, each additional one counts as one character."

How do I get tabs? My solution technique would benefit from tabs, but if I type a tab in the text box, it expands into spaces.
User avatar
octalc0de
 
Posts: 1
Joined: Tue Jul 12, 2011 2:44 pm

Re: Barrel cypher

Postby admin » Mon Oct 24, 2011 12:00 pm

octalc0de wrote:"The first 30 spaces, tabs and newlines are ignored, each additional one counts as one character."

How do I get tabs? My solution technique would benefit from tabs, but if I type a tab in the text box, it expands into spaces.


The only way to enter a tab is by copy paste. In the editor, we overload the tab key to generate 4 spaces.
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Barrel cypher

Postby Luis Palacios » Fri Oct 28, 2011 12:51 pm

Hi I have a solution and want to test it.. I made my PHP code and want to try it here:
http://codercharts.com/puzzle/barrel-cypher
Whats the name of the file to be decripted?
User avatar
Luis Palacios
 
Posts: 1
Joined: Fri Oct 28, 2011 12:47 pm

Re: Barrel cypher

Postby admin » Fri Oct 28, 2011 11:11 pm

The file name is provided as a command line argument, it was discussed in the PHP section a while ago:
viewtopic.php?f=15&t=70

Hope it clarifies
User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Barrel cypher

Postby TheSageMage » Sat Nov 05, 2011 9:34 am

First time coder here... so I know the scoring is based on program length? Is the language take into account(All Java scores compared to other Java) or is it any language?
User avatar
TheSageMage
 
Posts: 6
Joined: Sat Nov 05, 2011 9:25 am

Next

Return to Puzzles

Who is online

Users browsing this forum: No registered users and 2 guests

cron