in this blog post, we are going to take a look at what is backtracking and how to implement it using ruby
First thing first what is backtracking? according to wikipedia Backtracking is a general algorithm for finding all (or some) solutions to some computational problem notably constrain satisfaction problems that incrementally builds candidates to the solutions, and abandons a candidate ("backtracks") as soon as it determines that the candidate cannot possibly be completed to a valid solution.
To understand what backtracking is let's take a problem and try to solve it using backtracking.
we will be given a tow input where the first number is the desired sum and the remaining is an array of numbers. Determine if the array or any of its sub-arrays can be summed to get the exact sum
analyzing the above problem here are the steps we want to follow to solve the problem