Activity for Lundin
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Comment | Post #285821 |
The program is free to do any form of input/output. (more) |
— | over 1 year ago |
Comment | Post #287540 |
Using the return value always seemed like cheating to me, unless the challenge says otherwise. I think our default rules allow it though(?). (more) |
— | over 1 year ago |
Comment | Post #286362 |
f(1,4) returns 5 so your solution is not correct... Similarly this algorithm is wrong in many other answers you have posted here too. To use your own math example, the correct algorithm would have to be `result = x*y; if(result==x+y) return 5; else return x*y;`. (more) |
— | over 1 year ago |
Comment | Post #279657 |
Well as it says in the (several years old) answer, I had no idea which system I got it running on when I did the edit. Might have been gcc/mingw/Windows. Anyway, probably best to refer to the function-only version. (more) |
— | over 1 year ago |
Comment | Post #279657 |
I think it might depend on which standard lib that is used (libc/glibc and so on). The revised 53 byte version should be pure standard C however. (more) |
— | over 1 year ago |
Edit | Post #288397 | Initial revision | — | almost 2 years ago |
Answer | — |
A: Hosting fastest code challenges If restricting everyone to the same system, then we can force every contestant to use https://tio.run and the on-site bench-marking found below "debug" -> "real time" as efficiency metric. Example. Advantages: - No matter how (in)accurate, this gives everyone the same conditions and the same b... (more) |
— | almost 2 years ago |
Edit | Post #287816 |
Post edited: |
— | about 2 years ago |
Edit | Post #287816 |
Post edited: |
— | about 2 years ago |
Edit | Post #287816 |
Post edited: |
— | about 2 years ago |
Comment | Post #287816 |
Example of what I mean. (more) |
— | about 2 years ago |
Edit | Post #287816 | Initial revision | — | about 2 years ago |
Answer | — |
A: How should we handle incorrect answers? ^ That can be used. You can try to contact the person who posted the challenge and have them mark the answer as "React -> Invalid". Or otherwise it seems that anyone can mark an answer as invalid? I think this was the original purpose of that feature for this site. The help text for the react... (more) |
— | about 2 years ago |
Edit | Post #285821 |
Post edited: Typo |
— | about 2 years ago |
Edit | Post #287540 | Initial revision | — | over 2 years ago |
Answer | — |
A: Lowercase, but not just the letters [C (gcc)], 36 bytes f(intp){for(;p;putchar(32|p++));} Try it online! Similar solutions: - 36 bytes too but with new lines: `f(intp){for(;p;p|=32,puts(p++));}` - 37 bytes using recursion: `f(intp){p&&putchar(32|p)&&f(++p);}` (more) |
— | over 2 years ago |
Edit | Post #287341 | Initial revision | — | over 2 years ago |
Answer | — |
A: Sort letters by height [C (gcc)], 152 bytes r;e(c){r=c=='j'?5:strchr("bdfghklpqy",c)?4:c=='i'?3:c=='t'?2:1;}c;s;f(chari,charo){s?(e(i),c=r,e(o)):(qsort(i,strlen(i),s=1,f),puts(i));return r-c;} Try it online! Output: ```text a aa jbita kitc now jtus jpyitzx ``` I didn't fine tune it much, ... (more) |
— | over 2 years ago |
Edit | Post #285929 |
Post edited: |
— | over 2 years ago |
Comment | Post #285929 |
@#56271 Indeed! I'll give it an update. (more) |
— | over 2 years ago |
Edit | Post #286603 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286651 |
Post edited: Recursion isn't always the best solution... |
— | almost 3 years ago |
Edit | Post #286651 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Make a frequency table (histogram) [C (gcc)], 45, 42 bytes t[9999];f(s,a)inta;{for(;s;)t[a[--s]]++;} Try it online! Assumptions: - Passing the array size to a function can be used as a means to deal with empty arrays (not supported in C). - A table of integers can be regarded as a hashtable with an integer val... (more) |
— | almost 3 years ago |
Comment | Post #286630 |
Given that many languages do not support empty arrays, then how to deal with the `{ }` scenario in those languages? (more) |
— | almost 3 years ago |
Comment | Post #286603 |
@#53196 Yes well you'll have to use as many special characters as possible. You've already blocked yourself from using `if`, `else`, `for` and `while` now :) And if function solutions aren't allowed, you'll have to use `main` so you can't use `ifdef`. I honestly have no idea how good/bad hard/easy th... (more) |
— | almost 3 years ago |
Edit | Post #286603 | Initial revision | — | almost 3 years ago |
Article | — |
Code bowling using unique characters The aim of the challenge is to write as long a source code as possible (code bowling), every character typed gives 1 point, using the following rules: - No symbol typed in the source may be re-used twice. That is, only one `a`, only one `1`, only one `+` and so on. - Whitespace characters do not ... (more) |
— | almost 3 years ago |
Edit | Post #286602 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Rules for function submissions Function parameters should not be allowed to be used in place of a return value. Reasons: - Terms like return value and function result are explicitly specified as a specific, formal language item in most languages. Therefore, interpreting a challenge asking for a return value as "return th... (more) |
— | almost 3 years ago |
Edit | Post #286590 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Keyword golfing [C (gcc)], 358 bytes static inline Noreturn float f(union u);extern Threadlocal Complex long doublerestrict B;main(void){Atomic register enum {A};typedef Alignas(unsigned char)struct S;Staticassert(Alignof(Bool),"Imaginary");do goto a;while(sizeof B);if(1)for(auto volatile const signed sho... (more) |
— | almost 3 years ago |
Comment | Post #282785 |
I think we should clarify the meaning of "return value". Going by the formal terms of most languages, it's the value explicitly returned by the function. Many languages support pass by reference and then you can in practice return values through arguments, but this is not the language definition of a... (more) |
— | almost 3 years ago |
Edit | Post #286524 |
Post edited: |
— | almost 3 years ago |
Edit | Post #286524 |
Post edited: Swapping loop for recursion shaved 3 bytes |
— | almost 3 years ago |
Edit | Post #286524 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Roll n fair dice [C (gcc)], 48 43 bytes s;r(n,m){s+=rand()%m+1;return--n?r(n,m):s;} Try it online! Previous 48 bytes version using loop: `i,s;r(n,m){for(;i<n;i++)s+=rand()%m+1;return s;}` (more) |
— | almost 3 years ago |
Comment | Post #286394 |
Testing the original program is easy enough, but how do we test that an infinite amount of programs are unique? It seems that this would be a challenge where lots of people claim to have solved it, and then upon closer investigation perhaps they haven't. With a finite amount of programs created, it w... (more) |
— | almost 3 years ago |
Comment | Post #284049 |
@#56561 Indeed. This answer is using gcc as indicated and isn't a strictly conforming answer. (more) |
— | almost 3 years ago |
Comment | Post #286377 |
The challenge explicitly said to produce an infinite loop. Any answer implementing a size parameter is therefore not following the requirement, for that reason alone. I remember misunderstanding it at first and making a solution based on a finite counter based on user input. Perhaps it should have be... (more) |
— | almost 3 years ago |
Edit | Post #286293 |
Post edited: TIO example contained lots of whitespace for some reason |
— | almost 3 years ago |
Edit | Post #286293 | Initial revision | — | almost 3 years ago |
Answer | — |
A: Looping counter [C (gcc)], 47 bytes i,n;f(){for(i=n+++2;i--;)putchar(i?42:13);f();} Try it online! (more) |
— | almost 3 years ago |
Edit | Post #285929 | Initial revision | — | about 3 years ago |
Answer | — |
A: Can you give me half? [C (gcc)], 8 7 unique cos(cos-cos)/(cos(cos-cos)-(-cos(cos-cos))) Try it online! -1 unique character thanks to @orthoplex (more) |
— | about 3 years ago |
Edit | Post #285263 |
Post edited: |
— | about 3 years ago |
Edit | Post #285821 | Initial revision | — | about 3 years ago |
Question | — |
Keyword golfing 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) |
— | about 3 years ago |
Comment | Post #285675 |
Sounds fun, I take it the ASCII art will expand in width and size depending on size? I think it probably needs some twist so that it isn't as easy as counting the number of rows and columns. Maybe include different shirt models? Or tops, if shirt models are too tricky to draw in ASCII art? As in "is ... (more) |
— | about 3 years ago |
Edit | Post #285263 | Initial revision | — | over 3 years ago |