Created
February 24, 2013 14:56
-
-
Save mura303/5024127 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!ruby | |
# http://community.topcoder.com/stat?c=problem_statement&pm=11907 | |
# | |
def doit( str ) | |
citynum = str.count("C") | |
villagenum = str.count("V") | |
max = [citynum, villagenum].max | |
min = [citynum, villagenum].min | |
r = min * 2 | |
if not min == max | |
r += 1 | |
end | |
return r | |
end | |
puts doit "CVVVC" | |
puts doit "VVV" | |
puts doit "VVVVCVV" | |
puts doit "CVCVCVC" | |
puts doit "V" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment