I've given a pairing function
c = (x+y)(x+y) + x
and asked to make fst
and snd
functions which return x
and y
, if c
is given.
Values x,y,c
are non-negative integers: 0,1,2,3...
The problem is, that I'm currently working with plus
and multiply
operations only, so sqrt
is not allowed.
Is there a way to encode invert pairing function without sqrt
?
This is an educational task, so if there is a way, don't tell me the actual way for a while, please.