Skip to main content
2 of 2
added 4 characters in body
Chiru
  • 584
  • 3
  • 11

Avoiding commas when storing lots of data

If you have a lot of data (i. e. indices, characters, …) that you need to store in an array, you might be better off leaving all commas away. This works best if every piece of data has the same string length, 1 obviously being optimal.

43 Bytes (baseline)

a=[[3,7,6,1,8,9,4,5,2],[5,4,3,2,7,6,5,4,3]]

34 Bytes (no commas)

a=[[..."376189452"],[..."543276543"]]

If you're willing to change your array access, you might reduce this even further, storing the same values like so:

27 Bytes (same data, only changes array access)

a=[..."376189452543276543"]
Chiru
  • 584
  • 3
  • 11