Top Level Namespace
Defined Under Namespace
Modules: Codenjoy Classes: LengthToXY, Point, YourSolver
Constant Summary collapse
- ELEMENTS =
ELEMENTS TYPES #########################################################
Hash.new
- FIGURES =
List of figures
[ ELEMENTS[:I_BLUE], ELEMENTS[:J_CYAN], ELEMENTS[:L_ORANGE], ELEMENTS[:O_YELLOW], ELEMENTS[:S_GREEN], ELEMENTS[:T_PURPLE], ELEMENTS[:Z_RED] ]
Instance Method Summary collapse
- #compare(pt1, pt2) ⇒ Object
-
#indexes(s, char) ⇒ Array
Return list of indexes of char
charin strings(“STR”.index returns only first char/string appear). - #sort(array) ⇒ Object
Instance Method Details
#compare(pt1, pt2) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/codenjoy/games/tetris/board.rb', line 61 def compare(pt1, pt2) if (pt1.x <=> pt2.x) != 0 pt1.x <=> pt2.x else pt1.y <=> pt2.y end end |
#indexes(s, char) ⇒ Array
Return list of indexes of char char in string s (“STR”.index returns only first char/string appear)
57 58 59 |
# File 'lib/codenjoy/games/tetris/board.rb', line 57 def indexes(s, char) (0 ... s.length).find_all { |i| s[i,1] == char } end |
#sort(array) ⇒ Object
69 70 71 |
# File 'lib/codenjoy/games/tetris/board.rb', line 69 def sort(array) array.sort { |pt1, pt2| compare(pt1, pt2) } end |