Timeline for Output the alphabet, the ALPHABET, or just a character
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 2, 2022 at 12:46 | history | edited | Koneke | CC BY-SA 4.0 |
ew, I missed a parenthesis
|
Dec 24, 2015 at 14:32 | history | edited | Koneke | CC BY-SA 3.0 |
Down to 74
|
Dec 24, 2015 at 14:28 | comment | added | Koneke | True! We can actually use the same trick to replace the if else. Down to 76, neat! :) | |
Dec 23, 2015 at 16:03 | comment | added | wnnmaw |
You can save 5 bytes by replacing (97if c>'Z'else 65) with (67,97)[c>'Z']
|
|
Dec 22, 2015 at 16:50 | comment | added | Daniel |
Note that when inputing " to the function, you need \" instead.
|
|
Dec 22, 2015 at 11:27 | comment | added | Koneke | Ah, haven't actually used generator comprehensions before, learning new things! Thanks again :) | |
Dec 22, 2015 at 11:24 | history | edited | Koneke | CC BY-SA 3.0 |
84 -> 82
|
Dec 22, 2015 at 11:23 | comment | added | isaacg | Yeah, the standard definition of output on the site allow returning from functions, so you can edit the new version into your answer. Another golf is that the brackets aren't necessary - the function works exactly the same without them, as a generator comprehension instead of a list comprehension. | |
Dec 22, 2015 at 11:20 | comment | added | Koneke |
Ah, I assumed "output" to mean print, and not just return :) Neat, if that's the case it's down to 84, lambda c:''.join([chr(x+(97if c>'Z'else 65))for x in range(25)])if c.isalpha()else c . Thanks!
|
|
Dec 22, 2015 at 11:09 | comment | added | isaacg |
Hi, and welcome to PPCG! Nice answer. Here's a golfing suggestion: You can use a lambda expression (lambda c: ) instead of an explicit definition (def f(c):print( ), and save some bytes. Also, you don't need the space before the for .
|
|
Dec 22, 2015 at 11:04 | review | First posts | |||
Dec 22, 2015 at 11:09 | |||||
Dec 22, 2015 at 11:01 | history | answered | Koneke | CC BY-SA 3.0 |