Paste: AOC day 7 best

Author: chunes
Mode: factor
Date: Tue, 7 Dec 2021 07:57:06
Plain Text |
"input.txt" ascii file-lines first "," split [ dec> ] map
dup [ median ] keep n-v vabs sum . B
dup mean 2dup 1 +
[ >integer '[ _ - abs [1,b] sum ] map-sum ] 2bi@ min .

! previous solution only worked by happenstance.
! it turns out the median only guarantees you'll be 'close'
! to optimal. We have to check both integers lower and higher
! than the mean.

Annotation: small changes

Author: chunes
Mode: factor
Date: Tue, 7 Dec 2021 07:58:40
Plain Text |
s/median/mean and remove the B, oops

New Annotation

Summary:
Author:
Mode:
Body: