Skip to content

Instantly share code, notes, and snippets.

@portableworld
Created January 6, 2010 16:48
Show Gist options
  • Save portableworld/270403 to your computer and use it in GitHub Desktop.
Save portableworld/270403 to your computer and use it in GitHub Desktop.
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