Skip to content

Instantly share code, notes, and snippets.

@rbehrends

rbehrends/lc.nim Secret

Created May 1, 2014 21:44
Show Gist options
  • Save rbehrends/738010461a04b44cd2a5 to your computer and use it in GitHub Desktop.
Save rbehrends/738010461a04b44cd2a5 to your computer and use it in GitHub Desktop.
proc main =
const SIZE = 8192
var
buf: array[SIZE, char]
f = stdin
lineCount = 0
byteCount = 0
n = 0
while true:
n = f.readBuffer(addr(buf), SIZE)
if n == 0: break
byteCount += n
for i in 0 .. <n:
if buf[i] == '\L':
lineCount += 1
echo lineCount
echo byteCount
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment