Poné el conejo y la tortuga
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 self.size | |
| base = Pointer(self).null | |
| (base + 1).address - base.address | |
| end | |
| end | |
| struct Foo | |
| def initialize(@x, @y, @z) | |
| 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
| class HtmlBuilder | |
| def initialize | |
| @str = StringBuilder.new | |
| end | |
| def build | |
| self.yield | |
| @str.to_s | |
| 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
| class LinkedList(T) | |
| include Enumerable | |
| class Node(T) | |
| property :next | |
| property :data | |
| def initialize(@data : T, @next = nil) | |
| 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
| $x = 0 | |
| def foo1 | |
| foo2 | |
| end | |
| def foo2 | |
| foo3 | |
| 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
| class Board | |
| getter rows | |
| getter moves | |
| getter x | |
| getter y | |
| getter previous_board | |
| getter hash | |
| def initialize(@rows, @x, @y, @moves = 0, @previous_board = nil) | |
| @length_y = @rows.length |
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
| Directions = [:up, :down, :left, :right] | |
| class Board | |
| getter :cells | |
| def initialize | |
| @cells = [ | |
| ['x', 'x', ' ', 'o', ' ', 'x', 'x'], | |
| ['x', 'x', ' ', 'o', ' ', 'x', 'x'], | |
| [' ', ' ', 'o', 'o', 'o', ' ', ' '], |
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 Int64 | |
| def palindrome? | |
| num = self | |
| reverse = 0_i64 | |
| while num > 0 | |
| dig = num % 10 | |
| reverse = reverse * 10 + dig | |
| num = num / 10 | |
| end | |
| self == reverse |
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 "strscan" | |
| class Command | |
| end | |
| class Name < Command | |
| attr_reader :name | |
| def initialize(name) | |
| @name = name |