# Problem of the Week Problem C and Solution Taking a Hike

## Problem

There are five people in the Hidaka family: Shun, Naoki, Kana, Daichi, and Mitsuko. No two people are the same age. The family walks along a hiking trail in a single-file line. As they walk, each person counts the number of people in their family both in front of them and behind them who are older than them. This information is shown in the table.

Family Member Number of older people in front Number of older people behind
Shun 1 2
Naoki 3 1
Kana 0 0
Daichi 2 0
Mitsuko 1 0

Determine the order that the family members are walking in. Then list the family members in order from oldest to youngest.

This problem was inspired by a past Beaver Computing Challenge (BCC) problem.

## Solution

Since Kana is the only person who has nobody older in front of her, it follows that Kana must be the first in line. Since she also has nobody older behind her, she must also be the oldest. This information is summarized in the tables below.

Position in Line Name of Person
First Kana
Second
Third
Fourth
Fifth
Age Ranking Name of Person
Oldest Kana
Second Oldest
Middle
Second Youngest
Youngest

Since Naoki has three older people in front of him and one older person behind him, he must be fourth in line. Also, since four people are older than him, it follows that Naoki is the youngest. This information is summarized in the tables below.

Position in Line Name of Person
First Kana
Second
Third
Fourth Naoki
Fifth
Age Ranking Name of Person
Oldest Kana
Second Oldest
Middle
Second Youngest
Youngest Naoki

Since Shun has two older people behind him, he must be second in line, because Naoki is younger than him. In fact, Naoki is the only person who is younger than him, so it follows that Shun is second youngest. This information is summarized in the tables below.

Position in Line Name of Person
First Kana
Second Shun
Third
Fourth Naoki
Fifth
Age Ranking Name of Person
Oldest Kana
Second Oldest
Middle
Second Youngest Shun
Youngest Naoki

We are left with Daichi and Mitsuko. Since Daichi has two older people in front of him, but Mitsuko has only one older person in front of her, it follows that Mitsuko must be older than Daichi and must also be in front of Daichi. Thus, Mitsuko is third in line and is second oldest, and Daichi is fifth in line and is in the middle of the age ranking. This information allows us to complete the tables as shown below.

Position in Line Name of Person
First Kana
Second Shun
Third Mitsuko
Fourth Naoki
Fifth Daichi
Age Ranking Name of Person
Oldest Kana
Second Oldest Mitsuko
Middle Daichi
Second Youngest Shun
Youngest Naoki

Note that the age rankings could also have been determined by adding the two rightmost columns in the original table. This would give us the number of people older than each person. From that we could write the family members in order from oldest to youngest.