Y
Hacker News
new
|
ask
|
show
|
jobs
by
forgotmypw17
183 days ago
Wouldn't the correct answer be 5?
result = result + x // 5 0 5
5 comments
AlotOfReading
183 days ago
Iteration starts from the first element. X is 3, 3, then 5.
link
Daneel_
183 days ago
The logic results in 3 + 3 - 5 = 1, so it's not 5, sorry.
I'd love to know what logic path you followed to get 5 though!
link
commandlinefan
183 days ago
I did it in my head but got 4 (3 * 3 - 5), so I fail, too. Hopefully I'd be paying closer attention if I was actually applying for a job.
link
spike021
183 days ago
where did your multiplication come from?
link
commandlinefan
183 days ago
From not paying close attention :)
link
krackers
183 days ago
Presumably you'd get it if you short-circuited and didn't evaluate the else part.
link
forgotmypw17
183 days ago
Thanks to everyone who replied. I failed to account for the else condition when x is not > 3.
link
kevin061
183 days ago
3 comes before. Read it again.
link
dinkleberg
183 days ago
It’s in a loop
link