Here is a row of two-coloured beads.
I have been playing with creating mechanisms to detect their colour, and then transfer them correctly through a simple machine. Liberty BASIC makes this incredibly easy if you obtain an EiBotBoard, since this will drive solenoids, motors, or steppers. I use one of its outputs to drive a radio-control sevo.
Here, the upper tube was loaded with a pile of red/yellow alternates. The mechanism dropped them left or right into single-coloured piles. But I wasn't using colour detection here- just told LB to drop alternate balls on opposite sides as a check the present design of mechanism works. You can so this kind of thing if you have access to a lot of LEGO-tronics or sdimilar gear. I like to do it out of my pile of 'to be useful someday' bits!
Here is an animated GIF ( also created in Liberty BASIC) showing the reverse process, assembling a desired sequence..
The idea is to create 'machines' that can either take a mixed set of coloured beads and classify them- or select beads from bins of different colour to create a string of your choice.
This is another of my 'ongoing' projects ... I'll put a link to code at a later stage. The colour detection uses a photodetector/filter/LED/ threshold detector at present. I want to find some suitable transparent tubing ... still playing!!