Skip to content

Instantly share code, notes, and snippets.

function basicTeenager(age) {
if (age === 13 || age === 14) {
return "You are a teenager!";
}
}
console.log(basicTeenager(15));
console.log(basicTeenager(15));
// print string interpolated results
# ASSUMPTION
# image is an array of arrays
# EDGE CASES
# if image is empty
# if point is out of bounds
# if image consists of one pixel
# if point is already filled
def flood_fill(image, point)
# The Problem:
# From Wikipedia: "ROT13 ("rotate by 13 places", sometimes hyphenated ROT-13) is a simple letter substitution cipher
# that replaces a letter with the letter 13 letters after it in the alphabet."
# Imagine a generic ROT-n on the ASCII lower-case alphabet.
# ROT-1 transforms "abbc" -> "bccd" and "zaab" -> "abbc".
# ROT-2 transforms "abbc" -> "cdde" and "zaab" -> "bccd".
# ...
# ROT-25 transforms "abbc" ->"zaab" etc.
# iterative solution
def palindrome(str)
for i in 0..(str.length/2)
return false if str[i] != str[str.length - 1 - i]
end
return true
end
# recursive solution
def palindrome(str)