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
Suggested Edit Post #283978 Suggested edit:
Fixed spelling of my user name
(more)
helpful over 2 years ago
Comment Post #283978 And another golfing opportunity: the `if i:` can be replaced by multiplying `x[i]` with `bool(i)`, and then the whole line can be combined into a single string, getting rid also of the `end=`. This brings down the byte count to 92. [Try it online!](https://tio.run/##LcpBCsMgEEDRvaeQrGYUF2l3Fk8Ssmj...
(more)
over 2 years ago
Comment Post #283978 I've now noticed that you can dramatically shorten the code again by using Python's slicing syntax. Just replace the complete first loop with `x+=x[-2::-1]` and then remove the now unused variable `j`. This brings the byte count down to 103. [Try it online!](https://tio.run/##RckxCsMwDADAOXqFyCS18...
(more)
over 2 years ago
Comment Post #283978 You can save quite a few bytes here. First, you can replace `print(" ",end='')` with `print(end=" ")`, saving 3 bytes. But then, you can replace the whole `j` loop with `print(end=" "*(k-2))`. Then you can merge the two `print` statements into one: `print(x[i],end=" "*(k-2))`. Since now the `if` c...
(more)
over 2 years ago
Edit Post #283974 Initial revision over 2 years ago
Answer A: "Hello, {name}!"
[Bash], 20 18 bytes Saved two bytes by removing the quotes; the code works well without them. echo Hello, `cat`! Try it online!
(more)
over 2 years ago
Edit Post #283864 Post edited:
Adopted improvement by @Lundin
over 2 years ago
Edit Post #281721 Post edited:
Adopted improvements suggested by @user in the comments
over 2 years ago
Comment Post #283917 I think is is better to separate the tags. After all, if a draft introduces a new tag, but doesn't get to Challenges, then IMHO the tag shouldn't be in main either. Ideally, the tags in the Sandbox would be the union of the tags on Challenges and Sandbox-only tags. But I don't think the software s...
(more)
over 2 years ago
Edit Post #283865 Post edited:
fixed a spelling error in the test cases
over 2 years ago
Edit Post #283865 Post edited:
forgot to add the code-golf tag
over 2 years ago
Edit Post #283865 Initial revision over 2 years ago
Article Convert integer to English [FINALIZED]
Given a non-negative integer up to $999\\,999\\,999$, write it in English. The input number can be in any form other than English (though you'll typically want to use the native integer type of your language). When there are several variants of writing the number in English, you can choose whic...
(more)
over 2 years ago
Edit Post #283864 Initial revision over 2 years ago
Answer A: Make my value binary
[C (gcc)], 35 32 bytes Saved 3 bytes thanks to Lundin f(n){n&&f(n/2);putchar(n&1|48);} This solution exploits that leading zeros, while not required, are also not forbidden by the task. Try it online!
(more)
over 2 years ago
Edit Post #283862 Initial revision over 2 years ago
Answer A: Reduce over the range [1..n]
[C (gcc)], 50 bytes f(int(o)(i,j),int n){return n-1?o(f(o,n-1),n):1;} Try it online!
(more)
over 2 years ago
Edit Post #283803 Initial revision over 2 years ago
Answer A: Output 256 in many different ways
Unlambda, 1 solution Since Unlambda code that does something always contains the backtick character, there cannot be more than one solution. ``` ```.2.5.6i ```
(more)
over 2 years ago
Edit Post #283782 Post edited:
Saved two bytes thanks to Shaggy
over 2 years ago
Comment Post #283782 @#53588 Thank you. Since the JS solution is too different, changing to that now would seem to me like cheating, but I'll use the 31 byte solution.
(more)
over 2 years ago
Edit Post #283782 Initial revision over 2 years ago
Answer A: Make $2 + 2 = 5$
[C (gcc)], 33 31 bytes f(x,y){return x+y+(x==2&y==2);} Try it online! Saved two bytes thanks to Shaggy
(more)
over 2 years ago
Edit Post #283603 Post edited:
finalized
over 2 years ago
Edit Post #283690 Initial revision over 2 years ago
Question Multiply two strings
Given two strings, I define their product as follows: If any of the two strings is empty, the product is the empty string. If the second string consists of a single character, the result is obtained by replacing every character of the first string that compares larger than that character ...
(more)
over 2 years ago
Comment Post #283649 I just noticed that you put the encryption tag on this challenge. That is not appropriate; encryption means to encode a message so that only people with the correct decryption key can decode it. Decoding binary doesn't need a decryption key.
(more)
over 2 years ago
Comment Post #283652 Actually I started with a loop containing a single printf statement (but no width specifications; just a lot of `%1$s` style stuff), but then found that putting the singular/plural logic into a separate function saves more space because I essentially repeated the same logic for `i-1` as I couldn't de...
(more)
over 2 years ago
Comment Post #283649 If you don't care about negative integers, the best option would be to say that it may be assumed that the code is only called on non-negative integers.
(more)
over 2 years ago
Comment Post #283649 What about negative integers?
(more)
over 2 years ago
Edit Post #283652 Initial revision over 2 years ago
Answer A: 99 Shortened Bottles of Beer
[C (gcc)], 232 bytes f(n,w,p){printf("%i bottle%s of beer%s%s",n,"s"+(n1?"Take one down and pass it around, ":"Go to the store and buy some more, ");f(--i?:99,0,".\n\n");}} Try it online! Main golfing techniques: The repetitive part has been put into a function conditiona...
(more)
over 2 years ago
Comment Post #283649 You might want to restrict the input to disallow a “converter” that takes the number in binary and copies it to output unchanged.
(more)
over 2 years ago
Comment Post #283649 Why does the integer have to be named n?
(more)
over 2 years ago
Edit Post #283617 Initial revision over 2 years ago
Answer A: Evaluate a single variable polynomial equation
[C++ (gcc)], 61 bytes float f(int n,floatp,float x){return n?p+xf(n-1,p+1,x):0;} Try it online!
(more)
over 2 years ago
Edit Post #283603 Post edited:
Added that reversal of parameters is allowed if explicitly stated
over 2 years ago
Comment Post #283603 As long as you explicitly state that the second factor is passed in first, I'd consider that acceptable. I've edited the post accordingly.
(more)
over 2 years ago
Edit Post #283603 Post edited:
over 2 years ago
Edit Post #283603 Initial revision over 2 years ago
Article Multiply two strings [FINALIZED]
Given two strings, I define their product as follows: If any of the two strings is empty, the product is the empty string. If the second string consists of a single character, the result is obtained by replacing every character of the first string that compares larger than that character ...
(more)
over 2 years ago
Edit Post #281721 Initial revision almost 3 years ago
Answer A: Golf a FRACTRAN interpreter
[Python 3], 76 71 bytes Saved 5 bytes thanks to user def f(p,n):l=[np//q for(p,q)in p if n%q<1];return f(p,l[0])if l else n Try it online! This code assumes that the fractions are given as completely cancelled pairs of integers.
(more)
almost 3 years ago
Comment Post #279854 Figuring that out was intended to be part of the challenge? I would never have guessed *that.* The one single most important thing about a challenge is to be crystal clear on what is expected from a solution. Up to now, my comments were about things where people could be misled by reasonable assumpti...
(more)
over 3 years ago
Comment Post #279854 On the `{n}=2n`: That's just an observation/extrapolation from the examples given. But the order you describe implies `m<n => {m} < {n]`, which means that when `{5} > {6}` then your mapping does not respect your order. While there's of course not a requirement to respect the order, it is what I woul...
(more)
over 3 years ago
Comment Post #279854 According to the task description, the task is to return a string, not a set. I took it that your algorithm gives that string. So what you are saying is that the algorithm only gives *some* representation of the set, and the program has to then calculate the set from that representation, and then to ...
(more)
over 3 years ago
Comment Post #279854 Also, what number corresponds to the set `{{{}, {{{}}}}}` (that is, `{5}`)? Up to n=4, the sets {n} seem to have ascending numbers (`{0}=1`, `{1}=2`, `{2}=4`, `{3}=6`, `{4}=8`), but then the next single-element set is `{6}=12`. Indeed, from those examples, it seems that `{n}=2n`, but `10={1,3}≠{5}`.
(more)
over 3 years ago
Comment Post #279854 BTW, your algorithm produces strings without spaces, but your examples contain spaces after the commas. This raises the question of (a) whether those spaces should be generated, and (b) whether the code should handle such spaces and/or the absence of them in the input.
(more)
over 3 years ago
Comment Post #279854 Since all strings are of finite length, only hereditary finite sets can be represented as such strings anyway. And even if you consider strings of countably infinite length, you obviously cannot represent all sets as such strings. I think a better strategy would be to define the “set strings” by thei...
(more)
over 3 years ago
Comment Post #279854 I haven't completely gone through your algorithm, but I suspect what you define is the [Ackermann bijection](https://en.wikipedia.org/wiki/Hereditarily_finite_set#Ackermann%27s_bijection) between the natural numbers and the hereditary finite sets.
(more)
over 3 years ago