This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save this file to your computer so you can run it | |
# via the command line (Terminal) like so: | |
# $ ruby deaf_aunty.rb | |
# | |
# Your method should wait for user input, which corresponds | |
# to you saying something to your Aunty. | |
# You'll probably want to write other methods, but this | |
# encapsulates the core Aunty logic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_roman(num) | |
# Your code here | |
roman_hash = { "M" => 1000, | |
"CM" => 900, | |
"D" => 500, | |
"CD" => 400, | |
"C" => 100, | |
"XC" => 90, | |
"L" => 50, | |
"XL" => 40, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is how you define your own custom exception classes | |
class NoOrangesError < StandardError | |
end | |
class OrangeTree | |
def initialize | |
@age = 0 | |
@orange_on_tree = [] | |
@height = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convert(num) { | |
var roman_hash = { "M" : 1000, | |
"CM" : 900, | |
"D" : 500, | |
"CD" : 400, | |
"C" : 100, | |
"XC" : 90, | |
"L" : 50, | |
"XL" : 40, | |
"X" : 10, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function where(collection, source) { | |
var arr = []; | |
// What's in a name? | |
var key = Object.keys(source); | |
for( var i = 0; i < collection.length; i++ ){ | |
var counter = 0; | |
for (var k = 0; k < key.length; k++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myReplace(str, before, after) { | |
var regex = new RegExp(before); | |
if(before[0] === before[0].toUpperCase()){ | |
after = after[0].toUpperCase() + after.slice(1) ; | |
} | |
return str.replace(regex,after); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function translate(str) { | |
if((/^[aeiou]$/i).test(str[0])){ | |
str = str + "way"; | |
}else{ | |
if((/^[aeiou]$/i).test(str[1])){ | |
str = str.slice(1) + str[0] + "ay"; | |
}else{ | |
str = str.slice(2) + str[0] + str[1] + "ay"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pair(str) { | |
var dna_pair = { "A" : "T", | |
"T" : "A", | |
"C" : "G", | |
"G" : "C"}; | |
str = str.split(""); | |
for(var i = 0; i < str.length; i++){ | |
var arr = [str[i]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fearNotLetter(str) { | |
var charCode = String.charCodeAt(str[0]); | |
for(var i = 1; i < str.length; i++){ | |
charCode++; | |
if(str[i] != String.fromCharCode(charCode).toLowerCase()){ | |
return String.fromCharCode(charCode); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unite(arr1, arr2, arr3) { | |
var combined = arguments[0]; | |
for(var x = 1; x < arguments.length; x++){ | |
for(var i = 0; i < arguments[x].length; i++){ | |
var counter = 0; | |
for(var j = 0; j < combined.length; j++){ | |
if(arguments[x][i] != combined[j]){ | |
counter++; | |
} |
OlderNewer