Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,203 members, 7,953,746 topics. Date: Friday, 20 September 2024 at 02:56 AM |
Nairaland Forum / Science/Technology / Programming / Can You Solve PHP Problems? Let's Find Out.. (3492 Views)
Can You Solve This Tricky Question? / Number Generator Challenge : Can You Solve This? / Can You Solve This? (2) (3) (4)
Re: Can You Solve PHP Problems? Let's Find Out.. by Kodejuice: 3:59pm On Oct 08, 2016 |
toheebDOTcom: That only matters when your echo-ing it, i mean when you do:
AND
it outputs d same tin |
Re: Can You Solve PHP Problems? Let's Find Out.. by Kodejuice: 4:05pm On Oct 08, 2016 |
FrankLampard: Euler? eww |
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 4:05pm On Oct 08, 2016 |
FrankLampard: Nawa oo, this guy wants me to flex muscle sha..Okay here's my shot: I made this re-usable for anyone that needs it - ...Loading, brb have to get something done real quick. I'd be back. |
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 4:06pm On Oct 08, 2016 |
Kodejuice:I knew it was from Euler, just laughed inside of me |
Re: Can You Solve PHP Problems? Let's Find Out.. by Kodejuice: 4:15pm On Oct 08, 2016 |
make una try this one, saw it in a book i'm reading: Write a method/function which finds the maximum of two numbers. Don use if-else or any other comparison operator. EXAMPLE 5, 10 => 5 |
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 4:41pm On Oct 08, 2016 |
Kodejuice:Including PHP's max() ? |
Re: Can You Solve PHP Problems? Let's Find Out.. by Kodejuice: 4:45pm On Oct 08, 2016 |
DanielTheGeek:of cuz, dat one na cheating na. 1 Like |
Re: Can You Solve PHP Problems? Let's Find Out.. by noordean(m): 12:36am On Oct 09, 2016 |
FrankLampard: My solution: https://ideone.com/6BARWK My program does not loop beyond around 3000th position but I'm sure my algorithm is correct , I guess this is due to the strong looping process involved. I'm still trying it on online editor. When my system is up, I'll check and see. |
Re: Can You Solve PHP Problems? Let's Find Out.. by guente02(m): 3:19am On Oct 09, 2016 |
What needs to be changed to make the above code work as expected? Just add ! at the beginning of if-else condition. Just a hack tho. Still trying to figure out the why. cc: DanielTheGeek
|
Re: Can You Solve PHP Problems? Let's Find Out.. by FincoApps(m): 5:38am On Oct 09, 2016 |
DanielTheGeek, I'll appreciate if you created a similar thread but for Js. I feel it's easier to test Js codes, like right from the browser..... for php, small English go dey. Except the challenge is like who can write a working code without testing it (I would LOVE that too) |
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 6:00am On Oct 09, 2016 |
FincoApps: Of course, another thread for JS will be up soon. But I doubt anyone has been testing the above codes, na eye me I dey use debug am. |
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 6:05am On Oct 09, 2016 |
guente02:Strpos() will return 0 if matched and 0 is false except you check against the type using !== or !strpos(), so what you're doing is a good hack saying, hey, if strpos() does not evaluate to true then that's what I'm looking for. |
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 6:08am On Oct 09, 2016 |
noordean: I'm happy you gave it a shot. From visual debugging, that looks like a correct solution. |
Re: Can You Solve PHP Problems? Let's Find Out.. by noordean(m): 6:55am On Oct 09, 2016 |
DanielTheGeek:Thanks boss. 1 Like |
Re: Can You Solve PHP Problems? Let's Find Out.. by FrankLampard: 7:38am On Oct 09, 2016 |
noordean: Though I'm not a Python guy. But I can read your code slightly. You tried in your implementation, but you need to read the question and answer the question again. From your code you got 27437 (Not sure). The answer supposed to be 104743. It has been long since I solve that particular question. But you can effectively answer the question using Dynamic Programming DP, simply Google "sieve of eratosthenes". Hint: Use Sieve method to iterate all the prime number, then check if when the iteration has gotten to it 10001 number , then break out of the loop. Happy coding. |
Re: Can You Solve PHP Problems? Let's Find Out.. by ANTONINEUTRON(m): 5:06pm On Oct 09, 2016 |
abeg diz might be off topic but i notice a problem in php. For Example:: $i = 1; while($i<$antoniage){ $i++; echo $i; } once d loop above run finish, if i want to use $i again in another loop(i intend it to still be equal to 1) it return nothing or False What might be d problem Am just a beginner |
Re: Can You Solve PHP Problems? Let's Find Out.. by FrankLampard: 5:32pm On Oct 09, 2016 |
ANTONINEUTRON: Make your question clear. |
Re: Can You Solve PHP Problems? Let's Find Out.. by Kodejuice: 7:24pm On Oct 09, 2016 |
ANTONINEUTRON: Scope!, you're declaring the variable in an outer scope and incrementing it in the same outer scope, so its changed everywhere, try this <?php $i = 1; $antoniage = 10; //eg function fn1($arg) { $i = $arg; global $antoniage; //make it accessible from this fn while ($i < $antoniage) { $i++; echo $i; } } fn1($i); //$i is still 1 1 Like |
Re: Can You Solve PHP Problems? Let's Find Out.. by ANTONINEUTRON(m): 7:30pm On Oct 09, 2016 |
Kodejuice:it worked |
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 7:59pm On Oct 09, 2016 |
I like what I see here, thumbs up bros. I've been choked with work lately, keep the questions coming in. |
Re: Can You Solve PHP Problems? Let's Find Out.. by guente02(m): 11:05pm On Oct 09, 2016 |
DanielTheGeek:How do i implement a pin/serial number generator. I want the script to check for the existence of the pin in the db after every loop iteration.
|
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 6:19am On Oct 10, 2016 |
guente02: You can check this CodeIgniter library I did. You can make that to work out of CodeIgniter, just add a method that checks if it exists in the db, if true, re-generate, else use the generated hash. |
Re: Can You Solve PHP Problems? Let's Find Out.. by kenpanda(m): 10:19am On Oct 10, 2016 |
Check your parameters, you need three parameter passed strpos (string $haystack, mixed $needle [, int $offset = 0]): int |
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 5:33pm On Sep 14, 2018 |
FrankLampard: can you please help me with the solution to this? |
Re: Can You Solve PHP Problems? Let's Find Out.. by segbolon: 3:43am On Sep 15, 2018 |
Have you been coding PHP for many years but have not gone beyond few functions?, this thread tests your practical knowledge of the language. eww $ss = "Daniel"; $fs = "DanielTheGeek"; $conj = strstr($ss, $fs) ? "does not" : null; echo "'$fs' $conj contains '$ss'\n" ; |
Re: Can You Solve PHP Problems? Let's Find Out.. by segbolon: 4:11am On Sep 15, 2018 |
chukwukahenry:Here's a naive solution,
|
Re: Can You Solve PHP Problems? Let's Find Out.. by segbolon: 4:16am On Sep 15, 2018 |
chukwukahenry:A non native approach which is 100x faster than the previous
|
Re: Can You Solve PHP Problems? Let's Find Out.. by Nobody: 12:35am On Sep 16, 2018 |
thanks @segbolon |
Re: Can You Solve PHP Problems? Let's Find Out.. by citicapfin: 7:59pm On Sep 03, 2020 |
best digital marketing online courses |
Results For Programming Challenge Season 2 / Help With This:checking For Blank Textboxes In C# / .net Programmers I Need Your Help O
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 48 |