(Potential massive search-space) Is this an exponential problem?

  • Thread starter Thread starter htyj6g9jv1ev6
  • Start date Start date
  • Tags Tags
    Exponential
AI Thread Summary
The journey consists of 256 steps where a person can either walk or hop, leading to a total of 2^256 possible combinations of movements. The discussion confirms that the exponential nature of the problem makes it computationally intensive, as brute force algorithms would struggle with such a vast search space. To implement the algorithm, one can count from 0 to 2^256-1, converting each number to a 256-digit binary representation to denote the combinations. The order of the generated paths allows for insights into smaller step sizes as well. The necessity for 256 steps and the requirement for a complete list of combinations were questioned, suggesting potential reconsideration of the approach.
htyj6g9jv1ev6
Messages
6
Reaction score
0
I'm writing a piece of software, however, my math skills are VERY rusty at the moment.

The problem is as follows:

  1. There is a journey consisting of 256 steps
  2. The person, can either i) walk, or ii) hop
  3. The person can choose what to do at each step
  4. I want to compute a list of all possible journey

I'm wondering if my attempt is futile... As the search-space may be too huge if this problem is indeed exponential.

My specific question is, how many ways are there through this journey? How many combinations of "walk" and "hop"?

I'm hoping that I'm wrong and the answer is not 2^256 (or around that area...). Otherwise I will have to abandon my simplistic brute force algorithm :D

Thank you!
 
Mathematics news on Phys.org
htyj6g9jv1ev6 said:
I'm writing a piece of software, however, my math skills are VERY rusty at the moment.

The problem is as follows:

  1. There is a journey consisting of 256 steps
  2. The person, can either i) walk, or ii) hop
  3. The person can choose what to do at each step
  4. I want to compute a list of all possible journey

I'm wondering if my attempt is futile... As the search-space may be too huge if this problem is indeed exponential.

My specific question is, how many ways are there through this journey? How many combinations of "walk" and "hop"?

I'm hoping that I'm wrong and the answer is not 2^256 (or around that area...). Otherwise I will have to abandon my simplistic brute force algorithm :D

Thank you!

The answer is simply 2^256.

Test it out for smaller steps sizes.

2^1 = 2: 0,1
2^2 = 4: 00,01,10,11
2^3 = 8: 000,001,010,011,100,101,110,111

0 corresponding to walk
1 corresponding to hop

If you want to write your algorithm, it's incredibly easy. Just count from 0 to 2^256-1 writing out the number in 256 digit binary at each iteration. You'll need storage for 256 bits of precision, so you're not going to be able to rely on the built-in types, but you can handle this easily with nested loops. For 32-bit precision, you'll need 8 nested loops, then just write out the counters in 32-bit binary, in order.

The cool thing about this is that the order that the paths come out in, means that the early ones are valid for smaller step sizes too, so you can see where your computer stops making progress.

Was there a particular reason why you needed 256 steps?
Also is there a particular reason that you need a list of them?
 
Last edited:
Thread 'Video on imaginary numbers and some queries'
Hi, I was watching the following video. I found some points confusing. Could you please help me to understand the gaps? Thanks, in advance! Question 1: Around 4:22, the video says the following. So for those mathematicians, negative numbers didn't exist. You could subtract, that is find the difference between two positive quantities, but you couldn't have a negative answer or negative coefficients. Mathematicians were so averse to negative numbers that there was no single quadratic...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Thread 'Unit Circle Double Angle Derivations'
Here I made a terrible mistake of assuming this to be an equilateral triangle and set 2sinx=1 => x=pi/6. Although this did derive the double angle formulas it also led into a terrible mess trying to find all the combinations of sides. I must have been tired and just assumed 6x=180 and 2sinx=1. By that time, I was so mindset that I nearly scolded a person for even saying 90-x. I wonder if this is a case of biased observation that seeks to dis credit me like Jesus of Nazareth since in reality...
Back
Top