Another algorithm for "finding the minimum card"


#1

Two of my students (independently) came up with this algorithm - they gave me permission to share it here:

1 Move RH to position 7
2 Jump to line 5 if LHand lt RHand
3 Jump to line 8 if LHand gt RHand
4 Jump to line 8 if LHand eq RHand <–so proud they thought to handle this case!
5 Shift RH to the left
6 Jump to line 11 if RHPos eq LHPos
7 Jump to line 2
8 Shift LH to the right
9 Jump to line 11 if RHPos eq LHPos
10 Jump to line 2
11 End

I had another student do a brute force algorithm - basically check each card to see if it is 1. If not, start over in position 0 and check each card to see if it is a 2. If not, start over in position 0 and check each card to see if it is a 3. Keep going until you find the lowest card.

It lead to some interesting conversations about creativity and efficiency in algorithms.