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]
% π
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.
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. π
Do you have the test anywhere I can read or take it? Would be interested π
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. π
Timmo has found a good article on this topic: it can be found here.