Barand Posted January 15, 2007 Share Posted January 15, 2007 No trick. There is a solution, but it's bigger than MAXINT Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-160965 Share on other sites More sharing options...
.josh Posted January 15, 2007 Share Posted January 15, 2007 so...does finding the answer involve running it on a 64 bit processor then? Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-160971 Share on other sites More sharing options...
tauchai83 Posted January 15, 2007 Share Posted January 15, 2007 hehehe..all the good PHP programmer is challenging each other....let's write a shopping cart coding. Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161042 Share on other sites More sharing options...
Barand Posted January 15, 2007 Share Posted January 15, 2007 Didn't even have 8 bit processors when it was originally set :D Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161353 Share on other sites More sharing options...
Orio Posted January 15, 2007 Share Posted January 15, 2007 So what's the next [i]possible[/i] challenge Barand? ;)Orio. Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161356 Share on other sites More sharing options...
Barand Posted January 15, 2007 Share Posted January 15, 2007 The original solution was found using pencil, paper and algebra, so there's no impossibility, just a degree of difficulty. Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161408 Share on other sites More sharing options...
Barand Posted January 15, 2007 Share Posted January 15, 2007 HINT 1: for the "brute force" computational approach the bcmath library may helpHINT 2: to cut down on run time, you are looking for a 16 digit number Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161420 Share on other sites More sharing options...
.josh Posted January 15, 2007 Share Posted January 15, 2007 damn...someone figured that out using pencil and paper and it's a 16 digit number? That's epic... Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161426 Share on other sites More sharing options...
Barand Posted January 15, 2007 Share Posted January 15, 2007 I can remember the question and I can remember the answer (even after 40 years) but the route twixt the two is a little foggy.I know you start off with 3 * (a[sub]n[/sub]10[sup]n[/sup] + a[sub]n-1[/sub]10[sup]n-1[/sup] + ... + a[sub]1[/sub]10 + a[sub]0[/sub]) = 2 * (a[sub]n-1[/sub]10[sup]n[/sup] + a[sub]n-2[/sub]10[sup]n-1[/sup] + ... + a[sub]0[/sub]10 + a[sub]n[/sub])if that helps :D Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161483 Share on other sites More sharing options...
.josh Posted January 15, 2007 Share Posted January 15, 2007 okay well all of that wierd looking thing looks well...wierd. and not just cuz it's wavy. The wavy actually helped. so I opted for the bcmath/bruteforce method. It's been running for about 15 min. now... Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161535 Share on other sites More sharing options...
Philip Posted January 16, 2007 Share Posted January 16, 2007 I [b]think[/b] understand what you're saying Barand, however, did you write the Sigma in the correctly on the right side? Should it be 2 * (a[sub]n-1[/sub]10[sup]n[/sup] + a[sub]n-2[/sub]10[sup]n-1[/sup] + ... + a[sub]0[/sub]10 + a[sub]-1[/sub])?I dunno, I'm only in high school Calculus, but I'm afraid I'm trying to over-complicate it. However, I must admit, it does look like some tangent function, at least from what I could tell from looking at all the numbers. Asymptotes are at x=0 and x=5. Am I on the right path? Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161599 Share on other sites More sharing options...
Barand Posted January 16, 2007 Share Posted January 16, 2007 The last term should be a[sub]n[/sub] as that is the digit that was moved from the first position to the last.If I remember correctly, the solution went like this, but I remember you finally have to divide 3*10[sup]n[/sup] by 17, so I'm not sure how to get rid of that annoying "2*a[sub]n[/sub]"3 * (a[sub]n[/sub]10[sup]n[/sup] + a[sub]n-1[/sub]10[sup]n-1[/sup] + ... + a[sub]1[/sub]10 + a[sub]0[/sub]) = 2 * (a[sub]n-1[/sub]10[sup]n[/sup] + a[sub]n-2[/sub]10[sup]n-2[/sup] + ... + a[sub]0[/sub]10 + a[sub]n[/sub]) Let X = a[sub]n-1[/sub]10[sup]n-1[/sup] + ... + a[sub]1[/sub]10 + a[sub]0[/sub], then 3 * a[sub]n[/sub]10[sup]n[/sup] + 3*X = 2*10*X + 2*a[sub]n[/sub] 3 * a[sub]n[/sub]10[sup]n[/sup] - 2*a[sub]n[/sub] = 17*X Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161604 Share on other sites More sharing options...
Philip Posted January 16, 2007 Share Posted January 16, 2007 Hmm, okay. Makes sense... kinda.I guess I'll have to see if my calc teacher can get it. He can do crazy things in his head.And btw, - Someone posts a Simple - Intermediate PHP challenge. IS one of the rules... but I don't think you broke it, the PHP isn't hard... its the math getting to the PHP that is :P Nice workaround for the rules :P Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161611 Share on other sites More sharing options...
Barand Posted January 16, 2007 Share Posted January 16, 2007 It can be done with brute force, patience and a liquid-cooled processor.BTW, CV - how's it going. Is your cpu smoking yet? (the 3 * 10[sup]n[/sup]/17 is a hell of a hint) Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161614 Share on other sites More sharing options...
Barand Posted January 16, 2007 Share Posted January 16, 2007 In case it hasn't finished by breakfast timeAnswer : 1,176,470,588,235,294 Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161630 Share on other sites More sharing options...
.josh Posted January 16, 2007 Share Posted January 16, 2007 LoL I gave up. After an hour of my processor running at 100% I stopped it. I don't even know what number it got up to. Maybe I should have used some js or something to write the current number to the screen or something. Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-161638 Share on other sites More sharing options...
chiprivers Posted January 18, 2007 Share Posted January 18, 2007 What is the latest challenge? Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-163599 Share on other sites More sharing options...
redbullmarky Posted January 18, 2007 Share Posted January 18, 2007 [code]<?phpecho '1,176,470,588,235,294';?>[/code]does that count now? ;D Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-163601 Share on other sites More sharing options...
chiprivers Posted January 18, 2007 Share Posted January 18, 2007 If nobody else is setting a challenge, how about creating a function that compare two poker hands and returns the winning hand?The function could either accept two arguments where a hand is submitted in the form "3h7d9cJhAs" or each card could be submitted as an individual argument? Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-163608 Share on other sites More sharing options...
steviewdr Posted January 18, 2007 Share Posted January 18, 2007 It would be easier if it was Texas Holdem, as there would only be 2 cards that the player have. Quite do-able tho, if I had the time.-steve Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-163704 Share on other sites More sharing options...
chiprivers Posted January 18, 2007 Share Posted January 18, 2007 [quote author=steviewdr link=topic=119299.msg507829#msg507829 date=1169133842]It would be easier if it was Texas Holdem, as there would only be 2 cards that the player have. Quite do-able tho, if I had the time.-steve[/quote]Well how about a function for Texas Holdem then where you enter 7 arguments, 5 community cards and the 2 players cards and the function returns a point value for the best hand that can be created, this point value can the be compared against the points returned from another players hand to see who would win? Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-163751 Share on other sites More sharing options...
The Little Guy Posted January 25, 2007 Author Share Posted January 25, 2007 I don't think anyone knows, so if know one gets it, here is another challenge to maybe pick it up again:Create a strtoupper function without using any function that will uppercase a letter. This should be able to uppercase anything, and ever letter. Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-169329 Share on other sites More sharing options...
Orio Posted January 26, 2007 Share Posted January 26, 2007 I am happy someone finally gave a challenge that is short and fair...[code]<?phpfunction upper($str){ $letters = str_split($str); $new = array(); foreach ($letters as $char) { if($char >= ord("a") && $char <= ord("z"); $char = chr(ord($char) - 32); $new[] = $char; } return implode("", $new);}?>[/code]Next challenge- Make a function that will do the same job as [url=http://www.php.net/manual/en/function.trim.php]trim()[/url] does (without using trim, rtrim, ltrim or chop) - Remove all kinds of spaces from the begining and end of a string, as written in the manual.Orio. Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-169607 Share on other sites More sharing options...
makeshift_theory Posted January 26, 2007 Share Posted January 26, 2007 [code]<?phpfunction my_trim($str,$charlist){ $str = ereg_replace(" ","",$str); if(!empty($charlist) || $charlist != '') { if(is_array($charlist)) { foreach($charlist as $char) $str = ereg_replace($char,"",$str); } else $str = ereg_replace($char,"",$str); } return $str;}$trim = "LOT OF SPACES HERE WOOT FOR SPACES ";echo my_trim($trim,'');?>[/code]Pretty simple but it removes all spaces from a phrase. It can be tested here [url=http://www.startrekrpg.com/ajax/trim.php]www.startrekrpg.com/ajax/trim.php[/url]PS> I read on trim that you can use choose what characters you want to remove specifically. So with this function you can pass an array of characters that you wish to remove or just one. Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-169814 Share on other sites More sharing options...
Daniel0 Posted January 26, 2007 Share Posted January 26, 2007 [code]trim("LOT OF SPACES HERE WOOT FOR SPACES ");[/code] returns: [code]LOT OF SPACES HERE WOOT FOR SPACES[/code]So I am afraid your function isn't valid. Quote Link to comment https://forums.phpfreaks.com/topic/31283-the-php-challenge/page/3/#findComment-169823 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.