Other "Hello World" solutions.
proc hello*: string =
"Hello, World!"
Other "Isogram" solutions.
import sets, unicode, sequtils, sugar
proc isIsogram*(str: string): bool =
var seen: HashSet[Rune] = initHashSet[Rune]()
for c in toLower(str).toRunes.filter(c => c.isAlpha):
if seen.containsOrIncl(c):
return false
return true
Other "Leap" solutions.
func isLeapYear*(year: int): bool =
year mod 4 == 0 and (
year mod 100 != 0 or year mod 400 == 0
)
Other "Pangram" solutions.
import sequtils, strutils
func isPangram*(phrase: string): bool =
{'a'..'z'}.allIt it.in(phrase.toLower)
Other "Reverse String" solutions.
proc reverse*(s: string): string =
if s == "":
return s
var aux = s
for i in 0 .. high(s) div 2:
swap(aux[i], aux[high(aux) - i])
aux
Other "Two Fer" solutions.
import strformat
proc twoFer*(name = "you"): string =
&"One for {name}, one for me."