instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
I have written a few challenges related to matrices, and common for all are that I use a format like the one below when representing the matrices, both in examples and in test cases:
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
This is likely a cumbersome format in many languages.
Challenge... | stackexchange_codegolf |
Background:
In finance, the binomial options pricing model (BOPM) is the simplest technique used for option pricing. The mathematics behind the model is relatively easy to understand and (at least in their basic form) it is not difficult to implement. This model was first proposed by Cox, Ross, and Rubinstein in 1979. ... | stackexchange_codegolf |
Background
Inspired by a now deleted question by John Burger from which I quote:
Now obviously no human made this mistake. It's a mis-decode of something - perhaps the ISBN? My question is: does anyone know of an existing algorithm that was so messed up it would invent an entirely new calendar?
TFeld ingeniously com... | stackexchange_codegolf |
Your challenge, should you choose to accept it, is, given an integer K >= 1, find non-negative integers A and B such that at least one of the two conditions following hold:
K = 2^A + 2^B
K = 2^A - 2^B
If there does not exist such A and B, your program may behave in any fashion. (To clarify, A and B can be equal.)
Te... | stackexchange_codegolf |
Logic gates are functions which perform basic logic operations. In this problem, we will account for the following 6 logic gates: AND, OR, XOR, NAND, NOR, and XNOR. Each of these takes two boolean inputs \$ a \$ and \$ b \$, and outputs a boolean. Below are the truth tables which show the output of each gate given two ... | stackexchange_codegolf |
Your task is, given a family tree, to calculate the Coefficient of Inbreeding for a given person in it.
Definition
The Coefficient of Inbreeding is equal to the Coefficient of Relationship of the parents. The Coefficient of Relationship between two people is defined as weighed sum over all common ancestry as follows:
E... | stackexchange_codegolf |
It's lunch time, I am hungry and I came to your Sushi Bar. You are the Sushi Chef and you have to produce a full program or function to make me some sushi!
Credits: Wikipedia
Disclaimer: The image is for illustration purposes only and do not necessarily represent the exact product.
Although you have limited ingredien... | stackexchange_codegolf |
Input: from STDIN number of vertices in Graph \$2 \leq N \leq 100\$.
Rules: [Code size] = max ([code length without spaces, tabs and newlines], [total code length divided by 4])
Math formulation: In the graph of N vertices, between each pair of vertices can be 3 road states:
there is no road
there is a road from A to ... | stackexchange_codegolf |
A Belphegor number is a number of the form \$(10^{n+3}+666)*10^{n+1}+1\$ (1{n zeroes}666{n zeroes}1) where \$n\$ is an non-negative integer. A Belphegor prime is a Belphegor number that is also prime.
The \$n\$ values of the first few Belphegor primes are 0, 13, 42, 506 (A232448)
Task
Write a program that either:
take... | stackexchange_codegolf |
You will be given a point (x,y) relative to the center of the Ulam spiral (the center being the point which represents one), and length z. The task is to check whether there exists a path from (0,0) to (x,y) of length z, assuming prime numbers are obstacles and each turn in path has an angle of 90 degrees. Path may not... | stackexchange_codegolf |
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... | stackexchange_codegolf |
In the game Terraria, one of the game mechanics involves building houses so that an NPC can move in. There is a strict set of rules for what counts as a valid house or not. Here is the list of rules:
The total area in the house must be at least 60 square tiles, but less than 750. Also, the size of the house including ... | stackexchange_codegolf |
Columnar Transposition Cipher
While I have plenty of programs I have written for more advanced ciphers, I just realised I don't actually have one for one of the simplest: Columnar Transposition. The cipher, in case you don't know, works as follows:
First, you take the key, and write it as numbers. The numbers are made... | stackexchange_codegolf |
There are n boxes, numbered 1-n. Each box is locked, such that it can be opened by only one corresponding type of key (also numbered 1-n). These keys are randomly scattered in the boxes (one box may have any number of keys, one key may have any number of duplicates), and then all boxes are shut. A treasure (numbered 0)... | stackexchange_codegolf |
This challenge will have you count pseudo-polyforms on the snub square tiling.
I think that this sequence does not yet exist on the OEIS, so this challenge exists to compute as many terms as possible for this sequence.
Update: this is now on the OEIS as A309159: Number of generalized polyforms on the snub square tiling... | stackexchange_codegolf |
“Cut” a matrix of integers on the line where the sum of the absolute differences of “severed” neighbors is the least.
Example
Consider this matrix:
1 2 -4
5 -1 3
2 -2 0
It can be cut in 4 places, here shown by lines lettered A–D:
A B
╷ ╷
1 ╎ 2 ╎ -4
C ---╎----╎----
5 ╎ -1 ╎ 3
D ---╎----╎--... | stackexchange_codegolf |
Paper stars are a big thing in my family at christmas, so I thought a virtual one would be cool.
Below is an image of a regular dodecahedron (from https://en.wikipedia.org/wiki/Dodecahedron, attributed to the author mentioned there.)
The process of stellation (wikipedia) when applied to a polyhedron involves extending... | stackexchange_codegolf |
Input: Either one or two strings consisting of '0's and '1's. If there are 2, they are separated by a space. All strings are of length at least 1.
Output:
If a single input was given as input, 2 are output.
If 2 were input, 1 is output.
The output strings can be whatever you like, but if running your program with i... | stackexchange_codegolf |
Gematria is an ancient Jewish method to determine a numeric value of a letter sequence, using a fixed value for each letter. Gematria is originally applied to Hebrew letters, but for the context of this challenge, we'll use Latin script instead. There are many ways to implement Gematria in Latin script, but let's defin... | stackexchange_codegolf |
Consider an \$n \times n\$ grid and a circle of radius \$r \leq \sqrt{2} n\$ with its center in the top left. In each square there is an integer from the range -3 to 3, inclusive. For a given radius, there is a set of squares in the grid which are not at least half covered by a circle of radius \$r\$ but are at least ... | stackexchange_codegolf |
The idea of this is mainly from BIO 2017 q1. I got the idea for posting this challenge from my Binary Sequences challenge, since lots of people seemed to like it.
Also, this is the first challenge I've posted without posting on the sandbox. I'll delete it if no one likes it.
Rules
Take in a sequence of digits in ternar... | stackexchange_codegolf |
Philosophers have long pondered the Trolley problem. Unfortunately, no human has solved this problem yet. Luckily, as programmers we can use computers to solve the problem for us!
Input
Your program will take as input a (finite) directed graph (with at most one edge from x to y, for any x and y), with a designated nod... | stackexchange_codegolf |
It seems that any Simple Modification of deltas using a consistent function can almost always be done some other shorter way, Dennis.
Thus, the only solution I can imagine to make this harder, is to introduce some sort of inconsistent function.
Sorting.
Your task is to take an array of integers, sort their deltas, and ... | stackexchange_codegolf |
This is a challenge to write bots to play the 1st and 2nd players in the following simple poker game.
Rules of the poker game
There are two players, A and B. Each antes $10 into the pot, and is dealt a card, which is a real number in the range [0, 1).
Player A goes first, and may pass or bet. If A passes, then there is... | stackexchange_codegolf |
I just created a language on the spot, and it's called "interpreter". Called as such because the only valid word is "interpreter"!
A sample program in "interpreter" looks like this:
interpreter interpreterinterpreter interpreterinterpreterinterpreter interpreterinterpreterinterpreterinterpreter interpreterinterpreterin... | stackexchange_codegolf |
Note: this problem was inspired by the Unsolved Mathematical Problems for K-12 youtube video, which also features other interesting puzzles.
From the wikipedia article:
The no-three-in-line problem asks for the maximum number of points that can be placed in the n × n grid so that no three points are collinear ..... Al... | stackexchange_codegolf |
In the PPCG chatroom the Nineteenth Byte, using carets ^ (or carrots) is a way of indicating that you agree with one of the previously made comments just above yours.
A caret message consists solely of N ^ characters (where N is a positive integer) and it means agreement with the Nth previous message. So a single ^ mea... | stackexchange_codegolf |
In chess, the queen piece can move arbitrarily far in each cardinal and intercardinal direction. What does this mean? Well, I'll show you with an ASCII drawing:
\..|../
.\.|./.
..\|/..
---Q---
../|\..
./.|.\.
/..|..\
It means the queen (notated as Q) can move along these lines (notated as \, |, /, and -), and cannot r... | stackexchange_codegolf |
In this question I will talk about programs as strings, this is strings of bytes, not characters. How your resultant program is rendered or displayed is not important to this challenge, only how it appears in memory matters.
A pristine program is a program \$S\$ that when run does not error, however it will error when... | stackexchange_codegolf |
In Bloons Tower Defense 6, the strength of different bloons can be measured by their Red Bloon Equivalent (RBE), or the number of single pops it takes to completely defeat the bloon.
The RBE for the bloon types are as follows (sourced from the wiki)
Bloon
RBE
red
1
blue
2
green
3
yellow
4
pink
5
black... | stackexchange_codegolf |
Create the shortest program/function/whatever that splits an inputted string along un-nested commas. A comma is considered nested if it is either within parentheses, brackets, or braces.
Input and output
Output should be a list or a string joined with linebreaks. The input may contain any characters. All testcases wil... | stackexchange_codegolf |
This anecdote contains the following intriguing exchange:
"Fine, Fred," Avi interrupted. "Then how would you change this to
avoid duplicate entries?"
"Oh, just change that one there to a negative one."
While this claim is not accurate in context, I do wonder if there's some plausible code for which that makes sens... | stackexchange_codegolf |
Graham's number ends in a 7. It is a massive number, in theory requiring more information to store than the size of the universe itself. However it is possible to calculate the last few digits of Graham's number.
The last few digits are:
02425950695064738395657479136519351798334535362521
4300354012602677162267216041981... | stackexchange_codegolf |
Write a program that, for the numbers 1 through 255, prints out BF code that will produce the given number in some byte of the array, plus a newline.
For example, the first four lines of the output could (and most likely will) be:
+
++
+++
++++
The winner will be the smallest: source code + output (in bytes).
Clarific... | stackexchange_codegolf |
The Challenge
Write a program or function that takes no input and outputs a 3-dimensional vector of length \$1\$ in a theoretically uniform random direction.
This is equivalent to a random point on the sphere described by $$x^2+y^2+z^2=1$$
resulting in a distribution like such
Output
Three floats from a theoretically ... | stackexchange_codegolf |
Goal: Create the smallest possible code to open a separate window, in which there are 100 circles of random sizes and colors.
Rules: All circles must be visible to the unassisted, naked eye, so in other words more than 2 pixels across, the background must be black, at least 5 different colors must be recognizable, and ... | stackexchange_codegolf |
The player has to keep guessing a number from 1 to 10 until they guess the correct number to win the game. If they make an incorrect guess, they're told if their guess was too low or too high.
Each line has to render below the previous line for me to accept the solution as the new code for the game (However, you can st... | stackexchange_codegolf |
A skyline is an array of positive integers where each integer represents how tall a building is. For example, if we had the array [1,3,4,2,5,3,3] this would be the skyline in ascii art:
#
# #
## ###
######
#######
A maximal rectangle is a rectangle that cannot be extended in any direction while being contained... | stackexchange_codegolf |
Introduction
This challenge is about producing a code to count the frequency of bigrams in a text. A bigram is two consecutive letters in a text. For instance 'aabbcd' contains the bigrams aa, ab, bb, bc, cd once each. Counting bigram frequencies is super useful in cryptography. In a brute force algorithm, this code ma... | stackexchange_codegolf |
Scramble a Megaminx!
A megaminx is a dodecahedral version of the familiar Rubik's cube. Since 2008, the World Cube Association uses Stefan Pochmann's megaminx scrambler. The scrambles look like this:
R-- D++ R++ D-- R++ D-- R++ D++ R-- D-- U'
R++ D-- R++ D-- R-- D++ R-- D-- R-- D-- U'
R++ D++ R-- D++ R++ D++ R++ D++ R-... | stackexchange_codegolf |
Prelude is an esoteric programming language, which has very few, but unusual, restrictions on what constitutes a valid program. Any block of printable ASCII text ("block" meaning that lines of printable ASCII are separated by newlines - 0x0A) is valid provided that:
Every (vertical) column of text contains at most one... | stackexchange_codegolf |
Symja is a "computer algebra language & Java symbolic math library for Android NCalc calculator". It's a fun little language, so I'm wondering if y'all have any tips for golfing in Symja.
As per usual, "remove comments", etc, isn't really an answer. It turns out that there is no comment system in Symja, so "remove com... | stackexchange_codegolf |
This is a simple task. Given a positive or negative real number, round it to the next whole integer closer to zero.
The challenge
Take input through any reasonable form (stdin, function, etc.) of one positive or negative real number.
Round this number "towards zero" - this means if it is positive you will round down,... | stackexchange_codegolf |
Squares looks symmetric, and so are the required codes.
Objective: Write a program whose source code is a solid square (N lines with N printable, non-whitespace characters each line) and prints a square of equal size. A program (or output) with inconsistent width and height is invalid. (e.g. 6x5)
Example (HQ9+)
QAA
AAA... | stackexchange_codegolf |
Oh no! I have a theory test soon and I don't remember the scales yet! Help me remember my major scales by printing the following:
7♯ - C♯ D♯ E♯ F♯ G♯ A♯ B♯ C♯
6♯ - F♯ G♯ A♯ B C♯ D♯ E♯ F♯
5♯ - B C♯ D♯ E F♯ G♯ A♯ B
4♯ - E F♯ G♯ A B C♯ D♯ E
3♯ - A B C♯ D E F♯ G♯ A
2♯ - D E F♯ G A B C♯ D
1♯ - G A B C D ... | stackexchange_codegolf |
Objective
Given a string with single Unicode vulgar fraction, parse it to a rational number.
Valid inputs
A valid input is one of:
¼ U+00BC; one quarter
½ U+00BD; one half
¾ U+00BE; three quarters
⅐ U+2150; one seventh
⅑ U+2151; one ninth
⅒ U+2152; one tenth
⅓ U+2153; one third
⅔ U+2154; two thirds
⅕ U+2155; one fifth... | stackexchange_codegolf |
I saw a problem which asks you to print "Hello World" using the fewest characters, including spaces. How can I further shorten this code? Thank you in advance!
#include<iostream>
int main(){printf("Hello World");}
| stackexchange_codegolf |
Lambda calculus is a system of computation based on single-argument functions; everything in it is such a function. Due to this functional nature, juxtaposition is commonly used to denote function application, grouped from left to right. For example, \$(f g) h=f g h\$ denotes what would conventionally be written \$(f(g... | stackexchange_codegolf |
There is a parade marching through a city! There are 3 main groups of marchers: the (B)and, Poster (C)arriers, and (F)lag Holders. Also, every (P)oliceman in the whole city is on duty.
Flag holders (F) can march anywhere in the parade, but two flag holders cannot march next to each other, unless three or more flag hold... | stackexchange_codegolf |
So I'd like you to attempt to generate Rorschach images like the below image:
Here is a link to further inspiration.
This is a popularity contest, but I will say that colours are likely to be more popular than black and white, as well as textures.
Rorschach images are created by folding paper with ink on so one criter... | stackexchange_codegolf |
Credit to Geobits in TNB for the idea
A post without sufficient detail recently posited an interesting game:
2 children sit in front of an array of candy. Each piece of candy is numbered 1 to x, with x being the total amount of candy present. There is exactly 1 occurrence of each number.
The goal of the game is for the... | stackexchange_codegolf |
Your task is to take a sequence of characters (the music) as input (in a function or program), and print (or return) the music as it would look like in a music box.
You will only receive the characters ABCDEFG.() as input, and the input will never be empty. You may also receive the letters in lowercase, if you wish for... | stackexchange_codegolf |
makina is a cell-based esolang composed of automata which move around a grid. These automata follow paths of instructions that direct their movement. Your task is to, given a makina program using only the below instructions (so a subset of normal makina) as input, output two distinct values depending on whether or not ... | stackexchange_codegolf |
Write the shortest program or function that takes some text as input, and outputs either it or an empty line in a repeating pattern:
some text
some text
some text
some text
some text
some text
...
This must continue indefinitely, or until some unpreventable limitation occurs (stack size, memory, etc.). It must be n... | stackexchange_codegolf |
Introduction
As you all know, German has umlauts. They're these things: ¨
However, most keyboards don't have an umlaut key. That's fine, though, because you can write ö, ä, and ü as oe, ae, and ue.
Challenge
Your job is to to replace ö, ä, and ü with oe, ae, and ue (and likewise for their capital versions).
You have t... | stackexchange_codegolf |
We already have a challenge for computing the GCD of two Gaussian integers, but that challenge explicitly allows to choose any of the four possible values.
Your task now is to bring the Gaussian integer computed by the GCD in the following normal form:
The result differs from the original number by a factor of 1,i,-1 ... | stackexchange_codegolf |
What is the shortest way we can express the function
f(a,b)(c,d)=(a+c,b+d)
in point-free notation?
pointfree.io gives us
uncurry (flip flip snd . (ap .) . flip flip fst . ((.) .) . (. (+)) . flip . (((.) . (,)) .) . (+))
which with a little bit of work can be shortened to
uncurry$(`flip`snd).((<*>).).(`flip`fst).((.... | stackexchange_codegolf |
Your task is to create a program that determines whether a given string is a valid regular expression or not using code snippets sourced from sites on the StackExchange network.
For the purposes of this challenge, the regular expression dialect will be a stripped down and mostly minimal set of meta-characters: ()*?|\. ... | stackexchange_codegolf |
In a fictional 2D world, a set of 2D printing instructions for an object can be represented by a list of integers as follows:
1 4 2 1 1 2 5 3 4
Each number represents the height of the object at that particular point. The above list translates to the following object when printed:
#
# # #
# ###
## ####... | stackexchange_codegolf |
As some of you may know, to get a language onto Dennis's wonderful Try It Online!, a Hello, World! program is required. Recently, Dennis pushed up a way to load these programs from the website. Here is a JSON pastebin of the characters used in those programs, by frequency, as of July 27, 2017.
Some of those characters ... | stackexchange_codegolf |
Given a level from a simple platform game, your task is to make a program or function to determine if a level is winnable. Platform game levels are 4 characters tall and any number of characters wide. There is exactly one platform for each horizontal space in a level:
======= =
== = = ... | stackexchange_codegolf |
Draw the Biohazard symbol in an arbitrary colour on a distinctly coloured background. The specific proportions were published in the June 27th 1974 issue of the Federal Register of the US Government.
Details
As output, writing to a file (raster and vector formats are permitted) or displaying on the screen are both all... | stackexchange_codegolf |
Given the size of the chess board and initial position of the knight, calculate the probability that after k moves the knight will be inside the chess board.
Note:
The knight makes its all 8 possible moves with equal probability.
Once the knight is outside the chess board it cannot come back inside.
Input
Inputs ar... | stackexchange_codegolf |
the contest is already finished, so I don't think it's cheating to ask:
I am trying to optimize this small contest: pascal triangle
I started with 4.72 and worked myself up to 7.48.
The best made a 9.05 but in perl, python2 best score is 8.25.
Unfortunately they don't let you look at what others did.
My current solutio... | stackexchange_codegolf |
Take a string as an input, and perform addition/subtraction of all the digits in the string and output the sum of those operations as the result.
Rules
The digits in the string are read from left to right
If a digit (n) is odd, perform addition with the next digit (n + n1)
If a digit (n) is even, perform subtraction ... | stackexchange_codegolf |
Background
Here in the UK1, these are the income tax rules:
You get a personal allowance (untaxed) of up to £12,570:
If you earn less than £100,000, you get the full £12,570 as personal allowance
For every £2 over £100,000, your personal allowance goes down by £1
After the personal allowance, the next £37,700 is ta... | stackexchange_codegolf |
You are given an array \$A\$, which may contain duplicate elements. In each swap, you may swap the value of any two indices \$i, j\$ (i.e. switch the values of \$A_i\$ and \$A_j\$). What is the least amount of swaps needed to sort the array, and what are the corresponding swapped indices?
Scoring
This is code-golf, so ... | stackexchange_codegolf |
In C++, there exists a a <=> b three-way comparison operator that, for numerical types, does the following:
If a < b, then return a negative number.
If a = b, then return a (mathematically speaking) sign-less number.
If a > b, then return a positive number.
The Challenge
Implement the shortest full program, function,... | stackexchange_codegolf |
Lost is a 2-Dimensional programming language where the instruction pointer starts at a random location, moving in a random direction. A description of the language can be found at the bottom of the post for completeness' sake and a tutorial for the language can be found in the above link.
The task here is simple to de... | stackexchange_codegolf |
Traditionally when you compare two strings you use lexicographical comparison. That can be described by the recursive algorithm:
$$
f(x, y)=
\left\{\begin{array}[rr] \\
\mathrm{EQ} & \mathrm{if}\,\mid x\mid=0\,\mathrm{and}\,\mid y\mid=0 \\
\mathrm{GT} & \mathrm{if}\,\mid x\mid>0\,\mathrm{and}\,\mid y\mid=0 \\
\mathrm{L... | stackexchange_codegolf |
Background
Hello is a language "written" by Anne Veling, which errors if the program does not contain only h, and will print Hello World for every h
Task
You are to write an interpreter/compiler for Hello.
Example in Python
import os
i = input("Program: ")
for a in i:
if a != 'h':
print("err")
quit(... | stackexchange_codegolf |
One day in July 2020, I made the following C program:
#define A m]
a[9999],*m=a;main(){for(2[A=4[A=1;;){for(;4[A;putchar(6[m-=3]+48));
for(puts(a);7[A;2[A=4[A,4[A=1)if(4[A+=3[m+=3]-1,9<(3[A=2[A+=3[A))++
5[A,7[A=1,3[A-=10;}}
with three superfluous newlines removed, it's 167 bytes and it prints the fibonacci sequence (a... | stackexchange_codegolf |
Overview:
Your challenge is to write a program that will play minesweeper optimally, giving the best move in any position. Moreover, you must do this on the largest board possible.
Game details: Minesweeper is a one player game, played on a rectangular board. At the beginning of the game, a specified number of mines ar... | stackexchange_codegolf |
The challenge
You are given an integer n, and you have to use these operations to make it 1.
Divide it by 3.
Divide by 2.
Subtract 1.
Examples:
Input Output
1 0 (Its already 1, guys)
5 3 (3->2->2 or 3->3->1)
10 3 (3->1->1)
255 10(3->3->3->1->1->2->2->3->1->2)
| stackexchange_codegolf |
Challenge
Giving a valid arithmetic sum with some missing numbers, output the full expression.
Example:
1#3 123
+ 45# => + 456
-------- --------
579 579
Input
Expression format can be an array ["1#3", "45#", "579"], a string "1#3+45#=579", or 3 inputs f... | stackexchange_codegolf |
Eh!
You know, the problem with us Canadians is that sometimes, after a long day of moose hunting and dam repairing, we forget our way back to our cabins! Wouldn't it be great if our handy laptop (which, is always at our side), had some way to point us home? Well, it's been long told that, if you display a compass on yo... | stackexchange_codegolf |
The task is simple. Write an interpreter for the language *.
Here's a bigger link to the wiki.
There are only three valid * programs:
* Prints "Hello World"
* Prints a random number between 0 and 2,147,483,647
*+* Runs forever.
The third case must be an infinite loop according to the specifications in this question... | stackexchange_codegolf |
Daylight saving time (DST), is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. The typical implementation of DST is to set clocks forward by one hour in the spring ("spring forward") and set clocks back by one hour in autumn ("fall back") to re... | stackexchange_codegolf |
Mathematical Background
Let A be an N by N matrix of real numbers, b a vector of N real numbers and x a vector N unknown real numbers. A matrix equation is Ax = b.
Jacobi's method is as follows: decompose A = D + R, where D is the matrix of diagonals, and R is the remaining entries.
if you make an initial guess solutio... | stackexchange_codegolf |
Your task is to write a program or function that checks if a string is a valid phone number.
Given a string (or list of characters/codepoints) input, you will output a truthy value if the input is a valid phone number. If it is not, output a falsey value. An input string is considered a valid phone number for this chal... | stackexchange_codegolf |
inspired by thejonymyster's idea
Rules
This challenge is about finding languages that are very suitable for one task but quite the opposite in the other. The two tasks share a theme, but Task 1 is designed to be number-oriented while 2 is string-oriented. You can participate in three categories:
Numbers: Choose a lang... | stackexchange_codegolf |
Given as input a positive nonzero integer n >= 10 and a sequence of digits 0-9 (which may be taken as a string or a list), find the first contiguous subsequence of digits in the sequence that sums to n and output the start and end indexes. You may use zero- or one-based indexing. If no such subsequence exists, your pro... | stackexchange_codegolf |
The challenge is simple: write a program which takes in some non-empty string \$n\$ consisting of only uppercase and lowercase ASCII letters, and outputs the code for a program (in the same language) which takes in no input and outputs \$n\$. However, the code your program generates must not contain \$n\$ as a substrin... | stackexchange_codegolf |
An "Egyptian fraction" is a list of distinct fractions with a numerator of \$1\$. For example:
\$
\frac 1 1+ \frac 1 2 + \frac 1 3 + \frac 1 6
\$
The "size" of an Egyptian fraction is just the number of terms involved.
Your task is to take a positive integer \$n\$ and output the smallest Egyptian fraction that sums t... | stackexchange_codegolf |
This is a somewhat proof-golf-like cops-and-robbers challenge. This is the robbers' thread; the cops' thread is here.
Robbers
The cops will post abstract rewriting systems. Your task is to crack their submissions by proving that the target string either can or can not be reached from the source string by applying their... | stackexchange_codegolf |
Your challenge, should you choose to accept it, is to write a program in a language of your choice that, when given a string (limited to printable ASCII) as input, outputs a new program in the same language that outputs that string without using any characters from that string in the code.
But this task is impossible a... | stackexchange_codegolf |
Background
You may be aware that periods in between letters in gmail addresses are ignored. Email sent to example@gmail.com, exam.ple@gmail.com, and e.x.a.m.p.l.e@gmail.com all end up in the same place!
This is a great way to have multiple different emails addresses for things like signing up for free trails, or filter... | stackexchange_codegolf |
I need to go to the bank and withdraw some money. I need to withdraw $30, $22 to pay my roommate for the internet and $8 for laundry. Since neither of these can make change, I need my $30 to be split into two partitions of the two sizes. That means when the teller asks me how I want my $30 I am going to have to make... | stackexchange_codegolf |
In races in which racers go around at least one turn of a curved track, the starting positions for each racer are staggered, so that each racer travels the same distance around the track (otherwise, the racer in the innermost lane would have a huge advantage).
Given the lengths of the major and minor axes (or semi-majo... | stackexchange_codegolf |
RLE Brainfuck
(related to BF-RLE)
The hypothetical RLE (Run-Length Encoding) dialect of Brainfuck accepts the symbols for the 8 commands and also accepts digits. The digits are used to represent the number of successive repetitions of a command, thus allowing run-length encoding of the source code.
8> is equal to >>>>>... | stackexchange_codegolf |
You may know the game The Six Degrees of Kevin Bacon, based on the conjecture that every actor in Hollywood can be connected to Kevin Bacon by no more than 6 "co-star" relations, so Kevin Bacon is supposedly the "best-connected" node in that graph. Your task will be to find the Kevin Bacon of a graph.
We will use posit... | stackexchange_codegolf |
I am trying to push my limits of making a python code as short as possible.
I left the readability part way behind.
I was attempting the K-Goodness String problem from Round A of Google Kick Start 2021.
The following was my initial solution:
def func(N, K, S):
if not S: return 0
y = 0
for i in range(N//2)... | stackexchange_codegolf |
Introduction
Write a solver for the Hitori puzzles using least bytes.
Challenge
Your task is write a solver for the Hitori (ひとり, the word for "alone" in Japanese; the meaning of the game name is "Leave me alone") logical puzzles. The rules are as follows:
You are presented with a n-by-n grid of cells, each cell contai... | stackexchange_codegolf |
Every palindrome with an even number of digits is divisible by 11, so 11 is the only [palindromic prime] with an even number of digits. - David Wasserman, OEIS
I learned this today the manual way, before I did my research, when my program skipped numbers with an even number of digits (except 11) when calculating pali... | stackexchange_codegolf |
Create a program that generates a drum fill. Your program will output a pattern of L (left hand hits), 'R' (right hand hits), and K for kick drum hits.
Rules
The pattern must never have more than 2 of the same hits consecutively.
The pattern must be loopable, so it mustn't have more than 2 of the same hits when it lo... | stackexchange_codegolf |
A demonic number is a positive integer whose decimal representation consists of only 6. The list of demonic numbers starts with 6, 66, 666, 6666.
Given a positive integer, output the nearest demonic number. If there are two, output the bigger one.
Testcases:
n output
1 6
2 6
3 6
6 6
35 6
36 66
37 66
100 66... | stackexchange_codegolf |
The coin change problem is very well documented. Given an infinite supply of coins of denominations x_1 to x_m you need to find the number of combinations which add up to y. For example, given x = {1,2,3} and y = 4 we have four combinations:
{1,1,1,1}
{1,1,2}
{1,3}
{2,2}
Introduction
There are several variations of t... | stackexchange_codegolf |
Historical Background
The shield wall is a tactical war formation that dates back to at least 2500 BC. It consisted of warriors overlapping their shields with those of their companions to form a 'wall'. The appeal of the tactic comes from the fact that even the most unskilled warrior could fight in a wall as long as th... | stackexchange_codegolf |
Output the following table:
一一得一
一二得二 二二得四
一三得三 二三得六 三三得九
一四得四 二四得八 三四十二 四四十六
一五得五 二五一十 三五十五 四五二十 五五二十五
一六得六 二六十二 三六十八 四六二十四 五六三十 六六三十六
一七得七 二七十四 三七二十一 四七二十八 五七三十五 六七四十二 七七四十九
一八得八 二八十六 三八二十四 四八三十二 五八四十 六八四十八 七八五十六 八八六十四
一九得九 二九十八 三九二十七 四九三十六 五九四十五 六九五十四 七九六十三 八九七十二 九九八十一
Or you can use the first three letters in its ... | stackexchange_codegolf |
Introduction
In order to prevent keyloggers from stealing a user's password, a certain bank account system has implemented the following security measure: only certain digits are prompted to be entered each time.
For example, say your target's password is 89097, the system may prompt them to enter the 2nd, 4th and 5th ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.