Skip to content

Instantly share code, notes, and snippets.

@evanthebouncy
Created July 26, 2022 19:31
Show Gist options
  • Save evanthebouncy/ec38438130240b83e085b09d1a62033f to your computer and use it in GitHub Desktop.
Save evanthebouncy/ec38438130240b83e085b09d1a62033f to your computer and use it in GitHub Desktop.
sum_synth
import numpy as np
np.random.seed(0)
def generate_pair():
# make two random numbers x and y
# make x first randomly from 1 to 10
x = np.random.randint(1, 11)
y = np.random.randint(1, 11)
x_y = x + y
# output the pair as strings of ("x+y", "x = x, y = y")
input_dict = {'sum' : x_y}
output_dict = {'x' : x, 'y' : y}
return (repr(input_dict), repr(output_dict))
if __name__ == '__main__':
# import csv
import csv
to_add = []
for i in range(100):
to_add.append(generate_pair())
# convert to_add to a csv file
with open('data_gen.csv', 'w') as csv_file:
writer = csv.writer(csv_file)
writer.writerows(to_add)
print ('done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment