Wednesday 16 December

We recently held an interview day for second year Computer Science students who are interested in doing a year in industry as part of their degree. Throughout the day we gave them a number of different tasks to partake in to assess their skills, including a 5 minute technical challenge:

 

Subtract the sum of all the values ‘X’ where 0 <= X <= N and is divisible by 5

From the sum of all the values ‘Y’ where 0 <= Y <= M and is divisible by 7

 

Where N = 1000 and M = 500

 

We decided it would be fun to have an in house challenge to see who could solve the technical challenge in the least number of characters.

The rules are as follows:

  1.        Must be written in C# as a console application
  2.        The correct answer has to be written out to the console
  3.        N and M have to be declared as the values provided, not hard-coded into the solution, but must        give the correct answer if the values are changed
  4.        N and M will always be positive and whole
  5.        Character count includes white spaces
  6.        All code in the main method will be counted, excluding the initial curly braces
  7.        N will always be divisible 5 and M will always be divisible 7
  8.        All code must be declared in the main method – you cannot declare global variables or create           your own methods

 

Our current lowest character count is 58… Please let us know (via our Facebook or Twitter account) if you can beat it. Good luck!

 

Tips: Get the code working first before trying to minify it, use C# 6 and the answer is -82,608!