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.
3
votes
Ones and Twos for days
PowerShell, 23 bytes
for(){$i++;1;,2*$i++;1}
Try it online!
Prints the sequence indefinitely.
2
votes
Alternating Triangles
PowerShell, 42 bytes
"$args"..1|%{((" "*($_/2)+"/"),"|")[$_%2]}
Try it online!
Loops from input $args down to 1, each iteration choosing whether to output spaces and a /, or the | character base …
3
votes
Find self-locating strings in a number
PowerShell, 60 56 bytes
param($n)1..128|%{$o+=$_*($_-eq$n.indexOf("$_",$_))};+$o
Try it online!
Takes input $n as a string (else you'll get floating point inaccuracies), then constructs a range …
14
votes
ASCII art is ready for take-off
PowerShell, 131 117 bytes
param($n)' '*$n+" |"
$n..1|%{" "*$_+"/$(' '*++$i)\";$x="*-$('-'*++$i)*"}
$x
,("| $('o '*$n)|")*$i
$x
" /$('_'*--$i)\"
Try it online!
Line breaks added for clarity, but …
1
vote
Is it a doubling sequence?
PowerShell, 49 bytes
param($n)($n|?{$_-ge2*$l;$l=$_}).count-eq$n.count
Try it online!
Takes input $n then uses a Where-Object to pull out those elements that are -greaterthanorequal to 2 times t …
3
votes
Reversed Iota's
PowerShell, 19 bytes
1.."$args"|%{$_..1}
Try it online!
Generates the range from 1 to input $args, then constructs the reversed range for each of those numbers. Tack on a -join to better see how …
1
vote
Lonely Multiplication
PowerShell, 97 bytes
param($n)$a,$b,$c=$n|group;(($n-join'*'|iex),(($a,$b|?{$_.count-eq1}).name,1)[$a.count-eq3])[!$c]
Try it online!
Not terribly impressive, but given that PowerShell doesn't h …
5
votes
Give me Triangles
PowerShell, 36 bytes
"$args"..1|%{" "*--$_+"#"*++$i;$i++}
Try it online!
Loops from input $args down to 1, each iteration constructing a string consisting of the appropriate number of spaces plu …
3
votes
Repeat every other character in string starting with second character
PowerShell, 40 38 37 bytes
-join($args|% t*y|%{"$_"*(1+$i++%2)})
Try it online!
Takes input $args, transforms it toCharArray, pipes that into a loop. Each iteration, we repeat the character "$_" …
2
votes
Shift right by half a bit
PowerShell, 67 bytes
param([uint64]$n)($n/[math]::Sqrt(2)).ToString("G17")-replace'\..*'
Try it online!
.NET (and thus, by extension, PowerShell) doesn't have a BigDecimal, so we're limited to D …
1
vote
Internal Truth Machine
PowerShell, 41 bytes
0-ge1|iex -ov a
for(;"$a"-match"True"){1}0
Try it online!
I didn't think this would be possible in PowerShell, but then I remembered -outvariable, which is the key to making …
7
votes
Convert a 32 bit binary IPv4 address to its quad-dotted notation
Jelly, 10 6 bytes
s8Ḅj“.
Try it online!
s Slice input list
8 into size 8 chunks
Ḅ Convert from binary list to integer
j“. Join with dots as the separator
…
4
votes
Convert a 32 bit binary IPv4 address to its quad-dotted notation
PowerShell, 46 bytes
""+[IPAddress]"$([Convert]::ToInt64($args,2))"
Try it online!
First takes input $args binary string and [System.Convert]s it into Int64. Uses the .NET type call [System.Net. …
20
votes
Sleep for 1000 years
PowerShell, 35 32 24 21 19 bytes
1..3e4|%{sleep 1mb}
Try it online!
Strangely, the maximum seconds value for Start-Sleep is 2147483. No, I don't know why it's such an odd value. That works out t …
2
votes
Sort and Table a Sentence by Word Lengths
PowerShell, 63 53 bytes
$a=@{};$args|%{$a[$_.length]+=" $_"};$a|% *or|sort N*
Try it online!
(-10 bytes thanks to mazzy)
Takes arguments via splatting, which on TIO manifests as separate comman …