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
Which side has more?
Excel, 44 40 Bytes
=MOD(3-SIGN(1+LEN(A1)-2*FIND(",",A1)),3)
Finds the difference between Total Length + 1 and twice the position of the comma (Negative: Left; Zero: Tie; Positive: Right), use SIG …
2
votes
99 bugs in the code
VBA: 225 233 Bytes
Sub b()
For c = 99 To 0 Step -1
GoSub d
GoSub d
Debug.Print "Take one down and patch it around"
c = c + 5 - Int(rnd() * 20)
If c < 0 Then c = 0
GoSub d
Debug.Print
Next c
Exit Su …
2
votes
Greet according to the time of day
Excel, 97 bytes
=VLOOKUP(Hour(Now()),{0,"Zzz";6,"Good morning";12,"Good afternoon";18,"Good evening";20,"Zzz"},2)
Start with the list of cases
0 <= HOUR < 6 : "Zzz"
6 <= HOUR < 12 : "Good mor …
4
votes
Dad jokes are fun
VBA (Excel), 27 28 bytes
?"Hi"Mid([A1],4)", I'm VBA!
Input goes in cell A1 of the Active Sheet in Excel, run code in the Immediate Window
Takes advantage of the fact that "SomeString"SomeValue a …
8
votes
Third time the charm
SQL, 25 24 23 bytes
(-1 Byte Removed a mistyped character that was always commented out and doing nothing)
(-1 Byte Changed SELECT to PRINT as recommended by Razvan Socol)
PRINT 2/*
*2+1--*/-1
-- …
7
votes
Code Golf: Your own pet ASCII snake
VBA, 60 59 49 Bytes
For l=1To 30:?Spc(30+i)"+":i=i+Sgn(Rnd()-.5):Next
Paste it in the Immediate window and hit enter. (Make sure explicit declaration is turned off!)
Far more likely to move than …
3
votes
Create a Magic 8 Ball
Excel, 399 Bytes
=CHOOSE(1+20*RAND(),"It is certain","It is decidedly so","Without a doubt","Yes definitely","You may rely on it","As I see it, yes","Most likely","Outlook good","Yep","Signs point to …
0
votes
Factory workers
VBA, 144 bytes
Sub f(i)
Dim w(9) As Long
For x = 0 To 9
s = "|"
For y = 0 To 9
s = s & w(y)
If i * Rnd() < 1 Then w(y) = 1
Next
Debug.Print s; "|"
Next
End Sub
Indented for easier reading:
Sub f …
2
votes
Make an Emergency Corridor
Excel, 28 bytes
=REPT(2,A1+1)-10^MAX(A1-1,1)
Uses 2 for cars, and 1 for Corridor
Makes a list of 2s n+1 long, then subtracts the larger of 10^(n-1) and 10:
n=1 : 22 - MAX(1,10) = 12
n=2 : 22 …
1
vote
Block Rearrangement
Excel, 86 81 Bytes
=SUM(B1,A2,B3,C2)+B2*(AND(A1:A3)+AND(A1:C1)+AND(C1:C3)+AND(A3:C3))/(SUM(A1:C3)=5)
Old: When the 'impossible' output was -1
=IF(SUM(A1:C3)=5,SUM(B1,A2,B3,C2)+B2*(AND(A1:A3)+AN …
2
votes
It took me a lot of time to make this, pls like. (YouTube Comments #1)
VBA, 54 51 Bytes
(-3 bytes now that leading & trailing 0-character lines are confirmed as permitted)
x=Len([A1]):For i=-x To x:?Left([A1],x-abs(i)):Next
Just a simple loop from -Length to Length …
1
vote
Day of the week of an ambiguous date
Excel, 85 Bytes
=IF(OR(DAY(A1)>12,MOD(A1-DATE(YEAR(A1),DAY(A1),MONTH(A1)),7)=0),TEXT(A1,"ddd"),"???")
Input the date into cell A1
Since Excel will automatically evaluate the date into a valid form …
4
votes
Solve a 2xN Maze
Excel, 38 bytes
=AND(ISERROR(FIND({12,3,21},A1+2*A2)))
Input is 2 strings (1 for each row of the maze), in cells A1 and A2, with 1 for a Wall, and 0 for a space.
First, it adds the first row, and twi …
6
votes
Which Card is it?
Excel, 156 bytes
=TRIM(MID("two threefour five six seveneightnine ten jack queenking ace",1+MOD(A1,13)*5,5))&" of "&CHOOSE(1+(A1/13),"hearts","diamonds","spades","clubs")
Cards from 0-51. Unfor …
3
votes
Is it a Cyclops number? "Nobody" knows!
Excel, 97 63 Bytes
=A1=2*4^(ROUND(LOG(A1,4),0))-2^(ROUND(LOG(A1,4),0))-1
Calculates 2 numbers:
Twice the nearest Power of 4
>Num|Binary|2*Power4|Binary
> 1| 1| 2* 1= 2| 10
> 2| …