Jump to content

Kriptonic

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Kriptonic's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've conducted the changes listed in my previous post. Across a sample of 10 generations, I was it go as low as 200 loops to match the numbers or as high as 2500 loops to make a match. That was with a base of 4 numbers x 4 digits to get a total length of 16. I think this is acceptable. It might take around instant to 3 seconds max but I feel this will be acceptable as a result is better then no result. Thanks again to all who've provided input. Should I improve the function, I will post here those findings. I don't think I will mark it as complete yet because it's not that efficient and I'm interested to see if anyone comes up with a system that works better then my own.
  2. So I sat down and had a think. I came to the conclusion that what I really needed was to generate a list of possible number combinations. I've written the following code: if($_POST['submit'] == "Split"){ $split = '2889607315973661';//$_POST['res']; $sum = '14220';//$_POST['gat']; checkForMatch($split,$sum); } function checkForMatch($num,$tot){ //work out the length of the main number $numLen = strlen($num); //we know we HAVE to have 4 numbers, so after we take a random split, we need to be //100% sure we can make the remaining numbers that total 4 $numbersAssigned = 0; for($i=3;$i>=0;$i--){ //the next number will be: // numbers length - numbers we've assigned already - numbers left to make //the above ensures that after we've made a number, there are enough digits left to make the remaining numbers $randomSlice = rand(1,$numLen-$numbersAssigned-$i); //if this is the last number, just assign the unasigned numbers to it as there is no need for a random if($i==0) $randomSlice = $numLen-$numbersAssigned; //if we've taken our last number length as 4, increment the total so we can take it into consideration next time $numbersAssigned += $randomSlice; echo $randomSlice . "<br/>"; } echo "<b>$numLen</b>"; } The output will be 4 numbers, these are the lengths of of the internal 4 numbers and the final is the length of our string. See below an example of the output: 1 8 4 3 16 The problem to note here is that there is no structure to the number splitting, so should there be a large number and the random number generator sucks, we could theoretically go on forever. I've tested with different lengths of number and it's all working perfectly so far, but as I said, there is no structure at the moment. I'm going to keep messing around as well as expanding the function. I will make it get the numbers using the splits as well as checking that they match the total. I may also implement a while loop to keep checking until a match was found. I will post more results here when I'm done.
  3. Thanks for the comments. @AyKay47 - Thanks, the system I had in place worked like that, though it was a little more long winded, that will help @btherl - I agree with the 1, 11, 11, 1 cases, however the likely hood that the numbers are that small is small it's self, so things like that don't worry me. (numbers have a much higher chance to be in the thousands then the tens, though that chance still remains) I suppose my main challenge is figuring out how to break the big number up into almost every combination of 4 numbers that we can make, that way we can cycle through until we get a match... This tool is part of a bigger system, once I'm done with some of my current tasks I'll be back to work on this tool. I'll post my findings as others may find it useful.
  4. Probably not a good subject but I'll get to the point. I am creating a webpage parser where the user copies an entire page and dumps it to a text box, my PHP script will run through and extract all data it needs. One problem is 4 numbers I need. These numbers can be anything from 0 up to 50,000 each (could be higher). For this example I am going to say the 4 numbers in this instance are: 2889 6073 1597 3661, their total is 14220. (In all cases there will always be 4 numbers, 0 is always represented as 0 and I will always have the total of the 4 numbers) When pasted into the text box, the 4 numbers get combined, the above example would yield 2889607315973661 as a number. By using the number '2889607315973661' and the known total of '14220', how can I work out what the 4 separate numbers are that made it up? Just to point out, the numbers 10 16024 0 21 (1016024021) could come out with a total of '16055', the odds of the 4 numbers being equal in length are slim. I've thought about it, I've messed about with it, I am just completely stumped on where to start and the best way to go about it. Big thanks to anyone who can shed some light onto this matter and point me in the right direction, I'm just confused and it hurts my brain to think about
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.