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.
29
votes
9
answers
3k
views
Spell out numbers in French
There was a challenge to convert a number to its numeral in English, but that was too straightforward. Given a number 0–100, your task is to output the corresponding numeral in French. The French nume …
12
votes
6
answers
862
views
Count the crossing words
Consider the following standard 15×15 crossword puzzle grid.
We can represent this in ASCII art by using # for blocks and (space) for white squares.
# #
# #
# …
2
votes
String to Bit Transition
CJam, 21 bytes
1q{i2b7Te[}%e__(;.^);
Try it online!
Explanation
Showing the stack with a sample input of 5:
1 q e# Push 1 and then the whole input: 1 "5"
{
i e# Convert to its char c …
58
votes
27
answers
4k
views
Expand the number
You may remember in first or second grade using expanded form to learn about place value of numbers. It's easier to explain with an example, so consider the number 123. In expanded form it is represen …
26
votes
26
answers
2k
views
Make a (somewhat) self-referential string
You want to make a string where the (1-indexed) character at index n is n. When n is less than 10, this is easy: "123456789". When n is 12, for example, it becomes impossible, since numbers greater th …
1
vote
ASCII art uncompression from a base-n number
CJam, 11 bytes
liq_,@\b\f=
Try it online! Takes input as the number, then a newline, then the characters in the ASCII art.
Explanation
li e# Read the first line and convert it to an int …
1
vote
How long is this string?
Retina, 3 bytes
s`.
Try it online!
This isn't even technically a built-in function, but it is a central feature of the language: counting matches of a regular expression, in this case . (wildcard …
3
votes
Function clipboard: paste
JavaScript (Node.js), 57 bytes
a=>n=>a.map(e=>e[1]&&a.push(...[...e].reverse()))&&a[n-1]
Try it online!
This is an anonymous, curried function. Run it with ( function code )(clipboard)(n)
Expla …
4
votes
Grouping Array Data
Octave, 24 bytes
@(a,i)@(n)a(a(:,i)==n,:)
Try it online!
This creates an anonymous function that returns a matrix whose rows match the criteria. Octave indexes arrays at 1, not zero, and rows of …
0
votes
Grouping Array Data
JavaScript (Node.js), 29 bytes
a=>i=>n=>a.filter(e=>e[i]==n)
Try it online!
Updated now that I realize the loose output requirements. This uses currying as a golfing technique, and it also retur …
1
vote
The Ever-Increasing Graph
JavaScript (Node.js), 98 bytes
a=>m=>(r=[],b=[],a.map((e,i)=>e<a[--i]?(b[p](m+e),r[p](b),b=[a[i]-m,e]):b[p='push'](e)),r[p](b),r)
Try it online! This is quite a bit longer than the other JS answe …
5
votes
Is this a consecutive-prime/constant-exponent number?
CJam, 30 29 bytes
{mFz~)-!\__W=,\0=>\-:mp1#W=&}
Try it online!
My first answer after a nearly 2(!)-year break, so it can probably be golfed more. This is a block that takes input as an integer (ca …
63
votes
Do you want to code a snowman?
JavaScript ES6, 210 208 202 bytes
s=>` 0
8(213)9
4(6)5
(7)`.replace(/\d/g,p=>`_===_1 ___
.....1 _
/_\\1 ___
(_*_)1,1.1_11.1o101-1.1o101-1<11/11>11\\11 : 1] [1> <1 1 : 1" "1___1 11\\11 11/11 …
5
votes
The Letter A without A
Sesos, 3 bytes
The code contains two unprintable characters, so here is a hexdump:
0000000: a85a0d .Z.
Try it online! (Note that this uses the assembly c …
77
votes
Generating a single string with an Oxford comma from a list
CSS, 132 116 115 bytes
a:not(:last-child):nth-child(n+2):after,a:nth-last-child(n+3):after{content:","}a+:last-child:before{content:"and "
<p>
<a>one</a>
</p>
<p>
<a>one</a>
<a>two</a …