5 ms·
Really, that's easy peasy? Looks terrible to a Python programmer. :-) with open('input') as fin, open('output', 'w') as fout: for line_num, line in e
by benhoyt 13y ago
Really, that's easy peasy? Looks terrible to a Python programmer. :-)
with open('input') as fin, open('output', 'w') as fout:
for line_num, line in enumerate(fin, 1):
fout.write('{0}\n'.format(int(line) * line_num))
- biscarch 13y agoI would've went with Haskell myself ;) main :: IO () main = writeListAsLines . toDoubleList . lines =<< readFile "nums.txt" where toDoubleList y = zipWith (*) (map read y) [1..length y] writeListAsLines z = writeFile "output.txt" (concat $ intersperse "\n" $ map show z)