Skip to main content
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
Results tagged with
Search options not deleted user 42963

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

3 votes

Tournament Format Synonyms

Powershell, 111 The wordiness of PowerShell and required parentheses are its downfall again. Even golfing the .Substring(0,2) to [0..1]-join'' only saves 2 bytes each, and another couple bytes saved w …
AdmBorkBork's user avatar
  • 43.5k
1 vote

Exchange the Stacks!

PowerShell, 81 Bytes param([char[]]$a,[char[]]$b,$n);$n--;$t=$b[$n];$b[$n]=$a[$n];$a[$n]=$t;$a;"`n";$b Holy Dollar Signs, Batman! 16 of the 81 characters (~20%) are $. The input is expected to be lit …
AdmBorkBork's user avatar
  • 43.5k
1 vote

How many three-fruit pies can you make?

PowerShell, 92 Bytes $a=($args|sort)-ne0;while($a.count-ge3){$a[0]--;$a[-1]--;$a[-2]--;$a=($a-ne0;$c++}($c,0)[!$c] Uses the same greedy-based algorithm as FryAmTheEggman's answer ... just a lot wordi …
AdmBorkBork's user avatar
  • 43.5k
1 vote

Letters between two letters

PowerShell, 114 100 Bytes param($a)$b=$a.length;0..($b-1)|%{$i=$_;($_+1)..$b|%{$o+=[math]::Abs(+$a[$_]-$a[$i])-eq($_-$i)}};+$o Pretty straight-forward, but uses a couple tricks. param(..) takes our …
AdmBorkBork's user avatar
  • 43.5k
0 votes

Complementary colors

PowerShell, 48 bytes param($a)"#{0:x6}"-f(16MB-1-("0x"+$a.Trim('#'))) Necessarily takes input via param($a) as a string, delimited with ' or ", since C:\Tools\Scripts\Golfing> .\complementary-colors …
AdmBorkBork's user avatar
  • 43.5k
4 votes

Time-Sensitive Echo

PowerShell, 261 190 121 95 Bytes $(do{Measure-Command{$l=read-host};$l}while($l))|%{($_,(sleep -m($_.Ticks/1e4)))[($b=!$b+!$_)]} Props to TessellatngHeckler and tomkandy for the golfing assistance an …
AdmBorkBork's user avatar
  • 43.5k
1 vote

When does Santa enter the basement? (AOC Day 1)

PowerShell, 75 65 62 bytes [char[]]$args[0]|%{$c+=(1,-1)[$_%40];$d++;if($c-lt0){$d;exit}} Uses a similar technique as on Parenthifiable binary numbers to loop through all the input characters, keepin …
AdmBorkBork's user avatar
  • 43.5k
1 vote

CSV for fun and profit (mostly neither)

PowerShell, 16 bytes $args[0]-join',' Takes input, -joins 'em together. PowerShell supports mixed array types without anything special. Example PS C:\Tools\Scripts\golfing> .\csv-for-fun.ps1 ('Doorkn …
AdmBorkBork's user avatar
  • 43.5k
2 votes

The "Do While False" idiom

PowerShell, 40 bytes param($x,$y)(("ACE","ACD")[$y],"AB")[$x] Nested arrays indexed by input. In PowerShell, $true / 1 and $false / 0 are practically equivalent (thanks to very loose typecasting), so …
AdmBorkBork's user avatar
  • 43.5k
5 votes

The hue of a color

PowerShell, 232 226 222 161 Bytes See revision history for previous versions $z,$y,$x=($r,$g,$b=$args)|sort $c=((2,(0,3)[$y-eq$b])[$x-ne$b],1)[$x-eq$g] $d=((2,(0,3)[$x-eq$b])[$y-ne$b],1)[$y-eq$g] (( …
AdmBorkBork's user avatar
  • 43.5k
1 vote

The time after some time

PowerShell, 84 Bytes $a=$args-split'[hms]';"{0:HH:mm:ss}"-f(date 0).AddSeconds(3600*$a[0]+60*$a[1]+$a[2]) Splits the command-line input into an array of strings based on the [hms] regex. Uses the v …
AdmBorkBork's user avatar
  • 43.5k
4 votes

Implement a Truth-Machine

PowerShell, 24 Bytes param($a)do{$a}while($a) Gets variable $a, then uses the do-while loop functionality to output $a at least once, but continuing the loop if $a is truthy (i.e., 1). Alternati …
AdmBorkBork's user avatar
  • 43.5k
0 votes

Filter this string!

PowerShell v2+, 72 bytes param($a,$b)$i=0;-join([char[]]$a|%{if($_-ceq$b[$i]){$_;$i++}else{'#'}}) Takes input $a and $b, sets $i to 0 (our pointer). Then, we cast $a as a char-array and pump it thr …
AdmBorkBork's user avatar
  • 43.5k
0 votes

Smallest sum (and largest difference) of two 3-digit integers

PowerShell v2+, 90 68 bytes $a,$b=(($n=$args|sort)-ne0)[0,1];"$b{1}{3} $a{0}{2}"-f($n-ne$a-ne$b) Not quite as short as others, but showcases some nifty tricks. Takes input as command-line argument …
AdmBorkBork's user avatar
  • 43.5k
1 vote

Mutilating the Query

PowerShell v3+, 115 90 bytes param($n,$z)$a,$b=$n-split'\?';($z|%{$b=$b-replace"(^|&)$_(=[^&]*)?(&|$)"});$a+"?"*!!$b+$b Takes input $n as the URL and $z as a literal array of strings as the paramet …
AdmBorkBork's user avatar
  • 43.5k

1
2 3 4 5
33
15 30 50 per page