Jump to content

Recommended Posts

Posted (edited)

Ok, so people on here are generally pretty smart yer? Well give this gives go:

 

http://www.mythic-beasts.com/cgi-bin/job.pl

 

Simple eh? Provide it, it took me 2 hrs to do! Please don't post the solution or any hints.

 

When you do it you'll get further instructions, don't forget to tell them who sent you it either!

 

Let's see how many smart people we have

Edited by matt40k
Posted
Wow! Got the first question wrong. Spent about 4-5 minutes working out the next question and "not fast enough". So I was doing this with a pen and paper - is using a calculator cheating because it's the only way I'm gonna be any faster given the size of some of those numbers!
  • Thanks 1
Posted
Wow! Got the first question wrong. Spent about 4-5 minutes working out the next question and "not fast enough". So I was doing this with a pen and paper - is using a calculator cheating because it's the only way I'm gonna be any faster given the size of some of those numbers!

 

I've not done it, not fast enough. I don't think a calculator is going to help though.

  • Thanks 1
Posted
You can use any tool at your disposal

 

Well the last one was about 10sec with a calculator and still not fast enough!?!?!

 

I'm not bloody well Rainman you know ;)

  • Thanks 1
Posted
Well the last one was about 10sec with a calculator and still not fast enough!?!?!

 

I'm not bloody well Rainman you know ;)

Hmm even a quick cut a paste with excel taking a couple of secs isn't quick enough so there's something else going on here?

  • Thanks 1
Posted
Well the last one was about 10sec with a calculator and still not fast enough!?!?!

 

I'm not bloody well Rainman you know ;)

 

I think there is more to the question than meets the eye, but so far my attempts have failed. Having looked into the domain owners I'm following a different line of reasoning, but I am still too slow to provide an answer which suggests to me that the calculation is either irrelevant or must needs be copy/pasted in some way and the answer lies in syntax rather than resultant value...

 

But these are speculations, as at present I am still unable to solve this.

  • Thanks 1
Posted (edited)

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).

Edited by bladedanny
  • Thanks 1
Posted
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!

Posted

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.

  • Thanks 1
Posted (edited)

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:

 

  $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.'
';
 echo 'ANSWER: '.$answer.'
';
 echo 'ID: '.$id.'
';
 
 // Now, find a way to submit $answer AND $id to [url]www.mythic-beasts.com/cgi-bin/job.pl[/url], 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...

Edited by Marci
  • Thanks 1
Posted

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?

  • Thanks 1
Posted
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:

 

  $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.'
';
 echo 'ANSWER: '.$answer.'
';
 echo 'ID: '.$id.'
';
 
 // Now, find a way to submit $answer AND $id to [url=http://www.mythic-beasts.com/cgi-bin/job.pl]Job Application[/url], 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.

  • Thanks 1
Posted
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.

  • Thanks 1
Posted
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.

  • Thanks 1
Posted (edited)

@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

Edited by SimonD
  • Thanks 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...