Impressed but not impressively- A friend’s interview code sample

So a friend of mine is currently employed at a large multi-national IT contracting company. Well, that’s not entirely true, the company does staff augmentation for many sectors, IT being one of them, and while they can provide full software development life cycle services, they are typically staff augmentation.

That being said, he’s a developer. And a developer who came to developing later in life after learning, living, and dumping a previous career. He’s been doing professional development (i.e. it is his sole income) for 6 years and of the many developers I know he’s a natural, learns quick and the “right way” and the why’s. I’d hire the man for a senior developer position in a minute.

However, the economy being what it is, he is currently working a junior developer position. By which I mean doing senior developer work for junior developer money. Hey, it’s beats unemployment, no doubt, however things could be better along the compensation lines. As I’ve said, the man does not play around and he’d be a bargain at 3 times his salary (straight up.)

Well like any sane person (well as sane as one can be and still want to be a software developer), he’s taking the initiative and looking around for other employment where the compensation will be more commensurate with his efforts, and the challenges will be developmental and not overcoming ridiculous arbitrary management process (again, you’ll have to take my word that the problems are ridiculous and that he can not change them.)

So one of the places his recruiter is submitting his resume to is requiring he write a small windows console application that satisfies the following requirements:

  • Counts from between 1 and 100 inclusively
  • When the number is evenly divisible by 3, it should print “One
  • When the number is evenly divisible by 5, it should print “Two
  • When the number is evenly divisible by 3 and 5, it should print “OneTwo
  • When the number is not evenly divisible by 3 or 5, it should print the number
  • Ok, fair enough. I love that they asked for a code sample. At the end of the day, writing the code is part and parcel for software developers and I feel that the trend of those “what did you have to do”, “what were the results of doing it”, and “what could you have done differently” interviews… Sure you need to make sure the person is a good fit for the team as far as socializing, personality, not an asshat, but if they are a good fit, can they design and/or write the code.

    Well, I’ll say you have to at least consider it for a second but the above is not that challenging. Basically it will show you know how to nest/cascade if’s and perhaps know about the modulo operator.

    I would have been more impressed if they asked for a super and derived classes using interfaces to model a car, motorcyle, and airplane. But, I don’t know the company’s true needs so I’ll give them the benefit of the doubt.

    Anyway, good luck my man!

    Below is what I did… I feel it could be more performant but is pretty readable and gentle enough on resources for most stuff (I had to take a swing right?!?) …

    static void Main(string[] args)
    {
        StringBuilder valueBuilder = new StringBuilder();
        for (int counter = 1; counter <= 100; counter++)
        {
            if (counter % 3 == 0) valueBuilder.Append(“One”);
                if (counter % 5 == 0) valueBuilder.Append(“Two”);
                if (valueBuilder.Length == 0) valueBuilder.Append(counter.ToString());
                Console.WriteLine(valueBuilder.ToString());
                valueBuilder.Clear();
            }
        }
    }

    One Reply to “Impressed but not impressively- A friend’s interview code sample”

    1. void Main()
      {
      string str = string.Empty;
      Enumerable.Range(1, 100).Aggregate (str, (strThusFar, i) =>
      {
      str = string.Format(
      “{0}{1}”,
      strThusFar,
      (i % 3 == 0 && i % 5 == 0)
      ? “OneTwo”
      : (i % 3 == 0)
      ? “One”
      : (i % 5 == 0)
      ? “Two”
      : i.ToString());
      return str;
      });

      str.Dump(“The string”);
      }

    Comments are closed.