integer array(7) lilypad integer i integer only_one_hop_per_turn integer turn lilypad[0] = 1 lilypad[1] = 1 lilypad[2] = 1 lilypad[3] = 0 lilypad[4] = 2 lilypad[5] = 2 lilypad[6] = 2 only_one_hop_per_turn = 0 turn = 1 //Continue until solution while lilypad[0] != 2 or lilypad[1] != 2 or lilypad[2] != 2 or lilypad[3] != 0 or lilypad[4] != 1 or lilypad[5] != 1 or lilypad[6] != 1 for i = 0; i < lilypad.size; i = i + 1 if lilypad[i] == 0 //Jump Toad if i-2>=0 and lilypad[i-1] == 2 and lilypad[i-2] == 1 and only_one_hop_per_turn == 0 lilypad[i-2] = 0 lilypad[i] = 1 only_one_hop_per_turn = 1 //Jump Frog if i+2<=6 and lilypad[i+1] == 1 and lilypad[i+2] == 2 and only_one_hop_per_turn == 0 lilypad[i+2] = 0 lilypad[i] = 2 only_one_hop_per_turn = 1 //Slide Toad if turn == 1 and i-1>=0 and lilypad[i-1] == 1 and only_one_hop_per_turn == 0 lilypad[i-1] = 0 lilypad[i] = 1 turn = 3 - turn only_one_hop_per_turn = 1 //Slide Frog if turn == 2 and i+1<=6 and lilypad[i+1] == 2 and only_one_hop_per_turn == 0 lilypad[i+1] = 0 lilypad[i] = 2 turn = 3 - turn only_one_hop_per_turn = 1 //Halfway point, switch turns or will lead to dead end if lilypad[0] == 2 and lilypad[1] == 1 and lilypad[2] == 0 and lilypad[3] == 1 and lilypad[4] == 2 and lilypad[5] == 1 and lilypad[6] == 2 turn = 3 - turn only_one_hop_per_turn = 0