Skip to content

Instantly share code, notes, and snippets.

@brunokim
Created June 9, 2022 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunokim/af35afdf2e4cd73ba20a252d5841c01e to your computer and use it in GitHub Desktop.
Save brunokim/af35afdf2e4cd73ba20a252d5841c01e to your computer and use it in GitHub Desktop.
def create_file(num_elements: int, size: int, filename: str) -> int:
with open(filename, 'w') as f:
total = 0
while total < size:
value = random.randrange(num_elements)
total += f.write(f'{value}\n')
return total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment