Take input text like this: (all input should be considered strings)
Upi djpi;f ytu yu[omh pmr yp yjr ;rgy.
And figure out if it was offset left or offset right (on a standard qwerty keyboard as pictured below).
Also only keys that output something to the screen are considered valid, so these keys: caps, shift, tab, enter, delete(backspace), should not be considered when doing this challenge.
Once you have figured out what the offset is, print out the offset and the correct text.
For example the above input would have this output
text: You should try typing one to the left. offset: right
Your program has to 'know' that the sentence is correct before it prints out. (so no asking for user verification). Also no using libraries (should be a given).
All input will begin with a capital and end in a period (the period will not be offset left or right so you won't be able to use it to determine the offset.)
U kujw oeife'nnubf xibrwara. I like programming contests.
Some input samples to use:
X'ra 'bs sifa 'ew ai o'aaw. Yjod vpmysod sm stnoysto;u ;pmh eptf. Rgw x'r ;b rgw g'r qwbr iyr ri v'r. Og upi vtrsyr s d,s;; fovyopmstu pg yjr ,pdy vp,,pm rmh;odj eptfd yjrm upi vsm vjrvl upit piy[iy gpt yjpdr eptfd' yjr eptf ayjra smf yjr eptf asmfa str imowir ejrm pggdry ;rgy smf pggdry tohjy. //<< don't put this deciphered text in your answers.
And bonus option: write your program to be able to handle the input switching offsets.
Example above with switching offset:
Upi djpi;f ytu yu[omh ibw ri rgw kwdr. text: You should try typing one to the left. offset: right -> index, then left.
- Faster code gets more points (out of 10) so O(logn) would score more then O(n^2) solutions (obviously).
- Elegance (out of 20) There is a very elegant and simple solution to this problem. The closer you get to the simple solution the higher your score. (bonus +5 if you think of something simpler then my solution).
- This is not a code golf, but concise readable code will be scored (out of 10).
- Bonus is all or nothing for 5 extra points.
So A perfect score would be 40 but you could score up to 50 if you get both bonuses.
bonus +2 if you read all instructions