Problem 44497. It's Happy! It's Fun! It's Happy Fun Hyperball!
Yes, it's Happy Fun Hyperball! The CODY sensation that's sweeping MATLAB nation! All you need to do to get your free Happy Fun Hyperball is write a script that, when given a radius r, will tell us how many points with all integer coordinates are on the surface of your four-dimensional shape (defined by w^2+x^2+y^2+z^2=r^2) known as Happy Fun Hyperball! For example, if r=2, you will have 24 of these points:
* (+/-2),0,0,0 * 0,(+/-2),0,0 * 0,0,(+/-2),0 * 0,0,0,(+/-2) * (+/-1),(+/-1),(+/-1),(+/-1)
so happy_fun_hyperball(2)=24. Good luck!
- Warning: Pregnant women, the elderly, and children under 10 should avoid prolonged exposure to Happy Fun Hyperball.
- Caution: Happy Fun Hyperball may suddenly accelerate to dangerous speeds.
- Happy Fun Hyperball contains a liquid core, which, if exposed due to rupture, should not be touched, inhaled, or looked at.
- Do not use Happy Fun Hyperball on concrete.
- Discontinue use of Happy Fun Hyperball if any of the following occurs:
* itching * vertigo * dizziness * tingling in extremities * loss of balance or coordination * slurred speech * temporary blindness * profuse sweating * or heart palpitations.
- If Happy Fun Hyperball begins to smoke, get away immediately. Seek shelter and cover head.
- Happy Fun Hyperball may stick to certain types of skin.
- When not in use, Happy Fun Hyperball should be returned to its special container and kept under refrigeration. Failure to do so relieves the makers of Happy Fun Hyperball, Wacky Products Incorporated, and its parent company, Global Chemical Unlimited, of any and all liability.
- Ingredients of Happy Fun Hyperball include an unknown glowing green substance which fell to Earth, presumably from outer space.
- Do not taunt Happy Fun Hyperball.
Happy Fun Hyperball comes with a lifetime warranty. Happy Fun Hyperball! Accept no substitutes!
Solution Stats
Problem Comments
-
4 Comments
The 24 solutions for r=2 are actually [-2 0 0 0;-1 -1 -1 -1;-1 -1 -1 1;-1 -1 1 -1;-1 -1 1 1;-1 1 -1 -1;-1 1 -1 1;-1 1 1 -1;-1 1 1 1;0 -2 0 0;0 0 -2 0;0 0 0 -2;0 0 0 2;0 0 2 0;0 2 0 0;1 -1 -1 -1;1 -1 -1 1;1 -1 1 -1;1 -1 1 1;1 1 -1 -1;1 1 -1 1;1 1 1 -1;1 1 1 1;2 0 0 0].
Aahaa... Thank-you for the explanation, Tim. Actually it was quite simple when looking at the correct numbers. So we could also summarise it as four similar patterns (±2,0,0,0), (0,±2,0,0), (0,0,±2,0) and (0,0,0,±2) accounting for 4×2=8 points, and one more pattern (±1,±1,±1,±1) accounting for 1×2⁴=16 points. Thus a grand total of 24 points. —DIV
I originally had the points for w^2+x^2+y^2+z^2=r, as opposed to r^2. Sorry for the confusion, David...and thanks for taking care of the clarification, Tim!
They're fixed now, and the problem statement has been changed a bit to hopefully clear things up.
Solution Comments
Show commentsProblem Recent Solvers3
Suggested Problems
-
Return unique values without sorting
934 Solvers
-
1586 Solvers
-
How many trades represent all the profit?
603 Solvers
-
76 Solvers
-
Magic is simple (for beginners)
9613 Solvers
More from this Author80
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!