Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
2
votes
Cat goes "Meow"
Python, 62 58 48 - 15 = 48 44 33 bytes
Thanks to Unrelated String for -10 bytes!
x=input()
print(x,*['goes "Meow"'][:"c""at"==x])
0x61 = a.
Try it online!
Revision 3: with cat without cat
Revision 2: …
1
vote
Shortest code to produce infinite output
Python 3, 18 15 bytes
Thanks to DLosc for -3 bytes!
while 1:print()
0
votes
Russian Roulette
Python 3, 54 bytes
import random;1/random.randrange(5);print'I survived!'
On 1/0 it will crash:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: integer div …
1
vote
Simple cat program
Python, 14 bytes
print(input())
Print input... couldn't be more self-explanatory.
0
votes
Halloween Golf: The 2spooky4me Challenge!
Python, 39 bytes
x=int(input());print(f"{x}spooky{x+2}me)
Don't remove the int(). That will cause an error.
Tested on Python 3.10.1 (v3.10.1:2cd268a3a9, Dec 6 2021, 14:28:59) [Clang 13.0.0 (clang-13 …
1
vote
Convert YYYYMM to MMMYY
Python, 115 bytes
m='JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC'.split();d=input();print("%s%s"%(m[int(d[4]+d[5])-1],d[2]+d[3]))
Try it online
3
votes
Count the number of ones in an unsigned 16-bit integer
Python, 72 26 bytes
Thanks to mathcat for -12 -27 -36 bytes through various simplifications!
lambda a:bin(a).count('1')
Well, you said statements...
1
vote
Is it an Element?
Python, 229 bytes
Thanks to @Neil for the regex - :)
import re;bool(re.match("([HNOUVWY]|[CGLP]a|[DNPRSTY]b|[AMST]c|[CMNP][do]|Gd|[BCFGHNRSTX]e|[CHR]f|[AHMORS]g|[BNRT][ah]|[BLNST]i|Bk|[ACFT][lm]|Pm|Sm …
0
votes
The Ackermann function
Python 3.11, 96 bytes
def a(m,n):
if m==0:return n+1
elif n==0:return a(m-1,1)
else:return a(m-1,a(m,n-1))
Ungolfed:
def a(m, n):
if m == 0:
return n + 1
elif n == 0:
…
2
votes
Implement an Over function
Python, 27 bytes
lambda f,g,a,b:g(f(a),f(b))
0
votes
Is this even or odd?
Python REPL, 14 bytes
int(input())%2
Where 0 (falsy) is even, and 1 (truthy) is odd.
0
votes
Is this number evil?
Python, 34 bytes
lambda x:not bin(x).count('1')%2
Converts input to bin, then counts 1s, mod 2 (invert because of even=1)
Try it online (Python 3.8.0b4)
Try it online (OLD) (Python 3.8.0b4)
4
votes
1, 2, Fizz, 4, Buzz
Python, 108 102 bytes
Thanks to caird coinheringaahing for -6 bytes!
for x in range(1,101):
y=""
if x%3<1:y="Fizz"
if x%5<1:y+="Buzz"
y=y or x
print(y)