Here's my puzzle:
Write two unary functions
f
,g
and provide an inputx
so that only the combinationf(g(x))
will yield the resulty
but no other combination of them does - even if applied multiple times in any order.
The functions should use standard arithmetic operations, the numbers should be small integers, too keep it simple (so that the solution y = f(g(x))
is obvious to everyone). If that is not possible, feel free to use more advanced operations or rational numbers.
I am still trying to solve it myself. I just made it up[1], I don't think it's a well-known problem.
I have tried some simple additions and multiplications, but it proved unexpectedly hard. Maybe I just don't know the right mathematical tool or can't see the pattern. I thought about prime numbers, but they don't really seem to help here. Some (counter)examples:
1
,*3
,*5
- but also1 *5 *3 = 15
0
,+3
,*5
- but also0 *5 +3 *5 = 15
1
,+3
,*5
- but also1 *5 +3 +3 +3 +3 +3 = 20
1
,*5
,+2
- but also1 +2 +2 +2 = 7
1
,+3
,/2
- but also1 +3 +3 +3 /2 +3 /2 /2 = 2
2
,+3
,^2
- but also2 ^2 ^2 +3 +3 +3 = 25
1: If you're curious, I am trying to write a test for a computer program that implements function composition.
x
, it doesn't need to work on any input. $\endgroup$