Created
January 6, 2010 16:48
-
-
Save portableworld/270403 to your computer and use it in GitHub Desktop.
This file contains 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 'enumerator' | |
def scan(arr, pile) | |
val = "" | |
a = Array.new | |
a[0] = "#{pile}" | |
until val == "done" do | |
val = gets.chop! | |
unless val == "done" | |
val.chop! | |
a << val | |
end | |
end | |
arr << a | |
end | |
def find_which_pile(arr) | |
val = gets | |
val.chop! | |
a = Array.new | |
a = arr.find {|x| x.include? val} | |
puts "File is in pile #{a[0]}" | |
find_in_pile(a, val) | |
return nil | |
end | |
def find_in_pile(a, val) | |
a.each_with_index {|e,i| | |
if e == val | |
puts "File is at position #{i}" | |
puts "Out of #{a.length}" | |
a.delete_at(i) | |
end | |
} | |
return nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment