day 01
This commit is contained in:
commit
35e42e74ac
|
@ -0,0 +1,18 @@
|
|||
BEGIN {
|
||||
RS = "\n\n"; FS = "\n"
|
||||
TOP = 3
|
||||
toptot = 0
|
||||
}
|
||||
{
|
||||
tot = 0
|
||||
for (i = 1; i <= NF; i++)
|
||||
tot += $i
|
||||
cal[FNR] = tot
|
||||
}
|
||||
END {
|
||||
asort(cal, cal, "@val_num_desc")
|
||||
for (i = 1; i <=TOP; i++)
|
||||
toptot += cal[i]
|
||||
print "elf with most calories has " cal[1] " calories"
|
||||
print "sum of top 3: " toptot
|
||||
}
|
Loading…
Reference in New Issue