Activity for celtschk
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Edit | Post #284277 | Initial revision | — | over 3 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 3 years ago |
Comment | Post #284159 |
Thank you, adopted. (more) |
— | over 3 years ago |
Edit | Post #284159 |
Post edited: Got rid of a whitespace character, spotted by @MarkGiraffe |
— | over 3 years ago |
Edit | Post #284214 |
Post edited: |
— | over 3 years ago |
Edit | Post #284214 | Initial revision | — | over 3 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 3 years ago |
Edit | Post #284213 | Initial revision | — | over 3 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 3 years ago |
Comment | Post #284195 |
Thanks, edited. (more) |
— | over 3 years ago |
Edit | Post #284195 |
Post edited: Adopted improvements suggested by @user in the comments |
— | over 3 years ago |
Edit | Post #284180 |
Post edited: Added forgotten scoring criterion |
— | over 3 years ago |
Comment | Post #284180 |
Oops, yes, it's supposed to be code golf. I'll edit. (more) |
— | over 3 years ago |
Edit | Post #284195 |
Post edited: Adopted improvement by @Hakerh400 |
— | over 3 years ago |
Edit | Post #284195 | Initial revision | — | over 3 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 3 years ago |
Edit | Post #284136 |
Post edited: |
— | over 3 years ago |
Edit | Post #284180 | Initial revision | — | over 3 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 3 years ago |
Comment | Post #283865 |
@#53196 It was referring to the individual three-digit group. (more) |
— | over 3 years ago |
Edit | Post #284158 |
Post edited: Added example noted by @user |
— | over 3 years ago |
Comment | Post #284158 |
Thanks; actually I hadn't been aware of the number before keyword case. I'll add this. (more) |
— | over 3 years ago |
Edit | Post #284159 | Initial revision | — | over 3 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 3 years ago |
Edit | Post #284158 |
Post edited: |
— | over 3 years ago |
Edit | Post #284158 | Initial revision | — | over 3 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 3 years ago |
Edit | Post #284155 | Initial revision | — | over 3 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 3 years ago |
Edit | Post #284136 |
Post edited: Fixed two test cases and added another one |
— | over 3 years ago |
Comment | Post #284136 |
Oops, right, thank you again. I'll immediately fix this. (more) |
— | over 3 years ago |
Edit | Post #284136 |
Post edited: Added a few more test cases |
— | over 3 years ago |
Comment | Post #284088 |
Is it intentional that the standalone number is in words, but the numbers in expressions are in digits (except for the “negative” prefix)? (more) |
— | over 3 years ago |
Edit | Post #284136 |
Post edited: Fixed last testcase and added a few more |
— | over 3 years ago |
Comment | Post #284136 |
Oops, thank you for catching this. I'll fix and also add the extra test cases. (more) |
— | over 3 years ago |
Edit | Post #284137 | Initial revision | — | over 3 years ago |
Answer | — |
A: It's Hip to be Square [C (gcc)], 40 bytes i;f(n){for(i=1;n>0;n-=i,i+=2);return!n;} Try it online! (more) |
— | over 3 years ago |
Edit | Post #284136 | Initial revision | — | over 3 years ago |
Article | — |
Decode periodic decimal fractions [FINALIZED] 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 3 years ago |
Edit | Post #284131 |
Post edited: Typing the alphabet directly turned out to be shorter |
— | over 3 years ago |
Edit | Post #284131 | Initial revision | — | over 3 years ago |
Answer | — |
A: Create an Alphabet Diamond [Python 3], 99 bytes r=[range(26)] a="ABCDEFGHIJKLMNOPQRSTUVWXYZ" for i in r+r[-2::-1]:print(" "(26-i)+a[:i]+a[i::-1]) Try it online! (more) |
— | over 3 years ago |
Edit | Post #284104 |
Post edited: Removed one byte of unnecessary whitespace |
— | over 3 years ago |
Edit | Post #284104 | Initial revision | — | over 3 years ago |
Answer | — |
A: 1, 2, Fizz, 4, Buzz! [Python 3], 64 62 bytes for i in range(1,101):print("Fizz"(i%3<1)+"Buzz"(i%5<1)or i) Try it online! Saved two bytes thanks to Moshi in the comments. [Python 3]: https://docs.python.org/3/ [TIO-ku6jcjdz]: https://tio.run/##K6gsycjPM/7/Py2/SCFTITNPoSgxLz1Vw1DH0MBQ06qgKDOvREP... (more) |
— | over 3 years ago |
Edit | Post #284029 |
Post edited: posted as challenge |
— | over 3 years ago |
Edit | Post #284093 | Initial revision | — | over 3 years ago |
Question | — |
Repeat the characters Given a string and a non-negative integer $n$, output a new string in which each character is repeated $n$ times. Test cases: ``` "abc", 1 -> "abc" "Hello", 0 -> "" "double", 2 -> "ddoouubbllee" "Hi", 4 -> "HHHHiiii" "", 20 -> "" ``` (more) |
— | over 3 years ago |
Edit | Post #284060 | Initial revision | — | over 3 years ago |
Answer | — |
A: Are All Elements Equal? [C (gcc)], 46 bytes f(inta){return a<0|a[1]<0||a==a[1]&f(a+1);} This takes an array that is terminated by a negative number (which is not part of the list content, just like the terminating `\0` is not part of the string content in C strings). Try it online! (more) |
— | over 3 years ago |