OK I feel better. I was overcome with an urge to write some code. Now I have a program I should write. I want to combine my seating chart program (with pictures) with the program I use to randomly pick on students. I mean randomly pick who to call on. Whoops. But I don't have the time to work on that right now.
So I wanted a "toy program." I remembered that I had been playing with a simple Caesar cipher program (who else remembers ROT-13?) What I have long been meaning to do was to write a program that took a string and rotated it though all 25 possible rotations (26 puts it back the way it was) and build a list so that if you suspected a Caesar substitution you could test it to see how it was rotated. Fine.
So I took the code for rotating in the encoding program and made it a simple little string function. Added a loop to pass a string to the function with different values to rotate and put the result in a listbox. By reusing code I was done in about 10 minutes. And I have a toy program I will probably use once every couple of years and could probably find a web app that does the same thing in about the same time it took to write the code. But oh so much more satisfying.
Who knows - I might assign it as a programming assignment someday as well. BTW Mike Zamansky has a closely related (and probably more useful post) on his blog Rot13 - Gateway Drugs Techniques
Check out my related post from last year
ReplyDeleteI'd forgotten about that post Mike. Much more useful than mine. I added a link to it in body of the post.
ReplyDeleteI've long loved ciphers, as you know. While lazily watching cartoons I noticed an odd frame at the end of Gravity Falls ( http://vignette2.wikia.nocookie.net/gravityfalls/images/0/0d/S1e1_barf_gnome_code.png/revision/latest?cb=20140301184202 ). Turns out they had been embedding ciphers into every episode! A bit of fun figuring out what ciphers were used and decoding them.
ReplyDeleteChallenge accepted!
ReplyDeleteAfter reading the post, Alfred, I had to code it!
Here it is in Java: http://repl.it/e1r
(currently shows AndyNu's cipher from his image link (23rd rotation) :)
Andy, actually you are at least partially responsible for reenergizing an interest in ciphers I had but had left behind for a while.
ReplyDelete