instruction stringlengths 34 53.1k |
|---|
Challenge
Write code which, given an image of a panel from a random xkcd comic, returns a truthy value if Blackhat is in the comic or falsey if not.
Who is Blackhat?
Blackhat is the unofficial name given to the character in xkcd comics who wears a black hat:
Taken from the Explain xkcd page on Blackhat
Blackhat's hat ... |
Within the recesses of Unicode characters, there exists a Unicode block of (currently) 63 characters named "Number Forms", which consists of characters that have numerical values such as the roman numeral Ⅻ, vulgar fractions like ⅑ or ↉, or weird ones like ↊ (10) or ↈ (100000).
Your task is to write a program or functi... |
TeaScript is a powerful JavaScript golfing language created by StackExchange, PPCG, user Downgoat. TeaScript compiles to JavaScript and contains many helpful features for golfing
This question is to list some TeaScript golfing tips
|
Create a program (any language) which, given positive integer m, outputs a valid C expression that:
Uses a single variable x assumed of 32-bit unsigned type (i.e. uint32_t)
Would evaluate to range [0, m) for any of the 2³² possible x, reaching any of the m possible outcomes either 2³² / m or 2³² / m + 1 times (where /... |
In elementary school, children learn about proper fractions, where the numerator is less than the denominator, and thus the value of the fraction is less than one. Later, they are taught about fractions where the value of the fraction is greater than one, and two different ways to express these fractions: mixed fractio... |
In a now deleted stackoverflow question, someone posted the following:
Write a program or function to print alternating patterns in * and # based on a given integer n. Some examples:
Input: n=1
Output:
*
Input n=5
Output:
*####
###**
***##
###**
*####
Input: n=8
Output:
*#######
######**
***#####
####****
****####
##... |
It's Christmas in July, so what better way to celebrate than a virtual white elephant gift exchange!
For this King of the Hill challenge, you must create a bot that plays in a White Elephant exchange simulation, trying to get the highest-valued present it can.
Game Rules
The game will be played over many rounds, each ... |
Challenge
Given a list of integers and a velocity, \$v\$, implement a sorting algorithm which simulates a program sorting the list from smallest to biggest at the given velocity.
Einstein's Theory of Special Relativity
What do I mean? Well assume your program takes a time, \$T\$, to sort a particular list. If you ran t... |
An office (let's call it "The Office") is going to cut down on wasted time in 2019 by consolidating office birthday parties. Any two people with a birthday between Monday and Friday (inclusive) of the same week will be celebrated with a Shared Birthday Party some time that week. People whose birthdays fall on a Saturda... |
Most tip calculator apps simply take a flat percentage of the meal price. So, for example, if your meal is $23.45, you can leave a 15% tip = $3.52, or a more generous 20% tip = $4.69.
Convenient enough for credit card users. But not so if you prefer to leave cash tips, in which case these oddball cent amounts get in ... |
It's likely that anyone who used Twitter a couple of months ago would know about the 'Howdy! I'm the sheriff of X" meme. Where a simple image of a sheriff is drawn with emoji, and changes to fit a theme. So I thought it was time for the Sheriff of Code Golf. Here he is:
###
#####
###
###
###
#
... |
Related: Name the poker hand
A straight flush is a poker hand containing five cards of sequential rank, all of the same suit. As part of a straight flush, an ace can rank either above a king or below a two. An ace can rank either high (e.g. A♥ K♥ Q♥ J♥ 10♥ is an ace-high straight flush) or low (e.g. 5♦ 4♦ 3♦ 2♦ A♦ is ... |
I can't believe we don't have this already.. It's one of the most important data-structures in programming, yet still simple enough to implement it in a code-golf:
Challenge
Your task is to implement a stack that allows pushing and popping numbers, to test your implementation and keep I/O simple we'll use the following... |
This is a 2-dimensional version of this question.
Given a non-empty 2-dimensional array/matrix containing only non-negative integers:
$$ \begin{bmatrix}
{\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} & {\color{Red}0} \\
{\color{Red}0} & {\color{Red}0} & 0 & 1 & 0 \\
{\color{Red}0} & {\color{Red}0} & ... |
Time sheets
In a work place you often have to complete time sheets. This task is write code to help this.
Input
Two times in a slightly non- standard 12 hour clock signifying the start and end of the day separated by a space. A third number represents the number of minutes taken for lunch. For example
9:14 5:12 30
Th... |
This is a code golf version of a similar question I asked on stack earlier but thought it'd be an interesting puzzle.
Given a string of length 10 which represents a base 36 number, increment it by one and return the resulting string.
This means the strings will only contain digits from 0 to 9 and letters from a to z.
B... |
421 is a rather popular dice game in France and some other European countries. It is mostly played in bars and pubs to determine who's going to buy the next round of drinks. The full game is usually played in two rounds, with tokens that each player tries to get rid of, but this is irrelevant here. (Wikipedia page in F... |
Motivation: Sometimes certain items in a list don't count towards your totals. For example, counting plane passengers in rows, where babies sit on a parent's laps.
Challenge: write a program to split a list of items into chunks. Each chunk (except possibly the last) is the same size, where size is defined as the number... |
Display the remaining battery charge, as a percentage of maximum charge
Remember if you can't run your code on a phone, calculator, etc, you can probably install your environment on a laptop at least. If you absolutely can't run on a device that has a battery, then unfortunately your language isn't eligible since you h... |
Related: Calculate Power Series Coefficients
Given a positive integer \$X\$ and a max exponent (Also a positive integer too) \$N\$ calculate the result of a power series. Example:
$$X^0+X^1+X^2+\cdots +X^N$$
Assume \$(X + N) \le 100\$
Test Cases
1 2 => 3
2 3 => 15
3 4 => 121
2 19 => 1048575
Standard code-golf ... |
We define a tree-like list, or trist for short, as the empty list or a list containing only previously constructed trists.
The natural numbers can either include 0 or not, according to your preference.
The task is to create a pair of functions or complete programs f and g (they don't have to be named like this or even ... |
The matrix tornado is just like any other tornado: it consists of things rotating around a center. In this case, elements of the matrix instead of air.
Here is an example of a matrix tornado:
First we start by sectioning the matrix into square rings, each section consists of elements that are farther away from the bor... |
I'm a musician, and I need more polyrhythms in my life!
A polyrhythm occurs in music (and in nature) when two events (claps, notes, fireflies flashing etc.) are occurring at two different regular intervals. The two kinds of event happen a different number of times in the same interval.
If I tap with my left hand twice,... |
Description
Imaginary programming language (IPL) uses Polish Reverse Notation. It has the following commands:
i -- input number and push it to the stack
o -- non-destructive output top of the stack (number stays on the stack)
d -- discard top of stack
integer number -- push this number to the stack
+-* -- pop two num... |
Introduction
In number theory, a number is considered evil if there are an even number of 1's in its binary representation. In today's challenge, you will be identifying whether or not a given number is evil.
Challenge
Your job is to write a full program or function which accepts a single, non-negative integer as input... |
Non-associative operators (for example the subtraction-operator) often are either left- or right associative, such that one has to write less parentheses. Consider for example the following:
$$
a-b-c
$$
Probably everybody read that as \$(a-b)-c\$, by default (usually) subtraction is left-associative.
Now let us conside... |
We call a parens group the open paren (, its matching close paren ) and everything inside them.
A parens group or string is called parenthesly balanced if it contains either nothing or only 2 parenthesly balanced parens groups.
For example:
The string "(()())()" is parenthesly balanced
( )() ... |
You are chained to a chair. Underneath you is a huge volcano. A 12-hour clock next to you ticks ominously, and you see that it has wires leading from the back up to a chain, which will drop you into the center of the earth. Taped to the clock is a note:
Each clock hand has an electrode. When both clock hands are in th... |
NOTICE: This challenge is now closed: I will no longer be updating the leaderboard and will not change the accepted answer. However, you are free to run the controller and update the leaderboard yourself, if you wish.
Join the chat!
Introduction
Good evening, traders! You are all traders for the golfing company PPCG.... |
Sandbox post (deleted)
The old roman army formations are very famous around the world. In these formations roman legionaries grouped in a geometric shape (usually a rectangle) protecting the flanks and the superior part of it using their shields. The legionaries at interior positions covered the superior part placing t... |
I'm trying to get the shortest way (character possible) to obtain List 3.
List 1 and List 2 are already given to me as arguments and are the same length.
l1 = [1, 2, 3, 4, 5]
l2 = ['a', 'b', 'c', 'd', 'e']
And List 3 should look like (yes, it needs to be a list):
l3 = ['a', 1, 'b', 2, 'c', 3, 'd', 4, 'e', 5]
|
Introduction
I have some JavaScript code that uses Array.prototype.map to map an array of functions fns to their return values:
const fns = [() => 1, () => 2];
const result = fns.map(
fn => fn()
);
console.log(result); // => [1, 2]
Challenge
The argument to map above is fn => fn(). The challenge is to rewrite th... |
Input
A non-empty binary matrix consisting of 3x3 sub-matrices put side by side.
Task
Your task is to identify valid dice patterns (as described below) among the 3x3 sub-matrices. Each valid pattern is worth the value of the corresponding dice. Invalid patterns are worth 0.
Output
The sum of the valid dice values.
Dice... |
Goal
Given a deal result from Duplicate Contract Bridge, calculate the deal score.
Basically the same as iBug's question, which was deleted. I figured out this scoring system while trying to answer that question.
Input
Input is a deal result, and whether or not the declaring side is vulnerable.
The deal result is a str... |
A Geiger counter is a device that is used to detect radiation.
We will be making a Geiger counter program.
As we all know, when radiation hits a computer program it removes exactly 1 byte at random. So a Geiger counter program is a program that itself does nothing, but when any byte is removed the modified program pri... |
You will be given a sequence of memory requests and a cache size. You must return the least possible number of cache misses under any cache replacement strategy.
An optimal strategy is Belady's algorithm, which you can use if you want to.
A caching system works as follows: The cache starts out empty. Memory requests c... |
This challenge is based on a sandbox post by user48538. Since he is no longer active on this site, I took over this challenge.
apgsearch, the distributed soup search program for Conway's Game of Life and the search results database, Catagolue use apgcodes to classify and denote patterns. apgcodes themselves use the ex... |
Challenge
Given a positive integer \$n\$, output the \$n\$-dimensional pyramidal list.
Example
\$n = 1\$:
Objects arranged in a 1D pyramid (line) with side length 1 is just by itself.
So, the output is {1}.
\$n = 2\$:
Objects arranged in a 2D pyramid (a triangle) with side length 2 would have one on the first row (... |
I was in the bus today, and noticed this sign:
seated standing wheelchairs
max1 37 30 00
max2 36 26 01
max3 34 32 00
The number of seated passengers, standees, and wheelchairs all have to be no larger than some row in the table. (See chat fo... |
Topically related.
Objective: Given a matrix of positive integers \$M\$, output the smallest centrosymmetric matrix which contains \$M\$ (this matrix may contain non-positive integers as well).
A centrosymmetric matrix is a square matrix with rotational symmetry of order 2—i.e. it remains the same matrix after rotating... |
Not to be confused with Least Common Multiple.
Given a list of positive integers with more than one element, return the most common product of two elements in the array.
For example, the MCM of the list [2,3,4,5,6] is 12, as a table of products is:
2 3 4 5 6
---------------
2 | # 6 8 10 12
3 | # # 12 15 ... |
We've got quite a few national flag challenges already:
AU
CH
FI
FR
GB
GB
IS
KR
NP
US...
Here's another, somewhat more advanced one:
Return or print the decorative pattern from Belarus's national flag as a matrix of two distinct values for red and white.
If your language doesn't support matrices, use a list of lists o... |
I came across this picture, which I initially questioned and thought about posting to Skeptics. Then I thought they'll only tell me if this one case is true, but wouldn't it be great to know how true any "rule" really is? Today you're going program a skeptic-bot
Challenge
Write a program or function which when given a ... |
Naismith's rule helps to work out the length of time needed for a walk or hike, given the distance and ascent.
Given a non-empty list of the altitude at points evenly spaced along a path and the total distance of that path in metres, you should calculate the time needed according to Naismith's rule.
Naismith's rule is ... |
We define \$V(x)\$ as the list of distinct powers of \$2\$ that sum to \$x\$. For instance, \$V(35)=[32,2,1]\$.
By convention, powers are sorted here from highest to lowest. But it does not affect the logic of the challenge, nor the expected solutions.
Task
Given a semiprime \$N\$, replace each term in \$V(N)\$ with an... |
Given the name of a cation and anion, output "S" (soluble) or "I" (insoluble). The table we will be using is from wikipedia: https://en.wikipedia.org/wiki/Solubility_chart. It is copied at the end of the question for future reference.
Input: The cation, followed by the anion, separated by a space. The cation will be on... |
I'm surprised that this challenge isn't already here, as it's so obvious. (Or I'm surprised I couldn't find it and anybody will mark it as a duplicate.)
Task
Given a non-negative integer \$n\$, calculate the sum of the first \$n\$ primes and output it.
Example #1
For \$n = 5\$, the first five primes are:
2
3
5
7
11
... |
write a function to tell if a number is symmetric or not.
for example:
input:
151
output:
True
input:
142
output:
False
and so on:
1111 True,
2390 False,
1226221 True
|
Inspired and looted from this dice challenge by Arnauld
Input
You are given a 5x1 or 1x5 (your choice) dice matrix which consist of binary 3x3 sub-matrices.
Goal
Given a valid dice matrix, you are to score it using the rules of 6,5,4 which are as follows:
If the roll contains 6,5,4, add the other two dice together and... |
Introduction
On March 24th, 2015 @isaacg golfed his Pyth answer from 44 to 42 bytes. Since a crossed out 44 (44) looks a lot like a regular 44, @Optimizer made the following comment:
striked out 44 is still normal 44 :(
After that, on October 21st, 2015, @Doorknob♦ golfed his Ruby answer from 44 to 40 (and later 38) ... |
When you roll a die, you have a 6:1 chance of any given option.
There's a bookmaker taking bets on die rolls. He owns £20 at the start of the game.
The bookmaker offers odds of 4:1, but gamblers take it, because there's money on offer.
There are 10 gamblers. A, B, C, D, E, F, G, H, I, and J. Each gambler owns 10 pounds... |
Challenge
We take three positive integers a, b, and c as input. Using these integers, first create a sequence in the range [0, c] (inclusive on both ends), in steps of b. For example, for a=4, b=2, c=100, the sequence would be [0,2,4,...,96,98,100].
For every number in this sequence which is divisible by a, replace it ... |
Challenge
Write a program that greets a user depending on what time of day (GMT) it is.
Output
A string (printed or returned) according to these rules:
If the time is 06:00 to 11:59 the greeting has to be "Good morning"
If the time is 12:00 to 17:59 the greeting has to be "Good afternoon"
If the time is 18:00 to 19:5... |
Note: The survey for community favorite will be released soon
In this KoTH, the aim is to be the last bot alive. Coins will be placed in random areas, and your bot must get the coins first. If a bot runs into another bot, the bot with more coins wins, and the other bot dies. More details below.
Coin types
There will ... |
Given an integer \$N>3\$, you have to find the minimum number of bits that need to be inverted in \$N\$ to turn it into a square number. You are only allowed to invert bits below the most significant one.
Examples
\$N=4\$ already is a square number (\$2^2\$), so the expected output is \$0\$.
\$N=24\$ can be turned int... |
In 1.13, Minecraft language files were switched from being a simple multi-line key=value format to JSON.
Challenge
Write a program converting from the original format returning a JSON string. Input can be taken using any standard input method, output must be json from any standard output method
The original format cont... |
Display the 12 numbers on a clock face exactly like this:
12
11 1
10 2
9 3
8 4
7 5
6
To better see the grid, here's one with dots:
...........12............
.... |
Quine Relay!
A quine relay of order \$n\$ is a series of programs \$P_1\dots P_n\$ in distinct languages such that each program \$P_i\$ outputs \$P_{i+1}\$ and \$P_n\$ outputs \$P_1\$.
For example, a 2-quine relay can be seen here:
Ruby → Perl 6:
This Ruby program:
$><<"print ("
p (DATA.read*2).chars.map(&:ord)
$><<".m... |
Your goal is to determine whether a given number n is prime in the fewest bytes. But, your code must be a single Python 2 expression on numbers consisting of only
operators
the input variable n
integer constants
parentheses
No loops, no assignments, no built-in functions, only what's listed above. Yes, it's possible... |
It's been a while since I posted here, so here we go another day another challenge.
Challenge :
Given a number(n) split it into it's prime factors.
Input :
A positive non-zero integer greater than 2.
Output :
Decompose the number into it's prime factors and return the number of occurances of each prime in it.
Ouput... |
Background
This challenge is inspired by this website, which published the following diagram:
This diagram shows us that the longest Roman Numeral expression under 250 is that of 188, which requires 9 numerals to express.
Challenge
The standard symbols used to express most Roman Numerals are the following: {I, V, X, L... |
Back to back challenges I guess. Hopefully this one is more clear than the last.
Background
I was playing around with Goldbach's conjecture, and decided to plot evens (on the x-axis) vs the number of ways that two primes could be found to sum to a given even on the y axis.
The two plots I've made below in Python are fo... |
The reverse-then-add (RTA) sequence is a sequence obtained by adding a number to its reverse, and repeating the process on the result. For eg.,
$$ 5 + 5 = 10 \Rightarrow 10 + 01 = 11 \Rightarrow 11 + 11 = 22 \Rightarrow 22 + 22 = 44 \Rightarrow\text{ }... $$
Thus, 5's RTA sequence contains 10, 11, 22, 44, 88, 176, et... |
In chess, a knight can only move to the positions marked with X relative to its current position, marked with ♞:
A Knight's Graph is a graph that represents all legal moves of the knight chess piece on a chessboard. Each vertex of this graph represents a square of the chessboard, and each edge connects two squares th... |
Let \$L\$ be a list of positive integers with no particular ordering, and which can contain duplicates. Write a program or function which outputs a list of positive integers \$M\$ (whose ordering is unimportant) such that merging \$L\$ and \$M\$ results into the smallest list which can entirely split into identical ran... |
Challenge
Given an ASCII representation of a Babylonian number as input, output the number in Western Arabic numerals.
Babylonian Numeral System
How did the Babylonians count? Interestingly, they used a Base 60 system with an element of a Base 10 system. Let's first consider the unit column of the system:
The Babylonia... |
Given the Dowker notation of a knot and its crossing signs, calculate its bracket polynomial.
Although there are more technical definitions, for this challenge it is enough to think of a knot as something made physically by attaching the two ends of a string together. Since knots exist in three dimensions, when we draw... |
Consider the following alphabetically sorted list of words:
balderdash
ballet
balloonfish
balloonist
ballot
brooding
broom
All of the words start with b, and the first 5 start with bal. If we just look at the first 2 words:
balderdash
ballet
we could write instead:
balderdash
+let
where the ' ' is used where a wor... |
The Hamming distance between two strings of equal length is the number of positions at which the corresponding characters are different. If the strings are not of equal length, the Hamming distance is not defined.
Challenge
Write a program or function that finds the largest Hamming distance from among all pairs of str... |
Introduction:
(Source: Wikipedia)
When we look at a rainbow it will always have the colors from top to bottom:
Red; orange; yellow; green; blue; indigo; violet
If we look at these individual rings, the red ring is of course bigger than the violet ring.
In addition, it's also possible to have two or even three rainbow ... |
Introduction:
(Source: Wikipedia)
When we look at a rainbow it will always have the colors from top to bottom:
Red; orange; yellow; green; blue; indigo; violet
If we look at these individual rings, the red ring is of course bigger than the violet ring.
In addition, it's also possible to have two or even three rainbow ... |
Honestly, I can't believe this hasn't already been asked, but here it is
Background
Given a simple undirected planar (the graph can be drawn in the plane without intersections) graph, it is a proven theorem that the graph is 4-colorable, a term we will explore in a bit. However, it's far easier to 5-color a graph, whic... |
There is a job which can be decomposed into x equally-sized smaller tasks. You have a team of size y <= x, where every member works equally fast on any task. The goal for this challenge is to divide the work as evenly as possible such that every member of your team has at least 1 task to perform. As evenly as possible ... |
The Onion (warning: many articles are NSFW) is a satirical news organization that parodies traditional news media. In 2014, The Onion launched ClickHole (warning: also frequently NSFW), a satirical news website that parodies "clickbait" sites like BuzzFeed. Thanks to Poe's Law, it's fairly common for people to read the... |
Leonardo of Pisa (ca. 1175 - ca. 1245) is better known as Fibonacci. But this is actually a short for the Latin "filius Bonacci" (the son of Bonacci) which was made up during the 18th century (according to Wikipedia).
In this challenge, you'll be given an ordinal number (in the literal sense) between 1st and 20th and y... |
Introduction
Given an undirected graph G, we can construct a graph L(G) (called the line graph or conjugate graph) that represents the connections between edges in G. This is done by creating a new vertex in L(G) for every edge in G and connecting these vertices if the edges they represent have a vertex in common.
Here... |
The powers that be want to be able to quickly convert any number they have into their own number base using any format they would like.
Input
Your program must accept 3 parameters.
Number: The string number to be converted
InputFormat: the base string the number is currently in
OutputFormat: the base string that the ... |
Introduction:
After I posted two rainbow-related challenges: Codegolf Rainbow : Fun with Integer-Arrays 1 and Codegolf Rainbow : Draw in Black-and-White 2, the following comment was made by @ChrisM in the ASCII (Draw in Black-and-White) challenge:
Maybe you know this and it's by design (I know that rainbows are not rh... |
Given a positive integer, we can form a new number that's described by its digits taken pairwise (with a leading 0 added for numbers with odd number of digits).
For eg.:
1234 can be read as one 2, three 4s - so, the output for 1234 is 2444.
643 has an odd number of digits, so a leading zero is added to make it even.... |
Background
Consider the following sequence (A051935 in OEIS):
Start with the term \$2\$.
Find the lowest integer \$n\$ greater than \$2\$ such that \$2+n\$ is prime.
Find the lowest integer \$n'\$ greater than \$n\$ such that \$2 + n + n'\$ is prime etc.
A more formal definition:
$$a_n=\begin{cases}2 & \text{if }n=0 ... |
A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral:
Your task is to find out the number in row y and column x.
Example:
Input: 2 3
Out : 8
Input: 1 1
Out : 1
Input: 4 2
Out : 15
Note:
Any programming language is allowed.
This is a code-golf cha... |
Your goal is to write a program or function that takes in as input a string representing the path to a file, and outputs a truthy value if that file is not empty and contains no non-null bytes -- i.e., all bits are 0 -- and a falsey value otherwise.
I realize it is a very simple problem and I guess I could hack
somethi... |
As the title may suggest, this problem is semi-inspired by the Polite Near-Sighted Drunk Bot by @N.P.
Our poor bot is placed on a cartesian grid at the origin, and after each minute, it moves 1 unit in one of four directions (Up, Down, Left, Right).
After n minutes, all of the latent mines on the grid activate, killin... |
Given a string of text, output it as a 'tower'.
Each slice of the string (of the form 0:n) is repeated 5*n times, so the first character is repeated 5 times, then the first and the second 10 times, etc.
Examples:
'hello' ->
['h']
['h']
['h']
['h']
['h']
['h', 'e']
['h', 'e']
['h', 'e']
['h', 'e']
['... |
Entries are now closed. Any new entries or edits will not be counted in the final run.
Join the chat!
Challenge
Try to fill the canvas with as much paint as possible. Be careful of other bots that may paint over your hard work though!
Note: In this challenge description, paint means to change the colour of the squar... |
Given an integer greater than 1, output the number of ways it can be expressed as the sum of one or more consecutive primes.
Order of summands doesn't matter. A sum can consist of a single number (so the output for any prime will be at least 1.)
This is code-golf. Standard rules apply.
See this OEIS wiki for related i... |
Given an ordered list of same-case letter strings (a-z XOR A-Z) where each string is preceded by 0 or more space ( ) characters, output the same list but with the strings sorted at each level of indentation. Indentation depths under different parents count as distinct lists for sorting purposes.
Example
If your input i... |
When we publish some software, we assign a version number to it. And users may want to update to the latest version of some software. So, it is the time to find out which version should be newer.
Input
Input two version numbers as strings.
In the context of this challenge, we only support version numbers which are some... |
Okay, so I saw this in a meme and decided it'd be the perfect code golf challenge:
I prefer to increase the side of my indents according to the Fibonacci sequence:
class Kls
def method
t = Time.now
if t.hour >= 12
puts "It's afternoon"
if t.hour == 18
puts "It's time for your meal of:"
%w(bre... |
Given a large number (in base 10), such as 1234567891011121314151617, find prime "subnumbers" in it.
A prime "subnumber" is a consecutive sequence of digits (taken from the input), which represents a prime number (in base 10).
Input:
A number (either a string, a file, or whatever you like).
Output:
All prime subnumb... |
Sandbox Post
Intro
The information panels are everywhere. When the technology became cheaper, the paper posters were transformed into luminous signs that show words that appear on one side and come out on the other, like the one on the figure:
When one of these signs starts up, it usually starts empty and the text lea... |
Introduction
There is a group of people that have to cross a rickety bridge that can only support two people at a time. It is a dark and foggy night, but unfortunately, the group only has one lamp. The bridge must be crossed by an individual or pair that is holding the lamp. When a pair is traveling together, they must... |
Background
I like my old 8-bit 6502 chip. It's even fun to solve some of the challenges here on PPCG in 6502 machine code. But some things that should be simple (like, read in data or output to stdout) are unnecessarily cumbersome to do in machine code. So there's a rough idea in my mind: Invent my own 8-bit virtual ma... |
ProSet is a classic card game that is played normally with 63 cards. One card has 6 colored dots on it, like below
The rest of the cards are missing some of these 6 dots, but each card has at least 1 dot. Every card in the deck is different. Below are some example valid cards.
A ProSet is a nonempty set of cards such... |
Gomoku or Five in a row is a board game played by two players on a \$15 \times 15\$ grid with black and white stones. Whoever is able to place \$5\$ stones in a row (horizontal, vertical or diagonal) wins the game.
Rules
In this KoTH we'll play the Swap2 rule, meaning that a game consists of two phases: In the initial ... |
Influenced by Non-discriminating Programming, I made up an idea of a similar challenge.
Here, we say a string is a Lucas string if the number of appearances of each character is a Lucas number (2, 1, 3, 4, 7, ...), and a string is a Fibonacci string if the number of appearances of each character is a Fibonacci number (... |
New to code golf and enjoying it. I have a problem that I cannot figure out and am curious if others can solve it.
Start with two dictionaries, y and z:
y = {'a': 1, 'c': 3, 'e': 5, 'g': 7}
z = {'b': 2, 'd': 4, 'f': 6, 'h': 8}
y and z both map length-1 strings to numbers, where each number is between 1 and 26 (inclusi... |
Inspired by this post over on Puzzling. Spoilers for that puzzle are below.
Given three positive integers as input, (x, y, z), construct the inclusive range [x, y], concatenate that range together, then remove z not-necessarily-consecutive digits to produce the largest and smallest positive integers possible. Leading z... |
Related
Goal:
Given two creatures with optional combat abilities, return unique but consistent values that represent which creatures died, if any.
Input:
#Longest form:
[[P,T, "<abilities>"], [P,T, "<abilities>"]]
#Shortest form:
[[P,T], [P,T]]
Each creature will be given in the form of [P,T,"<abilities>"]. It will be... |
As I'm applying for some jobs whose job advert doesn't state the salary, I imagined a particularly evil interviewer that would give the candidate the possibility to decide their own salary ...by "golfing" it!
So it goes simply like that:
Without using numbers, write a code that outputs the annual salary you'd like to ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.