[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math

Search:


View post   

>> No.8887401 [View]
File: 77 KB, 1179x1209, 33335235236.png [View same] [iqdb] [saucenao] [google]
8887401

Comp-sci-god here

The simplest way to solve it would be to just brute force it. Try every number in a given range with every number in the range with every number in the range... etc checking each time to see if it satisfies the equation.

Of course that algorithm would run in O(n^6) time, where n is the test range. This is unacceptable. And there are some evident ways to improve the algorithm.

We will label the unknowns from a to h, going from left to right top to bottom.

Condition 1: Given a value, a, it is evident that the value f is always fixed. Simple algebra tells us that f is always equal to (a-6)/6. And, assuming that all numbers have to be integers, if (a-6)/6 isn't an integer, we can skip over that value of a.

Condition 2: the values of b and c both have to be factors of (a-8). We only need to iterate over the factors for the loops b and c, not the whole range

Condition 3: e's value will always be fixed at (d+4). So that loop can be left out.

Condition 4: h's value will always be fixed at (1 - f - g)* -1

Taking these into account, we can make an algorithm that has a time complexity of O(n^2)

Testing on the range -200 to 200 yields over 3000 valid answers.
On the right are some randomly selected values from the answer set

Navigation
View posts[+24][+48][+96]