Given a string and the characters used to encode it, you need to comrpess the string by only using as many bits as each character needs. You will return the character codes for each character needed to create a compressed string.
For example, given the string "the fox" and the encoder characters "...
A massive QBasic program that I was working on in Archive.org's emulator got corrupted somehow. No way to copy the file to some other system; no text editor available except QBasic's IDE, which wouldn't load the file. I had to write a QBasic program to read the file, try to diagnose the issue, and fix it. Which I did. Feeling kinda proud of myself, ngl.
Also, speaking of unwieldy ways of editing files, XKCD 378 has been oneboxed in this room 20 times over the course of its existence.
This is designed to make numbers that, when divided, approximate PI. For example, 22/7 or 333/.
For all numbers from 1 to 2^30, make numbers that are closer as so:
i/pi ~= x
i/round(x) ~= pi
Or, i/round(i/pi) ~= pi
with i being the number from 1 to 2^30.
Expected output:
1
3
22
333
355
103993
1...
@UnrelatedString the approach you described in the comments is basically how I did it initially lol :P (not the first solution I posted, but the first one I tried)
a good tip for jelly that i've come to use from experience over time is that if you can find a way to get behavior that works for what you need as a single link it almost always is going to save you bytes
so abusing quicks to do things whenever possible is good so you don't have to mess with chaining
I'm not sure if this is a QBasic problem or a DOSBox problem or what... it's like when I try to overwrite a file, it stays the same size as before, so if the new contents are shorter, part of the old contents are still there at the end.
are you using them in a language that doesn't have syntax for not having to escape backslashes (python raw string literals, perl's various regex constructs, ...)
The top was that overused random number one. I'll post the results soon but I did it in an about:blank tab and closed it by accident so I'll have to do it again lol
@DLosc Yep, this is exactly what's happening. Anytime I save the file in QBasic, if it's gotten shorter, the new file is the same size as the old one, "padded" at the end with the contents of the old file. I don't remember QBasic behaving like that, so I'm guessing it's an issue with DOSBox or maybe the way Archive.org has it set up.
It's not a problem as long as I just save the file and keep it in the editor, since the version that's in memory isn't corrupted. But if I close out of it and then come back later, there are problems.
(Caveat: that exact code has not been tested yet and might have bugs. It's essentially copied by hand from the code that I have tested.)
Other caveats are that it's very slow, it runs out of memory relatively quickly, and if you don't use proper tail recursion you will blow the QBasic call stack shockingly fast.