Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
Simple Particle Engine for a shooter game
Snake / Nibbles clone in C and Ncurses
Please improve
Parsing of XML data has high CPU usage
Convert simple Javascript to jQuery plugin
Active Record getting unique records
List the files in a directory without the directory name or the extension
clean the code
ohs system, recruitment software, hr software, oh&s software, human resources software, ohs software
Array parsing in a block
Popular
Parsing of XML data has high CPU usage
Snake / Nibbles clone in C and Ncurses
Please improve
List the files in a directory without the directory name or the extension
Convert simple Javascript to jQuery plugin
Active Record getting unique records
Simple Particle Engine for a shooter game
Breadth first cartesian product iterator
php refactoring
first BST
Pastable version of
Circular Cipher
<pre class='prettyprint' language='ruby'>#Input string msg = "I wonder if this code can be better." #Randomly-generated key key = "s7eOhg2fqgPRWXtp303B67551G5zpEyHe78q5NR5eWKP9eq9fk54D23" #This is the only way I can figure out how to store the result of the .each loops ciphered = "" deciphered = "" beg = 32 #Equivalent to ASCII's {space} in decimal fin = 91 #Equivalent to the distance between ASCII {space} and ASCII {z} (0..msg.length-1).each do |i| foo = (msg[i] - beg) + (key[i] - beg) foo %= fin if foo > fin foo += beg ciphered << foo end (0..msg.length-1).each do |i| foo = (ciphered[i] - beg) - (key[i] - beg) foo += fin if foo < 0 foo += beg deciphered << foo end #msg should now be the same as deciphered puts msg puts ciphered puts deciphered</pre> <a href="http://www.refactormycode.com/codes/138-circular-cipher" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>