[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Quiz#112

Kyle Schmitt

2/8/2007 10:03:00 PM

#ok, here's my perhaps inelegant solution, and hi, I'm Kyle.

input=gets("\n")
input.downcase!
input.gsub!(/[^a-z+=]/,'')
left=input.split("==").first.split('+')
right=input.split("==").last.split('+')
exit(1) unless right.length==(right-left).length
class String
def ==(i)
if super(self.split('').sort.join)
return(super(i.split('').sort.join))
else
return(self.split('').sort.join==i.split('').sort.join)
end
end
end
left=left.join
right=right.join
success=(left==right)
exit(1) unless success
puts success
exit(0)

3 Answers

Kyle Schmitt

2/8/2007 10:23:00 PM

0

Wowzers I feel dense, I should wake up more before writing/posting ;)

James Gray

2/8/2007 10:33:00 PM

0

On Feb 8, 2007, at 4:23 PM, Kyle Schmitt wrote:

> Wowzers I feel dense, I should wake up more before writing/posting ;)

Well, it solved a different part of the problem, but was still neat
to see.

James Edward Gray II


Kyle Schmitt

2/8/2007 11:03:00 PM

0

Heh, Thanks!

On 2/8/07, James Edward Gray II <james@grayproductions.net> wrote:
> On Feb 8, 2007, at 4:23 PM, Kyle Schmitt wrote:
>
> > Wowzers I feel dense, I should wake up more before writing/posting ;)
>
> Well, it solved a different part of the problem, but was still neat
> to see.
>
> James Edward Gray II
>
>
>