From: Eric Mahurin Date: 2007-05-06T10:59:27+09:00 Subject: Re: Unofficial Ruby Quiz -- Ranking Choices On 5/3/07, Ken Bloom wrote: > I have a list of some items, and I would like to manually rank which ones > are most important to me. But it's not easy to rank them when I'm looking > at them all at once, so I'd like to consider them in pairs and choose > from each pair which one is most important to me. Then I'd like to use my > answers to those questions to create a ranked list. Anyone think they can > come up with a good program to quiz me about these items pairwise, and > output a ranking? The way I see it, ranking is nothing more than sorting and choosing between pairs is just the comparison of the sort. So, here is a one-liner given the item list in a file and the questions on stdin: ruby -e 'puts(ARGF.read.split.sort { |a,b| print "1: #{a}\n2: #{b}\n"; STDIN.gets.to_i*2-3}.inspect)' Eric