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 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 |
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 | |
| 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) |
NewerOlder