import random
def main():
# rnd = random.randint(50, 100)
# rnd = random.random()
count = 0
postions = []
problem = ""
A = "Nu"
B = "Me"
for x in range(1, 11):
for y in range(1, 11):
if y % 10 == 0:
print(A)
problem += A + "\n"
else:
if random.random() < 0.1:
print(B, end="")
count = count + 1
problem += B
p = [x, y]
postions.append(p)
else:
print(A, end="")
problem += A
# print(count)
# print(postions)
# print("=======")
# print(problem)
print("--------------------")
print("Answer ⬇︎")
print("The number of "me" is{}Pieces".format(count))
for a in postions:
print(""Me" is{}line,{}Column".format(a[0], a[1]))
with open("result.txt", "w") as f:
f.write("Spot the difference quiz\n")
f.write(problem)
f.write("The number of "me" is{}Pieces\n".format(count))
for a in postions:
f.write(""Me" is{}line,{}Column\n".format(a[0], a[1]))
if __name__ == '__main__':
main()
The position and number of "me" will change randomly in columns of vertical x 10 and horizontal x 10.
It took a while because I did it to deepen my understanding, but I'm glad that it worked properly.
Recommended Posts