Pages

Monday 7 September 2015

CodeEval - Stepwise word - Easy

import sys

test_cases = open(sys.argv[1], 'r')
for test in test_cases:
    words=test.split()
    max_word=""
    max_length=0
    for i in range(len(words)):
        word_length=len(words[i])
        if word_length > max_length:
            max_length = word_length
            max_word = words[i]
    sol=""
    for i in range(max_length):
        if i> 0 :
            sol += " "
        for j in range(i):
            sol += "*"
        sol += max_word[i]
    print sol

test_cases.close()

No comments:

Post a Comment