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 hashify | |
Hash.new.tap do |hash| | |
each { |obj| hash[obj] = yield(obj) } | |
end | |
end | |
def reverse_hashify | |
Hash.new.tap do |hash| |
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
Topic | |
- [ ] Code Katas | |
- [ ] Find all the unique sequences of digits, like [1, 1, 2, 3, 8] that have the following properties: | |
Each element of the sequence is a digit between 1 and 9 | |
The digits add to 15 | |
There is at least digit that appears exactly twice | |
No digit appears more than twice | |
Order is irrelevant [1, 1, 2, 3, 8] and [1, 3, 2, 1, 8] are the same sequence and only count once. | |
I believe the original problem did specify that there are 38 sequences that match. | |
- [ ] Bowling Scores |
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 'benchmark' | |
require 'test/unit' | |
class Array | |
def map_with_index | |
ary = [] | |
each_with_index { |elt, i| ary << yield(elt, i) } | |
ary | |
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
select: | |
applicants: | |
- cas_id | |
- last_name | |
- first_name | |
designations: | |
- date_locked | |
statuses: | |
- name | |
join: |
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 Object | |
def truthy | |
self && yield | |
self | |
end | |
def falsy | |
self || yield | |
self |
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
[core] | |
repositoryformatversion = 0 | |
filemode = true | |
bare = false | |
logallrefupdates = true | |
[remote "origin"] | |
fetch = +refs/heads/*:refs/remotes/origin/* | |
url = [email protected]:cpi2.git | |
[branch "master"] | |
remote = origin |
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 foo | |
1 | |
end | |
def meth(arg) | |
"Arg = #{ arg }" | |
end | |
def same_line | |
foo = meth foo |
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 evaluate_game(game) | |
"PSRP"[ "#{ game[0][1] }#{ game[1][1] }" ] ? game[1] : game[0] | |
end | |
def report_game(game) | |
puts "#{ game[0][0] } vs. #{ game[1][0] }" | |
puts "\tWinner = #{ evaluate_game(game)[0] }\n\n" | |
end | |
paper1 = [ "Papa Err", "P" ] |
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
<!DOCTYPE html> | |
<head> | |
<title>and my axe</title> | |
<style type="text/css"> | |
* { text-align: center; } | |
a { | |
text-decoration: none; | |
color: #000; | |
} | |
h1 { |
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 Object | |
def send_key_path(key_path) | |
key_path.inject(self) { |current, method| current.send(method) } | |
end | |
end | |
class Foo | |
def bar |