What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc? My answer is: 1,000,000 * 3 bytes using struct module, but it seems like interviewer expected another answer...
Edit. Numbers from 1 to 1,000,000 in random order (so transform like 5, 6, 7 -> 5-7 can be applied in rare case). You can use any writing method you know, but the resulting file should have minimum size.
What is the most compact way to write 1,000,000 ints (0, 1, 2...) to file using Python without zipping etc
If you interpret the 1,000,000 ints as "I didn't specify that they have to be different", you can just use a for loop to write 0 one million times.
Python: Write 1,000,000 ints to file