![]() |
Programming Challenges
anyone up for some Programming Challenges ?
If so, post a challenge in here. So people can try it out. Brain pumping.. ;) -CF PS: i am working on a Challenge, will post it soon. |
Programming Challenges one:
make a function that do this: Get Filename From Domain Path difficulty rate: easy |
PHP Code:
|
Maybe I'm being dumb but it's my understanding that there is no filename in a domain path.
|
You name your php scripts right ?
a file(phpfile) name: index.php.. = filename.. PHP Code:
|
Programming Challenges two:
Simple HTTP authentication login make a login script with use of WWW-Authenticate header. difficulty rate: easy PS: please keep the game running by posting challenges.. brainPump.. Come on now! |
Quote:
|
New challenge! Challenge 3
Given the string variable $rhyme (with the contents as below), echo that string except for the last line.Starting Code PHP Code:
Go forth and solve: be creative but not silly! |
is this what you wanted, or did I misunderstand?
PHP Code:
|
Quote:
Anyone else got any ideas, or would you all normally explode and loop? 8-) |
PHP Code:
|
php Code:
|
Just another way, it's pretty pointless.
PHP Code:
|
Here's another way:
PHP Code:
PHP Code:
|
Hmm, it is very interesting to see all of your approaches; for example, I wouldn't have thought to look for the only question mark in there and to use that as a marker!
Well, to conclude this mini-challenge here is what I was thinking of when constructing the challenge: PHP Code:
So who wants to create the next mini-challenge? |
Challenge 4 (Salathe: added title so we can keep track)
Here is one that may be a brain teaser ... Without using the following Control Structures, Operators, print or echo. Create a snippet that while display a list of numbers 0 - 100 and backdown to 100 - 0 using only 3 lines of code in a unordered listed format Only PHP Counts toward the line count. Multiple un-nested functions existing on one line are considered a separate line for each function. All function logic (anonymous and custom) are considered a seperate line from the declaration. php Code:
Would be 2 lines Have Fun! Final Result should be
|
php Code:
Hope 2 is fine. P.S. - I'm taking un-nested functions to be something along the lines of php Code:
--- And I guess I'll make another little challenge Challenge 5 (Salathe: added challenge number so we can keep track)) Construct your a looping method to mimic for using only variables inside the scope of the function ( no global keyword ) ( I don't expect the break keyword to be respected, that would be a slight more difficult ) |
Taking a second look, while your code does produce the output, it would be considered 8 lines. Logic performed for anonymous functions would be coded in the same manner as a any other function ... also per the PHP Doc's this is the manner it is done.
http://us2.php.net/manual/en/functions.anonymous.php Also what about Code:
<ul> </ul> |
Posted the update with ul ( though browsers will format it as a list without the ul but for the purpose of being semantic ) - not very elegant but, it does it's thing.
|
With regards to challenge 4, I'm a little fuzzy on what actually counts as a line so I threw everything onto one long one! :-D
PHP Code:
|
| All times are GMT. The time now is 10:21 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0