DEV Community

Discussion on: Daily Coding Puzzles - Nov 11th - Nov 16th

Collapse
 
kungtotte profile image
Thomas Landin

Here's my Nim solution :)

There are filter and keepIf functions defined in the sequtils standard library but that feels like cheating :P

$ is Nim's stringify operator, and the find procedure returns -1 if it doesn't find the substring :)

import strutils # for the 'find' procedure

proc my_filter(start, stop: int): seq[int] =
  for i in start..stop:
    if find($i, "5") == -1:
      result.add(i)

echo my_filter(1,9).len
echo my_filter(4,17).len