daily pastebin goal
54%
SHARE
TWEET

Untitled

a guest Oct 12th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. STDOUT.sync = true # DO NOT REMOVE
  2. # Don't let the machines win. You are humanity's last hope...
  3.  
  4. width = gets.to_i # the number of cells on the X axis
  5. height = gets.to_i # the number of cells on the Y axis
  6. world = []
  7.  
  8. height.times do
  9.     y=[]
  10.     gets.chars.each{|e| y<<e} # width characters, each either 0 or .
  11.     world << y
  12. end
  13.  
  14. STDERR.puts width
  15.  
  16. for j in (0..width-1) do
  17.     for i in (0..height-1) do
  18.         STDERR.puts "x: y: "+ j.to_s + " " + i.to_s
  19.         if(world[i][j] == "0") then
  20.             print "#{j} #{i}"
  21.             for jj in (j..width-1) do
  22.                
  23.                 if(world[i][jj]=="0" && jj!=j) then
  24.                     print " #{jj} #{i}"
  25.                     break
  26.                 else
  27.                     if jj==(width-1) then print " -1 -1" end
  28.                 end
  29.             end
  30.             for ii in (i..height-1) do
  31.                 if(world[j][ii]=="0"&&ii!=i) then
  32.                     print " #{j} #{ii}"
  33.                     break
  34.                 else
  35.                     if ii==(height-1) then print " -1 -1" end
  36.                 end
  37.             end
  38.         puts
  39.         end
  40.     end
  41. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top