# FiveThirtyEight Riddler Express October 14 2016

**URL:** <https://boards.straightdope.com/t/fivethirtyeight-riddler-express-october-14-2016/768571>\
**Category:** Factual Questions\
**Created:** [October 15, 2016, 1:00am UTC](https://boards.straightdope.com/t/fivethirtyeight-riddler-express-october-14-2016/768571 "2016-10-15T01:00:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![asterion](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@asterion](https://boards.straightdope.com/u/asterion)\
**Post date:** [October 15, 2016, 1:00am UTC](https://boards.straightdope.com/t/fivethirtyeight-riddler-express-october-14-2016/768571/1 "2016-10-15T01:00:08Z")

</div>

FiveThirtyEight’s weekly riddler column has started a shorter version to go along with the longer one. The column is [here](http://fivethirtyeight.com/features/can-you-survive-this-deadly-board-game/). I’m not going to give the answer I got here in the OP, in hopes that there will be a better discussion. The basics are as follows:

Line up 100 coins heads up, numbered 1 to 100. For every number N, 1 to 100, flip over the coin which is a multiple of N. So, when N=1, all coins are flipped to tails, when N=2, all the even numbers flip back to heads, and so on. At the end of the operation, which coins are tails?

Now, I’m not very good at these sorts of things, so I brute-forced it using an Excel function. Leaving cell A1 blank, I ran the coin numbers down column A and the numbers N along row 1, with the initial state (all heads expressed as 1) in column B with B1=N=0. I then wrote the function =(IF(MOD,$A2,C$1)=0,B2\*-1,B2\*1). The MOD function takes the coin number, divides it by the value for N, and returns a remainder. If the remainder equals zero, the IF function flips the sign and if the remainder does not equal zero, the IF function keeps the value the same. Copying the function throughout the Excel sheet gave the results for all N.

I figure there has to be a more elegant way to find the answer. This just feels like the classic sort of puzzle that has a simple algorithm that returns the answer, but I have no idea how to do it.

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [October 15, 2016, 2:48am UTC](https://boards.straightdope.com/t/fivethirtyeight-riddler-express-october-14-2016/768571/2 "2016-10-15T02:48:01Z")

</div>

A coin will be tails if it is flipped over an odd number of times. It is flipped over once for each of its factors. Each factor f of x comes paired with a corresponding distinct other factor x/f, except in the case that these two actually coincide (i.e., when x = f[sup]2[/sup]; there will be precisely one such f if x is a perfect square, and none otherwise). Thus, a coin will end up tails if and only if its number is a perfect square.

---

<div class="post-metadata">

**Author:** ![Baffle](https://avatars.discourse-cdn.com/v4/letter/b/dec6dc/32.png) [@Baffle](https://boards.straightdope.com/u/Baffle)\
**Post date:** [October 15, 2016, 2:50am UTC](https://boards.straightdope.com/t/fivethirtyeight-riddler-express-october-14-2016/768571/3 "2016-10-15T02:50:21Z")

</div>

The numbers which end up tails have an odd number of factors. A factor being one of two integers, which when multiplied, give your starting number.

Every number, for example, is a product of one and itself, and so the minimum number of factors is 2.

Since there’s always 2 unique integers being multiplied, there should always be an even number of factors… right?

[spoiler] Unless one of the factorizations is the same number repeated… in which case, it’ll only get flipped once for a factor pair.

[spoiler] Which numbers have a factor pair where both integers are identical?

Perfect squares. The remaining tails will be 1, 4, 9, 16, 25, 36, 49, 63, 81, 100.  
 [/spoiler][/spoiler]

---

<div class="post-metadata">

**Author:** ![Great\_Antibob](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@Great\_Antibob](https://boards.straightdope.com/u/Great_Antibob)\
**Post date:** [October 15, 2016, 3:22am UTC](https://boards.straightdope.com/t/fivethirtyeight-riddler-express-october-14-2016/768571/4 "2016-10-15T03:22:59Z")

</div>

Already answered up thread, but from the Ask Dr Math archives: [100 lockers](http://mathforum.org/library/drmath/view/55812.html).

---

<div class="post-metadata">

**Author:** ![Rysto](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@Rysto](https://boards.straightdope.com/u/Rysto)\
**Post date:** [October 15, 2016, 4:24am UTC](https://boards.straightdope.com/t/fivethirtyeight-riddler-express-october-14-2016/768571/5 "2016-10-15T04:24:05Z")

</div>

> [@Indistinguishable](#):
>
> A coin will be tails if it is flipped over an odd number of times. It is flipped over once for each of its factors. Each factor f of x comes paired with a corresponding distinct other factor x/f, except in the case that these two actually coincide (i.e., when x = f[sup]2[/sup]; there will be precisely one such f if x is a perfect square, and none otherwise). Thus, a coin will end up tails if and only if its number is a perfect square.

What about prime numbers? Shouldn’t they only be flipped once?

Edit: Oh, I see, in this case we have to consider 1 as part of its factorization.

---

<div class="post-metadata">

**Author:** ![bob\_2](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bob_2/32/3341_2.png) [@bob\_2](https://boards.straightdope.com/u/bob_2)\
**Post date:** [October 15, 2016, 10:35am UTC](https://boards.straightdope.com/t/fivethirtyeight-riddler-express-october-14-2016/768571/6 "2016-10-15T10:35:39Z")

</div>

Those of you who enjoy this kind of puzzle may like to read [this](http://www.telegraph.co.uk/books/what-to-read/behind-gchqs-fiendish-new-puzzle-book/), have a go at the puzzles created by GCHQ, and maybe even buy the book.

I wonder how well the spooks at the NSA will do?

---

<div class="post-metadata">

**Author:** ![MikeS](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@MikeS](https://boards.straightdope.com/u/MikeS)\
**Post date:** [October 15, 2016, 2:33pm UTC](https://boards.straightdope.com/t/fivethirtyeight-riddler-express-october-14-2016/768571/7 "2016-10-15T14:33:57Z")

</div>

> [@Rysto](#):
>
> What about prime numbers? Shouldn’t they only be flipped once?
> 
> Edit: Oh, I see, in this case we have to consider 1 as part of its factorization.

One could also pose a version of the problem where we don’t flip all the coins whose numbers are divisible by 1 – in which case all of the coins with square numbers would be flipped an even number of times and the rest would be flipped an odd number of times. The result would still be basically the same, just with every coin reversed.
