DEV Community

loading...

Discussion on: Daily Challenge #60 - Find the Missing Letter

Collapse
citizen428 profile image
Michael Kohl

Nice, but I think there are a few edge cases you might consider handling:

  • Empty inputs return 0 (I guess that could work).
  • Inputs that don't actually miss a letter will return the ASCII code of the last element.
  • One element inputs return the ASCII code of the only letter (just a special case of the previous point really).

In other words, is returning the character representation of last really a sensible default if the input does not have a missing letter, either due to length or contents?

Collapse
dak425 profile image
Donald Feury

Its not but I didn't really have much time for this at the time. So I implemented it within the context of the challenge as specified

Collapse
dak425 profile image
Donald Feury

Meaning, slice is always valid, always has length of at least 2, always has exactly one character missing, and all the characters will be of the same case.

My solution includes no consideration for these edge cases since within the context of this challenge, those edge cases don't exist.

Thread Thread
citizen428 profile image
Michael Kohl

Sure, was just trying to have a discussion. Generally the problems in these challenges are not particularly interesting by themselves, but that doesn't mean one can't turn them into a learning experience by e.g. doing more than what was specified.

Thread Thread
dak425 profile image
Donald Feury

Oh no of course, you are right and I agree with all the points you made.