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
| #!/usr/bin/env ruby | |
| class Array | |
| def flatter | |
| if empty? # base case | |
| self | |
| else | |
| tail = pop | |
| if tail.kind_of? Array | |
| flatter + tail.flatter |
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
| Orders table with columns serviceid, Date, name, regionid | |
| Region table with columns id, name | |
| service table with columns id, fees |
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
| curl https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyBm7qeH-ey9sycnGi1sy8Barqm5f1E_ESU -H 'Content-Type: application/json' -d '{"longUrl": "http://www.google.com/"}' | |
| { | |
| "kind": "urlshortener#url", |
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 GameOfLife | |
| def initialize(name, size, generations, initial_life=nil) | |
| @size = size | |
| @board = new_board | |
| populate_board(initial_life) | |
| print_board(name, 0) | |
| reason = generations.times do |gen| | |
| prev_board = @board | |
| @board = evolve |
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
| #Input: K, N (where 0 < N < ∞, 0 < K < ∞, and K <= N) | |
| # Number of possible equations of K numbers whose sum is N | |
| # | |
| #Example Input: N=10 K=3 | |
| # | |
| #Example Output: | |
| #Total unique equations = 8 | |
| #1 + 1 + 8 = 10 | |
| #1 + 2 + 7 = 10 | |
| #1 + 3 + 6 = 10 |
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 Dictionary | |
| attr_accessor :entries | |
| attr_accessor :keywords | |
| def initialize | |
| @x = Hash.new | |
| end | |
| def entries | |
| @x |
NewerOlder