Files
codingame/puzzles/easy/horse-racing-duals.sh
2017-04-06 16:49:53 +02:00

15 lines
368 B
Bash

# https://www.codingame.com/ide/puzzle/horse-racing-duals
# Xavier Morel - 2016-03-12
# WIP: Only passing tests up to 55% : big performance issues, obviously...
read N
for ((i=0; i<N; i++)); do
read Pi
if ((i>0)); then
horses+=":"
fi
horses+=$Pi
done
echo $horses | tr ":" "\n" | sort -n | awk 'NR>1{print $1-p} {p=$1}' | sort -n | head -n 1