I have this rather simple script which generates 1000000000 (nine zeroes) numbers and then store in a file the generated numbers a how many times they were generated.
import random
import csv
dic = {}
for i in range(0, 1000000000):
n = random.randint(0, 99999)
if n in dic:
dic[n] += 1
else:
dic[n] = 1
writer = csv.writer(open('output', 'w'))
for key, value in dic.iteritems():
writer.writerow([key, value])
writer.close()
The script is exiting with a Killed
message. According to this question What does 'killed' mean?, using dic.iteritems()
should be enough for preventing such issue, but that's not the case.
So how could I proceed to accomplish such task?