Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
codygman
on March 8, 2015
|
parent
|
context
|
favorite
| on:
On Secretly Terrible Engineers
Oh cool, slices don't return index errors:
>>> print sum(sorted([])[-2:]) 0
Luyt
on March 9, 2015
[–]
Reading the original problem, "Write a function that returns the sum of the two largest numbers in an array", I took the liberty of assuming that the input list would always contain at least two items.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: