Skip to content

Instantly share code, notes, and snippets.

View vjdhama's full-sized avatar
🎯
Focusing

Vijay Dhama vjdhama

🎯
Focusing
View GitHub Profile
@vjdhama
vjdhama / Rock-Paper-Scissors
Last active December 20, 2015 05:39
Edx Class 169.1x HW 1-2
#!/usr/bin/env ruby
class WrongNumberOfPlayersError < StandardError ; end
class NoSuchStrategyError < StandardError ; end
class Object
def depth #Check depth of array passed
self.class == Array ? 1 + self[0].depth : 0
end
end
@vjdhama
vjdhama / Fun with strings
Created July 25, 2013 13:28
Edx Class 169.1x HW 1-1
#!/usr/bin/env ruby
def palindrome?(str)
str = str.downcase
r = /[\W]/ #/\W/ - A non-word character ([^a-zA-Z0-9_])
str = str.gsub(r,'')
return str == str.reverse
end
def count_words(str)