[Math] Number of ways to insert 4 wires into 8-pin 8P8C Ethernet connector

This is an Ethernet crossover cable to connect two Ethernet ports:

Let's say you forgot correct pinout. Can you try manually all possible ways to connect it?

OK, you may remember that pins 1, 2, 3 and 6 are used. How many permutations of wires are possible?

#!/usr/bin/env python3

import itertools

wires=["left_1", "left_2", "left_3", "left_6"]

print ("right_1, right_2, right_3, right_6")
for x in itertools.permutations(wires):
    print (x)

This is 4!=24:

right_1, right_2, right_3, right_6
('left_1', 'left_2', 'left_3', 'left_6')
('left_1', 'left_2', 'left_6', 'left_3')
('left_1', 'left_3', 'left_2', 'left_6')
('left_1', 'left_3', 'left_6', 'left_2')
...
('left_6', 'left_2', 'left_1', 'left_3')
('left_6', 'left_2', 'left_3', 'left_1')
('left_6', 'left_3', 'left_1', 'left_2')
('left_6', 'left_3', 'left_2', 'left_1')

Now if you forgot these pins, you may ask, how many ways there are to insert 4 wires in 8P8C connector?

#!/usr/bin/env python3

import itertools

wires=[1, 2, 3, 4, 5, 6, 7, 8]

for x in itertools.combinations(wires, 4):
    print (x)

This is 8 choose 4 or C(8,4)=70.

(1, 2, 3, 4)
(1, 2, 3, 5)
(1, 2, 3, 6)
(1, 2, 3, 7)
...
(4, 5, 6, 8)
(4, 5, 7, 8)
(4, 6, 7, 8)
(5, 6, 7, 8)

Now how many ways there are to connect two 8P8C connectors using 4 wires?

#!/usr/bin/env python3

import itertools

wires=[1, 2, 3, 4, 5, 6, 7, 8]

for x in itertools.combinations(wires, 4):
    for y in itertools.permutations(x):
        for z in itertools.combinations(wires, 4):
            print (y, "<->", z)

It's 117600:

(1, 2, 3, 4) <-> (1, 2, 3, 4)
(1, 2, 3, 4) <-> (1, 2, 3, 5)
(1, 2, 3, 4) <-> (1, 2, 3, 6)
(1, 2, 3, 4) <-> (1, 2, 3, 7)
(1, 2, 3, 4) <-> (1, 2, 3, 8)
...
(8, 7, 6, 5) <-> (4, 5, 6, 7)
(8, 7, 6, 5) <-> (4, 5, 6, 8)
(8, 7, 6, 5) <-> (4, 5, 7, 8)
(8, 7, 6, 5) <-> (4, 6, 7, 8)
(8, 7, 6, 5) <-> (5, 6, 7, 8)

This coincides with Number of non-attacking placements of 4 rooks on an n X n board (for 8*8 board). (Coincidentally? Not sure.)

(the post first published at 20251209.)


List of my other blog posts. Subscribe to my news feed,
If you enjoy my work, you can support it on patreon.
Some time ago (before 24-Mar-2025) there was Disqus JS script for comments. I dropped it --- it was so motley, distracting, animated, with too much ads. I never liked it. Also, comments din't appeared correctly (Disqus was buggy). Also, my blog is too chamberlike --- not many people write comments here. So I decided to switch to the model I once had at least in 2020 --- send me your comments by email (don't forget to include URL to this blog post) and I will copy&paste it here manually.
Let's party like it's ~1993-1996, in this ultimate, radical and uncompromisingly primitive pre-web1.0-style blog and website. This website is best viewed under lynx/links/elinks/w3m.