+ 1

Unique number of two not equal numbers

I want to get a unique number out of two not equal numbers

4th Aug 2019, 12:05 PM
Nico Ruder
Nico Ruder - avatar
2 odpowiedzi
0
Here is a method that would work for any integer less than 1 billion: 1. check that they are not equal 2. convert to strings 3. get the length of the first number 4. NewString=First+Second+len(first) 5. int(NewString) ex: input: 123, 45 output: 123453 The only downside is that the first number must be less than a billion, but the method should work for you. edit: you can add another term on the end to tell you the length of the length of the first one, which will get you to 10^(10^10) before it fails.
6th Aug 2019, 5:52 PM
Brenden Kelly
Brenden Kelly - avatar
0
Thank you for your answer but i have already a better code with https://en.m.wikipedia.org/wiki/Pairing_function Here: https://code.sololearn.com/w2x1afS83N2n/?ref=app
7th Aug 2019, 8:07 AM
Nico Ruder
Nico Ruder - avatar