nieltg / munemo-rs

Turn an integer into a more rememberable word, or vice-versa.
MIT License
3 stars 0 forks source link

Encoding rules #1

Open ghost opened 4 years ago

ghost commented 4 years ago

Is there any description on the encoding rules? To put more clearly, why do -1 corresponds to xabi, hayu to 2592, and so on?

Also, I see that you made this library to study Rust. Good luck on your journey learning Rust!

nieltg commented 4 years ago

Oh, I missed this one. The encoding rule is simple. As you can see, we have constants here:

Every negative number will be encoded into a word that starts with xa, then the rest will be treated as a positive number. The positive number itself will be encoded using division and modulo operation. I'll use 2592 as an example:

If the number is negative, it'll be xahayu. Simple, huh?

Anyway, thanks for that! It's one in my learning-list that I hadn't ever learned until now, I forced myself by writing this crate. 😅

ghost commented 4 years ago

I see, interesting. Did you make the rule yourself, or are you inspired by something?

Cool, working on a project is definitely one of the better ways to learn a language!

nieltg commented 4 years ago

No, it's based on munemo Ruby gem which is stated here and as you can see, munemo Ruby gem itself is also based on mnemo library, which is written on C.