Coding rules!

After being tipped by a colleague, I started to look into the apparent lack of skills applicants for programming jobs.
With me (and many at E&I) being trained to write code, and think in code, I asked around and found out that a lot of applicants (even self-proclaimed senior programmers and Bachelors from a university) do not have the basic coding skills needed to do such a job within 5 minutes.

In this light, a small programming task like the following seems to be the hurdle which separates the coders from the non-coders.

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Foo" instead of the number and for the multiples of five print "Bar". For numbers which are multiples of both three and five print "FooBar".

 What would be your solution?
Note: I’ll be posting mine later πŸ˜‰

for(int i=1; i< =100; i++) { if(i%3==0) { System.out.print("Foo"); } if(i%5==0) { System.out.print("Bar"); } if(i%3!=0 && i%5!=0) { System.out.print(i);} System.out.println(""); }[/code]

6 thoughts on “Coding rules!”

  1. Not exactly the most efficiënt code. You’re doing all three checks for all numbers, meaning you’re doing 300 if-checks.

    Best to move the third if statement up and put the %3 and %5 if’s in the else condition. That way, you only do about 200 if-checks. Saves a lot of runtime.

    Additionally, we’re in a tight market. Of course there’s a big lack in skilled applicants in as popular a branche as IT. In my opinion, the real added value of our eduction isn’t in being a coder.

  2. I can most definitely see why you’re performance-tweaking the code: it however is not the focus of the (short) test.
    Only knowledge about the modulo is being tested here, and not the performance of the code. I’m actually quite surprised the modulo is a hint to coding skills, but that could also be my total lack of knowledge on that field.

    Secondly: I agree with your second remark (third paragraph): scarcity is a fact, and no, we are not taught to become coders. πŸ˜‰

  3. Actually, no. I was referring to this small task as ‘the test’, it only consists of this task.
    The original author of the test (yes, I ripped it off ;)) stated he developed a class of tasks to identify a bad coder, of which only this one is published.

    Actually, the test has been developed into the enterprise version of it, and can be found here. πŸ˜‰

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.