by zellyn · 8y ago · 0 comments
The first question is: What is the sum of the numbers from 1 to 1024. Please use Python, not the Gauss/two-triangles-make-a-rectangle mathematical method.
* - “obnoxious” means it's a leading question: it's simple to state, but you might have to learn a bunch of crap to even really fully understand the question.
Sample far-future questions: - Does it seem magical that you can turn an NFA into a DFA? - How does a shell pass stdout from one process to the stdin of the next? - Why is the Frame Pointer technically unnecessary, but useful? - Why do people complain about Go's nil pointers? What's wrong with them?
Anyway, the author was posting google requirements. More than 80% of google developers have a master or more.
What they're asking for is a syllabus.
I... I never thought of that geometrically. but your way...
__ __ __
| || / | |
| ||/ | |
| / | / /|
|/ |/ /_|
that makes so much sense! .
..
...
....
That's 1 + 2 + 3 + 4. To sum, double the triangle, you'll get a rectangle: .oooo
..ooo
...oo
....o
1 + 2 + 3 + 4 = area ÷ 2 = (4 * 5) ÷ 2 = 10.So, the sum of 1..1024 is: 1024 * 1025 ÷ 2 = 524800.
Your way, the doubling is obvious, so you see why you can always /2 at the end.
Hmm. Haven't thought about this stuff in years. This was a pretty pleasing thing to revisit.
Actually, I came here to post the correction rodorgas beat me to posting. But your diagram works too: 1/2 base * height… nice.