OlveraeUNSW
Back to problems
COMP2041

21T2 Q4 — The missing integer

Argument 1 is a filename containing an unordered list of positive integers from n to m, one per line, with at most one integer missing (never n or m; no duplicates). Print the missing integer, or nothing if none is missing. At most one line of output.

$ cat numbers_1.txt
39
45
40
44
41
43
$ ./prog numbers_1.txt
42

POSIX shell only (#!/bin/dash); standard UNIX filters; no awk, Perl, C or Python. From COMP2041/9044 21T2 Final.

Samples

stdin
expected
42
shell
14