# Determining Call Chain

There were 25 kids in a class and each kid had some best friends. To simplify the problem, let's call each kid by their initial name. Here is a list of each kid's best friends:

a: [l, h]
b: [k, m, i]
c: [f, l, n, j]
d: [g, m, o]
e: [h, n]
f: [c, m, q]
g: [d, n, r, p]
h: [a, k, q, s, o, e]
i: [b, l, r, t]
j: [c, m, s]
k: [u, r, h, b]
l: [u, w, s, i, c, a]
m: [f, b, d, j, t, x, p, v]
n: [y, w, q, g, c, e]
o: [x, r, h, d]
p: [w, m, g]
q: [x, n, h, f]
r: [u, k, g, i, o, y]
s: [v, l, h, j]
t: [w, m, i]
u: [l, r]
v: [k, m, s]
w: [p, l, n, t]
x: [q, m, o]
y: [r, n]


One day all the kids were outside the class room except a. Then his teacher asked a to call one of his best friends into room. a called l. Then the teacher asked l to call one of his best friends outside to enter the room, and so on.

After all the call chain, there were no more kids outside, and s was the last kid called.

Determine the call chain!

• v has k as a best friend, but k does not have v. Is this intentional? – Mike Earnest Aug 16 '16 at 16:28
• @MikeEarnest Unrequited love, what a sad affair. – dcfyj Aug 16 '16 at 16:31
• @mike you are very conscientious, yes it is intentional, to make the answer unique. as dcfyj said Unrequited love haha – Jamal Senjaya Aug 16 '16 at 16:48
• – Aza Aug 16 '16 at 17:33
• @Emrakul - my idea of fun is soooo different... :P – Beastly Gerbil Aug 16 '16 at 18:33

I think I found it:

a, l, u, r, y, n, e, h, k, b, i, t, w, p, g, d, o, x, q, f, c, j, m, v, s

Explanation:

Since this puzzle is tagged with , I wrote a program that just brute-forces every possibility with recursion. If the last kid has the name "s", it prints out the sequence above. Here's a pseudo code of the recursion method I used:

void foo(Kid kid, List<Kid> history) {
if (history.size() == 25) {
if (kid.getName().equals("s")) {
for (Kid child : history) {
print(child.getName() + " ");
}
}
} else {
for (Kid friend : kid.getFriends()) {
if (!history.contains(friend)) {
foo(friend, history);
}
}
}
}

• Sadly you beat me to it, but then again, that's what I get for doing a computerpuzzle by hand. – dcfyj Aug 16 '16 at 16:59
• @dcfyj But you'll probably get more upvotes since doing it by hand is presumably much harder. :D – user14478 Aug 16 '16 at 17:01
• @LukasRotter wasn't necessarily hard, just slow. – dcfyj Aug 16 '16 at 17:03
• Is there only one solution? – Beastly Gerbil Aug 16 '16 at 18:32
• @BeastlyGerbil With the requirement that the last kid must be "s", yes. If that requirement doesn't exist, there are of course "a few" more :P. – user14478 Aug 16 '16 at 18:36

The calling order is:

For an easier read here's the order written out:

a, l, u, r, y, n, e, h, k, b, i, t, w, p, g, d, o, x, q, f, c, j, m, v, s

I got this order by slowly but surely ruling out the possibilities. For the most part this was a straight up logic puzzle (the grid kind, think Einstein's puzzle) but towards the end I had to make a guess in order to complete the sequence.

• Could you maybe use more neutral colors? (and preferably also a color combination that is accessible for colorblind folk) – Will Aug 16 '16 at 17:01
• @will right, sorry I tend to not think of that issue when doing these. I'll fix it. – dcfyj Aug 16 '16 at 17:02
• @will Does this work better? – dcfyj Aug 16 '16 at 17:07
• Just out of interest I work with someone who is colorblind and tend to use colororacle to check images before I send them on. You can basically put a filter over your screen (still image only) to check how it would look to someone who has different forms of colourblindness. (Note I've never actually asked anyone that's colourblind how well it works, the screen shouldn't change when filter is applied for them, but I've never had complaints since I started using it). – gtwebb Aug 16 '16 at 17:19
• @gtwebb nifty, I'll start using that too. – dcfyj Aug 16 '16 at 17:20