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
| # Write a method ordered_vowel_words that takes a string of lowercase words | |
| # and returns a string with just the words containing all their vowels | |
| # (excluding "y") in alphabetical order | |
| def ordered_vowel_words(words) | |
| vowels = %w(a e i o u) | |
| ordered = [] | |
| words.split(" ").each do |word| | |
| word_vowels = word.chars.select { |char| vowels.include? char } # amends = ae, complicated = oiae | |
| ordered << word if word_vowels == word_vowels.sort |
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
| # Write a function which takes a number N of cats and outputs which cats have | |
| # hats. Initially, none of the cats have hats. You walk down the line of cats, | |
| # stopping at every cat, taking off its hat if it has one or putting on a hat | |
| # if it doesn't have one. On the second round, you only stop at every second | |
| # cat [eg #2, #4, #6], on the third round you stop at every third cat [eg #3, | |
| # #6, #9...]. You continue this until you've done as many round as there are | |
| # cats. Your function should output an array containing booleans indicating | |
| # whether each cat has a hat or not by the end. | |
| def cats_in_hats(num_cats) |
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
| # Build a function morse_encode that takes in a word (no numbers or | |
| # punctuation) and outputs the morse code for it. Put two spaces between | |
| # words and one space between letters. | |
| # http://www.w1wc.com/pdf_files/international_morse_code.pdf | |
| def morse_encode(str) | |
| morse_codes = { a: ".-", b: "-...", c: "-.-.", d: "-..", e: ".", f: "..-.", | |
| g: "--.", h: "....", i: "..", j: ".---", k: "-.-", l: ".-..", | |
| m: "--", n: "-.", o: "---", p: ".--.", q: "--.-", r: ".-.", | |
| s: "...", t: "-", u: "..-", v: "...-", w: ".--", x: "-..-", |
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
| //= require jquery | |
| //= require track-events | |
| describe('TrackEvents', function () { | |
| beforeEach(function () { | |
| loadFixtures('track-events_fixture'); | |
| }); | |
| it('triggers a Test.fire', function() { | |
| Test = function () { } |
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
| // Write a function to get the common letters out of two strings | |
| // commonLetters('hello world', 'hello moon') => should return 'helo' | |
| function commonLetters(str1, str2) { | |
| var map = {}, | |
| common = ''; | |
| for (var i = 0; i < str1.length; i++) { | |
| var letter = str1[i]; | |
| if (letter != ' ') map[letter] = true; |
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
Show hidden characters
| { | |
| "font_size": 20, | |
| "date_format": "(%Y-%m-%d %H:%M)", | |
| "color_scheme": "Packages/PlainTasks/tasks-monokai.hidden-tmTheme" | |
| } |
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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>ANSIBlackColor</key> | |
| <data> | |
| YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS | |
| AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECgw | |
| LjE1NjE5MDIxMDUgMC4wMTk1OTcyNTAxNSAwLjEzOTY3MzE4NjEAEAGAAtIQERITWiRj | |
| bGFzc25hbWVYJGNsYXNzZXNXTlNDb2xvcqISFFhOU09iamVjdF8QD05TS2V5ZWRBcmNo |
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
| def nearest_larger(arr, idx) | |
| diff = 1 | |
| loop do | |
| left = idx - diff | |
| right = idx + diff | |
| diff += 1 | |
| if (left >= 0) && (arr[left] > arr[idx]) | |
| return left | |
| elsif (right < arr.length) && (arr[right] > arr[idx]) |
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
| def left_match(arr, idx) | |
| num = arr[idx] | |
| unless idx.zero? | |
| (idx - 1).downto(0) do |i| | |
| return i if arr[i] > num | |
| end | |
| end | |
| nil | |
| end |