← All challenges

// code challenge

Count non-empty lines

~15 min

SRE-flavored warm-up: count log lines that are not blank.

Read all of stdin. Print the number of lines that contain at least one non-whitespace character.

Example: stdin: error: timeout <blank> ok stdout: 2

Useful when skimming logs and metrics dumps.

Language: · Judge0

// sample tests

  • stdin "a\nb\nc\n"stdout "3"
  • stdin "x\n\ny\n"stdout "2"
  • stdin "\n\n"stdout "0"

Sign in to run and submit.

Count non-empty lines