Skip to content

Instantly share code, notes, and snippets.

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
def north_korean_cipher(coded_sentence)
input = coded_sentence.downcase.split("") # takes the input and splits each letter into its own string. Check out this method in IRB to see how it works! Also refer to the ruby docs.
decoded_sentence = [] #blank array
cipher = {"e" => "a", # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash
"f" => "b", # the best data structure for this problem? What are the pros and cons of hashes?
"g" => "c",
"h" => "d",
"i" => "e",
"j" => "f",
"k" => "g",
// refactored code
// first set of functions received from Jake
// sum function worked upon receiving; did not modify
var sum = function(array){
var total = 0;
for(var index in array)
total += array[index];
return total;
}