Convert Pi Into Letters?

In Pi Day, I'm trying to write a Java program that tries to find a given word in Pi (or another given irrational number). I have finished almost all of this, but I do not agree on how I should convert each digit / pi to a letter. I thought: A = 01, B = 02, C = 03 ... Y = 25, Z = 26.

However, then I felt bad for all poor numerical sequences that did not even have a chance, since any sequence that does not start with "0" or "2" will be completely ignored. Does this mean that 80% of the sequences do not matter?

Can I convert base-26 to base-10? Not sure how to do this by code if this is really the right decision?

Thanks!

+4
source share
2 answers

You can convert Pi from base-10 form to any other base (i.e. base 26, where you use the letters AZ, not the numbers 0-9), using a method like this . The final "numbers" will be all the letters.

You will need to change the fromDecimalToOtherBase method fromDecimalToOtherBase that it only fromDecimalToOtherBase letters. Otherwise, it should be fairly straightforward, and this is the same algorithm for converting between decimal and any arbitrary base.

Just for kicks, I also found this page , which contains an arbitrary base converter. If you enter Pi without a decimal place and enter “26” for the destination base, it will perform the conversion (although it still uses the numbers 0-9, so it does not “solve” the problem as you want).

+5
source

You can make an alphabet wrapper and use all the codes.

 00 = A 01 = B ... 24 = Y 25 = Z 26 = A 27 = B ... 

Or, why bother with base 10 at all? Just enter a number in base 26 to start, and each number represents a letter.

 pi = D,DRSQLOLYRTRCLRGGUKBJKPSRFVKRODHLJRFSZSOXNHXZ... 
+3
source

Source: https://habr.com/ru/post/1401393/


All Articles