オフラインリアルタイムどう書くF05の回答

迷走して2時間ほどかかりました。

```ruby:f05.rb
def get_board( block_bits )
  board = []
  block_bits.split('/').each_with_index { |line, y|
    line.chars.each_with_index { |c, x|
      board << [ x*2+1, y*2+1, ] if c == '1'
    }
  }
  board
end

def to_output_format( result )
  board = Array.new(5) { [0]*5 }
  result.each { |p|
    basex = (p[0]-1)/2
    basey = (p[1]-1)/2
    return '-' if basex < 0 or basex >= 5
    return '-' if basey < 0 or basey >= 5
    board[basey][basex] = 1
  }
  board.map( &:join ).join('/')
end

def solve( input )
  center_mark, block_bits = input.split(':')
  center = case center_mark
           when 'a'; [ 3, 5, ]
           when 'b'; [ 4, 4, ]
           end
  result = get_board( block_bits ).map { |x, y|
    absx = x - center[0]
    absy = y - center[1]
    [ -absy + center[0], absx + center[1], ]
  }
  to_output_format( result )
end

def test( input, expected )
  actual = solve( input )
  if actual != expected
    puts 'NG: input = %s, expected = %s, actual = %s' % [ input, expected, actual, ]
    exit(1)
  else
    puts 'OK'
  end
end

test( "a:00000/00110/00100/00100/00000", "00000/00000/00000/11100/00100" )
test( "b:00000/00000/00000/00011/00011", "-" )
test( "a:00000/00000/00000/00011/00011", "-" )
test( "b:00000/00000/00100/00000/00000", "00000/00000/01000/00000/00000" )
test( "a:00000/00000/00100/00000/00000", "00000/00000/00000/01000/00000" )
test( "b:00000/00110/00100/00100/00000", "00000/00000/11100/00100/00000" )
test( "b:00000/00000/00011/00011/00000", "00000/00000/00000/11000/11000" )
test( "a:00000/00000/00011/00011/00000", "-" )
test( "a:01110/00100/00000/00000/00000", "00000/00000/00010/00110/00010" )
test( "b:01110/00100/00000/00000/00000", "00000/00010/00110/00010/00000" )
test( "a:00000/11110/00000/00000/00000", "00000/00100/00100/00100/00100" )
test( "b:00000/11110/00000/00000/00000", "00100/00100/00100/00100/00000" )
test( "a:00000/00011/00110/00000/00000", "-" )
test( "b:00000/00011/00110/00000/00000", "00000/00000/01000/01100/00100" )
test( "a:00000/11100/11100/11100/00000", "00000/11100/11100/11100/00000" )
test( "b:00000/11100/11100/11100/00000", "11100/11100/11100/00000/00000" )
test( "a:01000/00000/00101/10010/10001", "-" )
test( "b:01000/00000/00101/10010/10001", "-" )
test( "b:10000/00000/10010/00000/00000", "01010/00000/00000/01000/00000" )
test( "a:10000/00000/10010/00000/00000", "00000/01010/00000/00000/01000" )
test( "a:00000/10101/11010/11010/01000", "-" )
test( "b:00000/10101/11010/11010/01000", "-" )
test( "b:01101/00011/01101/00000/00000", "00000/01010/01010/00100/01110" )
test( "a:01101/00011/01101/00000/00000", "-" )
test( "a:00001/00000/00000/00100/00010", "-" )
test( "b:00001/00000/00000/00100/00010", "-" )
test( "b:00100/00000/00100/01000/00000", "00000/10000/01010/00000/00000" )
test( "a:00100/00000/00100/01000/00000", "00000/00000/10000/01010/00000" )
test( "a:00010/00100/00000/10000/00000", "00000/10000/00000/00100/00010" )
test( "b:00010/00100/00000/10000/00000", "10000/00000/00100/00010/00000" )
test( "b:11010/00011/10101/00001/00001", "-" )
test( "a:11010/00011/10101/00001/00001", "-" )
test( "a:00100/00010/00000/11000/00000", "00000/10000/10000/00010/00100" )
test( "b:00100/00010/00000/11000/00000", "10000/10000/00010/00100/00000" )
test( "b:01010/00000/00000/01000/00000", "00000/10010/00000/00010/00000" )
test( "a:01010/00000/00000/01000/00000", "00000/00000/10010/00000/00010" )
test( "a:00000/00000/00100/10100/00000", "00000/10000/00000/11000/00000" )
test( "b:00000/00000/00100/10100/00000", "10000/00000/11000/00000/00000" )
test( "b:10000/01101/01000/01100/10011", "-" )
test( "a:10000/01101/01000/01100/10011", "-" )
test( "a:00010/00000/00110/01000/10001", "-" )
test( "b:00010/00000/00110/01000/10001", "-" )
test( "b:00000/01000/01100/00000/00000", "00000/01100/01000/00000/00000" )
test( "a:00000/01000/01100/00000/00000", "00000/00000/01100/01000/00000" )
test( "a:01000/00000/00000/10000/00000", "00000/10000/00010/00000/00000" )
test( "b:01000/00000/00000/10000/00000", "10000/00010/00000/00000/00000" )
test( "b:00000/01101/00000/01010/11010", "-" )
test( "a:00000/01101/00000/01010/11010", "-" )
test( "a:00110/00101/00000/10100/00100", "-" )
test( "b:00110/00101/00000/10100/00100", "-" )
test( "b:11000/10110/00000/00110/00000", "00110/00010/10100/10100/00000" )
test( "a:11000/10110/00000/00110/00000", "00000/00110/00010/10100/10100" )
test( "a:00000/00000/00000/00001/00110", "-" )
test( "b:00000/00000/00000/00001/00110", "-" )
test( "b:01011/10001/00000/00000/00000", "00100/00010/00000/00010/00110" )
test( "a:01011/10001/00000/00000/00000", "-" )
```