Skip to main content
Commonmark migration
Source Link

#Compressing String Arrays

Compressing String Arrays

Introduction

##Introduction IfIf you have an array of strings in your code, the most obvious way to compress it would be to run each string through Oc individually. For the purposes of this tip, we'll be working with the array ["lollipop","marshmallow","nougat","oreo"], which weighs in at 42 bytes initially. Running each string through Oc gives us:

Step 1

##Step 1 But, we can do better. If we join the array to a newline separated string, we can get rid of the brackets, commas, and extraneous backticks and split on newline to get our array. Applying that to our example array gives us the following:

##Step 2

Step 2

##Step 3

Step 3

Bonus Tip: Integer Array Compression

##Bonus Tip: Integer Array Compression YouYou can apply the same principle to arrays of integers by first converting each to a higher base. Using this sample, 36 byte array:

##Notes

Notes

##Credits

Credits

#Compressing String Arrays

##Introduction If you have an array of strings in your code, the most obvious way to compress it would be to run each string through Oc individually. For the purposes of this tip, we'll be working with the array ["lollipop","marshmallow","nougat","oreo"], which weighs in at 42 bytes initially. Running each string through Oc gives us:

##Step 1 But, we can do better. If we join the array to a newline separated string, we can get rid of the brackets, commas, and extraneous backticks and split on newline to get our array. Applying that to our example array gives us the following:

##Step 2

##Step 3

##Bonus Tip: Integer Array Compression You can apply the same principle to arrays of integers by first converting each to a higher base. Using this sample, 36 byte array:

##Notes

##Credits

Compressing String Arrays

Introduction

If you have an array of strings in your code, the most obvious way to compress it would be to run each string through Oc individually. For the purposes of this tip, we'll be working with the array ["lollipop","marshmallow","nougat","oreo"], which weighs in at 42 bytes initially. Running each string through Oc gives us:

Step 1

But, we can do better. If we join the array to a newline separated string, we can get rid of the brackets, commas, and extraneous backticks and split on newline to get our array. Applying that to our example array gives us the following:

Step 2

Step 3

Bonus Tip: Integer Array Compression

You can apply the same principle to arrays of integers by first converting each to a higher base. Using this sample, 36 byte array:

Notes

Credits

added 376 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

UPDATE: The tools featured in this tip have since be rewritten, improved and integrated into my Japt interpreter. For the best results it is recommended that you use that compressor over any of those linked below. I'll revisit this tip when I have some more time and rewrite it with the new compressor in mind.

UPDATE: The tools featured in this tip have since be rewritten, improved and integrated into my Japt interpreter. For the best results it is recommended that you use that compressor over any of those linked below. I'll revisit this tip when I have some more time and rewrite it with the new compressor in mind.

added 158 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

##Introduction If you have an array of strings in your code, the most obvious way to compress it would be to run each string through run each string through Oc individually. For the purposes of this tip, we'll be working with the array ["lollipop","marshmallow","nougat","oreo"], which weighs in at 42 bytes initially. Running each string through Oc gives us:

  1. Don't forget to factor in the 1 or 2 extra bytes q<letter>(<space>) costs over ·. Although, you may be able to use one of the Unicode shortcuts to get a byte back, depending on your delimiter ( is the same as ql<space>, for example).
  2. A word of caution when using the last tool: the more strings you have, the more permutations there will be and the slower the programme will run, until it eventually craps out. As detailed above, with our 4 sample strings and 11 possible letters to try, there are 264 possible combinations, increase the number of strings by just 1 with the same 11 letters and we already have 1320 combinations to try. (You can use this tool to count the number of combinations, if you want).

##Introduction If you have an array of strings in your code, the most obvious way to compress it would be to run each string through Oc individually. For the purposes of this tip, we'll be working with the array ["lollipop","marshmallow","nougat","oreo"], which weighs in at 42 bytes initially. Running each string through Oc gives us:

  1. Don't forget to factor in the 1 or 2 extra bytes q<letter>(<space>) costs over ·.
  2. A word of caution when using the last tool: the more strings you have, the more permutations there will be and the slower the programme will run, until it eventually craps out. As detailed above, with our 4 sample strings and 11 possible letters to try, there are 264 possible combinations, increase the number of strings by just 1 with the same 11 letters and we already have 1320 combinations to try. (You can use this tool to count the number of combinations, if you want).

##Introduction If you have an array of strings in your code, the most obvious way to compress it would be to run each string through Oc individually. For the purposes of this tip, we'll be working with the array ["lollipop","marshmallow","nougat","oreo"], which weighs in at 42 bytes initially. Running each string through Oc gives us:

  1. Don't forget to factor in the 1 or 2 extra bytes q<letter>(<space>) costs over ·. Although, you may be able to use one of the Unicode shortcuts to get a byte back, depending on your delimiter ( is the same as ql<space>, for example).
  2. A word of caution when using the last tool: the more strings you have, the more permutations there will be and the slower the programme will run, until it eventually craps out. As detailed above, with our 4 sample strings and 11 possible letters to try, there are 264 possible combinations, increase the number of strings by just 1 with the same 11 letters and we already have 1320 combinations to try. (You can use this tool to count the number of combinations, if you want).
added 133 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
added 1562 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
edited body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
deleted 11 characters in body
Source Link
LyricLy
  • 3.7k
  • 2
  • 19
  • 40
Loading
Post Undeleted by Shaggy
deleted 102 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
fix typos
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
Loading
added 165 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
bug fix
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240
Loading
added 3914 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
Post Deleted by Shaggy
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading