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 Lundin‭

Type On... Excerpt Status Date
Comment Post #290437 In case of for example the first `1`, there are zero identical numbers preceding it. So how does it become `1` and not `0`? Shouldn't the text rather say "the number of identical integers preceding it, including itself" or something like that.
(more)
4 months ago
Comment Post #289996 Also check out [Integer to Roman numeral](https://codegolf.codidact.com/posts/279820).
(more)
6 months ago
Edit Post #289517 Initial revision 8 months ago
Answer A: Reverse the bits in a Byte
[C (gcc)], 42 bytes c;f(i){c++>1));} Try it online! Binary output version.
(more)
8 months ago
Edit Post #289516 Post edited:
8 months ago
Edit Post #289516 Post edited:
8 months ago
Comment Post #289436 Would it be allowed to make the output format in binary?
(more)
8 months ago
Edit Post #289516 Initial revision 8 months ago
Answer A: Reverse the bits in a Byte
[C (gcc)], 47 bytes r,c;f(i){return c++>1)),r;} Try it online! I didn't manage to come up with anything better than the most obvious recursive implementation posted above. I tried to use a different algorithm based on iterating two counters instead, but it got quite a bit longer....
(more)
8 months ago
Comment Post #285821 @#64628 I think the first sentence of the challenge already explains this pretty well.
(more)
9 months ago
Edit Post #286590 Post edited:
9 months ago
Comment Post #285821 @#64628 This is defined by the official programming language specification. Like in the example given, by the ISO standard. Some languages might not have one (most esoteric programming languages don't) and then this challenge might not be suitable for that language.
(more)
9 months ago
Comment Post #285821 The program is free to do any form of input/output.
(more)
9 months 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)
9 months 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)
9 months 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)
9 months 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)
9 months ago
Edit Post #288397 Initial revision 11 months ago
Answer A: Hosting fastest code challenges
If restricting everyone to the same system, then 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 benc...
(more)
11 months ago
Edit Post #287816 Post edited:
about 1 year ago
Edit Post #287816 Post edited:
about 1 year ago
Edit Post #287816 Post edited:
about 1 year ago
Comment Post #287816 Example of what I mean.
(more)
about 1 year ago
Edit Post #287816 Initial revision about 1 year 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 1 year ago
Edit Post #285821 Post edited:
Typo
over 1 year ago
Edit Post #287540 Initial revision over 1 year 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 1 year ago
Edit Post #287341 Initial revision over 1 year 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 1 year ago
Edit Post #285929 Post edited:
almost 2 years ago
Comment Post #285929 @#56271 Indeed! I'll give it an update.
(more)
almost 2 years ago
Edit Post #286603 Post edited:
almost 2 years ago
Edit Post #286651 Post edited:
Recursion isn't always the best solution...
almost 2 years ago
Edit Post #286651 Initial revision almost 2 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 2 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 2 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 2 years ago
Edit Post #286603 Initial revision almost 2 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 2 years ago
Edit Post #286602 Initial revision almost 2 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 2 years ago
Edit Post #286590 Initial revision almost 2 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 2 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 2 years ago
Edit Post #286524 Post edited:
almost 2 years ago
Edit Post #286524 Post edited:
Swapping loop for recursion shaved 3 bytes
almost 2 years ago
Edit Post #286524 Initial revision almost 2 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 2 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 2 years ago