Skip to content

Instantly share code, notes, and snippets.

@DrunkenAlcoholic
Created May 14, 2024 03:44
Show Gist options
  • Save DrunkenAlcoholic/9d4bbfa866e6b62c926e89b551f920fe to your computer and use it in GitHub Desktop.
Save DrunkenAlcoholic/9d4bbfa866e6b62c926e89b551f920fe to your computer and use it in GitHub Desktop.
Bob [Exercism - Nim]
import strutils, unicode
proc hey*(s: string): string =
if s == s.toUpperAscii and contains(s, Letters.set) and s[^1] == '?':
return "Calm down, I know what I'm doing!"
elif s == s.toUpperAscii and contains(s, Letters.set):
return "Whoa, chill out!"
elif not contains(s, {'A'..'Z', 'a'..'z', '0'..'9', '?'}) or s == nil:
return "Fine. Be that way!"
elif strutils.strip(s)[^1] == '?':
return "Sure."
else: return "Whatever."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment