IdeaMonk

thoughts, ideas, code and other things...

Wednesday, June 11, 2008

KAMIL! jumping from 57 to 53 to 46!

Okay this is what made me happy about ruby -

10.times do
s=gets
p=1
s.gsub(/[DTFL]/){p*=2}
puts p
end

this made me happier :) to 53 bytes
i just remembered that Ruby is object oriented to the core!

10.times do
p=1
gets.gsub(/[DTFL]/){p*=2}
puts p
end

and some common syntax sense made it shrink to 48 bytes :))

10.times{p=1;gets.gsub(/[DTFL]/){p*=2}
puts p}

Still i know there is a shorter solution... that's the beauty of spoj.
The day ends in world rank of 1900 and 1.4 points. :)

Labels: , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home