+ 7

Is this PHP challenge question is logical?

as I think challenges exist to develop users to be more fast and effective in analyzing and to make them able to seek for new ideas and commands . but some PHP questions are really ugly and meaning less I will list one of these ugly question:- which of these answers is not possible to be output of this program:- <?php $x =""; for ($i=0;$i<=5;$i++) $x=$x.rand(10,11); echo $x; ?> ( ) 101110101110 ( ) 1111101110111 ( ) 101011111010 ( ) 0100100101 The answer is very simple and you have to start counting 2 digit from each that long 12 digits to find "01" or "00" which make that number not possible to be answer . but come on guys is that possible to do that within that 30 sec ? is there anyone else agree with me to delete this question and make PHP questions more logical for programmer not for digit counter ??!

20th Sep 2018, 7:18 PM
Ahmed Bahaddin
Ahmed Bahaddin - avatar
7 Answers
+ 2
This question may be designed to be uncomfortable in the 'manual' direction, i.e., find the shortcuts. Solutions may jump out at you if you skim the problem + possible solutions ahead of pair analysis. * Here, one of the answers starts with a 0. * Then, as you consider looking for valid pairs...well...valid answers must have even lengths. * Scanning the right columns: * Only one answer has an odd length offset with respect to the others. * Also, the "initial 0" answer is again bad because the last pair is bad. This isn't exhaustive coverage (I haven't verified a single pair, nor counted lengths) but those are the answers I would choose. Alternatives: * Count the shortest string's length (is that the right number of pairs?), then run up the right margin (only two have +1 pair). * Still no pair (10/11) validation; just one count and three tail checks. * Any answer with a 0 in an odd column is bad. I'd want to keep the question because while it can be solved exhaustively, it has additional optimization paths.
20th Sep 2018, 10:22 PM
Kirk Schafer
Kirk Schafer - avatar
+ 4
There's a lot of questions like that. You just need to remember them.
20th Sep 2018, 8:09 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
While I agree that there are some questions that might require longer calculations and do not really test the programming skills, I do NOT agree with your example. It looks frightening at first, but if you know what rand(10,11) does, the answer is obvious in the first seconds.
20th Sep 2018, 8:20 PM
Matthias
Matthias - avatar
+ 1
actually the two incorrect answers are obviously of different length and one has a leading zero, while the other has three ones at the end. so the question is pretty easy imho
21st Sep 2018, 2:10 PM
hinanawi
hinanawi - avatar
+ 1
PHP it isn't my language 🙄 I haven't studied it yet
24th Sep 2018, 3:39 PM
Metha
Metha - avatar
0
The answers in my question is samples not exact as challenge answers so hope you put that in your mind ...I think this kind of questions is meaningless in PHP challenges..
21st Sep 2018, 2:32 PM
Ahmed Bahaddin
Ahmed Bahaddin - avatar
0
Ahmed Bahaddin It tests if you understand what rand(10,11) does. This is totally valid to check programming skills, so there is a meaning. You don't even have to count or anything. Depending on the language it could either mean - 1 random number between 10 and 11 (11 included) - 1 random number between 10 and 11 (11 excluded, so 10 basically) - 11 random numbers between 0 and 10 etc. So absolutely valid question for checking your understanding of the code snippet.
21st Sep 2018, 4:19 PM
Matthias
Matthias - avatar