Help us understand the problem. What is going on with this article?

# 第6回オフラインリアルタイムどう書くrubyでの解答

More than 5 years have passed since last update.

http://nabetani.sakura.ne.jp/hena/ord6kinship/

```GEN = [1, 2, 5, 14]

def gen(n)
GEN.each_with_index do |e, i|
return i - 1 if n < e
end
3
end

def solve(q)
x, y = q.split('->').map(&:to_i)
return 'me' if x == y
gx = gen(x)
gy = gen(y)
xw = (x - GEN[gx]) / 3
yw = (y - GEN[gy]) / 3
if gx == gy
if xw == yw
return 'si'
elsif gx >= 2 and xw / 3 == yw / 3
return 'co'
end
elsif (gx - gy).abs > 1
return '-'
elsif gx > gy
if xw + GEN[gx-1] == y
return 'mo'
elsif  gx >= 2 and xw / 3  == yw
return 'au'
end
else
if yw + GEN[gy-1] == x
return 'da'
elsif  gy >= 2 and yw / 3 == xw
return 'ni'
end
end
'-'
end

no,q,a = line.chop.split(/\s+/)
ans = solve(q)
print no + "\t"
print ans
puts ans == a ? 'o' : 'x'
end
__END__
0   5->2    mo
1   28->10  au
2   1->1    me
```
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away