Fog Juice Posted August 23, 2009 Share Posted August 23, 2009 I've been struggling with this over the past few days and I can't seem to come up with the solution for what I'm trying to create. Suppose you have a bike combination lock with three wheels on it (one of those twist ones where there are 3 wheels, each side by side with numbers printed on each wheel). The wheels go between 0 and 15. Now suppose you have a random number generator that generates a set of 3 numbers, one for each wheel on the bike lock, and each random number generated is also between 0 and 15. And finally, suppose that the correct combination to unlock is defined by each wheel, so if the correct combination is 3,3,3 then it is $w1 = 3; $w2 = 3; $w3 = 3;, and the correct combination can be unlocked even if the wheels are offset by a total of 3. Meaning if $wh1 and $wh2 was equal to 3, and $wh3 was equal to 6 then it will still unlock. Or if $wh1, $wh2, and $wh3 all equaled 4, then that is still correct because the total offset of all 3 wheels combined is still 3. With each new random number set generated for the 3 bike lock wheels, what is the most appropriate and efficient way to check and see if the random number generated each time is the one defined as the correct combination? Quote Link to comment https://forums.phpfreaks.com/topic/171471-sixteen-numbers-and-finding-the-right-combination/ Share on other sites More sharing options...
gergy008 Posted August 23, 2009 Share Posted August 23, 2009 I've been struggling with this over the past few days and I can't seem to come up with the solution for what I'm trying to create. Suppose you have a bike combination lock with three wheels on it (one of those twist ones where there are 3 wheels, each side by side with numbers printed on each wheel). The wheels go between 0 and 15. Now suppose you have a random number generator that generates a set of 3 numbers, one for each wheel on the bike lock, and each random number generated is also between 0 and 15. And finally, suppose that the correct combination to unlock is defined by each wheel, so if the correct combination is 3,3,3 then it is $w1 = 3; $w2 = 3; $w3 = 3;, and the correct combination can be unlocked even if the wheels are offset by a total of 3. Meaning if $wh1 and $wh2 was equal to 3, and $wh3 was equal to 6 then it will still unlock. Or if $wh1, $wh2, and $wh3 all equaled 4, then that is still correct because the total offset of all 3 wheels combined is still 3. With each new random number set generated for the 3 bike lock wheels, what is the most appropriate and efficient way to check and see if the random number generated each time is the one defined as the correct combination? I hope your not hacking with this. I have tried making one of these in the past... It failed. Maybe you should try javascript...? Quote Link to comment https://forums.phpfreaks.com/topic/171471-sixteen-numbers-and-finding-the-right-combination/#findComment-904229 Share on other sites More sharing options...
Fog Juice Posted August 23, 2009 Author Share Posted August 23, 2009 I've been struggling with this over the past few days and I can't seem to come up with the solution for what I'm trying to create. Suppose you have a bike combination lock with three wheels on it (one of those twist ones where there are 3 wheels, each side by side with numbers printed on each wheel). The wheels go between 0 and 15. Now suppose you have a random number generator that generates a set of 3 numbers, one for each wheel on the bike lock, and each random number generated is also between 0 and 15. And finally, suppose that the correct combination to unlock is defined by each wheel, so if the correct combination is 3,3,3 then it is $w1 = 3; $w2 = 3; $w3 = 3;, and the correct combination can be unlocked even if the wheels are offset by a total of 3. Meaning if $wh1 and $wh2 was equal to 3, and $wh3 was equal to 6 then it will still unlock. Or if $wh1, $wh2, and $wh3 all equaled 4, then that is still correct because the total offset of all 3 wheels combined is still 3. With each new random number set generated for the 3 bike lock wheels, what is the most appropriate and efficient way to check and see if the random number generated each time is the one defined as the correct combination? I hope your not hacking with this. I have tried making one of these in the past... It failed. Maybe you should try javascript...? No it is nothing to do with hacking, to be honest it is actually part of a game. It doesn't have anything to do with wheels and bike locks. That was just the best I could do at giving a good example of what I'm trying to do without explaining the entire project. I would use javascript but I am not so good with it, I'm trying hard in PHP right now lol. Even if doing this in PHP is not as efficient, that's a sacrifice I'm willing to make to keep this only in PHP right now. Quote Link to comment https://forums.phpfreaks.com/topic/171471-sixteen-numbers-and-finding-the-right-combination/#findComment-904233 Share on other sites More sharing options...
Fog Juice Posted August 23, 2009 Author Share Posted August 23, 2009 I'd be willing to pay someone $10-20 to write this function, if someone could help. lol. Quote Link to comment https://forums.phpfreaks.com/topic/171471-sixteen-numbers-and-finding-the-right-combination/#findComment-904285 Share on other sites More sharing options...
markwillis82 Posted August 23, 2009 Share Posted August 23, 2009 The easiest way would be to create 3 nested loops starting at 0 to 15, populating you 3 variables, then process them in the final loop - how are you going to check that the number is correct (as storing the 3 pin number your trying to find in php, defeats the object). Creating the nested loops (and the offsets) isn't too much work - problem will be verifying that the number is correct Quote Link to comment https://forums.phpfreaks.com/topic/171471-sixteen-numbers-and-finding-the-right-combination/#findComment-904342 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.