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.
0
votes
Calculator that adds char values
K (ngn/k), 2 bytes
+/
Try it online!
In K, a string is basically a list of ASCII char codes, so just the sum adverb will do the job.
2
votes
Draw a battery indicator
C++, 267 bytes
#include<iostream>
#define c std::cin
#define o std::cout
#define h()o<<H<<'\n'
#define L 12
#define H 111111111111
#define M 1
typedef int I;
I main(){I l;c>>l;h();for(I i=0;i<3;i++){o …
1
vote
Shift a string gradually
Ruby, 73 bytes
s,w=gets.split;n=1;s.chars.each{|i|print w[(w.index(i)+n)%w.length];n+=1}
The method used is similar to the reference implementation.
Attempt This Online!
0
votes
Scream very loudly
Ruby, 14 bytes
loop{print"A"}
Attempt This Online!
2
votes
"DDoouubbllee ssppeeaakk!!"
K (ngn/k), 11 bytes
{,/{x,x}'x}
Try it online!
Quick.
Explanation:
{,/{x,x}'x} Main program.
'x For each character in the string...
{x,x} Duplicate the character twic …
1
vote
Sum of Powers of 2
K (ngn/k), 26 bytes
{_0.5+`exp x*`ln 2}'*|=|2\
Try it online!
My first function-less K answer. Port of Xcoder's Jelly answer.
Explanation:
{_0.5+`exp x*`ln 2}'*|=|2\ Main program.
…
3
votes
Product over a range
K (ngn/k), 11 bytes
{*/x+!y-x}
Try it online!
-1 byte thanks to PyGamer0 for telling me that I don't need ' after +
Another easy one. Exclusive at b.
Explainations:
Assuming that a is 2 and b is 5
{ …
2
votes
Simple cat program
Ruby, 6 bytes
p gets
Attempt This Online!
1
vote
Find the first duplicated element
K (ngn/k), 18 bytes
{x@({+/y=x}':x)?1}
Try it online!
A little bit lengthy, but works nonetheless. I still can't fully understand how this even works (especially the counting duplicates section) and …
1
vote
It's Just Rocket Science, Part 2 - Centrifuge
K (ngn/k), 13 bytes
29.9041677%%:
Try it online!
Dead simple. Doesn't display correctly with all numbers correct up to all precision, but that isn't a requirement anyway.
Explanation:
29.9041677%%: …
0
votes
Reverse stdin and place on stdout
K (ngn/k), 2 bytes
|:
Try it online!
Trivial questions got trivial answers. If it wasn't for the Right operator (:) this could be a one-byter though.
K (ngn/k), 5 bytes
`0:|:
Try it online!
This one …
3
votes
Separate a list into even-indexed and odd-indexed parts
K (ngn/k), 21 bytes
{t,x^t:x@&(0=2!)'!#x}
Try it online!
Down 2 bytes thanks to ngn
K (ngn/k), 23 bytes
{t:x@&(0=2!)'!#x;t,x^t}
Try it online!
The old solution is kept because of the explanations.
E …
0
votes
How many arguments were passed?
K (ngn/k), 2 bytes
#:
Try it online!
This is a lame answer, honestly.
2
votes
Bl lu ur rr ry yv vi is si io on - Blur the text
K (ngn/k), 47 bytes
{" "/2':x^"!@#$%^&*()~`_-+={}[]|\:;\"'<>?,./ "}
Try it online!
The window adverb finally got a use for once. Also, removing non-alphanumeric is such a huge pain to write.
Anyways, …
2
votes
Print invisible text
K (ngn/k), 14 13 bytes
{x,(1+#x)#""}
Try it online!
-1 byte thanks to ngn!
Dead simple.
Explanations:
{x,(1+#x)#""} Main function. Takes x as input
x, x concat with
"" …