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 KnightsPath | |
def initialize(start, finish) | |
@start = convert_chess_position(start) | |
@finish = convert_chess_position(finish) | |
@queue = [KnightNode.new(@start, nil)] | |
end | |
def find_path | |
past_moves = [] |
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 Student | |
attr_reader :first_name, :last_name, :courses_enrolled | |
def initialize(first_name, last_name) | |
@first_name = first_name | |
@last_name = last_name | |
@courses_enrolled = [] | |
end | |
def name |
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
# Time to complete: 40 minutes | |
class Robot | |
attr_accessor :position, :items, :health, :equipped_weapon | |
def initialize | |
@position = [0,0] | |
@items = [] | |
@health = 100 | |
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
def sort2(list) | |
unsorted, sorted = list.dup, [] | |
sorted[0] = unsorted.pop | |
while unsorted.size > 0 | |
val = unsorted.pop | |
sorted.each_with_index do |s, i| | |
if val <= s | |
sorted.insert(i, val) | |
break |
NewerOlder