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 '../lib/Queue' | |
| frontier = Queue.new | |
| # set up the adjacency list that defines the graph | |
| neighbors = {} | |
| neighbors = {:a => [:b,:f], :b => [:c,:d], :c => [:e], :d =>[:e], :e =>[:c,:d], | |
| :f => [:a,:g,:h,:i], :g => [:f], :h => [:f], :i => [:f] } | |
| parent = {} |
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 SimpleQueue | |
| def initialize | |
| @queue = Array.new | |
| end | |
| #adds item to back of queue and returns the queue | |
| def enqueue(item) | |
| @queue.unshift(item) | |
| 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 SimpleStack | |
| def initialize | |
| @stack = Array.new | |
| end | |
| #removes the first item from the stack and returns the item popped | |
| def pop | |
| @stack.pop | |
| 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 fizzbuzz(number) | |
| if number % 15 == 0 | |
| "Fizzbuzz" | |
| elsif number % 3 == 0 | |
| "Fizz" | |
| elsif number % 5 == 0 | |
| "Buzz" | |
| else | |
| number | |
| end |
NewerOlder