| about | help | code help+videos | done | prefs |
flipping_ages
This was CarTalk Puzzler #200813: RAY: This was sent in many weeks ago by Wendy Gladstone, and as usual I tweaked it a little bit. She writes: "Recently I had a visit with my mom and we realized that the two digits that make up my age when reversed resulted in her age. For example, if she's 73, I'm 37. We wondered how often this has happened over the years but we got sidetracked with other topics and we never came up with an answer. "When I got home I figured out that the digits of our ages have been reversible six times so far. I also figured out that if we're lucky it would happen again in a few years, and if we're really lucky it would happen one more time after that. In other words, it would have happened 8 times over all. So the question is, how old am I now?" NOTE: to adapt this Puzzler to CodingBat, write flipping_ages(diff) as a function to return a list of Wendy's ages at which she is the reverse of her mom's age, given that their difference in age is diff. (Note: for the purpose of this puzzle, the reverse of "30" is "03".) To avoid giving away the answer to the Puzzler, the entry with the correct answer will be hidden in the "other tests". flipping_ages(19) → [] flipping_ages(26) → [] flipping_ages(27) → [3, 14, 25, 36, 47, 58, 69] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 323 Post-solution available
Copyright Nick Parlante 2017 - privacy