Win a copy of Functional Reactive Programming this week in the Other Languages forum!

# Glass arrangement

Sameer Jamal
Ranch Hand
Posts: 1870

You are looking down at nine glasses labeled 1-9. All are half filled with milk and are arranged in a 3 x 3 pattern as shown above. The following actions are performed to the glasses: Glass 4 is switched with glass 6 after glass 8 is emptied into 6. Glass 7 is emptied into glass 1. Glass 8 is moved to where glass 5 sits, while glass 5 moves to where glass 3 sits, and glass 3 is placed where 8 began. Glass 2 is emptied into glass 4. Glass 6 is emptied into glass 7, and switches places with glass 8.

Referring to the actions above, what will be the possible arrangement of the glasses

bhuvan sundar
Ranch Hand
Posts: 104
what is the role of the action 'emptying'? shld the glasses be arranged in the order of the quantity?

Sameer Jamal
Ranch Hand
Posts: 1870
"Emptied" means pouring all the content of the source glass to destination. Arrangement of galsses should be shown after swapping including their content.

bhuvan sundar
Ranch Hand
Posts: 104
the final arrangement:

1(full) 2(empty) 5(1/2 full)
8(empty) 6(empty) 4(full)
7(full) 3(1/2 full) 9(1/2 full)
[ October 04, 2005: Message edited by: bhuvan sundar ]

Akhilesh Trivedi
Ranch Hand
Posts: 1608
1 2 3
4 5 6
7 8 9

You are looking down at nine glasses labeled 1-9. All are half filled with milk and are arranged in a 3 x 3 pattern as shown above.

The following actions are performed to the glasses:
Let me use following notations

E=Empty
F=Full
H=Half

Glass 4 is switched with glass 6 after glass 8 is emptied into 6.

At first,
1H 2H 3H
4H 5H 6H
7H 8H 9H

Emptying 8 into 6
1H 2H 3H
4H 5H 6F
7H 8E 9H

Switching 4 with 6
1H 2H 3H
6F 5H 4H
7H 8E 9H

Glass 7 is emptied into glass 1.
1F 2H 3H
6F 5H 4H
7E 8E 9H

Glass 8 is moved to where glass 5 sits, while glass 5 moves to where glass 3 sits, and glass 3 is placed where 8 began.
1F 2H 5H
6F 8E 4H
7E 3H 9H

Glass 2 is emptied into glass 4.
1F 2E 5H
6F 8E 4F
7E 3H 9H

Glass 6 is emptied into glass 7, and switches places with glass 8.
1F 2E 5H
6E 8E 4F
7F 3H 9H

1F 2E 5H
8E 6E 4F
7F 3H 9H

Hey its cool. Liked it very much.
----------------

Sameer Jamal
Ranch Hand
Posts: 1870
Akhil do you work for CMM Level 5 company