part 1 : 20 sec
part 2 : a very bad time ! even if I use HOF
part 2
@dardoro :i need some explications (if you have time): can you describe your algo plz.
questions inside Dardoro...
why 0 in front
what's this
3)and at the last line : numbers from 0 to max shoud be min to max ? (what if you have a neg pos? or if position are between 100000-110000?) it will be much faster with min (i think!)
what's this
3)and at the last line : numbers from 0 to max shoud be min to max ? (what if you have a neg pos? or if position are between 100000-110000?) it will be much faster with min (i think!)
ad.1. It's initial value of the accumulator for combine. For the first iteration of combine, two first elements are used at once but EVERY element of the list must be processed by the expression
ad.2.Fuel consumption for distance of 4 = 1+2+3+4 i.e. $$\displaystyle\sum_{i=1}^ni = n(n+1)/2$$
ad.3 YES.
Values pretends to be a depth so rather >0 (there is no info about flying crabs or submarine ).
"min" will be probably faster if depth values doesn't cover whole (0..max) range. But "min" also takes some time...