This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
P1 was just writing to a numbers file then union results with each output then filter on root P2 was doing a replace on humn's value by hardcoding some numbers into an adjusted macro to spit out the results. I wrote down input/output and figured out a relationship then kept manually replacing til I got it. Took about 30 minutes of trial/error
Part1: split to data with number and equation. build a macro to replace to equation, if the equation is solvable, add to iteration until everything solved!
Part2: using method learn from neural network. add the error to the number with certain percentage.
e.g. question is: find b, when 1000 - b = 100, rate is 10% round 1: guess b = 300, then error is 600, multiply by rate, then add 60 (600*10%) to b round 2 will be b = 360 (300+60), then error now will be 540, multiply by rate, then add 54 (540*10%) to b etc.
the b will slowly close to correct amount. key is the rate can't too high as we do not know what calculation taking place.
There are 3 parts to this challenge: 1) Parse: get it into a flat data structure - I chose to go with a flat table with NodeName; Operand1; Operand 2; and the Operator. 2) Resolve: This is kinda like a variable resolution process in compiler theory - you take the list of nodes and break them in to 2 groups - Where we still have variables to replace with real values - where we have an actual value (a literal) Then you just loop, replacing variables with literal values until you run out - and that solves part 1 3) the solve-for-x Part 2 is kinda interesting
if you have a massive binary tree - where buried somewhere in the tree is a value that you don't know - then you do get something else for free: - One half of the tree will completely resolve to a literal number. - The half with the unknown value (humn) will flatten out to a simple chain of linked formulae - because anything that doesn't have the humn in it's direct parentage will just resolve to a literal number
So to do part 2: - Remove the Human node from the set (which had a literal value in the original) - Run part 1 - then you get a chain of one side of the tree that still needs to be resolved - all simple formulae with one known value and one unknown value - Do a "Solve for X". for example - if you have a situation where XX = ?? + YY - then you can convert this to solve for ?? by saying that ?? = XX - YY. - this essentially turns the chain that was left inside-out so that humn becomes the root - Then just run your Part 1 solver again