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 answer=(value) | |
@answer = value | |
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
@answer = "42" # => "42" | |
"Deep Thought said #{@answer} is the answer." # => "Deep Thought said 42 is the answer." |
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 Array | |
def merge_sort(&prc) | |
return self if count < 2 | |
prc ||= proc { |left, right| left <=> right } | |
left = self[0...(count / 2)] | |
right = self[(count / 2)..-1] | |
Array.merge(left, right, &prc) | |
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
[1] pry(main)> jerry = {}; | |
[2] pry(main)> a = []; | |
[3] pry(main)> jerry[a] = "anti-dentite"; | |
[4] pry(main)> a << "seinfeld"; | |
[5] pry(main)> jerry[[]] = "yada"; | |
[6] pry(main)> jerry | |
=> {["seinfeld"]=>"anti-dentite", []=>"yada"} | |
[7] pry(main)> a.pop; a | |
=> [] | |
[8] pry(main)> jerry.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
function waysToScore(awards, score, sorted = false) { | |
// Ensure the ways to score points are sorted. | |
if(!sorted) { awards.sort((a, b)=>( a - b )); } | |
var ways = new Array(score + 1).fill(0); | |
// There's one way to score 0 points | |
ways[0] = 1; | |
// Loop through each integer from 1 up to the score |
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 waysToScore(awards, score) { | |
var ways = new Array(score + 1).fill(0); | |
// There's one way to score 0 points | |
ways[0] = 1; | |
// Loop through the awards | |
for (var a = 0; a < awards.length; a++){ | |
// Loop through each integer from the award value up to the score |
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 | |
# Source: https://gist.github.com/timheilman/1bb8da91be4b79425d67314c9ae23f6b | |
# credit to https://www.github.com/joneshf | |
require 'rubocop' | |
changed_files = | |
`git diff --name-only --cached -- '*.rb' '*.rake'` | |
.split("\n").join(' ') |
OlderNewer