05AB1E, 11 9 bytes
Thanks to @ovs for -2!
ÝãʒãÀ¦POQ
Oh my, I am getting in the hang of code golfing!
Prints a list of all the valid pairs (e.g [[1, 0], [0, 1]]
). If there are none, the list is empty ([]
). Also outputs both of any reverse integer pairs.
How?
You may count this as a port of the other answers, but I took a look only at the Husk answer before writing the program!
Ý # Push a list of all numbers from 0 to the input.
ã # Push the cartesian power of lists. (Basically, finding all possible pairs)
ʒ # For each pair...
ãÀ¦ # Find all other rotationspermutations of the pair.
P # Multiply each rotationpermutation.
O # Add the products.
Q # If the result is not equal to the input, yeet (throw) them from the list.
# Automatically print the pairs not yeeted.