Sure, between the spying on millions of Americans and the sitting on critical security vulnerabilities for years, the National Security Agency (NSA) has a pretty bad reputation.

But have you heard about its brain-teasers?

The US spy agency employs some of America's best and brightest as spooks and code-breakers, so it's no surprise that its employees might have an interest in riddles and puzzles.

Every month, the NSA publishes on its website a brain-teaser written by an employee that members of the public can try their hand at.

One month it's a maths challenge created by an applied research mathematician; the next it's a logic puzzle by a systems engineer. They're all published in what the NSA calls its "Puzzle Periodical."

"Intelligence. It's the ability to think abstractly. Challenge the unknown. Solve the impossible. NSA employees work on some of the world's most demanding and exhilarating high-tech engineering challenges. Applying complex algorithms and expressing difficult cryptographic problems in terms of mathematics is part of the work NSA employees do every day," the NSA says on its website.

We've rounded up a six of the most interesting brain-teasers below. So take a read, and see if you can out-smart the NSA's most fiendish riddlers!

### 1. Here's a relatively easy one to start off with, from July 2016:

*Submitted by Sean A., NSA Applied Mathematician*

On a rainy summer day, brothers Dylan and Austin spend the day playing games and competing for prizes as their grandfather watches nearby. After winning two chess matches, three straight hands of poker and five rounds of ping-pong, Austin decides to challenge his brother, Dylan, to a final winner-take-all competition. Dylan clears the kitchen table and Austin grabs an old coffee can of quarters that their dad keeps on the counter.

The game seems simple as explained by Austin. The brothers take turns placing a quarter flatly on the top of the square kitchen table. Whoever is the first one to not find a space on his turn loses. The loser has to give his brother tonight’s dessert. Right before the game begins, Austin arrogantly asks Dylan, “Do you want to go first or second?”

Dylan turns to his grandfather for advice. The grandfather knows that Dylan is tired of losing every game to his brother. What does he whisper to Dylan?

_{Image credit: MoneyBlogNewz/Flickr (CC)}

Dylan should go first. By doing this, Dylan can guarantee a win by playing to a deliberate strategy. On his first turn, he can place a quarter right on the center of the table. Because the table is symmetric, whenever Austin places a quarter on the table, Dylan simply "mirrors" his brother’s placement around the center quarter when it is his turn. For example, if Austin places a quarter near a corner of the table, Dylan can place one on the opposite corner. This strategy ensures that even when Austin finds an open space, so can Dylan. As a result, Dylan gains victory, since Austin will run out of free space first!

### 2. This one, from June 2016, requires a bit more math.

*Submitted by Robert B., NSA Applied Mathematician*

Following their latest trip, the 13 pirates of the ship, SIGINTIA, gather at their favorite tavern to discuss how to divvy up their plunder of gold coins. After much debate, Captain Code Breaker says, “Argggg, it must be evenly distributed amongst all of us. Argggg.” Hence, the captain begins to pass out the coins one by one as each pirate anxiously awaits her reward. However, when the captain gets close to the end of the pile, she realizes there are three extra coins.

After a brief silence, one of the pirates says, “I deserve an extra coin because I loaded the ship while the rest of you slept.” Another pirate states, “Well, I should have an extra coin because I did all the cooking.” Eventually, a brawl ensues over who should get the remaining three coins. The tavern keeper, annoyed by the chaos, kicks out a pirate who has broken a table and who is forced to return her coins. Then the tavern owner yells, “Keep the peace or all of you must go!”

The pirates return to their seats and the captain, left with only 12 total pirates, continues to distribute the coins - “one for you,” “one for you.” Now, as the pile is almost depleted, she realizes that there are five extra coins. Immediately, the pirates again argue over the five extra coins. The captain, fearing that they will be kicked out, grabs the angriest pirate and ushers her out of the tavern with no compensation. With only 11 pirates left, she resumes distribution. As the pile nears depletion, she sees that there won’t be any extra coins. The captain breathes a sigh of relief. No arguments occur and everyone goes to bed in peace.

If there were less than 1,000 coins, how many did the pirates have to divvy up?

_{Image credit: Disney}

There are actually infinite answers to the problem, but only one number if the answer is under 1,000. This puzzle is an example of modular arithmetic and the Chinese Remainder Theorem.

The smallest solution under 1,000 for this problem is 341 coins, and the answer is found by working backwards. To find it, we first note that with 11 pirates the coins divided evenly; hence, the number of coins is in the list:

11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143…

What happens if we take these numbers and divide them among 12 pirates? How many coins would be left over? Well, we want 5 coins to be left over after dividing by 12. Hence, we reduce the list above to:

77, 209, 341, 473…

These numbers divide by 11 evenly and have 5 left over when divided by 12. Now we take these remaining numbers and divide them by 13 until we find the number that gives 3 extra coins left over. Hence, 341 coins.

### 3. Here's a logic puzzle from August 2015. You need to figure two things out.

*Puzzle created by Roger B., Cryptanalytic Mathematician, NSA*

Nadine is having a party, and she has invited three friends – Aaron, Doug, and Maura. The three of them make the following statements on the days leading up to the party:

Two Days Before the Party:

Aaron: Doug is going to the party.

Doug: Maura is not going to the party.

Maura: Aaron will go to the party if, and only if, I do.

The Day Before the Party:

Aaron: Maura will go to the party if, and only if, I don't go.

Doug: An even number out of the three of us are going to the party.

Maura: Aaron is going to the party.

The Day of the Party:

Aaron: It is not yet 2018.

Doug: Aaron will go to the party if, and only if, I do.

Maura: At least one of the three of us is not going to the party.

Nadine also knows that out of Aaron, Doug, and Maura:

One of them never lies.

A different one of them lies on days of the month that are divisible by 2, but is otherwise truthful.

The remaining one of them lies on days of the month that are divisible by 3, but is otherwise truthful.

(1) Can you figure out who is going to attend?

(2) Can you figure out on what day, month, and year the party will be held, assuming it takes place in the future?

_{Image credit: YouTube/blackboxberlin}

**(1) Attendees solution:**

The first step is to realize that the date rules imply that nobody may lie on two consecutive days.

If Maura's third statement is false, then everyone is going to the party and Doug's first two statements are lies, which is impossible. Therefore Maura's third statement is true, and at least one person is not going to the party.

If Doug's second statement is false, then (from the above) exactly one person is going to the party. This can't happen without making Doug's first or third statement also false, which would have Doug lying on two consecutive days—an impossibility. Therefore Doug's second statement is true, and there are an even number of people going to the party.

If Doug is not going to the party, then Aaron's first statement is false, so his second statement must be true. This would result in an odd number of people at the party, which we have shown is not the case. Therefore Doug is going to the party.

Since an even number of people are going to the party, only one of Aaron or Maura is going, making Maura's first statement false. Therefore her second statement must be true, and Aaron is going to the party while Maura is not. **The attendees are Doug and Aaron**.

**(2) Date solution:**

Having established the attendees as Doug and Aaron, now we know that the only lies are Maura's first statement and potentially Aaron's third statement.

If the three days do not cross a month boundary, then either the second date or both the first and third dates would be divisible by 2, but nobody is available to lie with that pattern. Therefore either the second or third day is the first of a month.

If the day before the party was the first of a month, then the day of the party is the second of a month; Aaron would have to be the one who lies on dates divisible by 2. Then, for Maura but not Aaron to lie on the first day, it would have to be divisible by 3 but not 2. This is never true of the last day of a month. Therefore, the day before the party is not the first of a month, so the day of the party itself must be the first day of a month.

This makes the day before the party the last day of a month, and since nobody lies on that day it must not be divisible by 2.

This means two days before the party, the date is divisible by 2, so it must not also be divisible by 3 or there would be two liars on that day. The only way this can happen two days before the end of a month is when that day is February 28 of a leap year.

Since nobody lies on the first of a month, Aaron's third statement is true and it is not yet 2018.

Finally, since the only leap year before 2018 is 2016, we conclude that the party is being held on **March 1, 2016**.

### 4. This one (April 2016) is simpler — but not any easier.

*Puzzle created by Andy F., Applied Research Mathematician, NSA*

Mel has four weights. He weighs them two at a time in all possible pairs and finds that his pairs of weights total 6, 8, 10, 12, 14, and 16 pounds. How much do they each weigh individually?

*Note: There is not one unique answer to this problem, but there is a finite number of solutions.*

_{Image credit: Doug Pensinger/Getty Images}

There are exactly two possible answers: Mel's weights can be 1, 5, 7, and 9 pounds, or they can be 2, 4, 6, and 10 pounds. No other combinations are possible.

**Explanation**

Let the weights be a, b, c, and d, sorted such that a < b < c < d. We can chain inequalities to get a + b < a + c < a + d, b + c < b + d < c + d. Thus, a + b = 6, a + c = 8, b + d = 14, and c + d = 16. But we don't know if a + d = 10 and b + c = 12 or the other way around. This is how we get two solutions. If a + d = 10, we get 1, 5, 7, and 9; if b + c = 10, we get 2, 4, 6, and 10.

**More on the Problem**

Where this problem really gets weird is that the number of solutions depends on the number of weights. For example, if Mel has three weights and knows the weight of all possible pairs, then there is only one possible solution for the individual weights. The same is true if he has five weights.

But now suppose that Mel has eight weights, and the sums of pairs are 8, 10, 12, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32, 34, 36, 38, and 40. Now what are the individual weights?

This time, there are three solutions:

- 1, 7, 9, 11, 13, 15, 17, 23
- 2, 6, 8, 10, 14, 16, 18, 22
- 3, 5, 7, 11, 13, 17, 19, 21

### 5. October 2015 was another logic puzzler, with a school theme. Take a look:

*Puzzle created by Ben E., Applied Research Mathematician, NSA*

Kurt, a math professor, has to leave for a conference. At the airport, he realizes he forgot to find a substitute for the class he was teaching today! Before shutting his computer off for the flight, he sends an email: "Can one of you cover my class today? I'll bake a pie for whomever can do it." He sends the email to Julia, Michael, and Mary Ellen, his three closest friends in the math department, and boards the plane.

As Kurt is well-known for his delicious pies, Julia, Michael, and Mary Ellen are each eager to substitute for him. Julia, as department chair, knows which class Kurt had to teach, but she doesn't know the time or building. Michael plays racquetball with Kurt so he knows what time Kurt teaches, but not the class or building. Mary Ellen helped Kurt secure a special projector for his class, so she knows what building Kurt's class is in, but not the actual class or the time.

Julia, Michael, and Mary Ellen get together to figure out which class it is, and they all agree that the first person to figure out which class it is gets to teach it (and get Kurt's pie). Unfortunately the college's servers are down, so Julia brings a master list of all math classes taught that day. After crossing off each of their own classes, they are left with the following possibilities:

- Calc 1 at 9 in North Hall
- Calc 2 at noon in West Hall
- Calc 1 at 3 in West Hall
- Calc 1 at 10 in East Hall
- Calc 2 at 10 in North Hall
- Calc 1 at 10 in South Hall
- Calc 1 at 10 in North Hall
- Calc 2 at 11 in East Hall
- Calc 3 at noon in West Hall
- Calc 2 at noon in South Hall

After looking the list over, Julia says, "Does anyone know which class it is?" Michael and Mary Ellen immediately respond, "Well, you don't." Julia asks, "Do you?" Michael and Mary Ellen both shake their heads. Julia then smiles and says, "I do now. I hope he bakes me a chocolate peanut butter pie."

Which class does Kurt need a substitute for?

1) Since Julia only knows the class name, the only way she could immediately know is if it was Calc 3. Since Michael and Mary Ellen both know that Julia doesn't know, that means they know the class isn't Calc 3. Since Michael only knows the time, that means the class can't be at noon. Because Mary Ellen only knows the building, that means the building can't be West Hall. That leaves only the following possibilities:

- Calc 1 at 9 in North Hall
- Calc 1 at 10 in East Hall
- Calc 2 at 10 in North Hall
- Calc 1 at 10 in South Hall
- Calc 1 at 10 in North Hall
- Calc 2 at 11 in East Hall

2) Since Michael doesn't know which class it is, that means the time can't be 9 or 11. Since Mary Ellen doesn't know either, the class can't be in South Hall. That leaves only three possibilities:

- Calc 1 at 10 in East Hall
- Calc 2 at 10 in North Hall
- Calc 1 at 10 in North Hall

3) At this point, Julia now says she knows the answer. Since there are two Calc 1 classes, it must be that Julia knows the class is Calc 2. Thus, the class is Calc 2 at 10 in North Hall.

### 6. Last one: Can you figure out Charlie's birthday? (July 2015)

*Puzzle created by Stephen C., Applied Research Mathematician, NSA*

After observing Albert and Bernard determine Cheryl's birthday, Charlie decides he wants to play. He presents a list of 14 possible dates for his birthday to Albert, Bernard and Cheryl.

- Apr 14, 1999
- Feb 19, 2000
- Mar 14, 2000
- Mar 15, 2000
- Apr 16, 2000
- Apr 15, 2000
- Feb 15, 2001
- Mar 15, 2001
- Apr 14, 2001
- Apr 16, 2001
- May 14, 2001
- May 16, 2001
- May 17, 2001
- Feb 17, 2002

He then announces that he is going to tell Albert the month, Bernard the day, and Cheryl the year.

After he tells them, Albert says, "I don't know Charlie's birthday, but neither does Bernard."

Bernard then says, "That is true, but Cheryl also does not know Charlie's birthday."

Cheryl says, "Yes and Albert still has not figured out Charlie's birthday."

Bernard then replies, "Well, now I know his birthday."

At this point, Albert says, "Yes, we all know it now."

What is Charlie's birthday?

_{Image credit: Will Clayton/Flickr (CC)}

When Albert claims that Bernard does not know Charlie's birthday, he is saying that he knows that the correct day occurs more than once in the list. In other words, he is saying that Charlie's birthday is not Feb 19, 2000, and the only way he could know that is that he knows that the month is not February.

So by making this claim Albert has reduced the list for everyone to:

- Apr 14, 1999
- Mar 14, 2000
- Mar 15, 2000
- Apr 16, 2000
- Apr 15, 2000
- Mar 15, 2001
- Apr 14, 2001
- Apr 16, 2001
- May 14, 2001
- May 16, 2001
- May 17, 2001

When Bernard says that it is true that he does not know Charlie's birthday, it tells everyone that even with the restricted list the correct day occurs more than once in the list. So everyone can thus eliminate May 17, 2001.

Furthermore, the claim that Cheryl also does not know Charlie's birthday is a claim that Bernard knows that the year occurs more than once on the remaining list.

This rules out Apr 14, 1999, and since Bernard could only rule this out by knowing that the day was not 14, everyone can further reduce the list to:

- Mar 15, 2000
- Apr 16, 2000
- Apr 15, 2000
- Mar 15, 2001
- Apr 16, 2001
- May 16, 2001

When Cheryl says that Albert still has not figured out Charlie's birthday, she is telling everyone that given the new list the month occurs more than once and thus rules out May 16, 2001. This tells everyone that Cheryl knows that the year is not 2001 and the list can be reduced to:

- Mar 15, 2000
- Apr 16, 2000
- Apr 15, 2000

When Bernard then claims to know the date he is saying that the day occurs only once among the 3 remaining choices, thus telling everyone that Charlie's birthday is Apr 16, 2000.

*Watch this next on Business Insider: A sleep doctor reveals the best time to take a nap*