13 lines
246 B
Awk
13 lines
246 B
Awk
# echo -n '1,9,87,3,10,4,20,2,45' | tr ',' '\n' | sort -g | tr '\n' ' ' | awk -f longest-seq.awk
|
|
BEGIN {getline;
|
|
i = 2
|
|
j = 1
|
|
while (i < NF) {
|
|
if ($(i) - $(j) != i - j) {
|
|
j++
|
|
}
|
|
i++
|
|
}
|
|
}
|
|
END { printf "longest: %s\n", i-j }
|