Skip to content

Comment on Ask HN: What % of your job interviewees pass FizzBuzz type questions?parent

Comments

  <?php

  $string = "aeiouxabcd";
  $checkfor = array('a','e','i','o','u');
  $count = 0;

  for($x = 0; $x < strlen($string); $x++) {
    if(in_array($string[$x], $checkfor)) {
  	 $count++;
    }
  }

  echo $count . "\n";
Am I hired? Or do I lose cool points for PHP?

Every time FizzBuzz problems come up among engineers, people race to solve them and post their answers, then compete to see who can write increasingly more nifty answers for a question which does not seek niftiness at all.

I'm all for intellectual gamesmanship, but these are our professional equivalent of a doctor being asked to identify the difference between blood and water. You can do it. We know. Demonstrating that you can do it is not the point of the exercise. We do it to have a cheap-to-administer test to exclude people-who-cannot-actually-program-despite-previous-job-titles from the expensive portions of the hiring process.

    <?php
    echo strlen(preg_replace('/[^aeiou]/i', '', 'hello world'));

You lose the cool points for not using a regex, I'm afraid.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.