Puzzles/Compress
< Puzzles
Jump to navigation
Jump to search
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
0. The rate of compression is the ratio between the number of (decimal) digits and the number of characters in the expression. 1. Since the compression ratio is unbounded, the smaller the number the better. 2. 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 .
Smallest number (I know of) which can be compressed
RE Boss 1024 4^5 1.33 Trivial, since most of x^y are compressed.
x = 2 3 4 5 6 7 8 9 10
y>: 14 7 5 5 4 4 4 4 4RE Boss 9534410355667921512188400 *./33+i.29x 2.27 Smallest number which is divisible by all numbers 1,...,61,
except two successive ones. See Jforum
Raul Miller 73786976294838206000 #.66#1 3.333 Neat that it's a ratio of exactly 10r3 -- Dan Bron <<DateTime(2007-12-24T21:35:28Z)>>
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).