3 # $Id: lists.ruby,v 1.3 2005-06-10 16:59:56 igouy-guest Exp $
4 # http://www.bagley.org/~doug/shootout/
6 NUM
= Integer(ARGV.shift
|| 1)
11 # create a list of integers (Li1) from 1 to SIZE
13 # copy the list to li2 (not by individual items)
15 # remove each individual item from left side of li2 and
16 # append to right side of li3 (preserving order)
18 while (not li2
.empty
?)
21 # li2 must now be empty
22 # remove each individual item from right side of li3 and
23 # append to right side of li2 (reversing list)
24 while (not li3
.empty
?)
27 # li3 must now be empty
28 # reverse li1 in place
30 # check that first item is now SIZE
31 if li1
[0] != SIZE
then
35 # compare li1 and li2 for equality
39 # return the length of the list