instruction stringlengths 34 53.1k |
|---|
A compound word is a word that contains 2 or more words in it. We can do better than that, though. We need you to create 1 (nonsensical) word that contains every word.
However, we want this word to be as short as possible. We can use overlapping letters to achieve this.
For example, if your word list was ["cat", "at... |
Consider a permutation of the integers 1, ..., n, such as this one for n = 6:
[5,2,4,3,6,1]
If you view the permutation as a mapping from [1,2,3,4,5,6] to [5,2,4,3,6,1], the permutation can be decomponsed into disjoint cycles. A cycle is a subset of elements that map to each other. For example, 1 gets mapped to 5, whi... |
Write a program or function that takes in a nonempty single-line string of printable ascii characters excluding space:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
You may assume the input is valid.
Based on the input, draw a new string arranged on a textual grid of sp... |
Definition
\$a(0) = 0\$
\$a(n) = n-a(a(a(n-1)))\$ for integer \$n > 0\$
Task
Given non-negative integer \$n\$, output \$a(n)\$.
Testcases
n a(n)
0 0
1 1
2 1
3 2
4 3
5 4
6 4
7 5
8 5
9 6
10 7
11 7
12 8
13 9
14 10
15 10
16 11
17 12
18 13
19 13
20 ... |
Cheddar is a high-level, functional + object-oriented programming language created by our user Downgoat designed to make programming easier, faster, and more intuitive.
What general tips do you have for golfing in Cheddar? I'm looking for ideas which can be applied to code-golf problems and which are also at least som... |
Your task is to assemble the integers from 1 to N (given as input) into a rectangle of width W and height H (also given as input). Individual numbers may be rotated by any multiple of 90 degrees, but they must appear as contiguous blocks in the rectangle. That is, you cannot break one of the numbers into multiple digit... |
Definition
\$a(1) = 1\$
\$a(2) = 2\$
\$a(n)\$ is smallest number \$k>a(n-1)\$ which avoids any 3-term arithmetic progression in \$a(1), a(2), ..., a(n-1), k\$.
In other words, \$a(n)\$ is the smallest number \$k>a(n-1)\$ such that there does not exist \$x, y\$ where \$0<x<y<n\$ and \$a(y)-a(x) = k-a(y)\$.
Worked out ... |
Background
I have a collection of "weekday socks", which are seven pairs of socks labeled by the days of the week.
When I wash my socks, they end up in a pile, and I must arrange them into the correct pairs before putting them into the closet.
My strategy is to pull one random sock from the pile at a time and put it on... |
For this challenge, you need to compress a diff. A diff is some data that represents the difference between two strings. For this challenge, you need to provide one or more programs that can:
Input A and B, and output a diff, C
Input A and C, and output B
Input B and C, and output A
The goal is to make the diff, C,... |
The Challenge
Given either a string (may have newlines), or a two dimensional array, and a positive integer n, output the position of the platforms n turns after the
initial position.
U, D, R, L are platforms.
^, v, >, < are arrows that change the directions of the platforms.
U, D, R, L move up, down, right and left,... |
Challenge description
You have a music library with many tracks recorded by many bands, each of which has a name, like Queen, Aerosmith, Sunny Day Real Estate, The Strokes . When an audio player displays your library alphabetically by band name, it usually skips the The part, as many band names start with The, making i... |
King of the Torus!
Your job is to conquer the torus, but wait, there are multiple other players banded together in teams facing you! You will need to use your wit's to conquer the torus.
There are three teams: red, blue and green. Teams are self-assigned arbitrarily. If the teams are even you may join the team of your ... |
Martin Ender recently hit 100K, and has come up with some pretty awesome languages. We're going to have a bit of fun with one of them, Hexagony (and a bit of regex for Retina)
As a brief overview, you need to write a program that inputs a Hexagony grid and determines if there is a path on that grid that matches a stri... |
You are to print this exact text:
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
ABCDEFEDCBA
ABCDEFGFEDCBA
ABCDEFGHGFEDCBA
ABCDEFGHIHGFEDCBA
ABCDEFGHIJIHGFEDCBA
ABCDEFGHIJKJIHGFEDCBA
ABCDEFGHIJKLKJIHGFEDCBA
ABCDEFGHIJKLMLKJIHGFEDCBA
ABCDEFGHIJKLMNMLKJIHGFEDCBA
ABCDEFGHIJKLMNONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
ABCDEFGHIJKLMN... |
In my last challenge, you were asked to find all rectangles given a m x n grid of them. However, it turned out to be very trivial as there actually was a mathematical formula I did not even know about to solve the problem! So now, for a little bit more of a challenge, how about calculating the number of unique rectangl... |
Take the vector of unknowns , and apply some generic differentiable function . The Jacobian is then given by a matrix such that:
For example, suppose m=3 and n=2. Then (using 0-based indexing)
The Jacobian of f is then
The goal of this challenge is to print this Jacobian matrix.
Input
Your program/function should ... |
As a follow-up to this challenge, we now want to count the number of rectangles in grid with r rows and c columns where there is a line crossing through every diagonal of a square in the grid. Now, we are still counting the the same rectangles as before, but this time we must also include rectangles that are tilted by ... |
"The Nobel Prize in mathematics was awarded to a California professor who has discovered a new number! The number is bleen, which he claims belongs between 6 and 7." --George Carlin
In this challenge, you will print all Integers, inclusive, within the given input range. Print numbers ascending or descending according... |
Given six unique non-negative integers, print the two 3-digit integers comprised of those numbers that sum to the smallest amount.
Additionally,
If there is more than one set of numbers that meets the smallest-sum requirement, print the two that have the greatest difference. For example, 269 + 157 = 267 + 159 = 426; ... |
Definition
A vector a containing n elements is said to
majorize or
dominate a vector b with n
elements iff for all values k such that 1 ≤ k ≤ n, the sum of the first
element of a↓ through the kth element of a↓ is
greater than or equal to the sum of the first through kth elements of
b↓, where v↓ represents the vector v ... |
Write a program or function that takes in a positive integer and prints or returns a stack of that many ASCII-art turtles, where each turtle is larger than the one above it.
Specifically, if the input is 1, the output should be:
__
/,,\o
If the input is 2:
__
o/,,\
____
/,__,\o
If the input is 3:
__
/,,\o
... |
In a far-off kingdom, a chess queen takes a daily walk across a spiral path, numbered from 1 to n, not caring to follow the spiral itself, but simply making queen's moves as she would on a chessboard. The queen is beloved by her subjects, and they make a note of every square she visits on her path. Given that the queen... |
The Collatz conjecture is a very well-known conjecture. Take a positive integer; if it's even, divide by 2, else, multiply by 3 and add 1. Repeat until you reach 1 or something else happens. The conjecture is that this process always reaches 1.
You can also reverse the process. Start at 1, multiply by 2, and to branch ... |
Background
This is a standard textbook example to demonstrate for loops.
This is one of the first programs I learnt when I started learning programming ~10 years ago.
Task
You are to print this exact text:
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
Spe... |
A positive integer \$k\$ is a Loeschian number if
\$k\$ can be expressed as \$i^2 + j^2 + i\times j\$ for \$i\$, \$j\$ integers.
For example, the first positive Loeschian numbers are: \$1\$ (\$i=1, j=0\$); \$3\$ (\$i=j=1\$); \$4\$ (\$i=2, j=0\$); \$7\$ (\$i=2, j=1\$); \$9\$ (\$i=-3, j=3\$); ... Note that \$i, j\$ for... |
Previously, we computed the Bit-Reversal Permutation where we found how the order of indices would be permuted. In that case, we received an input n which was the order of the permutation of the indices where the length was 2n. However, this time, we are given a string of length m = 2k for some k. Now we want to apply ... |
Your task is to build a Game of Life simulation representing a digital clock, which satisfies the following properties:
The clock displays the hours and minutes in decimal (e.g. 12:00, 3:59, 7:24) with a different state for each of the 1,440 minutes of the day — either the hours will go from 0 to 23 or from 1 to 12 wi... |
Inspired by this Game of Life question.
Wireworld simulates "electrons" flowing through "wires", simple arrangements of which produce typical logic gate behavior.
I challenge you to build a digital clock in the Wireworld cellular automaton. Your clock must count upwards from 00:00 to 23:59 in the usual fashion, or to 1... |
The scenario
Lately you have been noticing some strange behavior with your favorite text editor. At first it seemed that it was ignoring random characters in your code when writing to disk. After a while you noticed a pattern; characters with odd ASCII values were being ignored. Under further inspection you discovered ... |
Mr Short likes to play chess. Mr Short is also a very traditional man. Hence, Mr Short is disturbed by the recent trend of using Algebraic notation in modern chess, and he would rather use Descriptive notation, like his father and his father's father before him.
Note
To simplify this challenge, I chose not to deal with... |
Jellyfish is a two-dimensional esoteric programming language inspired by J and written in Python 3. It was inspired by a challenge on PPCG. The name was suggested in PPCG chat as a combination of Jelly, a golfing language inspired by J, and Fish, a two-dimensional esoteric language.
What general tips do you have for ... |
This is a very simple challenge.
The joke language InterpretMe consists of one command; *, which causes the program to take input of an InterpretMe program and execute it.
An InterpretMe program will interpret as many InterpretMe programs as there are * in input.
Your goal is to create a program that interprets Inte... |
Challenge description
Let's define an W x H grid as a two-dimensional array of length H whose each subarray is of length W. Example: a 2x3 grid (. character used as a blank):
..
..
..
A unit is a single point of a grid. A block is either a single unit or a set of contiguous units (meaning each unit of a block has at l... |
Background
The Fibonacci sequence is defined as
$$f(1) = 1 \\ f(2) = 1 \\ f(n) = f(n-1) + f(n-2)$$
The Fibonorial, similar to the factorial, is the product of the first \$n\$ Fibonacci numbers.
$$g(n) = f(1) \times f(2) \times ... \times f(n-1) \times f(n)$$
The Fibonomial coefficient, similar to the binomial coefficie... |
My PPCG holiday is over :D
Intro
Fractional time is the year + (the value (minute of year) / number of minutes in the year).
Example calculation
You should assume that February always has 28 days and the year is always 365 days long.
Let's say we want to convert the time: 17:34 3rd March 2013 to fractional time. Firstl... |
The Challenge
Given a string, output the text in the shape of a square.
You can assume that the text will always fit in a square, and that it will never be an empty string.
You can also assume it will never have newlines.
Example
Input:
Hi, world
Output:
Hi,
wo
rld
Test Cases
Input:
Hi, world! Hello
Output:
Hi,
wo... |
The Chinese Remainder Theorem can be quite useful in modular arithmetic.
For example, consider the following set of congruence relations:
For sets of congruence relations like this, where all the bases (3, 5, 7 in this example) are co-prime with each other, there will be one and only one integer n between 1 and the pr... |
Task
Your task is to convert a text into medieval orthography.
Details
j is converted to i and J to I.
u and U at the beginning of words are converted to v and V respectively.
v and V at anywhere except the beginning of words are converted to u and U respectively.
s is converted to ſ (U+017F) unless at the end of the ... |
Cops section
The robbers section can be found here.
Thanks to FryAmTheEggman, Peter Taylor, Nathan Merrill, xnor, Dennis, Laikoni and Mego for their contributions.
Challenge
Your task is to write 2 different programs (full programs/functions/etc.) in the same language and the same version (e.g. Python 3.5 ≠ Python 3.4... |
Robbers section
The cops section can be found here.
Challenge
Your task is to outgolf the submissions of the cops in the same language and the same version (for example, Python 3.5 ≠ Python 3.4, so that is not allowed). A submission is outgolfed when the length in bytes is shorter than the original submission. You only... |
Text adventure games have a pretty set formula; there's a world composed of a series of rooms / spaces, the player can move around these rooms, and there are some items in the rooms. Items can be picked up by the player, put down, used to access other rooms (e.g. keys), and combined with other items to make new items.
... |
In this code-golf challenge, you must output an ascii-art of a random die roll.
like this:
________
/\ \
/ \ 6 \
{ 4 }-------}
\ / 5 /
\/_______/
Please note that:
________
/\ \
/ \ 3 \
{ 4 }-------}
\ / 5 /
\/_______/
is invalid output, because that is not a possib... |
The VIC cipher is one of the most complicated pencil and paper ciphers ever devised. Used in the 1950s by Soviet spy Reino Häyhänen, codenamed "VICTOR", its main principle is security through obfuscation; a lot of obfuscation.
Your task is to write a program or function that will take a message and encode it using the ... |
You've received a coded message from your ally that you know is encoded with the VIC cipher. As you know that the VIC cipher is notoriously convoluted, you want to write a program that will decode the VIC cipher but is small enough to hide from the enemy if you are captured, and thus uses as few bytes as possible.
Your... |
Given a Gaussian integer \$a+bi\$ where \$a\$,\$b\$ are integers and \$i = \exp\left(\pi i/2\right)\$ is the imaginary unit, return the closest (w.r.t to the Euclidean distance) Eisenstein integer \$k+l\omega\$ where \$k\$,\$l\$ are integers and \$\omega = \exp(2\pi i/3) = (-1+i\sqrt{3})/2\$.
Background
It is probably ... |
From what I've seen throughout my time here on PPCG, most JavaScript entries involving fat arrow functions tend to be one of two camps:
The simple ones that are capable of running as a single statement and returning an answer, straight off the bat, like x=(a,b)=>a*a+b
The more complex ones that usually have curly brac... |
The Challenge
Given an algebraic expression (eg 2ab, change it so it follows standard convention rules.
The Rules
Letters should be in alphabetical order. ie 2ab is allowed but not 2ba.
Numbers should always go first. ie 2ab is allowed but ab2 is not.
Exponentiation will be given as a^b to mean a to the power of b.... |
Taking some output from xxd and turning it into usable shellcode by hand is no fun, so your job is to automate the process.
Rules
Your submission can be a function, lambda, script, or any reasonable equivalent of those. You may print the result, or if your submission is a function/lambda then you may also return it.
Yo... |
See also: Make a move on a Go board.
Task
Go is a board game where two players (Black and White) place stones on the intersections of grid lines on a 19×19 board. Black moves first — for example, on D4:
In this challenge, you must take a Go board coordinate like D4 as input, and output an ASCII representation ... |
Taken from this question at Stack Overflow. Thanks also to @miles and @Dada for suggesting test inputs that address some corner cases.
The challenge
Given an array of integer values, remove all zeros that are not flanked by some nonzero value.
Equivalently, an entry should be kept either if it's a nonzero or if it's a ... |
Write a program or function that given two integers a, b outputs a string containing a decimal number representing the fraction a/b exactly.
If a/b is integer, simply output the value, without a decimal dot or leading zeroes:
123562375921304812375087183597 / 2777 -> 44494913907563850333124661
81 / 3 -> 27
-6 / 2 -> -3
... |
What general tips do you have for golfing in Common Lisp? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Common Lisp (e.g. "remove comments" is not an answer).
Please post one tip per answer.
|
Of course, the SE network is very knowledgeable about how to be respectful in the restroom, but for those of you who need a recap, being respectful means flushing the toilet, etc. Most importantly, though, it means using the stall as far away from others as possible.
The challenge
Given a blueprint of a set of stalls ... |
Given an input number n from 1 to 26 (or 0 to 25), output the alphabet reading left-to-right up to and including that corresponding letter, with a=1, b=2, c=3, .... The twist is the letters must also be repeated vertically corresponding to their position in the alphabet. Odd numbers (when 1-indexed) should be balanced ... |
Y'know, we've had a lot of "alphabet" challenges recently. (one two three four five.) While I love a good challenge, and those challenges were very fun, I think it's time for a change of pace. We need to exclude such challenges in the future. It's time for automation!
You're going to find some alphabets for me, and for... |
You are to print this exact text:
ABABABABABABABABABABABABAB
BCBCBCBCBCBCBCBCBCBCBCBCBC
CDCDCDCDCDCDCDCDCDCDCDCDCD
DEDEDEDEDEDEDEDEDEDEDEDEDE
EFEFEFEFEFEFEFEFEFEFEFEFEF
FGFGFGFGFGFGFGFGFGFGFGFGFG
GHGHGHGHGHGHGHGHGHGHGHGHGH
HIHIHIHIHIHIHIHIHIHIHIHIHI
IJIJIJIJIJIJIJIJIJIJIJIJIJ
JKJKJKJKJKJKJKJKJKJKJKJKJK
KLKLKLKLKLKLKLKL... |
For all you American folk out there, remove the "s" in "maths".
Ugh, my maths teacher gave me so much algebra to do. There's just lines and lines of meaningless junk like Expand (x+1)(x+6) and Factorise x^2+2x+1.
My hands are literally dying from the inside.
So I figured out a way to hack the system - why not write a p... |
Challenge description
Multiplification (totally not a made-up word) is a process in which you take two positive integers: a and b, and produce another integer which is equal to a repeated ("glued together") b times. For example, multiplifying 3 by 7 gives 3333333. Similarly, 103 multiplified by 5 is 103103103103103.
In... |
There are so many different ways to express whether something is true or not! The goal of this challenge is to produce a standardized output of truthy or falsy for various input truthy and falsy values.
For the purposes of this challenge, the following inputs are considered truthy:
A string representing a signed integ... |
The goal of this challenge is to reduce a list of string to a shorter more general list of string.
Input
The Input is provided with space between the string (a b c) or in list form (["a","b", "c"]). It's a list list of string that can be of the following form :
aaa
aaaX
aaaX/Y
With aaa any set of non capital alphabet... |
We see a lot of challenges here asking for a function to create a sequence from the OEIS. While these challenges are fun, as a programmer I see an opportunity for automation.
Your challenge is to make a program that takes the index of a sequence (e.g. A172141) and some integer n (e.g. 7), and pulls the appropriate val... |
Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. However, this is a multiple-holes (common theme is manipulation of data of any type and structure, especially special handling of empty data) code-golf version of the Phase I problems – open to any language. Enjoy!
Objec... |
Intro
The challenge is to create a program/function that prints the intersection of its own source code and a given string input. This is code golf and to be more precise:
Let I be the input set
{"a","b","c"}
Let S be the source code set
{"b","f"}
Then the intersection is what they share
I ∩ S = {"b"}
Inpu... |
For this challenge, you will be writing a program or function which outputs (or prints) (in a reasonable format, i.e single string or an array of lines) a chess board which indicates all the possible moves of a piece given an empty board.
There are 5 chess pieces (for this challenge a pawn may be ignored):
Bishop (Mo... |
Write a program or function that takes in a nonempty single-line string. You may assume it only contains printable ASCII excluding space.
Print or return an ASCII art lozenge shape similar to a lemon or lime made from the prefixes of the string.
Suppose the input string is n letters long. Then, such a shape consists of... |
A Proth number, named after François Proth, is a number that can be expressed as
$$N = k \times 2^n + 1$$
Where \$k\$ is an odd positive integer and \$n\$ is a positive integer such that \$2^n > k\$. Let's use a more concrete example. Take 3. 3 is a Proth number because it can be written as
$$ 3 = (1 \times 2^1) + 1 $$... |
Write a function or program that takes string inputs, fully-spelled, English month names in title case: January, February, March, etc. (null/CR/LF terminated OK, delimited with some non-alpha character if you so choose) and either
compares two inputs, returning a Truthy value if the second input is greater (in month o... |
Write a program or a function in your favorite programming language that will take as input a number n (integer or non-integer) between 0 and 100 inclusive, and output the corresponding grade as outlined below:
If 0 < n <= 40, then output E.
If 40 < n <= 55, then output D.
If 55 < n <= 65, then output C.
If 65 < n <= ... |
Introduction
Inspired by Dyalog Ltd.'s 2016 student competition. The challenge there is to write good APL code, but this is a code-golf and it is open to all languages. Derived from this closed challenge.
The real challenge here is to combine the various (quite trivial) parts of the problem in a byte-efficient way by r... |
The Challenge
Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list.
Details
The list should be in descending order.
Every built-in function to manipulate arrays and/or lists is allowed.
Shortest code in bytes wins.
When run ... |
Sometimes when I'm typing out an IPv4 address, I get all the numbers right, but I forget to type one or more periods. I'd like to have a program (or function) that takes my broken IPv4 address and outputs all possible valid placements of the missing periods.
Input
The input will always be a string that is a transformat... |
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 than 9 (in base 10) take up more than one character. We can compromise by dividing the string into two-character substring... |
About the Series
This is a guest entry for the Random Golf of the Day series.
First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information abo... |
There's quite a lot of work that's been done in the world of chess. For example, there is a standardized file format, .pgn, that describes a chess game, including the list of moves. Additionally, there's another file format .fen, that describes a board position. The challenge today is to convert a list of chess move... |
Last week, we worked to create the shortest 1-D string using the top 10,000 words in the English language. Now, lets try the same challenge in 2D!
What you need to do is to take all of the above words, and put them in a rectangle as small as possible, allowing for overlaps. For example, if your words were ["ape","pen... |
This is the first part of a three part challenge. The next parts will be released on August 13 and 14.
This challenge series was inspired by another challenge series. You can view the original one at Random Golf of the Day #1: Shuffle an Array.
Instructions
Your goal in this code golf is to reverse a URL, but not full... |
Introduction
Sometimes, my boxes are too small to fit anything in it. I need you to make a box expander! So, what makes a box a box in this challenge.
OOOO
O O
O O
O O
OOOO
The corners of the box are always spaces. The box itself can be made out of the same character. That character can be any printable ASC... |
Today we'll look at a sequence \$a\$, related to the Collatz function \$f\$:
$$f = \begin{cases}
n/2 & \text{if } n \equiv 0 \text{ (mod }2) \\
3n+1 & \text{if } n \equiv 1 \text{ (mod }2) \\
\end{cases}$$
We call a sequence of the form \$z, f(z), f(f(z)), …\$ a Collatz sequence.
The first number in our sequence, \$a(... |
You are to write a program or function that outputs this exact text:
OPQRSTU
NQPONMV
MREDCLW
LSFABKX
KTGHIJY
JUVWXYZA
IHGFEDCB
May also be lowercase and trailing spaces and newlines are allowed.
Standard loopholes are disallowed
This is code-golf, so smallest byte count wins.
|
Integers are tedious to represent in Brain-Flak. There are 8 operators:
() Evaluates to 1, but does not push anything on any stack
[] Evaluates to an indeterminate value for the purposes of this question
{} Removes the top of the stack and evaluates to it
<> Switches to or back from the alternate st... |
The Challenge
Your challenge is to write a program that evaluates the following function:
f(x, t) = d^x / dt^x (sin t)
That is, the x-th derivative of sin t. In case you aren't familiar with calculus, here is a table of derivatives for the sine function:
...
f(-1, t) = -cos t
f(0, t) = sin t
f(1, t) = cos t
f(2, t)= -s... |
Write a program or function that takes in a nonempty single-line string. The string will either be zero or more spaces followed by one period (a particle), such as . or ., or the string will be a sequence of one or more alternating forward and back slashes (a wave) that could start with either one, such as \ o... |
Your task is to, given an image, compress it to 100000 bytes or less, while following all of the below rules:
No cheating/loopholes.
Your code must not be optimized to work best only on the test set of images, but rather produce a good output in general.
Colours that do not exist in the original input image must also ... |
Introduction
As some of you may know, URLs actually have a list of characters that do special things. For example, the / character separates parts of the URL, and the ?, &, and = characters are used to pass query parameters to the server. In fact, there is a bunch of characters with special functions: $&+,/:;=?@. When ... |
Executive summary: test whether an input sequence of integers is "admissible", meaning that it doesn't cover all residue classes for any modulus.
What is an "admissible" sequence?
Given an integer m ≥ 2, the residue classes modulo m are just the m possible arithmetic progressions of common difference m. For example, wh... |
The challenge: Write a script to print the alphabet, but you can't use any ASCII strings in your program. Unicode escape characters are allowed (if thats what you call them).
External libraries are allowed, as long as a link to the documentation is provided, and an online example if possible.
As this is code-golf, the ... |
In this challenge we'll compute an infinite minimal admissible sequence.
The sequence for this challenge starts with a(1) = 1.
We continue this sequence by finding a(n) as the smallest possible number such that a(n) > a(n-1) and for every prime p, the set {a(i) mod p : 1 ≤ i ≤ n} has at most p-1 elements.
Write a progr... |
Challenge description
A Langford string of order N is defined as follows:
The length of the string is equal to 2*N,
The string contains first N letters of the English alphabet, each letter appearing twice,
For each pair of the same letters, there are M letters between them, where M is that letter's position in the alp... |
Definition
Two integers are coprime if they share no positive common divisors other than 1.
a(1) = 1
a(2) = 2
a(n) is the smallest positive integer which is coprime to the a(n-1) and a(n-2) and has not yet appeared, for integer n >= 3.
Task
Given positive integer n, output/print a(n).
Example
a(11) = 6 because 6 i... |
Introduction
Sharp edges are, frankly, just plain dangerous so, given a PNG as input, blur the image using the method described below and blunt those damned sharp edges.
Method
To get the RGB value of each pixel, use the following three equations:
$$R = \sqrt{\frac{1.5\times\sum^n_{a=1}R^2_a}{n}}$$
$$G = \sqrt{\frac{1.... |
A ballot number, which we'll label B, is the number of ways of arranging the numbers from 1 through B(B+1)/2 into a triangle, such that each row and column is in any increasing order. The first four ballot numbers are:
a(0) = 1
a(1) = 1
a(2) = 1
a(3) = 2
a(3) is 2, which means that there are 2 ways of arranging the nu... |
For this challenge, when given a list of (x,y) points your submission needs to output a polynomial function that goes through all of them.
For example, if your points were [(0,0), (2,5)], you could return y = 2.5*x or y = x + 1/4x^2.
All points passed in will consist only of integers
Two points will never have the sam... |
Disclaimer: Levenshtein coding is completely unrelated to the Levenshtein edit distance metric.
<Insert long story about why Levenshtein codes need to be calculated here.>
The code
Levenshtein coding is a system of assigning binary codes to nonnegative integers that retains some weird property in probability which isn'... |
In arithmetic, an n-smooth number, where n is a given prime number, is mathematically defined as a positive integer that has no prime factors greater than n. For example, 42 is 7-smooth because all its prime factors are less than or equal to 7, but 44 is not 7-smooth because it also has 11 as a prime factor.
Define a p... |
Consider a grammar over the alphabet {0, 1, ?, :} defined by the production rule
s → 0 ┃ 1 ┃ 0 ? s : s ┃ 1 ? s : s
Given a string generated from s, parse it as an expression where ?: is right-associative (for example, a?B?X:Y:c?d:e?f:g means a?(B?X:Y):(c?d:(e?f:g))) and evaluate it with the following semantics:
eval(... |
A right-truncatable prime is a prime where every prefix is a prime (in base 10). A left-truncatable prime is exactly the opposite, where every postfix is a prime (primes that start with 0 aren't allowed). Both of these sequences are finite (There are only 83 Right-truncatables, while there are 4260 Left-truncatables)... |
As a programmer or computer scientist one might encounter quite a lot of trees - of course not the woody growing-in-the-wrong-direction kind, but the nice, pure mathematical kind:
*<- root (also a node)
/|\<- edge
* * *<- inner node
| / \
* * *<- leaf (also a node)
|
*
Naturally over time we all have put tog... |
Challenge
Using data from the API here, output the names of the three countries with the most Olympic gold medals at the 2016 Rio Olympic Games (i.e. the first element of the returned list).
For example, at the time of posting (18:23 UTC+1, Monday, 15th August), the USA, the UK and China have the most gold medals, so t... |
What is the shortest way to see if an input is a wordinian using any programming language?
A wordinian is a word that contains words of length 1 to the original word's length. For example,
bin
'I' is a word
'in' is a word
'bin' is a word
Or,
stage
'a' is a word
'ta' is a word (yes it is)
'age' is a word
's... |
OEIS: A167171
A dense number is a number that has exactly as many prime divisors as non-prime divisors (including 1 and itself as divisors). Equivalently, it is either a prime or a product of two distinct primes. The first 100 dense numbers are:
2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 31, 33, 34,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.