Activity for Lundinâ€
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Article | — |
Keyword golfing [FINALIZED] Many programming languages have the concept of keywords, special syntax items that are not just identifiers reserved by some library, but words reserved by the language itself. The challenge is to write a minimal program for a language with such keywords, with as few characters as possible (code ... (more) |
— | over 3 years ago |
Comment | Post #285064 |
@#8046 https://tio.run/# for info (click logo upper left corner). They are as far as I can tell a non-profit open source organization just like us, so they should have more in common with Codidact than with SE. I could poke around (they have a chat on SE), but it's probably better if an official repr... (more) |
— | over 3 years ago |
Comment | Post #285064 |
The most common answer form we use here is the tio.run "Code Golf Submission (Stack Exchange)". We could ask them if they would be so kind to update this part to "Code Golf Submission (Stack Exchange or Codidact.com)". A small change that doesn't seem unreasonable and we get free advertising whenever... (more) |
— | over 3 years ago |
Comment | Post #284951 |
@#53588 I suppose these are names (of scores) so the first word should be a capital letter. (more) |
— | over 3 years ago |
Comment | Post #284952 |
A minor (non-conforming) improvement for gcc would be to swap the `char*` with an `int*`. `*t="the whole string";f(p,s){ ...` shaves down 4 bytes. (more) |
— | over 3 years ago |
Edit | Post #284951 | Initial revision | — | over 3 years ago |
Question | — |
Golf golf challenge The task is to create a program which displays a golf score as text. It takes 2 numbers as input, separated by space or new line: - The first number is the par of the specific hole. - The second number is the score that the player got. The program should print the textual golf term for the re... (more) |
— | over 3 years ago |
Edit | Post #284852 |
Post edited: |
— | over 3 years ago |
Comment | Post #284852 |
Yes par can only ever be 3, 4 or 5. (more) |
— | over 3 years ago |
Comment | Post #284852 |
@#8056 Thanks, I added one. (more) |
— | over 3 years ago |
Edit | Post #284852 |
Post edited: |
— | over 3 years ago |
Edit | Post #284852 | Initial revision | — | over 3 years ago |
Article | — |
Golf golf challenge [FINALIZED] The task is to create a program which displays a golf score as text. It takes 2 numbers as input, separated by space or new line: - The first number is the par of the specific hole. - The second number is the score that the player got. The program should print the textual golf term for the re... (more) |
— | over 3 years ago |
Edit | Post #284705 | Initial revision | — | over 3 years ago |
Answer | — |
A: Reactions on Code Golf Codidact None of these are applicable at least not for Code Golf challenges. I think this community should "opt out" of reactions unless we can come up with more relevant ones. - "Works for me". Answers are supposed to live up to the challenge specification - if they don't, then one should use comments to ... (more) |
— | over 3 years ago |
Edit | Post #284534 |
Post edited: |
— | over 3 years ago |
Edit | Post #284534 | Initial revision | — | over 3 years ago |
Answer | — |
A: Operation "Find The Operator" [C (gcc)], 147 151 bytes #define L(X)X(+,a+b)X(-,a-b)X(,ab)X(/,b&&a/b)X(%,b&&a%b)X(^,pow(a,b)) #define M(o,d)printf("%s",d==c?#o" ":z++==5?".":""); z;s[99];f(a,b,c){L(M)} Try it online! Somewhat naive solution with X macros that builds up a string before printing. The `... (more) |
— | over 3 years ago |
Comment | Post #284407 |
In case multiple operators match, shouldn't it print all operators that would give the result. That is, the correct output from `2 2 4` should be `+ *`, or perhaps optionally `* +` (the order doesn't matter as long as it prints all results). This would make quite the difference for the algorithm, sin... (more) |
— | over 3 years ago |
Comment | Post #282795 |
@#8056 But what if the language has it but doesn't use it in the specific program. "Turing machine" is not a description of a programming language, but of a program running on a computer. Also there's the terminology confusion with Turing complete. Again, too vague. (more) |
— | over 3 years ago |
Comment | Post #284326 |
@#8056 That might be true. I just wanted something fairly repetitive, so that it would make sense to "optimize" certain parts of the string printing. Regardless, since Codidact is a non-profit organization and earns no money from the site, I'm not sure how copyright matters long as you state the sour... (more) |
— | over 3 years ago |
Edit | Post #284326 | Initial revision | — | over 3 years ago |
Article | — |
Bird is the word Make a program that prints the lyrics of the first verse of Surfin' Bird by the Trashmen: > A-well-a everybody's heard about the bird B-b-b-bird, b-bird's the word A-well, a bird, bird, bird, bird is the word A-well, a bird, bird, bird, well-a bird is the word A-well, a bird, bird, b... (more) |
— | over 3 years ago |
Edit | Post #284106 | Initial revision | — | over 3 years ago |
Answer | — |
A: Repeat the characters [C (gcc)], 56 bytes i;f(s,n)chars,n;{for(;s;s++)for(i=n;i--;putchar(s));} Try it online! My attempt at recursion ended up at 61 bytes: o;f(s,n)chars,n;{for(o=n;s&&n--;putchar(s));s&&f(++s,o);} I still think there's probably a more elegant way to solve both loops wit... (more) |
— | over 3 years ago |
Comment | Post #284084 |
@#53503 No, or you would be able to read them with an input function the first thing you do when launching a program. Stdin is kind of an artificial concept too, mostly related to old terminal I/O. (more) |
— | over 3 years ago |
Edit | Post #284087 | Initial revision | — | over 3 years ago |
Answer | — |
A: Can we have [popularity-contest]s? Well... maybe not in combination with a code golf challenge, but more like an artistic challenge with some theme, similar to screenshot of the month? For reference see for example Outdoors photo contest or Writing challenges. So rather than giving a detailed specification of what the program must ... (more) |
— | over 3 years ago |
Edit | Post #279657 |
Post edited: |
— | over 3 years ago |
Edit | Post #279657 |
Post edited: |
— | over 3 years ago |
Comment | Post #283946 |
Not sure what a popularity contest is in this context. Do you mean a leader board based on vote score rather than characters used? Answers are already sorted by vote score by default, I believe. (more) |
— | over 3 years ago |
Edit | Post #284084 | Initial revision | — | over 3 years ago |
Answer | — |
A: Default Rules: Code Golf I/O Command-line arguments may be used as input instead of stdin Languages/systems that support reading input from command-line arguments may use those as input instead of reading from stdin. (more) |
— | over 3 years ago |
Comment | Post #282792 |
I disagree, this isn't necessarily printed anywhere meaningful. I think each challenge needs to explicitly specify that this is are allowed, or it shouldn't be allowed. (more) |
— | over 3 years ago |
Comment | Post #282795 |
While I agree in principle for languages without convenient input, this is too vague to actually be helpful. For example the "tape" could be a previously defined constant, in which case languages which do support stdin would be free to abuse that rather than taking input. Example of such abuse in C l... (more) |
— | over 3 years ago |
Comment | Post #284049 |
@#53588 You can't store input in thin air, you need to allocate memory for it. Otherwise the program might crash arbitrary. Also `[];` isn't valid C. (more) |
— | over 3 years ago |
Edit | Post #284049 | Initial revision | — | over 3 years ago |
Answer | — |
A: "Hello, {name}!" [C (gcc)], 43 bytes a[99];main(){printf("Hello, %s!",gets(a));} Try it online! (more) |
— | over 3 years ago |
Comment | Post #283770 |
_Must_ it be a function or are function-like macros allowed (in case of C)? (more) |
— | over 3 years ago |
Edit | Post #284048 |
Post edited: |
— | over 3 years ago |
Edit | Post #284048 | Initial revision | — | over 3 years ago |
Answer | — |
A: Make $2 + 2 = 5$ [C (gcc)], 30 bytes f(x,y){return x+y|!(x^y|x^2);} Try it online! In case the "preferably on a function" requirement can be dropped, then #define f(x,y)x+y|!(x^y|x^2) is 28 bytes. (more) |
— | over 3 years ago |
Comment | Post #283917 |
@#53588 It might be worth keeping discussions archived at least for a few weeks after a new challenge is released. In case anyone has questions they might be able to go check the reasoning behind some rule in the sandbox. In the long term I agree that finalised sandbox drafts hold no value. (more) |
— | over 3 years ago |
Comment | Post #283864 |
Same solution: `f(n){n&&f(n/2);putchar(n&1|48);}` (more) |
— | over 3 years ago |
Edit | Post #283736 |
Post edited: |
— | over 3 years ago |
Comment | Post #283736 |
@#54114 I'm decent at C programming but still a beginner at code golfing :) (more) |
— | over 3 years ago |
Edit | Post #283736 |
Post edited: |
— | over 3 years ago |
Edit | Post #283736 |
Post edited: Oh hey, printf happens to return 3 in this case. This is some truly evil code... :) |
— | over 3 years ago |
Edit | Post #283736 |
Post edited: Move the first print to the first condition of inner for loop. Lose && but adds a , |
— | over 3 years ago |
Comment | Post #283716 |
@#54114 I think the fastest code is an interesting idea, though for this to work out we'd have to come up with a standardized way to benchmark the code, preferably online in TIO. That probably means that challenges will be restricted to one particular language. Ideally, all answers are expected to pr... (more) |
— | over 3 years ago |