

See the Pen was really the meat of what I needed for my solution. So for help with implementing this solution, I looked for a Javascript implementation of the Euclidian algorithm, and came across this post Find the Great Common Divisor in Javascript. To understand why this is true, you can check this link to the Khan Academy. If you find the biggest box that will work for this size, that will be the biggest box that will work for the entire farm. So basically we want to divide an area with a certain X & Y and divide it into the largest equal squares possible.Īlong with recursion, the book explains that Euclid's algorithm will help us solve this problem.Įxplanation of Euclid's algorithm from the book: You want the plots to be as big as possible. You want to divide this farm evenly into square plots. Suppose you’re a farmer with a plot of land. I have written another post that goes more in depth into recursion, which is also an implementation of D&C.

To divide and decrease the problem it is common to use recursion and this algorithm was no different.
#JAVASCRIPT DIVIDE AND CONQUER ALGORITHM FULL#
I have been reading the book grokking algorithms and I found an interesting challenge whilst learning the divide and conquer algorithm / technique, where the full solution had not been provided.
