Activity for Lundin
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Article | — |
Print the alphabet using alphabetic source The task is to write a program that takes no input and prints the English alphabet in upper-case letters. It can be printed either as a single line `ABCDEFGHIJKLMNOPQRSTUVWXYZ`, or as letters separated by spaces, or as letters separated by new line. This is code golf, so the shortest program in e... (more) |
— | over 3 years ago |
Comment | Post #279883 |
Covid 19 holidays happened unfortunately, I had no time to post this before xmas. (more) |
— | over 3 years ago |
Edit | Post #280390 |
Post edited: |
— | over 3 years ago |
Edit | Post #280390 | Initial revision | — | over 3 years ago |
Answer | — |
A: Truthify an array [C (gcc)], 100 bytes i,j;f(x,y,p)intp;{puts("[");for(;i<x;i++)for(j=0;j<y;j++)p++&&printf("[%d,%d],",i,j);puts("\b]");} Try it online! Note that TIO console doesn't handle backspace properly. (more) |
— | over 3 years ago |
Comment | Post #280343 |
"We can't currently vary properties of post types per category" This is strange though. The various metas shouldn't give rep IMO and that's a much bigger issue than the sandbox category on some sites. (more) |
— | over 3 years ago |
Comment | Post #280242 |
I think test cases (such as examples of input/output) should not only be encouraged but mandatory. An example snippet of a non-golfed version in some common programming language is encouraged, as discussed [here](https://codegolf.codidact.com/posts/279635). (more) |
— | over 3 years ago |
Edit | Post #280306 | Initial revision | — | over 3 years ago |
Answer | — |
A: Tile pyramids on top of each other! C (compliant), 106 bytes char r,i,s[80];void f(int n){memset(s,32,79);for(;r<n;puts(s),r++)for(i=0;i++<n2;s[n-r-1]=47,s[n+r]=92);} Try it online! Standard C compliant function solution. (more) |
— | over 3 years ago |
Comment | Post #279883 |
@Razetime That's kind of the core of this whole silly joke :) Tannenbaum = Christmas tree in German, though it could as well have been the name of some less famous computer scientist :) O Tannenbaum refers to a famous Christmas carol, etc. (more) |
— | over 3 years ago |
Comment | Post #279883 |
Would appreciate some feedback on this! Is it too confusing? Too silly? Could I clarify it? Or draw ASCII art prettier somehow? (more) |
— | over 3 years ago |
Edit | Post #279883 | Initial revision | — | over 3 years ago |
Article | — |
The Tannenbaum series A series of 7 single digits, that if added in sequence to create an unbalanced binary search tree, is considered a Tannenbaum series, in case: - the left branch of the root has depth 3 and consists of ever-increasing numbers, and - the right branch of the root has depth 3 and consists of ever-de... (more) |
— | over 3 years ago |
Edit | Post #279856 |
Post edited: Save 1 space by moving return inside the x macro list |
— | over 3 years ago |
Comment | Post #279856 |
Amusingly, this is "Y macros", not "X macros"... because X didn't sit well with Roman numerals. I got trouble in one version of the code that used `X(10,X)` :) (more) |
— | over 3 years ago |
Edit | Post #279856 | Initial revision | — | over 3 years ago |
Answer | — |
A: Integer to Roman numeral C (compliant), 197 198 bytes. Golfed version of the function in the question, using X macros: ```c #define L Y(1000,M)Y(900,CM)Y(500,D)Y(400,CD)Y(100,C)Y(90,XC)Y(50,L)Y(40,XL)Y(10,X)Y(9,IX)Y(5,V)Y(4,IV)Y(1,I)return r; #define Y(n,R)for(;v>=n;v-=n)strcat(r,#R); char r[99];charf(int v)... (more) |
— | over 3 years ago |
Edit | Post #279820 | Initial revision | — | over 3 years ago |
Question | — |
Integer to Roman numeral The task is to take a decimal integer as input and print the corresponding Roman numeral with capital letters. The program must handle all positive integer numbers between 1 and 1000. Input can be assumed to be correct and no error handling is necessary. Example data: ``` Input Output 1 ... (more) |
— | over 3 years ago |
Edit | Post #279817 | Initial revision | — | over 3 years ago |
Answer | — |
A: "Hello, World!" LOLCODE, 37 bytes HAI 1 VISIBLE "Hello, World!" KTHXBYE Try it online! (more) |
— | over 3 years ago |
Comment | Post #279797 |
I went ahead and proposed a [move post between different categories feature request](https://meta.codidact.com/questions/279815). It would be generally handy to have, I think. (more) |
— | over 3 years ago |
Comment | Post #279797 |
Great idea. Although... is there a point in archiving old, finalized sandbox posts? Otherwise I believe that the best solution would make it possible for the poster move the post between categories, from sandbox to live challenges. (more) |
— | over 3 years ago |
Edit | Post #279722 |
Post edited: |
— | over 3 years ago |
Edit | Post #279814 |
Post edited: Got rid of break |
— | over 3 years ago |
Edit | Post #279814 | Initial revision | — | over 3 years ago |
Answer | — |
A: Prime Difference C (gcc), 126 129 bytes ```c N=9999;f(n){int p[N],i,j,P;memset(p,1,N);for(i=P=2;ii=n?j=N:(P=i);}e:return P;} ``` Try it online! This is an integer input/output function solution. The upper limit of prime number supported is the square root of`N`, so currently it counts prime numbers up to 9... (more) |
— | over 3 years ago |
Comment | Post #279755 |
However, chasing down a specific poorly-specified program output to a certain compiler, system + options could perhaps be an interesting and very different challenge. If you write a program that purposely does something bad, resulting in crazy results, then task people to find a system and compiler t... (more) |
— | over 3 years ago |
Comment | Post #279755 |
A problem with your example is that can only be reproduced with a non-standard compiler for that language. So you would have to specify to what extent non-standard language extensions are allowed and if your program relies on them... which in turn would be a major spoiler. Running `main;` on a confor... (more) |
— | over 3 years ago |
Comment | Post #279759 |
@Quintec That's a l (L). And yeah the reason that l and 1 look identical on some fonts is the reason why one shouldn't name identifiers like that. (more) |
— | over 3 years ago |
Comment | Post #279754 |
Isn't it a big problem that the robbers can just "brute force" it with trail & error by trying online compilers until they find a match? (more) |
— | over 3 years ago |
Comment | Post #279759 |
And yeah `(int){8<88}<<8` can be rewritten as `1<<8` or `u'\xff'+!!u'\xff'` as `u'\xff'+1` but I'm saving the 1 for a rainy day. (more) |
— | over 3 years ago |
Edit | Post #279759 | Initial revision | — | over 3 years ago |
Answer | — |
A: Output 256 in many different ways C, 8 solutions Standard C, no extensions. 1 solution snippet per line: ```c "llll"[3]^33^333 4444 5555-555-555-555-555-555-555-555-555-555-55-55-55-55-55-5-5-5-7-7 6666/26 (int){8<88}<<8 u'\xff'+!!u'\xff' 0XFFFFFeFF LINE ``` Somewhat naive solution so far, but the nu... (more) |
— | over 3 years ago |
Comment | Post #279743 |
If snippets are ok, what about necessary libs to make the snippet run? That is, to access some language features I would strictly speaking have to include/import etc a lib. (more) |
— | over 3 years ago |
Edit | Post #279722 | Initial revision | — | over 3 years ago |
Article | — |
Integer to Roman numeral The task is to take a decimal integer as input and print the corresponding Roman numeral with capital letters. The program must handle all positive integer numbers between 1 and 1000. Input can be assumed to be correct and no error handling is necessary. Example data: ``` Input Output 1 ... (more) |
— | over 3 years ago |
Comment | Post #279679 |
Oh, and `t` actually doesn't have to be char. So with gcc implicit int abuse, this should be possible: `t;f(char*s){s[1]?f(s+1):0;for(t=*s;s[1];*++s=t)*s=s[1];}`. (more) |
— | over 3 years ago |
Comment | Post #279679 |
Also, switching `while` with `for` will save you lots. `for(char t=*s;s[1];*++s=t;)*s=s[1];` should work. So how about this? `f(char*s){s[1]?f(s+1):0;for(char t=*s;s[1];*++s=t)*s=s[1];}`, 59 bytes. (more) |
— | over 3 years ago |
Comment | Post #279679 |
I think this might be a possible improvement: `f(char*s){s[1]?f(s+1):0;while(s[1]){char t=*s;*s=s[1];*++s=t;}}}`. In case s[1] is a character, it makes the recursive call and then while loop. If not, a `0;` dummy statement. `s[1]` is zero in that case so the while loop isn't executed. (more) |
— | over 3 years ago |
Comment | Post #279657 |
`*p=b+strlen(gets(b))` works too but gives identical size. (more) |
— | over 3 years ago |
Edit | Post #279657 |
Post edited: |
— | over 3 years ago |
Edit | Post #279657 | Initial revision | — | over 3 years ago |
Answer | — |
A: Reverse an ASCII string C (gcc), 62 bytes main(){char b[99],p=strchr(gets(b),0);for(;p-->b;)putch(p);} This relies on the usual gcc extension abuse. It assumes that max user input is 98 characters + null term, since this wasn't specified. EDIT: Revisited, function-based equivalent of the above (plus I have ... (more) |
— | over 3 years ago |
Comment | Post #279639 |
Max length of input string? (more) |
— | over 3 years ago |
Comment | Post #279635 |
Probably a good idea. If the OP makes an attempt to write the non-golfed version of the challenge, then they'll realize various requirements that need to be addressed. (more) |
— | over 3 years ago |
Comment | Post #279601 |
What's the upper limit to number of items supported and the values themselves? Does it need to cover negative numbers? (more) |
— | over 3 years ago |
Comment | Post #279426 |
How can you say that it relies on non-standard extensions while lecturing me about the standard at the same time? It's either, not both at once. (more) |
— | over 3 years ago |
Comment | Post #279415 |
I think this is kind of cheating since that online compiler declares a main() elsewhere. Otherwise you could improve it to `m(){m();}`, 9 bytes, a recursive call that will eventually stack overflow with seg fault (more) |
— | over 3 years ago |
Comment | Post #279383 |
Nice solution since it's quite straight-forward, +1. I managed 108 bytes with same compiler settings (default gcc) but a much more obscure solution [here](https://codegolf.codidact.com/a/279365/279534). (more) |
— | over 3 years ago |