# How Many Ways Can You Raid The Candy Shop?

A FiveThirtyEight Riddler puzzle.
Riddler
mathematics
Published

November 8, 2019

## Riddler Express

Suppose I asked you to generate the biggest number you could using exactly three nines. Specifically, you can add, subtract, multiply, divide, exponentiate or write them side-by-side. Given this challenge, 9×9×9 is a pretty good start — it equals 729. Better yet is just writing the nines side-by-side, giving you 999. The biggest number is $$9^{9^9}$$, which equals 9387420489. If you were to write one digit of that number every second, it would take you more than a decade to write the whole thing.

Now let’s up the challenge: What’s the biggest number you can generate using exactly four threes?

## Solution

The largest number that can be created by four threes is $$3^{3^{33}}$$.

## Riddler Classic

Now that Halloween has come and gone, your chances of getting free candy have similarly disappeared. Desperate for sugar, you wander into the candy store, where three kinds of candy are being sold: Almond Soys (yummy, sounds vegan!), Butterflingers and Candy Kernels.

You’d like to buy at least one candy and at most 100, but you don’t care precisely how many you get of each or how many you get overall. So you might buy one of each, or you might buy 30 Almond Soys, six Butterflingers and 64 Candy Kernels. As long as you have somewhere between one and 100 candies, you’ll leave the store happy.

But as a member of Riddler Nation, you can’t help but wonder: How many distinct ways are there for you to make your candy purchase?

## Solution

from itertools import product

cnt = 0
for a,b,c in product(range(101), range(101), range(101)):
if a + b + c >= 1 and a+b+c <= 100:
cnt += 1
print(cnt)

The number of distinct ways to make the candy purchase is 176850.
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 1, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}