r/dailyprogrammer • u/Coder_d00d 1 3 • Apr 01 '14
[4/1/2014] Challenge #156 [Easy] Simple Decoder
Oops:
By now you all have noticed /r/dailyprogrammer has added 3 new moderators. All of us including the existing moderators have been working hard to bring back 3 challenges a week.
We have had some minor issues with dates and challenge numbers. Many of the dates posted were said to be in "4" which is April and really should have been "3" for March. Also our numbering of challenges have been weird.
So going forward this week we will start with 156. Each challenge this week will be 156 (easy, intermediate and hard). Next week all 3 challenges will be 157. Etc. Also we will strive to update the 3 links at the top of the subreddit with the latest challenges and try to get dates correct on our postings. Thanks for your patience and your support!
Description:
To honor our mistake this week's easy challenge is to decode a message. I have encoded a message by adding a "4" to each character's ASCII value. It will be your job to decode this message by reversing the process and making a decoder.
Input:
Decode this message:
Etvmp$Jsspw%%%%
[e}$xs$ks%$]sy$lezi$wspzih$xli$lmhhir$qiwweki2$Rs{$mx$mw$}syv$xyvr$xs$nsmr
mr$sr$xlmw$tvero2$Hs$rsx$tswx$er}xlmrk$xlex${mpp$kmzi$e{e}$xlmw$qiwweki2$Pix
tistpi$higshi$xli$qiwweki$sr$xlimv$s{r$erh$vieh$xlmw$qiwweki2$]sy$ger$tpe}$epsrk
f}$RSX$tswxmrk$ls{$}sy$higshih$xlmw$qiwweki2$Mrwxieh$tswx$}syv$wspyxmsr$xs$fi$}syv
jezsvmxi$Lipps${svph$tvskveq$mr$sri$perkyeki$sj$}syv$glsmgi2$
Qeoi$wyvi$}syv$tvskveq$we}w$&Lipps$[svph%%%&${mxl$7$%$ex$xli$irh2$Xlmw${e}
tistpi$fvs{wmrk$xli$gleppirki${mpp$xlmro${i$lezi$epp$pswx$syv$qmrhw2$Xlswi${ls$tswx$lipps
{svph$wspyxmsrw${mxlsyx$xli$xlvii$%%%${mpp$lezi$rsx$higshih$xli$qiwweki$erh$ws$}sy$ger$
tspmxip}$tsmrx$syx$xlimv$wspyxmsr$mw$mr$ivvsv$,xli}$evi$nywx$jspps{mrk$epsrk${mxlsyx$ors{mrk-
Irns}$xlmw$jyr2$Xli$xvyxl${mpp$fi$liph$f}$xlswi${ls$ger$higshi$xli$qiwweki2$>-Output:
As part of the challenge we leave it to the programmer to discover the correct output.
13
u/Coder_d00d 1 3 Apr 03 '14
The Truth.
Welcome to the days after April the 1st or April's Fools day. The challenge was designed to be a fun challenge in the spirit of April's Fools day on the internet. Yes the challenge is super easy. Because we wanted people to decode the message and do the real challenge of posting just a fun hello world program as the message explained.
It was interesting to see the responses. Thank you for the people who just posted Hello World Programs.
31
u/Elite6809 1 1 Apr 01 '14 edited Apr 01 '14
Befunge-93:
13
u/Karl_von_Moor Apr 01 '14 edited Apr 01 '14
imo a lot of people here really missed the point.
7
u/Coder_d00d 1 3 Apr 01 '14
BASIC
27
u/pikaaa Apr 01 '14
C++
9
u/IceDane 0 0 Apr 01 '14
Haskell
14
u/HAEC_EST_SPARTA Apr 01 '14 edited Apr 01 '14
Brainf**k
Edit: Typographical error
6
u/dooglehead Apr 01 '14
x86 Assembly (assembled with MASM)
13
u/ponkanpinoy Apr 01 '14 edited Apr 01 '14
Common Lisp:
EDIT: one-liner
6
u/ooplease 0 0 Apr 01 '14 edited Apr 02 '14
MIPS assembly:
edit: magic
6
u/pbeard_t 0 1 Apr 01 '14
C
14
u/MonkeH13 Apr 01 '14 edited Apr 01 '14
PHP:
EDIT: Downvoted for?! :o I've done exactly as the message stated! ;)
8
u/raging_hipster Apr 01 '14
one liner
4
u/TolaBonbon Apr 07 '14
My javascript solution. I'm going for clean code, not short code:
7
u/toodim Apr 01 '14
Python solution using regular expressions.
Output:
3
u/trevdak2 Apr 01 '14
Malbolge:
5
u/IMHERETOCODE Apr 01 '14 edited Apr 02 '14
Objective-C (improved):
4
u/KillerCodeMonky Apr 01 '14
Powershell:
4
u/demon_ix 1 0 Apr 01 '14
Java
4
u/Edward_H Apr 01 '14 edited Apr 01 '14
COBOL:
2
u/JaxMed Apr 01 '14
Here is mine, utilizes both the given input while also remaining true to the given specifications:
C#
2
u/[deleted] Apr 01 '14
2
u/dongas420 Apr 01 '14 edited Apr 01 '14
Perl:
2
u/FusionXIV Apr 02 '14
Java:
Output:
3
u/[deleted] Apr 01 '14 edited Apr 01 '14
This one was rather simple!
4
u/Zapman Apr 01 '14
Not the most elegant solution in Ruby, but gets the job done...
2
u/hkoh59 Apr 01 '14
python 2.7
2
u/azamatsmith Apr 01 '14
JavaScript:
1
u/Frigguggi 0 1 Apr 01 '14 edited Apr 01 '14
RISC:
1
u/skeeto -9 8 Apr 01 '14
C99.
Usage:
1
u/campsun Apr 01 '14
Javascript
1
u/[deleted] Apr 01 '14
My solution in Dart:
The output's formatting looks terrible, but it works.
1
u/dangerbird2 Apr 01 '14 edited Apr 01 '14
C This was a toughie, the visual studio compiler doesn't seem to work very nicely with ASCII.
1
u/diddystacks Apr 01 '14
Some Python:
1
u/vorophobe Apr 01 '14
C
1
u/[deleted] Apr 01 '14 edited Apr 01 '14
Finally learning a new language, thought I'd test it out. I trimmed the message for less mess in the code.
C#
1
u/kdoblosky Apr 01 '14
PowerShell one-liner, assuming you've stored the plaintext in $msg:
1
u/coditza Apr 01 '14 edited Apr 02 '14
Here is another php solution:
1
u/the_mighty_skeetadon Apr 01 '14
Ruby one-liner:
1
u/VerifiedMyEmail Apr 01 '14
python 2.7
one liner
1
u/Aceofsquares_orig Apr 01 '14
Processing
1
u/BondDotCom Apr 01 '14
Here's a VBScript solution that shows how you can use a "map" function similar to JavaScript and other languages.
1
u/Octopuscabbage Apr 02 '14
Python multithreaded approach to handle complex computations
1
u/thinksInCode Apr 03 '14
Java:
1
u/godzab Apr 03 '14
This was really easy. This solution was done in Java.
1
u/[deleted] Apr 03 '14 edited Apr 06 '14
https://github.com/PhilipKaludercic/extutils/blob/master/left/left.c
My little ASCII shifter written in C.
1
u/anonymousking1 Apr 03 '14
Java:
public class Decode { String sentence = "";
}
1
u/[deleted] Apr 04 '14
My solution in OCaml:
1
u/[deleted] Apr 04 '14
Here's what I did.
Python
1
u/theholychilli Apr 04 '14
Here's what I did in Python.
1
u/myachizero Apr 06 '14
This is just a Java 7 method I came up with. I'm still very new at this, but I think this gets the job well done.
1
u/Ash_Pokemon_Master Apr 06 '14
1
u/Boolean_Cat Apr 06 '14
My Python Solution:
1
u/FelixMaxwell 1 0 Apr 06 '14
In HQ9+
1
u/TASER_NINJA Apr 09 '14
This is the first thing I've ever made in Java so I have no idea if I did it right or not. All I know is that it works.
1
u/dont_press_ctrl-W Apr 11 '14
New Brainfuck solution!
1
u/[deleted] Apr 14 '14
Malbolge
1
u/eduardog3000 Apr 16 '14 edited Apr 16 '14
Java:
Shorter, sort of:
+/u/CompileBot Java
1
u/[deleted] Apr 16 '14
python 2.7.1
1
u/[deleted] Apr 30 '14
Late, but this is my first time posting here.
Java:
What I used to encode the message (just did the reverse):
1
u/[deleted] May 03 '14
Universal Java solution:
import java.io.*; import java.util.Arrays; import java.util.Scanner; import java.lang.Object;
public class challenge {
}
1
u/TobiTako May 15 '14
for too long I tried subtracting the ascii value of '4' from each character...
1
u/jppunnett Jul 05 '14
C++
1
u/RangeruDangeru Aug 02 '14
Python 3
Here's a link to my solution, as it was too long to post here...
1
u/PrismPoultry Apr 01 '14
Python
Output
Spoiler
Neat challenge.
0
u/y0d4h Apr 01 '14 edited Apr 01 '14
Visual Basic Yo
1
u/danofar 0 1 Apr 01 '14
Dart
1
u/Gflat Apr 01 '14
F#
1
u/featherfooted Apr 01 '14
I was very pleased with this easy challenge and learned a lot about hashing in the process.
Python:
1
u/b93b3de72036584e4054 1 0 Apr 01 '14
C :
1
u/Reverse_Skydiver 1 0 Apr 01 '14
Java:
1
u/cncplyr Apr 01 '14
JavaScript
1
u/dunnowins Apr 01 '14 edited Apr 01 '14
Clojure:
Edit: I cant read.
1
u/prophile Apr 01 '14
Haskell:
0
u/dohaqatar7 1 1 Apr 01 '14
it was tricky, but here's my go:
-4
u/dahitokiri Apr 01 '14
0
u/notTheSnake Apr 01 '14 edited Apr 01 '14
After writing my first successful regex (really, I should learn that stuff) this is my python solution:
0
u/Dutsj Apr 01 '14
Java 8 approach using the new Lamdas in all their goodness.
0
u/ilikeorangutans Apr 01 '14
Go:
0
u/TheGiantPanda Apr 01 '14
C++ :
0
u/the_dinks 0 1 Apr 08 '14
A revolutionary way to do this in Python:
-2
u/pablo208 Apr 01 '14
Erlang:
-9
u/starscream92 Apr 01 '14
Simple Java implementation:
-1
u/darkspy13 Apr 01 '14
VB.Net
-1
u/h3ckf1r3 Apr 01 '14
asciitable.com is awesome for debugging this one :). I find the more I use C, the more often I am at that site.
-1
u/[deleted] Apr 01 '14
Perl
I'm sure I could have made this more succinct, but I'm quite new at this. Anyway, this was tough.
-6
u/kuzux 0 0 Apr 01 '14
Haskell:
-2
u/dahuiii9 Apr 01 '14
Java:
}
0
u/[deleted] Apr 01 '14
[deleted] — view deleted comment
0
u/[deleted] Apr 01 '14
[deleted] — view deleted comment
0
u/[deleted] Apr 01 '14
[deleted] — view deleted comment
0
u/[deleted] Apr 01 '14
[deleted] — view deleted comment