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 super_fizzbuzz(array) | |
| fizzbuzzed = [] | |
| array.each do |num| | |
| if num % 3 == 0 && num % 5 == 0 # return "FizzBuzz" | |
| elseif num % 3 == 0 # return "Fizz" | |
| elseif num % 5 == 0 # return "Buzz" | |
| elseif num / | |
| place | |
| end |
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
| # shortest_string is a method that takes an array of strings as its input | |
| # and returns the shortest string | |
| # +array+ is an array of strings | |
| # shortest_string(array) should return the shortest string in +array+ | |
| # If +array+ is empty the method should return nil | |
| # array.sort.first | |
| def shortest_string(array) | |
| new_count = [ ] |
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
| max_hits = arrayfreq.values.sort.last | |
| array.find_all{ |v| arrayfreq[v] == max_hits } |
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 mode(array) | |
| arrayfreq = array.inject(Hash.new(0)) { |h,v| h[v] += 1; h } | |
| max_hits = arrayfreq.values.sort.last | |
| array.find_all{ |v| arrayfreq[v] == max_hits } | |
| end | |
| # starting with this | |
| mode([1,2,2,2,3,3,4,5,5,5,5]) | |
| # after the first line of your mode function, arrayfreq looks like this: |
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 total(scores) | |
| total = 0 | |
| scores.each do |score| | |
| total += score | |
| end | |
| return total | |
| end |
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 valid_triangle?(a, b, c) | |
| if a**2 + b**2 == c**2 | |
| return "true" | |
| else | |
| return "false" | |
| end | |
| end |
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 valid_triangle?(a, b, c) | |
| if a**2 + b**2 == c**2 | |
| return true | |
| else | |
| return false | |
| end | |
| end | |
| def valid_triangle?(a, b, c) | |
| return a**2 + b**2 == c**2 |
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
| names = %w( | |
| Andrew\ Bloom | |
| Christopher\ Castro | |
| Diego\ Lopez | |
| Steven\ Targos | |
| Matt\ Milkowski | |
| Christine\ Livingood | |
| Marta\ Contino | |
| ) |
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
| class View | |
| nameBinding: "model.name" | |
| class Model | |
| name: "andrew" | |
| view.set("name", "rob") | |
| # same as | |
| model.set("name", "rob") |
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
| { | |
| "id": 6, | |
| "name": "Campaign with RFPs and IOs", | |
| "budget_cents": 11100000, | |
| "start_date": "2013-04-29", | |
| "end_date": "2014-02-21", | |
| "client": { | |
| "id": 6, | |
| "name": "Kwik-E-Mart" | |
| }, |