Binary - should empty input be rejected?

I’ve done the Binary exercise in the Roc track. I’ve found out that:

  1. There is no test case with the input being the empty string.
  2. Most solutions return 0 when the input is the empty string.

Regarding 2. this is the natural thing to do when one implements the algorithm without thinking about this edge case. But I believe the result is wrong. The empty string is not a binary representation of a number; therefore the result should be an error.

I don’t know how this is handled in other language tracks.

See also Binary - expected output is not decimal representation of a number

Most tracks seem to expect zeroes, but Wren notably expects nulls to be returned for invalid inputs. Since this is a deprecated exercise, I suspect there’s not much use in updating the problem specifications repo since only a small handful of tracks still implement it.

The Roc maintainers can always just add this test for their track alone.

1 Like