Pages

Sunday 6 September 2015

CodeEval - Strings and arrows - Easy

import sys

test_cases = open(sys.argv[1], 'r')
for test in test_cases:
    window=""
    for i in range(4):
        window+=test[i]
    counter=0
    for i in range(4,len(test)):
        window+=test[i]
        if(window==">>-->" or window=="<--<<"):
            counter+=1
        window=window[1:]
    print counter

test_cases.close()

No comments:

Post a Comment