Problem
Compress the decimal representation of a natural number to an expression in J with less characters than the number of digits.
E.g. 120 can be compressed to !5 .
Constraints
The expression(s) in J should produce the number for anyone in a new session in a freshly installed J-version with the maximal printing precision: (9!:11) 20 .
The total number of characters needed (in a new session in a freshly installed J-version) should be less than the number of digits in the decimal representation of the number.
Credits
This puzzle was inspired by a solution given by Raul Miller in Jforum where he gave an excellent example of compression. See example.
Rules
- The rate of compression is the ratio between the number of (decimal) digits and the number of characters in the expression.
- Since the compression ratio is unbounded, the smaller the number the better.
- Higher (rate of) compression per number is better.
Remarks
%~&(#@":)". can be used to determine the compression (rate) of an expression.
{{{ (%~&(#@":)".)'!5'
1.5 }}}
Numbers which are not compressable are "Kolmogorov random", see Kolmogorov
Proliferation of modern programming languages:
"APL: You shoot yourself in the foot, then spend all day figuring out how to do it in fewer characters."
Solutions
Number |
Sentence |
Compression |
Notes |
Author |
120 |
!5 |
1.5 |
Trivial, since !y needs less characters for all y>4 . |
|
1024 |
4^5 |
1.33 |
Trivial, since most of x^y are compressed. |
|
9534410355667921512188400 |
*./33+i.29x |
2.27 |
Smallest number which is divisible by all numbers 1,...,61, |
|
73786976294838206000 |
#.66#1 |
3.333 |
Neat that it's a ratio of exactly 10r3 |
-- DanBron 2007-12-24 21:35:28 |
See Also
* The angels dancing Forum thread from 2005. It has many good examples of short J expressions which produce astronomically large numbers (some actually can't be executed, but it is easily seen that if they could, the result would be unimaginable).
Note that the link provided only points to the head of the thread; most the examples are contained in later messages (just follow the "next in thread" links).
