This file contains hidden or 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 basicTeenager(age) { | |
| if (age === 13 || age === 14) { | |
| return "You are a teenager!"; | |
| } | |
| } | |
| console.log(basicTeenager(15)); | |
| console.log(basicTeenager(15)); | |
| // print string interpolated results |
This file contains hidden or 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
| # 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) |
This file contains hidden or 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
| # 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. |
This file contains hidden or 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
| # 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) |