Documented examples · No live execution
main.py
import sys
names = sorted({line.strip().lower() for line in sys.stdin if line.strip()})
print("\n".join(names))main.rs
use std::io::{self, Read};
fn main() {
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
let mut names: Vec<String> = input.lines()
.map(|s| s.trim().to_ascii_lowercase())
.filter(|s| !s.is_empty())
.map(String::from).collect();
names.sort();
names.dedup();
println!("{}", names.join("\n"));
}UTF-8 · Educational comparisonPerformance: not benchmarked
Compatibility contract
Read UTF-8 lines from stdin, trim ASCII whitespace, lowercase ASCII letters, remove empty and duplicate names, sort ascending, and print one name per line.
Shared test fixtures
Input
" Ada\nBOB\nada\n"Expected output
"ada\nbob\n"Input
"\n"Expected output
"\n"Migration considerations
- Define case folding and sort order before replacing production text handling.
- Compare output fixtures across both implementations.
Known limitations
The example contract is limited to ASCII names and whitespace.
No benchmark measurements exist for these examples. A production migration needs its own contracts, tests, and baseline.