Zach Adams Web Developer and Programmer

Fun Puzzles for Programmers

June 25, 2014

I found this neat article from DataGenetics that has a bunch of fun puzzles and challenges for programmers. Hints and answers can be found in the article here.

1. Two Bases

Challenge: Find three digits X, Y and Z such that XYZ in base10 is equal to ZYX in base9.

2. One Million

Challenge: Write 1,000,000 as the product of two numbers; neither of which contains any zeroes.

3. High Product

Challenge: Use the digits 0-9 to create two numbers. What is the highest product you can achieve when these two numbers are multiplied together?

4. Exactly a Third

Challenge: Arrange the numerals 1-9 into a single fraction that equals exactly 1/3 (one third). No other math symbols wanted; just concatenation some digits for the numerator, and some to make a denominator.

5. Three Dice

Challenge: I roll three dice, and multiply the three numbers together. What is the probability the total will be odd?

6. Word Doc

Challenge: I open up a Word document and type all the numbers 1-10000, separated by spaces, (I did not use any ‘thousands’ punctuation; just raw numbers). Then, my daughter came along and used search and replace, and changed all the digits ‘0’ into spaces. If I now sum up all the numbers in the document what is the total? (Any number delineated by one or more spaces is a distinct number).

7. Legs

Challenge: In a room there are a mixture of people and dogs. There are 72 heads, and 200 legs. How many dogs are in the room? (No tricks, no chromosomal abnormalities, no disabilities …)

8. One, Two, Three

Challenge: Using just one 1, one 2, and one 3 (no concatenation of digits) and any combination mathematical symbols you wish (addition, subtraction, multiplication, division, parenthesis, exponents, factorial, square root …). Write an equation to gives the total 19.

9. One, Seven

Challenge: As above, how about making a total of 71 using just one 1 and one 7 (again, no concatenation of digits, or this would be trivial!)

10. Buckets

Challenge: Put the numbers 1-13 into three buckets with the constraint that the difference between any two pairs of numbers in any bucket is not a number also in that bucket. (e.g. If you place 5,7 in a bucket, then you cannot place 2 in that same bucket).

11. Product and Sum

Challenge: I’ve written down all the integers from 1 to 65,502 inclusive. I select two of them, cross them out, and multiply them together to get a product. When I sum up the remaining 65,500 numbers, I get the same result. What two numbers did I pick?

12. Adjacent Squares

Challenge: Arrange the integers 1-17 (inclusive) so that each adjacent pair of numbers is a perfect square. e.g. 14, 2, 7 … (The first and last do not have to wrap around)

13. How Many

Challenge: ABCDEFGHIJ is a ten-digit-number. All of the digits are distinct. If 11111 divides it evenly, how many possibilities are there for ABCDEFGHIJ?

14. Reciprocals

Challenge: Find six distinct integers: A, B, C, D, E, F the reciprocals of which add up to exactly one. e.g. 1/A + 1/B + … 1/F = 1

15. Fan Fun

Challenge: You’re taking care of a friend’s house whilst he’s on vacation. In one room you pull the chain on a ceiling fan, and when it doesn’t respond you realize the house has temporarily lost power. Doh! Unfortunately, you have to leave now, and you’ll be away for several days.

You know that the fan was in the “off” position before you pulled the chain, and that pulling the chain successively will cycle it through its remaining settings (“off,” “high”, “medium”. etc.). You don’t know how many settings there are, but you are sure there aren’t more than four.

How can you ensure the fan will be in the “off” positions when power is restored?

16. LED Clock

Challenge: You are in a totally dark room. The only light in the room comes from an old LED digital alarm clock (with four seven segment displays). The clock display is HH:MM (no seconds). The clock is configured to display time in 24 hour format and the leading digit is blank if not used. What is the period of time between when the room is at its darkest, to when it is at its lightest?

17. Use All the Digits

Challenge: Find a five-digit number, all digits distinct and non-zero, such that that number is equal to the sum of all three-digit numbers can be made with the digits of that number.

i.e. A number ABCDE that is equal to ABC + ABD + ABE + BCA + CBA + BDA + DBA + … etc.

18. Sticky Calculator Buttons

Challenge: My daughter just spilled orange juice over my scientific calculator. The number buttons 0-9 are all stuck (not working), as are the basic arithmetic functions + – * /

Thankfully, all the scientific buttons work (trig, powers, inverse, exponential, log, root, factorial …)

The display currently reads “0”.

How can I use the buttons that work to make the display show “1”, then press buttons to convert this to a “2”, and finally “3”?

19. Using Twos

Challenge: Multiple parts, some easy, some hard. Add mathematical symbols (factorial, +, -, / , *, sqr , trig functions, log, decimal points, exponents …) to make the desired sums. Concatenation is allowed.

  1. Make 11 using three 2s
  2. Make 1 using three 2s
  3. Make 10 using two 2s
  4. Make 5 using two 2s

20. Filling My Pool

Challenge: If I fill up my pool using my red hose pipe, it takes me eight and a half hours. If I fill it up using both my red hose pipe and my blue hose pipe, it takes just five and a quarter hours. How long will it take me to fill my pool if I used just the blue hose pipe?

(All the common sense simplifications apply: constant flow rates, don’t try to complicate things with physics!)

21. Start and End

Challenge: Find the smallest possible natural number that ends in 6 such that if the 6 is erased and placed in front of the remaining digits, the resulting number is 4 times as large as the original number.

Comments

Sashen says:
July 5th 2015 at 12:00am
I have 5 dogs. The total number of all the dogs' legs add up to 19. Why is this?

Leave a Reply

Your email address will not be published. Required fields are marked *