Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 1060 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

Sometimes you want to compress an entire list of integers instead of a single number. For example, let's say we want the list [5,9394,17,83,4,44,32,19,4,45,83,90,0,14,3,17,17,81] for whatever reason. In this case, we can use the following instead: •4βŸ{©£MG]q‡dZΘp•94в•5O›YJ&p‘ÑÎ!6 ̄8,•3в Try it online. Try it online.

One thing to note is that it's usually shorter to use a slightly larger single-byte integer constant (i.e. T263т514 for 10,26,36,95,100,255,256,1000 respectively) instead of the maximum+1 found by the program above. Let's say our example [5,94,17,83,4,44,32,19,4,45,83,90,0,14,3,17,17,81] was [5,95,17,83,4,44,32,19,4,45,83,90,0,14,3,17,17,81] instead, it would find •6MÖ∊]ć;?,ćiåÑ6Š•96в (20 bytes) as shortest, but •CRā»ïζyˆö͆y"a±•тв (19 bytes) with the single-byte constant 100 would be 1 byte shorter.
You can still get the compressing program above by replacing the Z> with the single-byte constant (or its value): Try it online .

  • •a1⁄24Ƶ6®í• is 9 bytes (generated by compressed large integer generator)
  • •1∊}•2вJ is 8 bytes (generated by compressed integer list generator with added join)
  • •1∊}•b with 6 bytes would be even shorter (compressed integer list, with a to binary instead of , which implicitly joins)
  • AndBut Ž«ǝbĆ with 5 bytes would be the shortest option here (compressed integer, to binary, and enclose - appending its own head)

Sometimes you want to compress an entire list of integers instead of a single number. For example, let's say we want the list [5,93,17,83,4,44,32,19,4,45,83,90,0,14,3,17,17,81] for whatever reason. In this case, we can use the following instead: •4βŸ{©£MG]q‡dZΘp•94в Try it online.

  • •a1⁄24Ƶ6®í• is 9 bytes (generated by compressed large integer generator)
  • •1∊}•2вJ is 8 bytes (generated by compressed integer list generator with added join)
  • •1∊}•b with 6 bytes would be even shorter (compressed integer list, with a to binary instead of , which implicitly joins)
  • And Ž«ǝbĆ with 5 bytes would be the shortest option (compressed integer, to binary, and enclose - appending its own head)

Sometimes you want to compress an entire list of integers instead of a single number. For example, let's say we want the list [5,94,17,83,4,44,32,19,4,45,83,90,0,14,3,17,17,81] for whatever reason. In this case, we can use the following instead: •5O›YJ&p‘ÑÎ!6 ̄8,•3в Try it online.

One thing to note is that it's usually shorter to use a slightly larger single-byte integer constant (i.e. T263т514 for 10,26,36,95,100,255,256,1000 respectively) instead of the maximum+1 found by the program above. Let's say our example [5,94,17,83,4,44,32,19,4,45,83,90,0,14,3,17,17,81] was [5,95,17,83,4,44,32,19,4,45,83,90,0,14,3,17,17,81] instead, it would find •6MÖ∊]ć;?,ćiåÑ6Š•96в (20 bytes) as shortest, but •CRā»ïζyˆö͆y"a±•тв (19 bytes) with the single-byte constant 100 would be 1 byte shorter.
You can still get the compressing program above by replacing the Z> with the single-byte constant (or its value): Try it online .

  • •a1⁄24Ƶ6®í• is 9 bytes (generated by compressed large integer generator)
  • •1∊}•2вJ is 8 bytes (generated by compressed integer list generator with added join)
  • •1∊}•b with 6 bytes would be even shorter (compressed integer list, with a to binary instead of , which implicitly joins)
  • But Ž«ǝbĆ with 5 bytes would be the shortest option here (compressed integer, to binary, and enclose - appending its own head)
added 161 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

10101001100101001 (usedinitially used in this answer of mine):

  • •a1⁄24Ƶ6®í• is 9 bytes (generated by compressed large integer generator)
  • •1∊}•2вJ is 8 bytes (generated by compressed integer list generator with added join)
  • But in this case •1∊}•b with 6 bytes would be the best optioneven shorter (compressed integer list, with a to binary instead of , which implicitly joins)
  • And Ž«ǝbĆ with 5 bytes would be the shortest option (compressed integer, to binary, and enclose - appending its own head)

10101001100101001 (used in this answer of mine):

  • •a1⁄24Ƶ6®í• is 9 bytes (generated by compressed large integer generator)
  • •1∊}•2вJ is 8 bytes (generated by compressed integer list generator with added join)
  • But in this case •1∊}•b with 6 bytes would be the best option (compressed integer list, with a to binary instead of , which implicitly joins)

10101001100101001 (initially used in this answer of mine):

  • •a1⁄24Ƶ6®í• is 9 bytes (generated by compressed large integer generator)
  • •1∊}•2вJ is 8 bytes (generated by compressed integer list generator with added join)
  • •1∊}•b with 6 bytes would be even shorter (compressed integer list, with a to binary instead of , which implicitly joins)
  • And Ž«ǝbĆ with 5 bytes would be the shortest option (compressed integer, to binary, and enclose - appending its own head)
added 1349 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

[85,30,29,39,28,37,33,88,31,40,34,89,35,41,32,90,36,38,42,43,44,60,45,61,46,62,47,63,48,64,49,65,81,50,66,51,67,52,68,53,69,86,54,70,87,55,71,56,72,82,57,73,79,80,58,74,59,75,76,77,78,83,84] (used in this answer of mine ):

[85,30,29,39,28,37,33,88,31,40,34,89,35,41,32,90,36,38,42,43,44,60,45,61,46,62,47,63,48,64,49,65,81,50,66,51,67,52,68,53,69,86,54,70,87,55,71,56,72,82,57,73,79,80,58,74,59,75,76,77,78,83,84] (used in this answer of mine ):

Minor formatting to make it clearer where the links of the generators are
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
minor update (added some links and parts to some sentences)
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Added `Ƶ` as 2-byte integer compression method for integers in the range [101,355]
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Found out that the string compression can not only compress the letters of the lowercase alphabet, but also spaces
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Added section about Integer compression vs Integer list compression
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Fixed dictionary generator for single-word inputs
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Added dictionary generator
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
added 134 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Added compression of integers with 2 characters using `Ž`
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Updated links to new Elixir docs and minor improvements
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
added 90 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
deleted 2 characters in body
Source Link
Emigna
  • 53.2k
  • 5
  • 44
  • 164
Loading
Enhanced generation programs and added `„` and `...` to the compressed dictionary strings part
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Added section about compressing integer lists
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Added short part about `ÿ` (string interpolation) in combination with the dictionary compression
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Added short part about `ÿ` (string interpolation) in combination with the dictionary compression
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Added section of compressing strings not part of the dictionary, as well as ' for single-word dictionary compressions
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading

AltStyle によって変換されたページ (->オリジナル) /