[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Fwd: Answer to #113

James Gray

2/11/2007 11:31:00 PM

Begin forwarded message:

> From: "Luke Ivers" <technodolt@gmail.com>
> Date: February 9, 2007 3:17:19 PM CST
> To: james <james@grayproductions.net>
> Subject: Answer to #113
>
> I'm not sure if I've seen you say how we're supposed to submit
> answers, but here are the lines of code I used, each line
> corresponding to a given quiz question.
>
> (ie first line of cod is first question, second line is second
> question, etc.)
>
> quiz.to_s.reverse.gsub(/(\d\d\d)(?=\d)(?!\d*\.)/, '\1,').reverse
>
> t=[];quiz.each{|x|(Array===x)?x.each{|y|t<<y}:t<<x};t
>
> quiz.sort{rand}
>
> eval("#{quiz}.new").class
>
> quiz.gsub(/(.{1,40})( +|$\n?)|(.{1,40})/, "\\1\\3\n")
>
> t=[];quiz[1..-1].each{|v|(v.scan(/./).sort==quiz[0].scan(/./).sort)?
> t<<v:nil};t
>
> s='';quiz.split.each{|v|v.each_byte{|x|s<<'%b'%x};s<<"\n"};s
>
> quiz.readlines.each{|v|rand(2)==0?eval('s=v;break'):s=v};s
>
> t=[quiz];until quiz==1;t<<(quiz=(quiz%2==0?quiz/2:quiz*3+1));end;t
>
> h={};t=h;quiz[0..-3].each{|v|t[v]={};t=t[v]};t.store(quiz[-2],quiz
> [-1]);h