Hi architkap,The posted solution by imeanup is correct, let me walk you through it cleanly. The whole thing comes down to
three constraints working together: the prefix, "odd," and "exactly one 9."
Set up the structureThe number is
7 digits: _ _ _ | _ _ _ _. The first three are
635 or
674 - that's
2 options for the front.
Now notice something important:
neither 635 nor 674 contains a 9. So the "exactly one 9" must live somewhere in the
last four positions (
4-
7). This is the key observation that makes the counting work.
Also, the number must be
odd, so the last digit (position
7) must be from
{1, 3, 5, 7, 9}.
The trick is that position
7 has
two jobs at once - it controls oddness
and it might be the slot holding the
9. That overlap is why we split into two cases.
Case 1: the single 9 is the last digitPosition
7 =
9, which is odd, so the "odd" rule is satisfied automatically.
Positions
4,
5,
6 must each be
non-9 -
9 choices each (
0-
8).
Count:
9 × 9 × 9 = 729 per prefix.
Case 2: the single 9 is in position 4, 5, or 6The
9 sits in one of those three spots -
3 placements.
Position
7 must be odd but
not 9 (only one
9 allowed) -
{1, 3, 5, 7} =
4 choices.
The two remaining middle spots are non-
9 -
9 choices each.
Count:
3 × 9 × 9 × 4 = 972 per prefix.
CombinePer prefix:
729 + 972 = 1701.
Two prefixes:
1701 × 2 = 3402.
The one thing to carry away: because the prefix has no
9, the
9 is forced into the back four, and you must case-split on whether it lands on the odd last digit.
Answer: Carchitkap