Anyone else watch this youtube channel? I just caught this video:
That got me thinking about how you could automate card sorting, for when they inevitably got mixed up. Assuming cards are fed into one side and spat out the other, all cards are numbered in a way that can be read by the sorting machine, and the sorting machine can store three numbers in memory at a time:
Variables
n# is the ID number of the current card
hi# is the highest ID number read so far
lo# is the lowest ID number read so far
Pseudo Commands
LOAD loads the next card.
READ [var] reads the currently loaded card number into a variable.
SPIT ejects the currently loaded card.
BEEP [n] computer emits an audible noise n times, or once if there is no n.
HALT suspends the program until the operator presses a key.
GOTO [n] moves to line n.
FAIL tells the program what to do if the previous command fails.
Manual
Beeps are used to instruct the operator:
* One beep indicates that the next card is destined for the bottom of the output pile. The operator should remove the pile and replace it once the next card has been ejected.
* Two beeps indicate that the next card is destined for the position immediately below the top card. The operator should remove the top card and replace it once the next card has been ejected.
* Three beeps indicate that the loading bay is empty. The operator should take the entire output pile and put it back in the loading bay.
* When any number of beeps are sounded, the operator must prepare the output pile as required and press a key to continue the program.
Program
00 hi# = 0; lo# = 0;
01 LOAD; FAIL → BEEP 3 → HALT → GOTO 06;
02 READ n#;
03 if n# > hi# → hi# = n# → SPIT → GOTO 01;
04 if n# < lo# → lo# = n# → BEEP → HALT → SPIT → GOTO 01;
05 BEEP 2 → HALT → SPIT → GOTO 01;
// This half is reversed because the card order has been reversed
// so it means more cards can simply be spat out, making the process faster.
06 hi# = 0; lo# = 0;
07 LOAD; FAIL → BEEP 3 → HALT → GOTO 00;
08 READ n#;
09 if n# > hi# → hi# = n# → BEEP → HALT → SPIT → GOTO 07;
10 if n# < lo# → lo# = n# → SPIT → GOTO 07;
11 BEEP 2 → HALT → SPIT → GOTO 07;
Formerly OBese87.