+ Post New Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 41
General Chat Thread, Geek challenge in General; I've also tried copying the source to my own web server. Calculating the sum and pre-entering the value into the ...
  1. #16

    bladedanny's Avatar
    Join Date
    May 2009
    Location
    Sheffield
    Posts
    1,268
    Thank Post
    188
    Thanked 298 Times in 224 Posts
    Rep Power
    130
    I've also tried copying the source to my own web server. Calculating the sum and pre-entering the value into the html. It recognises the correct answer but it still not fast enough, even though it's page load -> click submit. I've only tried with html, the original is a perl script so I'm guessing it notes the time before displaying the html to the browser.

    I have a feeling the calculation is irrelevant (or at least in human terms).
    Last edited by bladedanny; 1st August 2012 at 11:04 AM.

  2. Thanks to bladedanny from:

    matt40k (1st August 2012)

  3. #17

    matt40k's Avatar
    Join Date
    Jun 2008
    Location
    Ipswich
    Posts
    4,382
    Thank Post
    368
    Thanked 637 Times in 519 Posts
    Rep Power
    158
    Quote Originally Posted by localzuk View Post
    Yeah, I had a simple subtraction one, and did it within about 2 seconds yet still not fast enough.
    If I had to put money on who could have done it, it would have been you! Right now I wouldn't be suprised if @PhilNeal does it first!

  4. #18


    AMLightfoot's Avatar
    Join Date
    Feb 2011
    Location
    Hampshire, England
    Posts
    2,136
    Thank Post
    370
    Thanked 615 Times in 392 Posts
    Rep Power
    250
    I think the solution is in the question evaluate. Funny choice of word isn't it? Specific.

    I think I'm close to an answer, but I'm either wrong or too slow. I have a suspicion that if you are within the time and wrong, you are 'wrong' but if you are outside the time the result doesn't differentiate between right and wrong answers, you are always 'too slow' regardless of whether your answer is right or not.

    I think copy/paste is needed, but I suspect it is only to insert into a string of some kind, but I can't determine if the resultant value needs to be present. As an interview question, I would suspect not as those kinds of calculations don't exactly roll off the top of your head meaning that the correct answer is some sort of query, but I have yet to succeed on this. That being said, I can't write code so I'm not surprised.

  5. Thanks to AMLightfoot from:

    matt40k (1st August 2012)

  6. #19
    Marci's Avatar
    Join Date
    Jun 2008
    Location
    Wakefield, West Yorkshire
    Posts
    888
    Thank Post
    84
    Thanked 234 Times in 193 Posts
    Rep Power
    82
    The fact that it's the mythic-beasts guys says to me they want a scripted solution that parses the question from the html, evals it, submits it, and displays the response. Seems simple at first...

    eg:

    Code:
    <?php
      $url = "http://www.mythic-beasts.com/cgi-bin/job.pl";
      $input = file_get_contents($url) or die("Could not access file: $url");
        
      function getp($string, $tagname) {
          $pattern = "/<$tagname>(.*?)<\/$tagname>/";
          preg_match($pattern, $string, $matches);
          return $matches[1];
      }
      
      $str = $input;
      $txt = getp($str, "p");
      $pieces = explode(" ", $txt);
      $num=count($pieces);
      $end=$num - 10;
      $a=1;
      $question=''.$pieces[1].'';
      $a++;
      while($a<=$end){
        $question.=$pieces[$a];
        $a++;
      }
      $answer=eval("return $question;");
      preg_match('/value="(\w+)"/',$input,$result);
      $id=substr($result[0],7,-1);
      echo 'QUESTION: '.$question.'<br />';
      echo 'ANSWER: '.$answer.'<br />';
      echo 'ID: '.$id.'<br />';
      
      // Now, find a way to submit $answer AND $id to www.mythic-beasts.com/cgi-bin/job.pl, and _THEN_ display the resultant output!
    ?>
    The above is functional in terms of getting the question, working out the answer, and grabbing the hidden 'id' field from the form to accompany the answer... however, it opens the job.pl to get this, and doesn't hold it open. If we add a step at the end to submit via PHP, then (1) it reloads job.pl - suspect we want job.pl to be opened and HELD open, and (2) PHP can't parse the response to tell you whether the answer is correct, quick enough, and reveal the next stage.

    Crafty combo of PHP / cURL / Javascript required to handle all of this, submit results via ajax and display response. Then you can start working on the next part of the sequence for Q2...

    Next step would be to submit a JSON encoded array to it and see what response is fired back.

    PERFECT interview question if you're wanting to test someone's ability to problem solve AND their coding skills...
    Last edited by Marci; 1st August 2012 at 11:38 AM.

  7. Thanks to Marci from:

    matt40k (1st August 2012)

  8. #20

    tmcd35's Avatar
    Join Date
    Jul 2005
    Location
    Norfolk
    Posts
    5,620
    Thank Post
    845
    Thanked 883 Times in 731 Posts
    Blog Entries
    9
    Rep Power
    326
    Well since @Marci has posted some code; here are my thoughts

    He is over complicating the solution a little. I think the answer to the question does matter, but so does the time. I think the only way of submitting the answer in time is to write script. Some relatively simple PHP should do it (no need for any Javascript, keeping pages open, etc).

    But then, I can't be bothered to sit here and right the script to prove it - so what do I know?

  9. Thanks to tmcd35 from:

    matt40k (1st August 2012)

  10. #21


    AMLightfoot's Avatar
    Join Date
    Feb 2011
    Location
    Hampshire, England
    Posts
    2,136
    Thank Post
    370
    Thanked 615 Times in 392 Posts
    Rep Power
    250
    Quote Originally Posted by Marci View Post
    The fact that it's the mythic-beasts guys says to me they want a scripted solution that parses the question from the html, evals it, submits it, and displays the response. Seems simple at first...

    eg:

    Code:
    <?php
      $url = "http://www.mythic-beasts.com/cgi-bin/job.pl";
      $input = file_get_contents($url) or die("Could not access file: $url");
        
      function getp($string, $tagname) {
          $pattern = "/<$tagname>(.*?)<\/$tagname>/";
          preg_match($pattern, $string, $matches);
          return $matches[1];
      }
      
      $str = $input;
      $txt = getp($str, "p");
      $pieces = explode(" ", $txt);
      $num=count($pieces);
      $end=$num - 10;
      $a=1;
      $question=''.$pieces[1].'';
      $a++;
      while($a<=$end){
        $question.=$pieces[$a];
        $a++;
      }
      $answer=eval("return $question;");
      preg_match('/value="(\w+)"/',$input,$result);
      $id=substr($result[0],7,-1);
      echo 'QUESTION: '.$question.'<br />';
      echo 'ANSWER: '.$answer.'<br />';
      echo 'ID: '.$id.'<br />';
      
      // Now, find a way to submit $answer AND $id to Job Application, and _THEN_ display the resultant output!
    ?>
    The above is functional in terms of getting the question, working out the answer, and grabbing the hidden 'id' field from the form to accompany the answer... however, it opens the job.pl to get this, and doesn't hold it open. If we add a step at the end to submit via PHP, then (1) it reloads job.pl - suspect we want job.pl to be opened and HELD open, and (2) PHP can't parse the response to tell you whether the answer is correct, quick enough, and reveal the next stage.

    Crafty combo of PHP / cURL / Javascript required to handle all of this, submit results via ajax and display response. Then you can start working on the next part of the sequence for Q2...

    Next step would be to submit a JSON encoded array to it and see what response is fired back.

    PERFECT interview question if you're wanting to test someone's ability to problem solve AND their coding skills...
    I reckon you're spot on, although given the time limit and the tiny text box, I'm not sure how that solution would translate to the interview scenario: assuming we're in interview situation with a 10 second time limit, the suggestion would seem to be that they are looking for a single line of code. I was working under the eval(string); // resultant value sort of answer. But I'm not a coder so I don't stand a hope in hell of getting this right.

  11. Thanks to AMLightfoot from:

    matt40k (1st August 2012)

  12. #22

    tmcd35's Avatar
    Join Date
    Jul 2005
    Location
    Norfolk
    Posts
    5,620
    Thank Post
    845
    Thanked 883 Times in 731 Posts
    Blog Entries
    9
    Rep Power
    326
    Quote Originally Posted by AMLightfoot View Post
    I reckon you're spot on, although given the time limit and the tiny text box, I'm not sure how that solution would translate to the interview scenario: assuming we're in interview situation with a 10 second time limit, the suggestion would seem to be that they are looking for a single line of code. I was working under the eval(string); // resultant value sort of answer. But I'm not a coder so I don't stand a hope in hell of getting this right.
    I think they are after the correct answer in <1sec which is faster than a human is capable of doing it, even with a calculator. I don't think there is anything else to it. Submit the right answer in time with the correct hidden ID that goes with that answer and you'll get the next question as a response.

  13. Thanks to tmcd35 from:

    matt40k (1st August 2012)

  14. #23


    AMLightfoot's Avatar
    Join Date
    Feb 2011
    Location
    Hampshire, England
    Posts
    2,136
    Thank Post
    370
    Thanked 615 Times in 392 Posts
    Rep Power
    250
    Quote Originally Posted by tmcd35 View Post
    I think they are after the correct answer in <1sec which is faster than a human is capable of doing it, even with a calculator. I don't think there is anything else to it. Submit the right answer in time with the correct hidden ID that goes with that answer and you'll get the next question as a response.
    Perhaps you're right, although @Marci s solution is extensive. I'm probably looking at this the wrong way as I am putting myself in the shoes of a person in an interview, but we're not. We're at our desks with time and resources. Although I quickly worked out that code was needed, I lack the skills to write it so I think that disqualifies me from progressing further under my own merit. That being said, I wouldn't mind seeing what happens next.

  15. Thanks to AMLightfoot from:

    matt40k (1st August 2012)

  16. #24


    Join Date
    Aug 2012
    Posts
    16
    Thank Post
    8
    Thanked 8 Times in 7 Posts
    Rep Power
    237
    @Ric_ asked me to comment here. You have 2.5 seconds to post the answer from when you first request the page. What happens next isn't that exciting Posting code spoilers it. It took me 8 minutes to solve it here, then a further 15 minutes to work out how long you had to submit the correct answer. I was taunting him with this exact puzzle a few days ago.

    Cheers

    Simon
    Last edited by SimonD; 1st August 2012 at 12:27 PM.

  17. 2 Thanks to SimonD:

    matt40k (1st August 2012), tmcd35 (1st August 2012)

  18. #25

    Ric_'s Avatar
    Join Date
    Jun 2005
    Location
    London
    Posts
    7,590
    Thank Post
    109
    Thanked 762 Times in 593 Posts
    Rep Power
    180
    Quote Originally Posted by SimonD View Post
    I was taunting him with this exact puzzle a few days ago.
    @Domino and @Beard were also taunted by @SimonD

  19. Thanks to Ric_ from:

    matt40k (1st August 2012)

  20. #26


    Join Date
    Aug 2012
    Posts
    16
    Thank Post
    8
    Thanked 8 Times in 7 Posts
    Rep Power
    237
    Quote Originally Posted by Ric_ View Post
    @Domino and @Beard were also taunted by @SimonD
    They couldn't solve it either, google calculator TSK!

  21. Thanks to SimonD from:

    matt40k (1st August 2012)

  22. #27

    matt40k's Avatar
    Join Date
    Jun 2008
    Location
    Ipswich
    Posts
    4,382
    Thank Post
    368
    Thanked 637 Times in 519 Posts
    Rep Power
    158
    Please don't post the solution or any hints.
    Proves how many people read the problem. Like I said, it's a two step problem, first it identifying the issue and correctly scoping the solution, the second is fixing it. Doesn't that sound like the ideal test for an IT person?

  23. Thanks to matt40k from:

    tmcd35 (1st August 2012)

  24. #28

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,639
    Thank Post
    514
    Thanked 2,443 Times in 1,891 Posts
    Blog Entries
    24
    Rep Power
    831
    Quote Originally Posted by matt40k View Post
    Proves how many people read the problem. Like I said, it's a two step problem, first it identifying the issue and correctly scoping the solution, the second is fixing it. Doesn't that sound like the ideal test for an IT person?
    Only if their job is going to be scripting websites... If not, then this would be out of their area of expertise.

    Context is important.

  25. #29

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    6,734
    Thank Post
    1,272
    Thanked 1,645 Times in 1,101 Posts
    Blog Entries
    22
    Rep Power
    505
    Quote Originally Posted by matt40k View Post
    Proves how many people read the problem. Like I said, it's a two step problem, first it identifying the issue and correctly scoping the solution, the second is fixing it. Doesn't that sound like the ideal test for an IT person?
    Good test for website scripter, when I realised I probably needed to script I lost interest and dropped it, guess I'm not a suitable candidate

  26. Thanks to sparkeh from:

    AMLightfoot (1st August 2012)

  27. #30

    matt40k's Avatar
    Join Date
    Jun 2008
    Location
    Ipswich
    Posts
    4,382
    Thank Post
    368
    Thanked 637 Times in 519 Posts
    Rep Power
    158
    Quote Originally Posted by localzuk View Post
    Only if their job is going to be scripting websites... If not, then this would be out of their area of expertise.

    Context is important.
    Well durr, it's basically unseating the RAM from a PC for a IT technician in a school but for a linux administrator. You wouldn't ask a junior IT technician at a primary school about setting up a SAN, well normally
    Last edited by matt40k; 1st August 2012 at 01:17 PM.

SHARE:
+ Post New Thread
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Geek maths and classroom control
    By ITWombat in forum Educational Software
    Replies: 6
    Last Post: 21st April 2006, 08:49 PM
  2. Replies: 8
    Last Post: 13th February 2006, 03:05 PM
  3. Geeks?
    By GrumbleDook in forum Jokes/Interweb Things
    Replies: 2
    Last Post: 10th January 2006, 07:11 PM
  4. Top 11 Geek Pickup Lines (Part 1)
    By Geoff in forum Jokes/Interweb Things
    Replies: 5
    Last Post: 5th December 2005, 12:28 PM
  5. Sleazy geek bars..
    By Dos_Box in forum Other Stuff
    Replies: 3
    Last Post: 12th August 2005, 07:54 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •