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 #285805 Initial revision over 2 years ago
Article Word wrap a string
Given a string `s` of text and a line length `l`, your task is to word-wrap that text to that line length. Concretely, the given string consists of words separated by single spaces, with no leading or trailing space. The task is then to replace spaces by newlines such that in each line, there are ...
(more)
over 2 years ago
Comment Post #285479 The straightforward `n%(i*i)==0` would be shorter than your double equality. Moreover, you then could remove the `==0` by replacing `1in` with `0in`, saving another 3 bytes.
(more)
over 2 years ago
Comment Post #285479 Well, it is a code golf challenge, not a run time challenge. BTW, I suspect that dividing by all the single factors (your re-assignment of `n`) does *not* make your code faster, but slower. Anyway, it definitely makes it longer.
(more)
over 2 years ago
Comment Post #285477 I've added a few.
(more)
over 2 years ago
Comment Post #285477 Thanks for pointing this out; I've added the link to the post.
(more)
over 2 years ago
Edit Post #285477 Post edited:
Added reference to OEIS and test cases
over 2 years ago
Edit Post #285340 Post edited:
finalized
over 2 years ago
Edit Post #285477 Initial revision over 2 years ago
Question Determine whether an integer is square-free
An integer is called square-free if it is not a multiple of a perfect square other than 1. For example, 42 is square-free, but 44 is not because it is a multiple of the perfect square 4 = 2². Your task is to write a program or function that takes a positive integer, and returns a truthy value if t...
(more)
over 2 years ago
Edit Post #285340 Initial revision over 2 years ago
Article Determine whether an integer is square-free [FINALIZED]
An integer is called square-free if it is not a multiple of a perfect square other than 1. For example, 42 is square-free, but 44 is not because it is a multiple of the perfect square 4 = 2². Your task is to write a program or function that takes a positive integer, and returns a truthy value if t...
(more)
over 2 years ago
Comment Post #285231 If I read the Wikipedia article correctly, there does *not* exist a finite projective plane for each $n$ up to $11$. In particular, $n=6$ and $n=10$ are cases that are known not to work.
(more)
over 2 years ago
Comment Post #285273 @m90: Thanks, adopted.
(more)
over 2 years ago
Edit Post #285273 Post edited:
Saved 2 bytes thanks to @m90
over 2 years ago
Edit Post #285139 Post edited:
Fixed a typo
over 2 years ago
Edit Post #285273 Initial revision over 2 years ago
Answer A: Find the IP address class
[C (gcc)], 64 62 bytes Saved 2 bytes thanks to m90 in the comments. i;f(chars){i=atoi(s)>>4;return'A'+(i&8?i&4?i&2?i%2+3:2:1:0);} Try it online!
(more)
over 2 years ago
Suggested Edit Post #285139 Suggested edit:
Fixed a typo
(more)
helpful over 2 years ago
Comment Post #284994 Your capitalisation is wrong. That's easy to fix in “Hole in one”, but changing the capitalisation of “Double bogey”/“Triple bogey” without changing “Bogey” as well surely makes the code longer.
(more)
over 2 years ago
Comment Post #284952 Thank you, applied.
(more)
over 2 years ago
Edit Post #284952 Post edited:
Saved two bytes thanks to @m90 in the comments
over 2 years ago
Comment Post #284952 I tried it and it doesn't work. Probably because pointer increments cause the wrong address increment that way.
(more)
over 2 years ago
Edit Post #284952 Initial revision over 2 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)
over 2 years ago
Edit Post #284950 Initial revision over 2 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)
over 2 years ago
Edit Post #284894 Post edited:
over 2 years ago
Edit Post #284894 Initial revision over 2 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)
over 2 years ago
Comment Post #284852 There's no testcase for Double bogey
(more)
over 2 years ago
Edit Post #284501 Post edited:
finalized
over 2 years ago
Edit Post #284893 Initial revision over 2 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)
over 2 years ago
Comment Post #284852 @#53196 OK, somehow I missed that.
(more)
over 2 years ago
Comment Post #284864 Please use the sandbox.
(more)
over 2 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)
over 2 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)
over 2 years ago
Comment Post #284777 Thanks. You didn't address the leading/trailing whitespace, though.
(more)
over 2 years ago
Edit Post #284810 Initial revision over 2 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)
over 2 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)
over 2 years ago
Edit Post #284578 Post edited:
over 2 years ago
Suggested Edit Post #284578 Suggested edit:

(more)
helpful over 2 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)
over 2 years ago
Edit Post #284501 Post edited:
Fixed test case thanks to @Hakerh400
over 2 years ago
Comment Post #284501 You're right. Thank you for catching this. I'll update.
(more)
over 2 years ago
Edit Post #284522 Post edited:
Saved 15 bytes thanks to @Moshi in the comments
over 2 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)
over 2 years ago
Edit Post #284522 Initial revision over 2 years ago