You are viewing a single comment's thread. Return to all comments →
Briefest I can make it in Python
def countingValleys(steps, path): elevation = count = 0 for i in range(steps): elevation += 1 if path[i] == "U" else -1 if elevation == 0 and path[i] == "U": count += 1 return count
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Valleys
You are viewing a single comment's thread. Return to all comments →
Briefest I can make it in Python