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
Hello, James & all. What a happy Problem! There are a few details I am not getting and would appreciate clarifications on:
***Summation of enumerated cases*** In the example there are fourteen occurrences of "±". Wouldn't that provide a total of 28 distinct points in space (instead of 24)? That is, 2 for each of the first four bullets, and 4 for each of the last five bullets? ***Enumeration of cases*** Following the pattern in the example, I would have expected one additional bullet comprising (±1,0,0,±1). That would suggest happy_fun_hyperball(2)=32. ***Points "on" surface*** If points are to be "on" the surface, then can (±1,±1,0,0) qualify for r=2? Given this has the third and fourth variables set to zero, then shouldn't (±1,±1,0,0) also be "on" the circle of r=2 in the x–y plane? Yet (1,1) is a distance of √2 from the origin. So then could happy_fun_hyperball(2)=8?
Thanks, David
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
-
958 Solvers
-
9977 Solvers
-
Create a vector whose elements depend on the previous element
656 Solvers
-
347 Solvers
-
Geometry: Find Circle given 3 Non-Colinear Points
61 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!