All problems

Blank Lines Counted as Shipment Labels

Level 2 · node · Correctness · Empty input rows included in label count

Scenario

A fictional warehouse accepts a newline-separated list of shipment codes to preview a batch of shipping labels. Pasting a list can introduce trailing blank lines or whitespace-only lines between codes. The implementation currently counts those lines as printable labels, causing the preview total to exceed the number of valid labels.

Requirements

Trim each input line and include only nonempty shipment codes. Preserve the order and duplicate codes, and return zero labels for empty input.

Acceptance criteria

  • Two normal shipment codes produce two labels.
  • A trailing blank line does not create a label.
  • A whitespace-only line between codes is excluded.
  • Repeated shipment codes remain as two labels.