0
$\begingroup$

I am currently experimenting on compression algorithms, I am using proven algorithms and I am just trying to see if I can make some things more efficient, so I am very sorry if this is a stupid question. I am trying to decode an array from a string for example I have [123, 4, 12, 7, 51] so if I turn this into a string it would be "123412751" are there ways to decode this without bloating the array? like you can keep the length of this by doing something like 31231421217251 so you'd know how to decode this but the problem is you'd bloat the data needed so instead I would like to know if this is solvable with constraint satisfaction and how would I go about that?

What I did with constraint satisfaction is I'd get the sum of [123, 4, 12, 7, 51] which is 197 and the length needed which is 5 so now I'd look for combinations from "123412751" with a length of 5 and a sum of 197 however with larger arrays it gives me different values not really the exact one I needed, is this something that is possible?

$\endgroup$
4
  • $\begingroup$ What do you mean by "with constraints"? Please edit your question to clarify what you are asking. $\endgroup$
    – D.W.
    Sep 21, 2022 at 5:56
  • $\begingroup$ Sorry I meant "constraint satisfaction" $\endgroup$
    – gushkash
    Sep 21, 2022 at 6:24
  • $\begingroup$ experimenting on compression algorithms algorithms solve problems. Compression algorithms turn original data into something smaller (cheaper to keep/transfer) that can be decompressed into something useful - the original if lossless. A useful algorithm allows implementation with non-prohibitive resource requirements - combinations reminds of combinatorial explosion: Not everything possible is feasible. $\endgroup$
    – greybeard
    Sep 21, 2022 at 6:44
  • $\begingroup$ So what happens if you have a 10 digit number? $\endgroup$
    – gnasher729
    Sep 21, 2022 at 7:18

1 Answer 1

1
$\begingroup$

I’d look first at Huffman coding and arithmetic coding, which will handle th commas and spaces quite efficiently. Or Lempel-Ziv which munches these separators away at practically no cost.

Or encode the integers as UTF-8, extended to 5 or 6 byte codes in case you have some huge integers.

$\endgroup$
1
  • $\begingroup$ I've tried this before it works quite well, however the problem is I use this arrays for characters as well so when you have a character that is above >9 length it will bloat the data with significant margin so I would much prefer the ones without seperators and of course with rules of entrophy it is impossible to get the same compression ratio as without the seperators $\endgroup$
    – gushkash
    Sep 21, 2022 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.