#!usr/bin/env ruby
# -*- coding: utf-8 -*-

i = 0

def search(target_num,input)
  input.each_with_index do |num,index|
    if num == target_num
      puts "#{index +1}番目"
      return
    end
  end
  puts "ないよ"
end

puts "8パズル\n15パズル"
choice = gets.chomp
while true
  if choice == "8パズル"
    input = [1,2,3,4,5,6,7,9]
    break
  elsif choice == "15パズル"
    input = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,16]
    break
  else
    puts "もう一回入力して"
    redo
  end
end
search(1,input)
search(2,input)
search(3,input)
search(4,input)
search(5,input)
search(6,input)
search(7,input)
search(8,input)
search(9,input)
search(10,input)
search(11,input)
search(12,input)
search(13,input)
search(14,input)
search(15,input)
