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

50.0% Correct | 50.0% Incorrect
Last Solution submitted on Dec 11, 2022

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers3

Suggested Problems

More from this Author80

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!