Skip to content

Instantly share code, notes, and snippets.

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 = []
@rsepassi
rsepassi / Students_and_Courses.rb
Last active December 10, 2015 20:48
Ryan's comments for (Ketabchi-Oleinikov)
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
@rsepassi
rsepassi / robot.rb
Created January 3, 2013 19:41
intro exercise
# Time to complete: 40 minutes
class Robot
attr_accessor :position, :items, :health, :equipped_weapon
def initialize
@position = [0,0]
@items = []
@health = 100
end
@rsepassi
rsepassi / gist:4446280
Last active December 10, 2015 14:18
Two array sort methods
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