Sport fencing competitions are organised in pools, where every fencer fences every other and the total score is totted up at the end. Sheets like this are used to keep track of which bouts have been played and what the score is: http://www.soton.ac.uk/~fencing/files/pool.pdf These sheets show an order of bouts for between 4-7 fencers, a typical number in a pool. An impending competition* got me wondering how one might use Ruby to generate those lists of bouts. A simple list of what bouts need to be fought is easy, and I wrote a simple script that produces an array of the following values for any number of contestants (in this case 4): 1 - 2 1 - 3 1 - 4 2 - 3 2 - 4 3 - 4 The difficult bit is that fencers need to be given a rest between bouts if possible, so this order won't do. Simply randomising this array may still mean someone having to do more than one fight in a row. Not having a mathematical background I can't think of a suitable method to approach this, and if anyone could suggest some hints I'd be interested to know. * I can, of course, use the existing pool sheets for the competition; this is just for my amusement. -- Posted via http://www.ruby-forum.com/.