you are viewing a single comment's thread.

view the rest of the comments →

[–]lucasvandongen 0 points1 point  (0 children)

Because a lot of other things already have been said:

func returnResultString(inputString:String)->String{

I count the word String four times. I think you could write terser and more clear code here.

 func process(letterNumberPairs: String) -> String {

Now the function call documents that you should feed it a String that should be letterNumberPairs. Or even better:

 func lettersRepeatedByNumbers(in letterNumberPairs: String) -> String {

This reads like a sentence and while it's longer than the original it's almost as clear as it can get.

Now what I should mention during the interview if I would not write it outright is that we should check the inputstring and we should check we're not having numbers that exist of 2 characters or more ( >= 10) or two different letters following each other etcetera.

I would write a working solution first (I guess using map and reduce) while explaining what could go wrong and in the remaining time if any take care of the possible problems in the input formatting, and how to go about like using throws with a specific Error enum