Skip to main content
note
Source Link
sporeball
  • 1.7k
  • 1
  • 11
  • 22

naz -u, 3 distinct characters

I've been waiting for a chance to do this.

It turns out that JavaScript's String.fromCharCode(), which the naz interpreter uses internally for output, will truncate any values passed to it to their four least significant digits in hexadecimal — so passing a value of \$41_{16}\$ (\$65_{10}\$) will return A, but so will passing \$10041_{16}\$ (\$65601_{10}\$). The upper \$1\$ is ignored.

This essentially means given a function \$f(x)\$ which returns String.fromCharCode(x),

$$ \forall x \in \mathbb{Z}_{0}^{+}: f(x) = f(x \bmod 65536) $$

making it possible to write a naz program to output any string using only the characters 1, a, and o, as long as the -u command line flag (which removes naz's default integer limits) is used.

The code to output The quick brown fox jumps over the lazy dog via this method, which I've now stored in naz's GitHub repository (right-click > "Save linked content as" will work best), is over 5,500,000 bytes in size and finished running in just over 60 minutes on my machine. You probably shouldn't run this if you need to do other things with your terminal.

Note: As of March 12, 2021 I've added a comment to the top of the file linked above, but this is simply a warning to anyone who happens to find it without reading this answer. The program works identically without it, so the header will contain the original score — 3 distinct characters.

The best score that can be achieved without the -u flag is 4 distinct characters (1, a, s, and o.)

naz -u, 3 distinct characters

I've been waiting for a chance to do this.

It turns out that JavaScript's String.fromCharCode(), which the naz interpreter uses internally for output, will truncate any values passed to it to their four least significant digits in hexadecimal — so passing a value of \$41_{16}\$ (\$65_{10}\$) will return A, but so will passing \$10041_{16}\$ (\$65601_{10}\$). The upper \$1\$ is ignored.

This essentially means given a function \$f(x)\$ which returns String.fromCharCode(x),

$$ \forall x \in \mathbb{Z}_{0}^{+}: f(x) = f(x \bmod 65536) $$

making it possible to write a naz program to output any string using only the characters 1, a, and o, as long as the -u command line flag (which removes naz's default integer limits) is used.

The code to output The quick brown fox jumps over the lazy dog via this method, which I've now stored in naz's GitHub repository (right-click > "Save linked content as" will work best), is over 5,500,000 bytes in size and finished running in just over 60 minutes on my machine. You probably shouldn't run this if you need to do other things with your terminal.

The best score that can be achieved without the -u flag is 4 distinct characters (1, a, s, and o.)

naz -u, 3 distinct characters

I've been waiting for a chance to do this.

It turns out that JavaScript's String.fromCharCode(), which the naz interpreter uses internally for output, will truncate any values passed to it to their four least significant digits in hexadecimal — so passing a value of \$41_{16}\$ (\$65_{10}\$) will return A, but so will passing \$10041_{16}\$ (\$65601_{10}\$). The upper \$1\$ is ignored.

This essentially means given a function \$f(x)\$ which returns String.fromCharCode(x),

$$ \forall x \in \mathbb{Z}_{0}^{+}: f(x) = f(x \bmod 65536) $$

making it possible to write a naz program to output any string using only the characters 1, a, and o, as long as the -u command line flag (which removes naz's default integer limits) is used.

The code to output The quick brown fox jumps over the lazy dog via this method, which I've now stored in naz's GitHub repository (right-click > "Save linked content as" will work best), is over 5,500,000 bytes in size and finished running in just over 60 minutes on my machine. You probably shouldn't run this if you need to do other things with your terminal.

Note: As of March 12, 2021 I've added a comment to the top of the file linked above, but this is simply a warning to anyone who happens to find it without reading this answer. The program works identically without it, so the header will contain the original score — 3 distinct characters.

The best score that can be achieved without the -u flag is 4 distinct characters (1, a, s, and o.)

Source Link
sporeball
  • 1.7k
  • 1
  • 11
  • 22

naz -u, 3 distinct characters

I've been waiting for a chance to do this.

It turns out that JavaScript's String.fromCharCode(), which the naz interpreter uses internally for output, will truncate any values passed to it to their four least significant digits in hexadecimal — so passing a value of \$41_{16}\$ (\$65_{10}\$) will return A, but so will passing \$10041_{16}\$ (\$65601_{10}\$). The upper \$1\$ is ignored.

This essentially means given a function \$f(x)\$ which returns String.fromCharCode(x),

$$ \forall x \in \mathbb{Z}_{0}^{+}: f(x) = f(x \bmod 65536) $$

making it possible to write a naz program to output any string using only the characters 1, a, and o, as long as the -u command line flag (which removes naz's default integer limits) is used.

The code to output The quick brown fox jumps over the lazy dog via this method, which I've now stored in naz's GitHub repository (right-click > "Save linked content as" will work best), is over 5,500,000 bytes in size and finished running in just over 60 minutes on my machine. You probably shouldn't run this if you need to do other things with your terminal.

The best score that can be achieved without the -u flag is 4 distinct characters (1, a, s, and o.)