Skip to content

Instantly share code, notes, and snippets.

@mura303
Created February 24, 2013 14:56
Show Gist options
  • Save mura303/5024127 to your computer and use it in GitHub Desktop.
Save mura303/5024127 to your computer and use it in GitHub Desktop.
#!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