Random coding sidequest
So there is a game on AoPS called All-Ten where you're given 4 single-digit numbers and are asked to make all numbers 1-10 using just those 4 numbers and operations. You must use all four (you can't just use 3) and u can also combine digits, u can just play the game on the site if u dont get what i mean.
Anyway so the other day I was sooo stuck. You are given numbers 4, 5, 8, 8. And you want to make the number 6 out of them. Think about it. It's not that bad in hindsight.
I tried everything in my head and I was staring at my screen for like 30 minutes just figuring out this last number out. I've never been stuck like this before where I can't get it even after 30 minutes. And so with that frustration in my mind I was stubborn to find it so I was like "imma just write a quick program to figure this last one out" cuz I really wanted to complete the board.
So here we go writing a program that brute forces all combinations, it's very similar to https://leetcode.com/problems/24-game/description/. It ended up taking me like 40 minutes thru debugging and everything. I did it iteratively without backtracking and it was mainly the python eval function that carried.
https://replit.com/@wilsonxie/all10-beast-academy?v=1#main.py
Very proud of this program as it passed all the testcases I gave it which I did fairly exhaustively.
Comments
Post a Comment