Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »

Activity for celtschk‭

Type On... Excerpt Status Date
Edit Post #284952 Initial revision about 3 years ago
Answer A: Golf golf challenge
[C (gcc)], 133 131 bytes f(p,s){chart="Hole in one\0Albatross\0Eagle\0Birdie\0Par\0Bogey\0Double bogey\0Triple bogey";for(--s?s+=5-p:0;s-=!t++;);puts(t);} Saved two bytes thanks to m90 in the comments. Try it online!
(more)
about 3 years ago
Edit Post #284950 Initial revision about 3 years ago
Answer A: 1, 2, Fizz, 4, Buzz!
[C (gcc)], 103 bytes Using a different approach than my previous solution, therefore posting as new answer as suggested here. i;main(){while(i++<100){char s[]="FizzBuzz",t=s+4!!(i%3);if(i%5)s[4]=0;t?puts(t):printf("%d\n",i);}} Try it online!
(more)
about 3 years ago
Edit Post #284894 Post edited:
about 3 years ago
Edit Post #284894 Initial revision about 3 years ago
Question New solution to same challenge in same language: Change existing answer or add new one?
A while ago I wrote an answer in C (gcc) to the FizzBuzz challenge. Now I've found a shorter solution for the same compiler, which however uses a completely different strategy. Now I wonder if I should add that solution to my current answer, or instead add a new answer with that different solution...
(more)
about 3 years ago
Comment Post #284852 There's no testcase for Double bogey
(more)
about 3 years ago
Edit Post #284501 Post edited:
finalized
about 3 years ago
Edit Post #284893 Initial revision about 3 years ago
Question Implement Rule 110
[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)
about 3 years ago
Comment Post #284852 @#53196 OK, somehow I missed that.
(more)
about 3 years ago
Comment Post #284864 Please use the sandbox.
(more)
about 3 years ago
Comment Post #284668 Which rules of inference are allowed to be used? I expect modus ponens is one of them. Also, given that you don't give any axioms for $\leftrightarrow$, you'll need to allow some rules of inference for that as well.
(more)
about 3 years ago
Comment Post #284852 What about scores beyond par &minus;3 (other than hole in one)? For example, what should the program output for `6 2`? BTW, technically, &minus;3 below par would be 3 above par.
(more)
about 3 years ago
Comment Post #284777 Thanks. You didn't address the leading/trailing whitespace, though.
(more)
about 3 years ago
Edit Post #284810 Initial revision about 3 years ago
Answer A: Tips for golfing in C
Use pointer arithmetic and `\0` with string literals In C, strings are just zero-terminated character arrays, which means you can play tricks with pointer arithmetic. For example, the line ``` chars=a<2?"":"s"; ``` can be replaced with ``` chars="s"+(a<2); ``` Note that you also can use ...
(more)
about 3 years ago
Comment Post #284777 Does the code have to handle leading zeros (say, `"010.000.007.023"`)? What about leading/trailing spaces (say, `" 127.0.0.1 "`)? Is the string guaranteed to be a valid IPv4 address? Will the IPv4 address always be given in point form, or does the code also need to handle the integer form (e.g. `"16...
(more)
about 3 years ago
Edit Post #284578 Post edited:
about 3 years ago
Suggested Edit Post #284578 Suggested edit:

(more)
helpful about 3 years ago
Comment Post #284572 The title is misleading: That's not what “solving a crossword” means. Rather, this is a [word search.](https://en.wikipedia.org/wiki/Word_search)
(more)
about 3 years ago
Edit Post #284501 Post edited:
Fixed test case thanks to @Hakerh400
about 3 years ago
Comment Post #284501 You're right. Thank you for catching this. I'll update.
(more)
about 3 years ago
Edit Post #284522 Post edited:
Saved 15 bytes thanks to @Moshi in the comments
about 3 years ago
Comment Post #284522 Nice. I actually started with lambda and list comprehension, but got stuck at the fact that this doesn't allow to handle exceptions, and didn't see that you could pre-check that cheaply.
(more)
about 3 years ago
Edit Post #284522 Initial revision about 3 years ago
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)
about 3 years ago
Comment Post #284520 I'm not sure the conditions allow reordering the input values that way. Maybe Mark Giraffe can clarify.
(more)
about 3 years ago
Edit Post #284501 Initial revision about 3 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)
about 3 years ago
Edit Post #279407 Post edited:
about 3 years ago
Edit Post #284498 Initial revision about 3 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)
about 3 years ago
Edit Post #284397 Post edited:
about 3 years ago
Edit Post #284449 Initial revision about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 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)
about 3 years ago