On Fri Oct 31 14:57:21 2008, Paul Robinson wrote:
> a) Produce working code that passes through at least the examples  
> given on that page
> b) Figure out how to get onto that leader board

Here are both my inital and golfed solutions.

-- 
Fred O. Phillips
http://fophillips.org
BBC7 7572 755F 83E0 3209  504A E4F7 874F 1545 9D41
m,q,r,x=nil,'',%w(F E D C B A G F E),[]
z=x
gets"\0"
$_.each{|a|x<<a.split(//)}
(x[0].count/4).times{|a|b=4*a
n=1
i=0
x[3..12].each{|y|if'o'==y[b]
print r[i]
if x[i][b]=='|'
n*=4
3.times{|c|n*=2if x[i+c][b+1]=='\\'}end
print"/#{n}"if n!=1
print' 'end
i+=1}}
r = %w( F E D C B A G F E )
m,n,x,z = nil,1,[],[]
gets("\0")
$_.each_line { |a| x << a.split(//) }
(x[0].count/4).times do |a|
  b = 4*a
  x[3..12].each do |y|
    if y[b] == 'o'
      i = x.index(y) - 3
      m = r[i]
      if x[i][b] == '|'
        n *= 4
        3.times do |c|
          n *= 2 if x[i+c][b+1] == '\\'
        end
      end
      z << [m,n]
    end
  end
end
z.each do |p|
  print p[0]
  print "/#{p[1]}" unless p[1] == 1
  print " "
end
puts

Attachment: pgpGNZFPH3UUE.pgp
Description: PGP signature

Reply via email to