Linked Questions
65 questions linked to/from Tips for Golfing in ECMAScript 6 and above
173
votes
98
answers
70k
views
Tips for golfing in JavaScript
What general tips do you have for golfing in JavaScript? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to JavaScript (e.g. "remove ...
125
votes
110
answers
18k
views
Loading... Forever
Your challenge is to make an infinite loading screen, that looks like this:
Or, to be more specific:
Take no input.
Output Loading..., with a trailing space, but ...
91
votes
119
answers
12k
views
N(e(s(t))) a string
To "function nest" a string, you must:
Treat the first character as a function, and the following characters as the arguments to that function. For example, if the input string was ...
59
votes
100
answers
9k
views
Find the smallest number that doesn't divide N
This challenge is simple enough that it's basically all in the title: you're given a positive integer N and you should return the smallest positive integer which is not a divisor of N.
An example: the ...
52
votes
96
answers
9k
views
Alphabet triangle
You are to print this exact text:
...
47
votes
101
answers
17k
views
Draw an ASCII chess board!
Here is a simple challenge for you: You must produce this ASCII representation of a chess board. White is represented by uppercase characters, and black is represented by lowercase. Empty tiles are ...
53
votes
76
answers
7k
views
Output the alphabet, the ALPHABET, or just a character
The challenge is simple:
Write a function or program that takes an input x, and outputs the lower case alphabet if x is part of ...
46
votes
73
answers
4k
views
Can this number be written in (3^x) - 1 format?
Challenge:
Create a program that accepts a positive integer and checks if it can be written in the form of (3^x)-1, where X is another positive integer.
If it can, output X
If it can't, output -1 ...
44
votes
56
answers
8k
views
Don't give me five!
Question :
You will be given the starting and ending integers of a sequence and should return the number of integers within it which do not contain the digit 5. The ...
33
votes
68
answers
6k
views
Count the divisors of a number
Introduction
This is a very simple challenge: simply count the divisors of a number. We've had a similar but more complicated challenge before, but I'm intending this one to be entry-level.
The ...
27
votes
76
answers
6k
views
Display numbers lacking 2's
Display numbers from one to one-hundred (in increasing order), but number 2 shouldn’t appear anywhere in the sequence. So, for example, the numbers two (2) or ...
38
votes
70
answers
7k
views
Cat goes "Meow"
cat goes "Meow"
We are all familiar with the concept of a cat program. The user types something in, it is echoed back to the ...
36
votes
59
answers
6k
views
Is my barcode valid?
An EAN-8 barcode includes 7 digits of information and an 8th checksum digit.
The checksum is calculated by multiplying the digits by 3 and 1 alternately, adding the results, and subtracting from the ...
44
votes
47
answers
4k
views
Is it a balanced number?
A number is balanced if the sum of the digits on each half of the number is equal, so: 1423 is balanced because 1+4 = 2+3, so is:...
25
votes
67
answers
9k
views
Compare two numbers given as strings
I have a problem at work. I need to compare two numbers that come as strings from two different databases. The numbers may come with leading zeroes and/or leading/trailing spaces. So I may have ...
38
votes
40
answers
4k
views
16-bit binary grid
Given any unsigned 16 bit integer, convert its decimal form (i.e., base-10) number into a 4x4 ASCII grid of its bits, with the most-significant bit (MSB) at the top left, least-significant bit (LSB) ...
52
votes
33
answers
4k
views
Element names above 118
IUPAC in their insufferable wisdom have created a systematic element name for any newly created element. This is the temporary name of an element until they finally make up their minds about an actual ...
49
votes
31
answers
3k
views
Output the first position in your program for each input character
Challenge
Write a non-empty program/function p that, given a non-empty input string s, outputs the position of the first ...
55
votes
25
answers
3k
views
Dennis numbers 2.0
PPCG user and elected mod, @Dennis just became the second ever user to earn over 100k rep!
This is a totally original idea, that I did not get from anybody else, but let's make a challenge based off ...
53
votes
23
answers
3k
views
Rotate the dots
Introductions
A 2×n Boolean matrix can be represented as a string of the four characters . ':.
The string has an "upper row" and a "lower row", with dots ...
30
votes
33
answers
3k
views
Numbers Increase While Letters Decrease
Inspired by this Stack Overflow question: Sorting a list: numbers in ascending, letters in descending. Your task is to solve the following problem and, as this is code-golf, you should do so in as few ...
32
votes
40
answers
4k
views
Am I a Cullen Number?
A Cullen Number is any number that is contained in the sequence generated using the formula:
C(n) = (n*2^n)+1.
Your Task:
Write a program or function that receives an input and outputs a truthy/...
47
votes
15
answers
8k
views
Attack, Decay, Sustain, Release
Sound synthesizers use envelope generators to control how certain parameters of the sound (such as overall loudness) change with time. In many synthesizers an envelope is defined by four parameters, ...
23
votes
41
answers
5k
views
Display a Digital Clock
Display a Digital Clock
(I see there are many clock challenges, I have tried to read them all, I'm pretty sure this is unique)
Write some code that continuously updates a digital clock displayed in ...
51
votes
16
answers
3k
views
Serial voting detection
Stack Exchange automagically detects serial
voting (when one user either
upvotes or downvotes many of another user's posts) and reverses it. In this
challenge, you will implement a very, very simple "...
27
votes
31
answers
3k
views
Reverse and Invert a String
Reverse and Invert a String
Challenge
In this challenge. You'll be writing a program which will output or return the input, reversed and inverted.
First, each character should be converted to its ...
27
votes
29
answers
1k
views
When integers join the queue
Introduction
A queue is an abstract data type where elements are added to the front (enqueue) and removed from the back (dequeue). This is also known as the FIFO (First In First Out) principle.
It is ...
23
votes
29
answers
1k
views
Reverse odd runs
Inspiration.
Task
Reverse runs of odd numbers in a given list of 2 to 215 non-negative integers.
Examples
0 1 → 0 1
...
18
votes
26
answers
2k
views
Is it a valid list?
Given a string like [[[],[[]]],[]], made of only commas and square brackets, your challenge is to determine whether it represents a list.
A list is either:
...
28
votes
20
answers
2k
views
Armistice Day Challenge
Today, November 11th, is known as Remembrance Day, Armistice Day, or Veterans Day (depending upon the country), and is a day of reflection and gratitude for members of the military and their service, ...