# How do Hopscotch project links work?

I’m just curious, how do the links to projects on Hopscotch work? Is it just a completely random string of numbers and letters(after the part that is the same in all links) or is there some reason to it?

10 Likes

not sure, but maybe ask one of the mods?

6 Likes

All it is is an encoded version of the project’s creation timestamp.

The toString(36) means it encodes it as BASE-36 after multiplying the current date by 65536.

Btw, 65536 is the result of 2^16

5 Likes

… my brain cant wrap around this lol

First: why is it 2 raised by 16?

4 Likes

Most computers can only understand number in powers of 2. I guess 65536 was the best number for this kind of stuff. I don’t know the specific reason why, tho…

4 Likes

Multiplying by 2**16 is the same as adding 16 zeroes to the end of the number in binary, just like how multiplying by 10**16 does in decimal (1 becomes 10000000000000000) so it’s probably just the easiest way to get a number big enough.

4 Likes

Ok then, another question because this sounds really interesting:

Is it possible to use Hopscotch and code with this?

4 Likes

Like to generate your own UUID or to convert it to a timestamp?

Both of these require a BASE-36 Encoder / Decoder, and making one is easier said than done. The encoder is simpler, but the decoder is not as straight forward.

4 Likes

I was thinking like generating UUIDs. But im kinda confused about how Hopscotch changes a timestamp into a string of numbers and letters. Arent the timestamps just numbers?

4 Likes

That’s what Base-36 is for.

Base10 is 0-9, while Base36 is 0-9a-z

All you would need to do it figure out how to make the encoder…

Hint: it’s gonna take a lot of (x % 36) operations

4 Likes

So- would that be a normal encoder thing like 1=a, 2=b, etc?

4 Likes

0-9 is the same in Base36, but numbers from 10-35 returns a-z (a=10, b=11, c=12, etc.)

I can make the encoder for you, if you’d like…

Edit: I was off by one, lol…

4 Likes

So, 21 would equal L?

And i’m going to try to make the encoder myself, but I might fail and run to you for help. /hj

4 Likes

Gahh already confused. How do you separate the single-digit numbers from the two-digit ones? This was the timestamp a little while ago(copied from a website)1681769336. So 1681769336 could make it g81769336 or just stay as 1681769336, because they are both single numbers if you ignore that. Yeah confusment.

4 Likes

It’s a lot (like 1000 times) more complicated than that, lol.

Take your number and mod it by 36

Then convert the result to Base36

Then subtract the input by the modulo result and divide that by 36

Repeat until the input returns 0.

Take 123456789 as an example, which returns 21i3v9

123456789 % 36 = 9

(123456789 - 9) / 36 = 3,429,355 (you can also do floor(input/36) to get the same result)

3429355 % 36 = 31

31 to Base36 = v

(3429355 - 31) / 36 = 95259

All you have to do is do join (character) with (output) with each conversion to get the result you need.

I just finished the encoder, btw…

3 Likes

This returns rta5i0 in my encoder (on its own)

When the given timestamp is multiplied by 65536 before encoding, it returns 132gqbte60

3 Likes

Is this something along the lines of what i have to do?

3 Likes

Not exactly… you got the modulo part right… somewhat…

Here’s how I did it:

And yes, I like to do these frame recursion stuff. That’s why there’s an extra “recursions” parameter.

The recursions = 250 check is just a protection feature, this is to prevent the project from crashing due to a Stack Overflow error.

5 Likes

I got some extra info. The input before the UUID conversion is…

((TIME / 1000) * 65536)

Convert that result to BASE 36, and it’ll return a UUID like HS

3 Likes

Yeah, my brain just about exploded from looking at that. Im a much better coder than a year ago but im not up to this level yet…

Can i play around with that code of yours? I’ll give credit if I make a project out of it.

3 Likes