isset() is a constructpapa wrote:You are using isset()
Challenge section
Moderator: General Moderators
Re: Challenge section
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: Challenge section
I think challenges are a good idea as long as the finished product might actually be useful to someone. So there isn't much point in trying to create a string reverse function without using the letter 's' anywhere in the code, for example.
So a good challenge in my opinion would be something like: create an optimised string reverse function. The quickest implementation wins.
So a good challenge in my opinion would be something like: create an optimised string reverse function. The quickest implementation wins.
Re: Challenge section
Code: Select all
<?php
function my_strlen($str)
{
for($i = 0; isset($str[$i]); $i++){}
return $i;
}
function str_reverse($str)
{
$buffer = '';
for($i = my_strlen($str) - 1; isset($str[$i]); $i--)
{
$buffer .= $str[$i];
}
return $buffer;
}
echo str_reverse('hello');
?>Re: Challenge section
I was trying to manage such section in one forum with general questions (not programming related), something like the game "what? where? when?" (что, где, когда). It was very popular actually, a lot of users have been answering questions, but no one wanted to post new ones.
So, challenging sections is a good idea, but we need people to post the challenges.
So, challenging sections is a good idea, but we need people to post the challenges.
Re: Challenge section
I'm happy posting challenges 
Re: Challenge section
I love this idea. I just posted a challenge. I hope I provided enough hints to make it solvable. There are some goodies for the first three people to come up with a solution.
Edit: This post was recovered from search engine cache.
Edit: This post was recovered from search engine cache.
Last edited by McInfo on Wed Jun 16, 2010 7:17 pm, edited 1 time in total.
Re: Challenge section
Hey it was funjackpf wrote:Ok!!
There was a bit of this back when I was on phpfreaks.com.
There was a challenge made to create a rot_13 encryption function without using any PHP functions (constructs are OK). It's pretty easy...but it makes you think.
Anyway, here's the original function you have to mimic: http://uk.php.net/str_rot13. Remember, no predefined PHP functions!!!
I've already done this. If you want to cheat or check your version, mine is here: http://jackpf.co.uk/index.php?action=fo ... #Post:2232
Good luck!
Regards,
Jack.
Code: Select all
<?php
function papa_str13($str) {
$alphabet = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
$incr = 13;
//Iterates string
for($i=0; $str[$i] != ""; $i++) {
foreach($alphabet as $k => $a) {
//If char matches letter
if($str[$i] == $a) {
$inc = $k;
for($j=0; $j<$incr; $j++) {
//Reset key counter if array is empty
$alphabet[$inc] !="" ? $inc++ : $inc = 1;
}
//Return new letter
$str[$i] = $alphabet[$inc];
break;
}
}
}
//Return processed string
return $str;
}
echo papa_str13('php 4.3.0');
?>Re: Challenge section
Can we stop using this thread to talk about specific challenges please. This is for discussing the idea of having challenges here on the forum, not the challenges themselves.
I've created a sticky thread in PHP-Code to work as an index for challenges.
I've created a sticky thread in PHP-Code to work as an index for challenges.
Re: Challenge section
Sorry, sorry...just one more thing:
@papa
for the string 'a string', your function returns 'n fgev�t'
It also has undefined indexed errors...and takes around 8 times longer than mine.
For these reasons, I win
yaaaay
@papa
for the string 'a string', your function returns 'n fgev�t'
It also has undefined indexed errors...and takes around 8 times longer than mine.
For these reasons, I win
Re: Challenge section
Haha yada yada.jackpf wrote:Sorry, sorry...just one more thing:
@papa
for the string 'a string', your function returns 'n fgev�t'
It also has undefined indexed errors...and takes around 8 times longer than mine.
For these reasons, I winyaaaay
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: Challenge section
Correct me if I'm wrong, but "PHP - Code" is for PHP related questions, not for posting challenges. If the moderation team supports the idea of challenges (which it should because it's a great complement to the spirit in which this forum was founded) but resists dedicating a forum to it you're sending mixed messages about topic placement. Are also saying that it is now acceptable to violate existing rules on topic placement? Or is "PHP - Code" for questions and challenges now?I actually think this is a pretty good idea, but whether it needs a whole section of the forum to itself is questionable. Why not give it a try first by posting things in "PHP - Code" with the challenge as part of the subject line, like "[Challenge - Basic] Reversing a string" for example? If it's popular then we could make a new folder just for those threads.
Personally, I'm not brilliantly interested in participating in challenges but I can't see any harm in adding a forum specifically for it. I can, however, see lots of reasons why you should do it:
- If you have a forum especially for challenges you send a clear message that challenges are encouraged, without it you risk sending the opposite message.
- People interested in helping people with their questions won't get distracted by challenges, especially seeing as challenges threads are likely to be long (read: bumped lots of times).
- Challenges might get drowned out by all the traffic in "PHP - Code" and go unnoticed.
- Challenges are arguably more about learning to program than fixing other people's code is.
- With challenges in "PHP - Code" you have to use the forum search feature to find an old challenge much more often that you would if it was in a separate forum.
- Programmers interested in challenges are more likely to be interested in learning and stand to gain more by having that attitude. Bringing a bunch of people like that together could have synergistic benefits.
- Ruby equivalent of this (Ruby Quiz) has been hugely successful and has even had a book published.
- PHPDN is not really about learning after-all, just helping people with their queries.
- The challenge section could bring too much new traffic to the site that we can't avoid.
- The person who's really in charge of adding new forums isn't around and nobody really want to contact him because he lives in a isolated wood on his own without a phone or internet connection and smells really bad.
- It would be un-American or possibly communist.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Challenge section
Ghosts especiallyOllie Saunders wrote:What are you guys afraid of?
Seriously though, I support the idea of creating a dedicated forum for a challenges section. However, we have come to the conclusion in the past to keep the number of forums to a minimum for the purposes of keeping things simple and less cluttered.
Perhaps adding this section as a sub-forum?
Re: Challenge section
Ok, the moderation team will vote on this and we'll get back shortly.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: Challenge section
I can see the motivation behind such a thing but, by that virtue, why don't we have just one? Obviously that would be silly. My point is, there must be some point where something is big enough or distinct enough that it is favorable to give it a special home; that point needs to be defined.However, we have come to the conclusion in the past to keep the number of forums to a minimum for the purposes of keeping things simple and less cluttered.
For instance the Databases forum I view largely as a failure because PHP - Code is littered with threads about databases that nobody bothers to move there. Why is that? Probably because it's often arguable as to whether the issue of those threads is the database or something else. If I was completely in charge of this forum
I would probably rename PHP - Code to "I'm stuck! What's wrong with my code?" targeting people who are very new to PHP
Create a new forum "How do I implement...?" for helping people approach new projects etc.
And another "Please explain..." for teaching and settling confusions.
Some statistical analysis could confirm how good these categories are and identify other good ones. I'd also remove Miscellaneous and Databases among other things.
Re: Challenge section
I feel like you have animosity towards the forum and that your comments are a bit harsh. We definitely appreciate comments and suggestions though. I would invite you to propose new naming conventions for the forums along with the results of your analysis. The issue here however is that these were created years and years ago and agreed upon by many of the founding members. That said, if something is identified as an improvement and is feasible, we will make the change.Ollie Saunders wrote:I can see the motivation behind such a thing but, by that virtue, why don't we have just one? Obviously that would be silly. My point is, there must be some point where something is big enough or distinct enough that it is favorable to give it a special home; that point needs to be defined.
For instance the Databases forum I view largely as a failure because PHP - Code is littered with threads about databases that nobody bothers to move there. Why is that? Probably because it's often arguable as to whether the issue of those threads is the database or something else. If I was completely in charge of this forum
I would probably rename PHP - Code to "I'm stuck! What's wrong with my code?" targeting people who are very new to PHP
Create a new forum "How do I implement...?" for helping people approach new projects etc.
And another "Please explain..." for teaching and settling confusions.
Some statistical analysis could confirm how good these categories are and identify other good ones. I'd also remove Miscellaneous and Databases among other things.
I disagree with your comments regarding the Database forum. The database forum is distinct from PHP - Code in the sense that questions in it are related to crafting database queries, tuning queries, broken queries, what data types to use etc. This is not related to PHP. Granted there is a little bit of overlap on occasion, for the most part the Database forum is the correct place to post database related questions.