This file contains 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 my_map(&nameless_fn) | |
new_arr = [] | |
return Enumerator.new(self, :my_map) unless nameless_fn | |
self.each do |x| | |
new_arr << nameless_fn.call(x) | |
end | |
new_arr | |
end |
This file contains 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
# challenge 2: http://www.therubygame.com/challenges/2 | |
gifts = "12 Drummers Drumming | |
11 Pipers Piping | |
10 Lords-a-Leaping | |
9 Ladies Dancing | |
8 Maids-a-Milking | |
7 Swans-a-Swimming | |
6 Geese-a-Laying | |
5 Gold Rings | |
4 Colly Birds |
This file contains 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
# Challenge 3: http://www.therubygame.com/challenges/3/submissions | |
str = "The small brown & ginger fox JUMPED OVER the gate" | |
# output = "The Small Brown & Ginger Fox Jumped Over The Gate" | |
# Algorithm: | |
# 1. downcase #{str} | |
# 2. to_a | |
# 3. capitalize on each array elements | |
# 4. merge as str | |
def Capitalize(str) |
This file contains 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
# Puns, Palindromes and Parrots | |
# Challenge 4: http://www.therubygame.com/challenges/4/submissions | |
#str = "abacdfgdcabaypqqpy" # 324 171 163 | |
#str = "natarajan" # 81 45 42 # "ata" | |
str = "ghjiiooiijplr" | |
# desired output "ypqqpy" | |
def find_longest_palindrome(string) | |
p = "" |
This file contains 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
# http://www.therubygame.com/challenges/5/submissions | |
# = 1 | |
# V = 5 | |
# X = 10 | |
# L = 50 | |
# C = 100 | |
# D = 500 | |
# M = 1000 | |
# Sample i/o: | |
# MCMXCIX gives 1999, MMXII gives 2012 |
This file contains 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
# http://www.therubygame.com/challenges/6/submissions | |
module RubyChallenge | |
extend self | |
MORSE = { | |
A: '.-', B: '-...', C: '-.-.', D: '-..', E: '.', F: '..-.', G: '--.', | |
H: '....', I: '..', J: '.---', K: '-.-', L: '.-..', M: '--', N: '-.', | |
O: '---', P: '.--.', Q: '--.-', R: '.-.', S: '...', T: '-', U: '..-', |
This file contains 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
source 'https://rubygems.org' | |
# Specify your gem's dependencies in boomboom.gemspec | |
gemspec |
This file contains 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
# spec/spec_helper_lite.rb | |
def stub_module(full_name) | |
full_name.to_s.split(/::/).inject(Object) do |context, name| | |
begin | |
context.const_get(name) | |
rescue NameError | |
context.const_set(name, Module.new) | |
end | |
end | |
end |
This file contains 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
div#container { | |
border: 2px solid black; | |
background: #ddd; | |
width: 485px; | |
} | |
p { | |
background: gray; | |
padding: 10px; | |
display: inline-block; |
This file contains 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
.one { | |
background: green; | |
} | |
.two { | |
background: red; | |
} |
OlderNewer