From: "Mauricio Fernández" Date: 2005-07-16T19:34:03+09:00 Subject: Re: [QUIZ] Sampling (#39) On Sat, Jul 16, 2005 at 08:42:12AM +0900, Ezra Zygmuntowicz wrote: > Heres my final solutions time. again on a 1.6Ghz G5. I got the code > down to 7 lines and I don't think I can get it any faster. > > ezra:~/Sites/______raill_stuff ez$ time ./sample.rb 5_000_000 > 1_000_000_000 > big_sample.txt > > real 0m31.023s > user 0m29.406s > sys 0m0.857s Let the cheating begin: batsman@tux-chan:/tmp$ time ruby ./sample2.rb 5_000_000 1000_000_000 > big_sample.txt real 0m2.637s user 0m2.370s sys 0m0.270s batsman@tux-chan:/tmp$ wc big_sample.txt 5000000 5000000 49444494 big_sample.txt batsman@tux-chan:/tmp$ tail big_sample.txt 999998676 999998939 999998953 999999212 999999272 999999344 999999665 999999724 999999908 999999982 batsman@tux-chan:/tmp$ head big_sample.txt 184 271 649 900 930 1266 1277 1370 1620 1842 -- Mauricio Fernandez