Quiz#112

K

Kyle Schmitt

#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)
 
J

James Edward Gray II

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top