Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.
I then proceeded to press the Execute button, and was surprised when it told me that the code I had entered was invalid. I took a second look at the textbox and saw this:
Wha??? That's not what I entered! So what happened here? To figure it out, I entered two simple lines:
This turned out as:
By now, I still had no clue about what happened to letters, but the numbers seemed simpler, so I took a closer look. As it turned out, the webpage was simply entering the first character, then repeating all the rest in the string every time a new one was pressed:
But what about the sections of letters? After pondering for a minute, I realized that it's just the same, but instead of repeating each subsection once, it repeats it twice:
A combination of the two works with a combination of these techniques:
Whatever glitch causes this seems to reset at punctuation and spaces, so
abc def becomes
By this point, I was so absorbed in figuring it out and turning it into an interesting challenge that I forgot why I had been on there in the first place. (I did figure out how to type normally, however: pressing space-backspace after every character. Pretty tedious, but you gotta do what you gotta do.)
The goal of the challenge is to write a program or function that takes in the text to be processed, makes the changes listed above, and outputs/returns the result.
- The input will only contain printable ASCII, and no tabs or newlines.
Inputs: (one per line)
Mess up text
This is some longer text.
CAPS LOCK && "Punc-tua"+'tion'
CaPs wItHIn loWERs
Code-golf is the best!
Meeesesessess upp teeexexextext
Thhhihihishis iss sooomomomeome looononongongongeongeongeronger teeexexextext.
CAAAPAPAPSAPS LOOOCOCOCKOCK && "Puuunununcunc-tuuuaua"+'tiiioioionion'
CaaaPaPaPsaPs wIIItItItHItHItHIItHIItHInItHIn loooWoWoWEoWEoWERoWERoWERsoWERs
Cooodododeode-gooolololfolf iss thhhehe beeesesestest!
This is code-golf, so shortest valid code in bytes wins. Tiebreaker goes to submission that reached its final byte count first.
The winner will be chosen next Monday, Nov 2. Good luck!
Edit: And the winner is... @MartinBüttner using Retina for an incredible 43-byte solution!
1 Yes, this story is completely true, and if you need any more clarification, see footnote 1.