Activity for celtschk
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Question | — |
Convert integer to English Given a non-negative integer up to $999\\,999\\,999$, write it in English. The input number can be in any form other than English (though you'll typically want to use the native integer type of your language). The numbers must be formatted as follows: Two-digit numbers must be written wit... (more) |
— | over 2 years ago |
Edit | Post #284383 | Initial revision | — | over 2 years ago |
Answer | — |
A: Define a mathematical expression in English [C (gcc)], 774 bytes #define S strcat(o, #define I(s)if(n)S s);else{S" ");return;} #define B);break;case n,N,s;chari,o[999],d[]={"zero ","one ","two ","three ","four ","five ","six ","seven ","eight ","nine ","ten ","eleven ","twelve ","thir","four","fif","six","seven","eigh... (more) |
— | over 2 years ago |
Edit | Post #284088 |
Post edited: fixed nested list markdown |
— | over 2 years ago |
Suggested Edit | Post #284088 |
Suggested edit: fixed nested list markdown (more) |
helpful | over 2 years ago |
Comment | Post #284088 |
Can you please be more specific? What do you let pass? A final newline? Occasional other trailing whitespace? Leading whitespace? Occasional double spaces? All of them? Some of them?
And what about the supposed behaviour on input characters not in the specification? (more) |
— | over 2 years ago |
Comment | Post #284088 |
I'm not talking about a newline (well, I get that, too, since I use the C function `puts` for output, but I assumed that would be OK; if not, I'll replace it by `printf` at the cost of 2 characters), I'm talking about a space character (ASCII code 32), which my code currently in *some* cases adds at ... (more) |
— | over 2 years ago |
Comment | Post #284088 |
Is it OK to sometimes have a trailing space in the output? Also, may I assume that the input is always a valid input (that is, never contains any characters not in the specification)? (more) |
— | over 2 years ago |
Comment | Post #284088 |
On testing my code for this (not yet finished), I've noticed that three-digit numbers are not tested; also the number zero is easy to get wrong. I suggest adding the following test cases:
```
500
five hundred
129
one hundred and twenty-nine
0+0=0
zero plus zero equals zero
0 -- 0 = 0
... (more) |
— | over 2 years ago |
Comment | Post #282795 |
A Turing machine has a **very strict definition,** and that definition includes the tape and what it is. Note that if your language has stdin, it definitely does **not** describe a Turing machine. (more) |
— | over 2 years ago |
Comment | Post #284326 |
Copyright is independent of making money. There are some fair use exceptions, but those are for commenting on the text. I don't think this use is covered (but then, I am not a lawyer).
And even if it is covered by fair use, the copyright holder (or, more likely, some organisation representing the ... (more) |
— | over 2 years ago |
Edit | Post #284339 |
Post edited: |
— | over 2 years ago |
Edit | Post #284339 |
Post edited: |
— | over 2 years ago |
Edit | Post #284339 |
Post edited: |
— | over 2 years ago |
Edit | Post #284339 |
Post edited: |
— | over 2 years ago |
Edit | Post #284339 | Initial revision | — | over 2 years ago |
Article | — |
Encode and decode floating point integers [FINALIZED] Imagine you have only one byte (8 bits) to store a value, but need to store values from $0$ to $4032$. Impossible, until you are also told that an error of 1/64 of the exact value does not matter. With that knowledge, you decide to design a floating point integer type, which is defined as follows:... (more) |
— | over 2 years ago |
Comment | Post #284326 |
I believe that text is still copyrighted. I'm not sure it is a good idea to use it for a challenge, especially given that the music industry in particular is very active in copyright issues. (more) |
— | over 2 years ago |
Edit | Post #284277 | Initial revision | — | over 2 years ago |
Answer | — |
A: Reverse your quine [Python 3], 69 bytes i="))43,]1-::[i,43,73(%ci(tnirp;%c%s%c=i";print(i%(37,34,i[::-1],34)) Try it online! (more) |
— | over 2 years ago |
Comment | Post #284159 |
Thank you, adopted. (more) |
— | over 2 years ago |
Edit | Post #284159 |
Post edited: Got rid of a whitespace character, spotted by @MarkGiraffe |
— | over 2 years ago |
Edit | Post #284214 |
Post edited: |
— | over 2 years ago |
Edit | Post #284214 | Initial revision | — | over 2 years ago |
Answer | — |
A: Tips for golfing in Python Replace `n+1` with `-n` and `n-1` with `-n` For integers, `n+1` and `-n` have the same value, as have `n-1` and `-n`. While the expressions themselves have the same lengths, the replacements often allow to save space by allowing either to remove whitespace or to omit parentheses due to differen... (more) |
— | over 2 years ago |
Edit | Post #284213 | Initial revision | — | over 2 years ago |
Answer | — |
A: Tips for golfing in Python Replace if/else expressions by array subscripts Consider the statement ``` a=b if x<y else c ``` You can get rid of the expensive keywords by using the implicit conversion of boolean values to integer and array indexing: ``` a=b,c ``` Note however that here `b` and `c` are evaluated uncond... (more) |
— | over 2 years ago |
Comment | Post #284195 |
Thanks, edited. (more) |
— | over 2 years ago |
Edit | Post #284195 |
Post edited: Adopted improvements suggested by @user in the comments |
— | over 2 years ago |
Edit | Post #284180 |
Post edited: Added forgotten scoring criterion |
— | over 2 years ago |
Comment | Post #284180 |
Oops, yes, it's supposed to be code golf. I'll edit. (more) |
— | over 2 years ago |
Edit | Post #284195 |
Post edited: Adopted improvement by @Hakerh400 |
— | over 2 years ago |
Edit | Post #284195 | Initial revision | — | over 2 years ago |
Answer | — |
A: Collatz conjecture; Count the tries to reach $1$ [Python 3], 48 42 39 bytes Saved 6 bytes thanks to Hakerh400 in the comments Saved another 3 bytes thanks to user in the comments f=lambda n:n-1and-f(n//2,3n+1) Try it online! (more) |
— | over 2 years ago |
Edit | Post #284136 |
Post edited: |
— | over 2 years ago |
Edit | Post #284180 | Initial revision | — | over 2 years ago |
Question | — |
Decode periodic decimal fractions Rational numbers in decimal representation can have an infinite periodic part. One common way to write this down is to repeat the periodic digits and then add three dots. Numbers without those three dots are taken to be non-periodic (or equivalently, have a periodic `0` after the given digits). Your ... (more) |
— | over 2 years ago |
Comment | Post #283865 |
@#53196 It was referring to the individual three-digit group. (more) |
— | over 2 years ago |
Edit | Post #284158 |
Post edited: Added example noted by @user |
— | over 2 years ago |
Comment | Post #284158 |
Thanks; actually I hadn't been aware of the number before keyword case. I'll add this. (more) |
— | over 2 years ago |
Edit | Post #284159 | Initial revision | — | over 2 years ago |
Answer | — |
A: Weave Strings Together [Python 3], 91 90 bytes Saved one byte thanks to Mark Giraffe in the comments lambda l:"".join(["".join(x)for x in ziplongest(l,fillvalue='')]) from itertools import Try it online! (more) |
— | over 2 years ago |
Edit | Post #284158 |
Post edited: |
— | over 2 years ago |
Edit | Post #284158 | Initial revision | — | over 2 years ago |
Answer | — |
A: Tips for golfing in Python Reorder expressions in order to save whitespace Consider the following code: ``` if c=='U':c='X' ``` The space between `if` and `c` obviously cannot be removed, as that would merge them to the identifier `ifc`. However by reversing the order of the arguments to `==`, the space becomes removabl... (more) |
— | over 2 years ago |
Edit | Post #284155 | Initial revision | — | over 2 years ago |
Answer | — |
A: Abbreviate everything [Python 3], 142 bytes def f(s): 	m=1;r="" 	for c in s.upper(): 		if'@'<c<''or'-'==c:r+=cm;m=0 		if c in":; ":r+=c(c!=' ');m=1 		if c in".?!":r+=' ';m=1 	return r [Try it online! (more) |
— | over 2 years ago |
Edit | Post #284136 |
Post edited: Fixed two test cases and added another one |
— | over 2 years ago |
Comment | Post #284136 |
Oops, right, thank you again. I'll immediately fix this. (more) |
— | over 2 years ago |
Edit | Post #284136 |
Post edited: Added a few more test cases |
— | over 2 years ago |