Activity for celtschk
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Answer | — |
A: Operation "Find The Operator" [Python 3], 106 91 bytes Saved 15 bytes thanks to Moshi in the comments lambda a,b,c:[p for p in"+ - // % ".split()if(p in'+-'or b)and eval(f"{a}{p}{b}")==c] Try it online! (more) |
— | over 2 years ago |
Comment | Post #284520 |
I'm not sure the conditions allow reordering the input values that way. Maybe Mark Giraffe can clarify. (more) |
— | over 2 years ago |
Edit | Post #284501 | Initial revision | — | over 2 years ago |
Article | — |
Implement Rule 110 [FINALIZED] [Rule 110] is a Turing complete cellular automaton. It is defined as follows: Take as initial value a sequence of symbols that's infinite to both sides, which consists only of two different symbols (I'm going to use $+$ and $-$ here). This sequence can be seen as a function that maps the integers ... (more) |
— | over 2 years ago |
Edit | Post #279407 |
Post edited: |
— | over 2 years ago |
Edit | Post #284498 | Initial revision | — | over 2 years ago |
Question | — |
Run-length encode a byte sequence Run-length encoding is a simple compression technique which compresses sequences of repeating identical bytes. The encoding rules for this task are as follows: Any sequence of $n$ identical bytes ($3 \leq n \leq 63$) is replaced by a byte with value `n+0xc0` followed by only one copy of that by... (more) |
— | over 2 years ago |
Edit | Post #284397 |
Post edited: |
— | over 2 years ago |
Edit | Post #284449 | Initial revision | — | over 2 years ago |
Question | — |
Find good coalitions As you might know, there were elections in Germany, and now the parties have to form a government coalition. Let's help them with it! A good coalition has the strict majority of seats (that is, more seats than the opposition). Moreover you don't want more parties than necessary in a coalition, tha... (more) |
— | over 2 years ago |
Comment | Post #284407 |
Shouldn't the test case `2 2 4` also include `^` in the output?
Also, you might add the test case `0 0 0` (giving `+ - *`). (more) |
— | over 2 years ago |
Comment | Post #284428 |
Found yet another improvement: `(2*l==f and N%2)or 2*l>f` is equivalent to `2*l+N%2>f`.
[Try it online!](https://tio.run/##lZTfi5tAEMefs3/FEuixq17R9UeiOYWDplAooXCPx3Hkx9oE7Bp0fSghf3vq7mrQDD7Uh8Hx48w48x33/FceS@Hfbgee4y0RNOEpEVkW0a@7k/wsuPgtj4Su8pRZFl8VqXgi@bNHVxv9GqdPvrequGwqQQi322e@R@nLS0jtjU2YVdi... (more) |
— | over 2 years ago |
Comment | Post #284428 |
I just noticed that the logic for `M` in the return statement now was equivalent to just adding `M`. After that, only one use of `M` remained, allowing elimination of the variable by inserting the expression directly.
[Try it online!](https://tio.run/##lZRLi6NAEMfP6U/RBHboNplF20eiGYWBzcLCEhbmOAxDH... (more) |
— | over 2 years ago |
Comment | Post #284428 |
I just found the function `bit_length` which gives the functionality of the loop, and thus allows to make the encoding function a one-liner, too.
[Try it online!](https://tio.run/##lZRLa@MwEMfP0acQgRbJSRdbfiR2KkNhs7CwCQs9llLykDcBrxxs@bBk89lTPexgR/jQHAZPfp4ZzfzHOv0Th4L71@ueZXCDOE4YRTxNI/xtexQfOeN/x... (more) |
— | over 2 years ago |
Comment | Post #284428 |
The last `if` in `a(n)` can also replaced with logic/arithmetic/bitwise operations, allowing subsequent elimination of `E` and getting rid of a newline/indent.
[Try it online!](https://tio.run/##lZTbitswEIavracQgS6S7QVbPiR2VoaFplBoQmEvl6UksUwCrhx8oJQ0z57VwQl2hC/qi8GTzzOjmX@i09/2UPHges1ZAbeI4xRYjHr... (more) |
— | over 2 years ago |
Comment | Post #284428 |
I just noticed that the early return is not necessary if a small adjustment is done to the initialisation of `E`, saving quite a few bytes again.
[Try it online!](https://tio.run/##lZTbitswEIavracQgS6SkwVbPiS2V4aFulBoQmEvl6XkIBODKwcfKCXNs2d1cIId4YvmYvDk88xo5h/r9Lc9Vty7Xg8sh1vEcQwsRh1g/TkWJYM8pcS2m... (more) |
— | over 2 years ago |
Comment | Post #284428 |
The if/else in `b(r)` can be replaced by `e=E-(E>0);m=M+32*(E>0)`. After that replacement, M can be inserted in place, and so can `m` and `e`.
[Try it online!](https://tio.run/##lZTbitswEIavracQgV0kJwu2fEjsRIaFulBoQmEvl2XJQSYBVw4@UEqaZ8/qYAc7whfNxeDJ55l/RjPW@W99LLh3ux1YBreI4xhYpwzylUfiktVNySEHFqM... (more) |
— | over 2 years ago |
Comment | Post #284391 |
Exactly. I absolutely intended to have thin spaces (LaTeX `\,`) here. I strongly prefer that to commas as thousands separators.
Also, LaTeX inserts a small space after each comma, making it into a list of three numbers instead of one number with commas as thousands separators. Clearly, a list of t... (more) |
— | over 2 years ago |
Comment | Post #284001 |
You can save even more bytes by shortening the colours to the uniquely identifying prefix (also, since my previous suggestion only resulted in a single line, the newline was unnecessary).
[Try it online!](https://tio.run/##dVC7bsMwDNzzFYQnGyi6dAuQLwkyyAptM6FFgfID7s@7olK4QIBOpE7H4x3jNg0SvvbdXSpF2KB... (more) |
— | over 2 years ago |
Comment | Post #284001 |
By replacing the loops with list comprehension, you can save quite a few characters.
[Try it online!](https://tio.run/##dZLBbsMgDIbP61NYOSXStMtuk/okVQ@EOg0dAeSEVtnLZ7@h66ZKu2ADtvH/mbQuYwzv22b2jfCJVvY@3ugszIF6ibdAszXieaHeG/tJ0Y7ClNjYkST3K0XvrkxXFzVmMEjwDpF0jv5Edow2erMwTSYjzAqbCaub5ojKzl9ZSOLMZL4y6n... (more) |
— | over 2 years ago |
Comment | Post #284428 |
The condition of the if/else converts to 1 if true and 0 if false. That's exactly the difference between the two assignments.
Furthermore, you can omit the `==1` from `N%2==1`.
[Try it online!](https://tio.run/##lZTbitswEIavracQgS6SkwVbPiR2IsNCXSg0obCXy7LkIJOAIwcfKCXNs6c62Isd4YvNxeDJ55l/RjPW5W9... (more) |
— | over 2 years ago |
Comment | Post #284396 |
Since after removing the "teen" and "ty" there is some repetition in the string, you can save even more characters by putting that into a separate string and interpolating it.
[Try it online!](https://tio.run/##XZLdbqMwEIWvk6cYjVQJQ3ZrSH82UPMiVS4iMhRL1ET2pHW36rOnY1Ju6gt7/OmcmWPB6YOHyW0vlyP10GdR1et... (more) |
— | over 2 years ago |
Comment | Post #284396 |
You can get rid of even more bytes by moving the repeating `teen` and `ty` from the constant into the final expression.
[Try it online!](https://tio.run/##dZLfboIwFIev9SlOmphQcLOg@yNaXsRwYbCMJqyY9qh1y56dnYLcLFkvaPvl@50eKOc7Np1Z9/1J1VBHnufzmZOM7Y6SfSnbQWcU4K0DbKxSUHcXC7W@KnDag1NXZUDpjwbB6CCGbTtQvKm... (more) |
— | over 2 years ago |
Comment | Post #284407 |
Maybe the challenge could be named:
**Find the operation, if any, that results in a true equation**
(more) |
— | over 2 years ago |
Edit | Post #279407 |
Post edited: Rediscovered this old forgotten draft of mine; did some minor improvements |
— | over 2 years ago |
Edit | Post #284397 |
Post edited: Added a note that the order in the output does not matter |
— | over 2 years ago |
Edit | Post #284339 |
Post edited: |
— | over 2 years ago |
Edit | Post #284421 | Initial revision | — | over 2 years ago |
Question | — |
Encode and decode floating point integers Imagine you have only one byte (8 bits) to store a value, but need to store values from $0$ to $4032$. Impossible, until you are also told that an error of 1/64 of the exact value does not matter. With that knowledge, you decide to design a floating point integer type, which is defined as follows:... (more) |
— | over 2 years ago |
Edit | Post #284418 | Initial revision | — | over 2 years ago |
Answer | — |
A: Truthify an array [Python 3], 75 bytes lambda a:[[i,k]for i in r(l(a))for k in r(l(a[0]))if ai] r=range;l=len Try it online! (more) |
— | over 2 years ago |
Edit | Post #284417 | Initial revision | — | over 2 years ago |
Answer | — |
A: "Hello, World!" [Unlambda], 40 bytes `````````````.H.e.l.l.o.,. .W.o.r.l.d.!i Try it online! (more) |
— | over 2 years ago |
Edit | Post #284185 |
Post edited: Turned link-only footnote into direct links |
— | over 2 years ago |
Suggested Edit | Post #284185 |
Suggested edit: Turned link-only footnote into direct links (more) |
helpful | over 2 years ago |
Comment | Post #284407 |
Is division supposed to be integer division or real division? In other words, should `10 3 3` give true for division (because with integer division, 10/3 gives 3), or false (because in reals, 10/3 gives a fraction that definitely isn't 3). Also, different languages give different results for modulo o... (more) |
— | over 2 years ago |
Comment | Post #284407 |
Instead of two values, I suggest to output only the second value, but with the condition that it is none of the operation symbols if no operator works. (more) |
— | over 2 years ago |
Edit | Post #284397 |
Post edited: |
— | over 2 years ago |
Edit | Post #284397 |
Post edited: Fixed test case thanks to @Moshi |
— | over 2 years ago |
Edit | Post #284104 |
Post edited: I had accidentally deleted the links |
— | over 2 years ago |
Edit | Post #284104 |
Post edited: Saved two bytes thanks to @Moshi in the comments |
— | over 2 years ago |
Comment | Post #284401 |
But `if a>0 or b>0:` is exactly as long as `if(a>0)|(b>0):`. (more) |
— | over 2 years ago |
Edit | Post #284391 |
Post edited: Corrected LaTeX correction |
— | over 2 years ago |
Comment | Post #284397 |
<del>Then you didn't read the specification correctly:
> A good coalition has the strict majority of seats (that is, more seats than the opposition).
Clearly 20 is not more than 20.</del>
Sorry, I misread your correct coalition. Actually, you're right. I'll fix the test case. (more) |
— | over 2 years ago |
Edit | Post #284397 |
Post edited: |
— | over 2 years ago |
Edit | Post #284397 | Initial revision | — | over 2 years ago |
Article | — |
Find good coalitions [FINALIZED] As you might know, there were elections in Germany, and now the parties have to form a government coalition. Let's help them with it! A good coalition has the strict majority of seats (that is, more seats than the opposition). Moreover you don't want more parties than necessary in a coalition, tha... (more) |
— | over 2 years ago |
Comment | Post #284396 |
You can get rid of a few characters by replacing the two `and` with multiplication.
[Try it online!](https://tio.run/##VZLRboMwDEWfy1d4kSaVlWpAu02jS3@k4qGlYUSCMCVhhU379s5OQqflIb52fY9N1I/JNr3aXK9nUUO9HOMiWhjO2O7ID@xL6J4lrFcCb3shbRstKKv7QVOQn5QZOdItPoXCKOR7YzEq6Y2@2IZf7UW0zmQbqa1wNaLNUtZBIXRWZA3awb0... (more) |
— | over 2 years ago |
Edit | Post #283865 |
Post edited: |
— | over 2 years ago |
Edit | Post #284391 | Initial revision | — | over 2 years ago |