instruction stringlengths 34 53.1k |
|---|
Sandbox
What is Hexagonification™?
Hexagonification™ is a transformation that creates a hexagon with 3 copies of a rectangle block, each skewed to the right by 30 degrees and then rotated by 0, 120 and 240 degrees respectively, as shown in the following image. A triangle hole may appear in the middle, but that isn't a ... |
This is kept fairly original:
Write a program that creates a standard blackjack game:
input "h" means hit or draw another card
input "s" means stand, or take what you have already
Rules:
cards values are as follows:
2-9 = face value of card
10, J, Q, K = 10
aces = 11 unless player busts, then it's only a 1
if 2 or m... |
Dowker notation is a common way of representing mathematical knots.
Dowker notation can be derived from a knot diagram in the following way (based on the description from the wikipedium):
We will label each of the \$n\$ intersections with two numbers whose absolute value is on the range \$1, \dots 2n\$ (one odd one ev... |
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... |
Golfeek is the working name of an esolang I'm occasionally working on. One distinctive feature of this language is that each statement is encoded as a sequence of bits rather than a sequence of bytes.
Instead of just showing a long binary sequence, the 'gutter' of the source editor contains a representation of each sta... |
Sandbox
Adapted from exercise 4 of 100 little Keg exercises
The ability to repeat chunks of code within a program is an important part of any programming language. Also just as important is the ability to make decisions based on different values.
The Challenge
I want you to write a program that:
Starts at the number ... |
In a challenge of CodingGame, there is a challenge that ask you to decode a string composed by reversed words ('Hello world' > 'olleH dlrow') then each characters converted into ascii value separeted by space:
>>> decode('111 108 108 101 72 32 100 108 114 111 119 32 41 58')
Hello world :)
The challenge is to be the fa... |
This challenge is inspired by the same task I read some time ago in CACM.
There are many ways to sort stuff. Most attempt to sort in as few operations as possible (= as fast as possible). However, it is also possible to consider how few resources you might require to sort stuff, which seems more fitting for a codegolf ... |
The goal is simple, print out each day of the twelve days of Christmas, the text should match this exactly
On the first day of Christmas my true love gave to me
A partridge in a pear tree
On the second day of Christmas my true love gave to me
Two turtle doves, and
A partridge in a pear tree
On the third day of Christ... |
Flip flop is a memory / arithmetic game that I played in high school. Some number of players stand in a circle. The players take turns. On the nth turn, the current player checks:
What is the largest power of 7 dividing n?
How many instances of the digit 7 does the decimal representation of n contain?
What is the larg... |
The \$d\$-dimensional vector space \$\mathbb{F}_2^d\$ over the field with two elements \$\mathbb{F}_2\$ is the set of vectors of \$d\$ bits. Addition of vectors is bitwise xor. A linear dependence is a set of vectors whose total (xor them all together) is \$0\$. Every set of \$d+1\$ vectors in \$\mathbb{F}_2^d\$ contai... |
The Challenge
Given a finite list of integers, split it into the fewest partitions possible such that no partition contains a number more than once.
Rules
Input can be in any format and any order.
Output can be in any format, as long as it's clear that each group is separate.
This is code-golf, so lowest score wins!
Ex... |
(This is not a duplicate of Follow the path, as this challenge have invalid path detection and use ><^v in the output.)
Task
So your task is to take in the description of the path and draw it out in a "Befunge(or a lot of other 2D esolangs)-like" format, and detect if it is invalid. Note that if the path is invalid, yo... |
\$GF(9)\$ or \$GF(3^2)\$ is the smallest finite field whose order isn't a prime or a power of two. Finite fields of prime order aren't particurlarly interesting and there are already challenges for \$GF(2^8)\$ (link) and \$GF(2^{64})\$ (link).
Challenge
First define nine elements of the field. These must be distinct in... |
Is there any javascript-like language? Something that can be interpreted by browsers?
|
(Inspired by the Keg utility of this challenge)
Given a non-empty input string, e.g. s c 1= e(a"E"), split the input into even-odd chunks.
Example (Feel free to suggest more)
I can only think of this test case, fee free to suggest more.
This input string, when mapped to its code points, yields the list [115, 32, 99, 32... |
Every so often I have a function of type a -> b and a function of type b -> b -> c and I would like a function of type a -> a -> c. For example if I wanted to check the second element of each two tuples were equal
snd :: (a , b) -> b
(==) :: Eq a => a -> a -> Bool
And I want something of type
Eq b => (a, b) -> (c, b)... |
If \$f,g\colon \mathbb{Z}_{\geq 1} \to \mathbb{R}\$, the Dirichlet convolution of \$f\$ and \$g\$ is defined by
\$ \qquad\qquad\qquad \displaystyle (f*g)(n) = \sum_{d|n}f(d)g(n/d).\$
This question asked about computing Dirchlet convolution of functions.
The identity element of the Dirichlet convolution is the functi... |
Introduction
Adam (A) and Bubbler (B) are playing coin toss, where the one who wins 5 times first would win the prize of $32. If the game is aborted when the scores are A:B = 4:3, how should they distribute the prize? Assume the coin toss is fair, so the winning chance of either player is 1/2 for each game.
The answe... |
On CodingGame, there is a Puzzle that ask to write words with ascii art.
I solve the puzzle then tried to golf it. What improvement can I do on it?
INPUT
>>> 20
>>> 11
>>> MANHATTAN
>>> .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------... |
The challenge
Given a positive integer N, compute the proportion of N-step walks on a plane that don't intersect themselves.
Each step can have any of the 4 possible directions North, East, South, West.
A walk intersects itself if it visits a previously visited point.
Examples
N=1: a single-step walk obviously doesn'... |
I often have to take character data and categorize it numerically at work. A common thing I do is to take character type variables and convert them to numeric type characters, keeping same categories according to the level of work I'm doing. (The longer the substring, the more in depth and specific, shorter substrings ... |
Sandbox
Adapted from exercise 8 of 100 little Keg exercises
String manipulation is a very important part of any programming language. Consequently, that is what this challenge is about.
The Challenge
I want you to write a program that:
Takes a series of characters as input and,
Then takes another input (integer/letter... |
As the trip through the solar system on your way to rescue Santa gets a little droll, so perhaps some optimizations to your Intcode Computer are in order. Namely, making it as small as possible because you've got nothing better to do with your time.
Check out Advent of Code if you haven't already, the guy that makes th... |
You are given an countable ordinal \$1 < r < \varepsilon_0\$. Determine whether or not it is prime. If not, provide exactly two ordinals \$r_0, r_1 < r\$ such that \$r_0r_1 = r\$, following rules of ordinal multiplication, and furthermore satisfy at least one (not necessarily both) of the following:
\$r_0\$ is a limit... |
Can you recover a sequence of letters from a sequence of dots and dashes? In Morse code, x is represented by -..-, but without the help of spaces, -..---.-... could represent xmas, or dole, or teettteteee, etc.
I took the lyrics from "Rudolph, the Red-Nosed Reindeer" to make the following sequence of letters:
youknowda... |
In the plane (\$\mathbb R^2\$) we can have at most five distinct points such that the distances from each point to every other point (except itself) can assume at most two distinct values.
An example of such an arrangement is a regular pentagon - the two different distances are marked with red and blue:
Challenge
Give... |
Intro/Background
I was looking at "You Had One Job" pictures lately, and noticed an old favourite of mine:
And I said to myself: "I need a program that can generate text like that".
So I devised a set of rules for character swapping and wrote a CGCC challenge!
The Challenge
Given a single string as input, output a str... |
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one. Given a binary string \$S\$ of length \$n\$, we are a interested in the number of different strings of length \$n\$ which have distance at most \$3\$ ... |
Given a sequence \$S\$ with length \$n\$ of exactly one each of whole numbers from \$1\$ to \$n\$, your task is to return a number \$\sigma\$ indicating how shuffled it is.
Definition of shuffledness
Humans perceive shuffling randomness locally [Citation Needed], so the shuffledness of a sequence is based on the abilit... |
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 ... |
Your task is to make a program which interprets the language it is run in, but also works in many languages.
Let's say you make a Brainfuck-Underload self-interpreglot, as it will be called. Run in Brainfuck, this program should be a Brainfuck interpreter; run in Underload, it should be a Underload interpreter.
Your pr... |
Introduction
Your job is to write a function or program that detects if a number a is less than a number b.
But... You are not allowed to use built-in alternatives for equals, less than, greater than, less than or equal to, greater than or equal to, or not equal to operators. (Writing your own implementation is allowed... |
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one.
The challenge is to compute the average Levenshtein distance between two independent and uniformly random chosen binary strings of length n each. Your... |
Output a random triple \$(x,y,z)\$ of real numbers such that
\$x+y+z=\frac{3}{2}\$
Each of \$x,y,z\$, taken alone, is uniformly distributed from \$0\$ to \$1\$.
Please explain in your answer what distribution your code produces and why it meets these conditions. In particular, please include a demonstration that with... |
Significantly harder version of Spanning tree of a rectangular grid.
Background
A spanning tree (Wikipedia) of an undirected graph is a subgraph that is a tree which includes all of the vertices of the original graph. The following is an example of a spanning tree of a 4-by-4 grid graph.
Task
Given two positive intege... |
Introduction
In a list of strings, there is a certain length you can shorten strings to before they become indistinguishable. This is a pretty bad explanation, so here is an example.
['hello', 'help', 'helmet']
['hell', 'help', 'helme']
['hell', 'help', 'helm']
['hel', 'hel', 'hel'] <- At this point the strings are i... |
In golf, a knowledgable caddie helps an already good golfer to be even better. In this challenge, you build a "caddie" to help you code golf. In particular, your caddie will compress golfed code in such a way that another program can uncompress and then run the code. A good caddie will compress golfed code to be much s... |
Given a non-empty list/vector of positive integers, write a function to check the following conditions in as few bytes as possible.
Take the first integer (the key, or k1) and check that the next k1 values have no duplicate values, excluding instances of k1.
Take the last integer (the second key, or k2) and check tha... |
Given a sequence of base-10 digits, output the longest list of integers that contains all the digits exactly once, in the order in which they appeared in the input, without repeating any integers.
Examples
Input: 12345
Output: [1, 2, 3, 4, 5]
Input: 12123
Output: [1, 2, 12, 3]
Input: 10010
Output: [100, 1, 0]
Input:... |
In this task you are expected to provide a list output given an input tq program. The tq programs will not contain whitespace inside them.
What is tq, in the first place?
tq is a lazy-evaluated language that is designed with the idea that array items should be accessable during the definition of them. In tq, there is n... |
Introduction
Nine-Ball is a popular pool game played casually and as a competitive sport.
There is one of each numbered ball, with the numbers 1 to 9.
The game starts with all 9 of the balls in a diamond shaped rack, like so:
1
2 3
4 9 6
5 7
8
The 1 ball is always at the front of the diamond, and the 9 ball is a... |
Input
The input will be a year between 1583 and 2239. We just want to know when Hannukah was or will be in that year. This is information used by millions of people every year and put in calendars across the world. What could be easier?
Output
The Gregorian date of the first evening of Hannukah that year. That is the ... |
Write the smallest program that maps strings injectively to outputs and maps itself to 2020.
To be clear, your program \$p\$ must have the following properties:
every possible input string \$s\$ has a well-defined output \$p(s)\$,
for every pair of strings \$s\$ and \$t\$ with \$s\neq t\$, it holds that \$p(s)\neq p(t... |
Related: Is this quadrilateral cyclic?
Background
A tangential quadrilateral is a quadrilateral which has an incircle:
Examples include any square, rhombus, or a kite-like shape. Rectangles or parallelograms in general are not tangential.
Task
Given the four vertices of a quadrilateral (as Cartesian coordinates), dete... |
I am trying to find the shortest code in python 3, to solve this problem:
You are driving a little too fast, and a police officer stops you.
Write code to take two integer inputs, first one corresponds to speed, seconds one is either 1 or 0, corresponding to True and False respectively to indicate whether it is birthd... |
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... |
Do randomly generated drum loops sound good?
A drum loop is a \$5\times 32\$ matrix \$A\$ of \$1\$s and \$0\$s such that
\$A_{1,1}=A_{1,17}=A_{2,9}=A_{2,25}=1\$,
for each \$i\$, the \$i\$th row has exactly \$f(i)\$ different \$1\$s, where \$ f(1)=3, f(2)=2, f(3)=6, f(4)=8, f(5)=5\$,
for each \$j\equiv 1\bmod 4\$, the ... |
Just over seven years ago, everybody suddenly stopped talking about the Maya people. It is time to rectify that!
For clarification, I am talking about the Mesoamerican Long Count Calendar. Your program will have as input a date in the Gregorian Calendar, and as output the corresponding date from the aforementioned Meso... |
Question
Write a program to accept one string on the console only and print back its letters arranged in alphabetical order. The string must only have the following characters:
0123456789abcdefghijklmnopqrstuvwxyz
Rules
The ascending alphabetical order is defined in the given string.
All repeated characters must be ... |
Posted from sandbox
The Intro
What is an ACU? This challenge is based on the concept of money and since this is an international community, we all use different currencies, so in keeping with our spirit of inclusiveness, I have invented a new currency called Arbitrary Currency Units (ACUs) specifically for this challen... |
In LLAMA, you want to dump cards from your hand as quickly as you can, but you might not be able to play what you want.
Each player starts a round with six cards in hand; the deck consists of llama cards and cards numbered 1-6, with eight copies of each. On a turn, the active player can play a card or draw a card. To p... |
Challenge
Write a program or function that converts a 32 bit binary number to its quad-dotted decimal notation (often used for representing IPv4)
Quad-dotted decimal
A quad-dotted decimal is formed like so:
Split the binary representation into its 4 individual bytes
Convert each byte into denary
place "." between each... |
Given two nonempty arrays of natural numbers \$a\$ and \$b\$, return the shortest nonempty array of pairs of natural numbers \$q\$ such that the sequence of first elements of \$q\$ consists of a whole number of repeated copies of \$a\$, and the sequence of second elements of \$q\$ consists of a whole number of repeated... |
Challenge
Create 2 programs A and B
The output of program A is exactly program B
The output of program B is exactly program A
Neither program should depend on inputs to yield the correct output
A and B are not identical programs
A and B are of different programming languages
Neither program may be equivalent to i... |
Suppose we have two different types of coin which are worth relatively prime positive integer amounts. In this case, it is possible to make change for all but finitely many quantities. Your job is to find the largest amount that cannot be made with these two types of coin.
Task
Input: A pair of relatively prime integer... |
If \$f(x) = x + \sum_{i>1} a_ix^i\$ and \$g(x)=x+\sum_{i>1}b_ix^i\$ then there is a composite power series \$f(g(x))\$ also of this form. Given a power series \$f\$ the goal is to find a compositional inverse \$f^{-1}\$ so that \$f(f^{-1}(x))=x\$.
One approach to this is recursive: start with a guess \$g_1(x)=x\$ for t... |
Challenge
Write a complete program that prints out the time it took to execute a certain part of itself. That part must include a process whose total number of operations (and therefore execution time) is dependent on a user-substituted numeric value - this can be denoted in any way in your code (uppercase N for exampl... |
Background
The special linear group \$ SL_2(\mathbb{Z}) \$ is a multiplicative group of \$ 2 \times 2 \$ matrices whose elements are integers and determinant is 1.
It is known that every member of \$ SL_2(\mathbb{Z}) \$ is a product of some sequence of the following two matrices \$ S \$ and \$ T \$ (reference pdf):
$$
... |
This is a version of this question which should not have such a straightforward solution and so should be more of an interesting coding challenge. It seems, for example, very likely there is no easy to find closed form solution, even though we have only increased the bound by one from the previous version. Having said ... |
Inspired by this blog post.
Write a program that outputs 99 distinct programs (in the same language) that output the string I love you.
How the programs are separated from one another in the output will be defined by you. However, Each byte of output can only belong to at most 1 of the 99 programs.
Constraints for Out... |
Special thanks to Bubbler and AdmBorkBork for supplying feedback about this challenge
Keta (Keyboard tacit — clever naming, I know!) is a golfing language I’ve been working on recently. One of it’s features is it’s most probably unique bracket autocompletion system, which will hopefully allow for shorter programs.
The... |
Background
Perfect shuffle algorithms like Fisher-Yates shuffle don't produce great results when it comes to music playlist shuffling, because it often produces clusters of songs from the same album. In an attempt to solve this problem, Spotify introduced an interesting shuffle algorithm in 2014. At the end of the arti... |
You are given 4 positive integers: volume of the first container (v1), volume of the second container (v2), volume of the liquid in the first container (l1), and volume of the liquid in the second container (l2). Your task is to move some of the liquid from container 1 to container 2, making the amount of empty space i... |
In musical notation, groups of notes shorter than one beat are joined together by a line at the bottom called a beam. Here are a few bars of music with the beams highlighted:
(Taken from Second Suite in F by Gustav Holst; you can hear how these notes sound at 0:13 in this video.)
You may notice that beam #6 is above t... |
Challenge
Write a program or function that takes a number \$n\$ and returns the smallest \$k\$ such that concatenation \$n'k\$ is a square. This sequence is described by A071176 on the OEIS.
I/O Examples
input --> output
1 --> 6 (4^2)
10 --> 0 (10^2)
35 --> 344 (188^2)
164 --> 836 (406^2)
284 --> 2596 (168... |
Inputs:
The program or function should take 2 vector-like (e.g. a list of numbers) O and V of the same number of dimensions, and a number T (all floating-point numbers or similar)
Constraints:
T >= 0
All elements of Vector O will be in the range [0,1)
Output:
The program or function should output the N dimensional c... |
In this fastest-code challenge, you are provided with a set of \$n\$ identical blocks and need to determine how many unique buildings can be constructed with them. Buildings must satisfy the following rules:
No overhangs - each block must either be on the ground or supported by one or more blocks directly underneath i... |
Challenge:
Input: a string, consisting of only printable ASCII characters
Output: a truthy/falsey value whether its characters are in alphabetical order (based on their UTF-8 unicode values), from any starting point inside the string including wrap-around by going left-to-right
For example: xyzabc would give a truthy r... |
Introduction
The telephone numbers or involution numbers are a sequence of integers that count the ways \$n\$ telephone lines can be connected to each other, where each line can be connected to at most one other line. These were first studied by Heinrich August Rothe in 1800, when he gave a recurrence equation where th... |
The Challenge
Write two programs P and Q such that:
P and Q are written in the same language
The output of P is Q
The output of Q is P
P and Q are both non-empty
Simple enough. Surely that's been done here before. Where this gets interesting is the scoring.
Scoring
P and Q are selfish, they don't want to sheir their... |
It's a normal truth machine but instead of taking input, it uses the first character of the program. Thus, internal.
The 0 and 1 are plain characters, i.e. ASCII code 0x30 and 0x31 respectively.
Example: 0abcd prints 0 and halts, and 1abcd prints 1 infinitely. Then your submission is abcd, whose score is 4 bytes. The 0... |
In math a magic square is an N×N grid of numbers from 1 to N2 such that every row, column, and diagonal sums to the same total. For example here's a 3×3 magic square:
In this challenge we'll extend the idea to magic code squares where, instead of numbers, each grid cell is any non-newline character. They can be be rep... |
The challenge - given a numeric list L and an integer N as inputs, write a function that:
finds the bucket sizes for L such that it is split into N whole buckets of equal or near-equal size, and
returns for each element in L the minimum of that element's bucket.
Example -
L=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
N=... |
The McGill Billboard Project annotates various audio features of songs from a random sample of the Billboard charts. I scraped this data to produce the following file of chord progressions:
chords.txt
Write the shortest code that outputs the above file (or its contents).
Edit: Here's a quick description of the notation... |
The challenge is to implement a program or function (subsequently referred to as "program") that takes a nonnegative integer \$n\$ as input and returns \$n\over\sqrt{2}\$ (the input divided by the square root of two) as output, rounded to a nonnegative integer.
You may take your input and output in any reasonable forma... |
Creating a golfing language can be hard. Let's help budding golfing language creators out and provide some helpful tips on how to create one.
I'm looking for tips on:
The design process
Implementation
Community engagement
One tip per answer would be appreciated, and tips like "don't create a new language, use an exis... |
Background
One of the commonly meme'd aspects of javascript is its incredibly loose type coercion that allows for +!![]+[+[]] == '10' this technique can also be used to create letters as seen in the following example:
[[][[]]+[]][+[]][-~[]] == 'n'
[undefined+[]][+[]][-~[]] // [][[]] -> undefined
['undefined'][+[]][-~[]... |
Something unusual: a code golf question with a purpose.
I occasionally find myself in scenarios resembling the following:
Suppose you have two computers, A and B. Both of them have a fresh copy of Windows 10 installed. It comes with all the usual stuff, like notepad and paint and a browser, but no extras, like a Linu... |
Super permutations
Input: A string
The program should loop through all lengths of the input (decrementing one each time), generate all combinations with replacement of the string, then make permutations out of the generated combinations, and display all of the strings.
They can be separated with anything (doesn't need... |
Write a program/method that:
Becomes a quine when the input matches the source code;
Doesn't halt otherwise.
This is code-golf, so shortest solution wins. Avoid any standard loopholes.
|
A "simple circular" word is a word whose chords do not intersect. The chords of a word may be seen by laying out the alphabet in a circle, and then connecting the word's consecutive letters.
Examples of Simple Circular Words
ROLE
LAKE
BALMY
Failing Example
A word fails to be simple circular if any of its chords in... |
This challenge is about the number of orderings which contain at most \$n\$ classes and at most \$k\$ of the \$k^{\text{th}}\$ class.
One way to represent such an ordering is as a sequence of positive integers with these three restrictions:
A number may only appear after all lower numbers have appeared
All numbers whi... |
Inspired by this question on the puzzling stack exchange.
Rules
Given 5 stacks of 5 cards with numbers from 1 to 7, output the moves needed to empty all stacks. A move is defined as the index of a column to pull the card off of, and a move is only valid if:
The stack is non-empty
The value of the card at the top of ... |
Background
We define the prime-counting function, \$\pi(x)\$, as the number of prime numbers less than or equal to \$x\$. You can read about it here.
For example, \$\pi(2) = 1\$ and \$\pi(6) = 3\$.
It can be shown, using dark magic, that
\$ \lim_{x \to \infty} \frac{\pi(x)}{x/\log x} = 1 \$
which means we can approxima... |
The 3Blue1Brown Youtube channel released a video a year ago called "Why do colliding blocks compute pi?" which describes a model where a block A of mass \$a\$ slides into a block B of mass \$b\$, which then pushes block B into a wall, causing it to bounce off the wall and then collide again with block A.
The miracle of... |
Write a program using the fewest bytes of source code which given a list of strings finds all elements which are still in the list when any character is deleted.
For example, given a list of all English words boats would be output because oats, bats, bots, boas, boat are all English words and thus would be in the list.... |
Challenge:
Your challenge is to write an interpreter for Whitespace. Given a string consisting of spaces, tabs, newlines, and potentially other characters, as well as possible inputs for the Whitespace program itself, output the result of the given Whitespace program.
Here is an overview of the Whitespace language and ... |
Tonight, 31 January 2020, Brexit will happen and the United Kingdom will leave the European Union, the first time that the number of EU member states will decrease.
Your job is to take a date and output the number of EU1 members on that date, according to the following table:
| Start | End | Number of memb... |
Consider \$3\$ binary strings of length \$n\$ chosen independently and uniformly at random. We are interested in computing the exact expected minimum Hamming distance between any pair. The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different.... |
Requirements:
Take a single word as input with only lowercase alphabetical characters (a-z)
Output a string where every other character is repeated, with the first repeated character being the second character in the string
Example:
Input: abcde
Output: abbcdde
Winning Criteria:
Standard code golf. Shortest number of... |
You're at integer coordinates \$(x,y)\$ facing one of North, South, East, or West. Your goal is to walk home to \$(0,0)\$. At each step, you may do one of:
Walk one step in the current facing direction, that is to whichever of \$(x+1,y)\$, \$(x-1,y)\$, \$(x,y-1)\$, or \$(x,y+1)\$ you're facing.
Rotate 90 degrees left,... |
Generator functions
This gives the context for why this challenge came to life. Feel free to ignore.
Generator functions are a nice way of encoding the solution to a problem of combinatorics. You just write some polynomials, multiply them and then your solution is the coefficient of one of the terms.
For example, how m... |
Alice and Bob are perfect logicians trapped on an island with a puzzle generator. Although they can instantly solve the Riemann hypothesis and P=NP just by thinking about it, rather than doing anything useful, they amuse themselves by giving each other puzzles. The setup is as follows: a positive integer n is chosen by... |
Intro/Background
I was looking at a Flybuys card at Coles recently and noticed that if I took something like this:
Source, randomly found on the Internet
And swapped some words around, I'd get this:
After I finished laughing (don't judge my sense of humour please), I said to myself: "I need a program that can gener... |
When you look at the last decimal digit of each power of a non-negative integer a repeating pattern forms. For example, 3:
3^1 = 3
3^2 = 9
3^3 = 27
3^4 = 81
3^5 = 243
3^6 = 729
3^7 = 2187
3^8 = 6561
3^9 = 19683
The last digits go 3971 which repeats indefinitely. In fact any number we choose that en... |
In this task you will take as input a non-negative integer \$n\$, and output the number of pairs of non-negative integers \$a,b\$ such that both are palindromes*, \$a \leq b\$, and \$a+b = n\$. For example if \$n\$ is \$22\$ then the valid pairs are
\$
\begin{array}{c|c}
a & b \\
\hline
0 & 22 \\
11 & 11 \\
\end{arra... |
Background
SKI combinator calculus, or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of combinators, namely S, K, and I instead of lambda abstraction. Unlike lambda calculus, beta reduction is possible only when a combinator is given enough arguments to reduce.
T... |
Definition
We say a pair of integers \$(a,b)\$, where \$0<a<b<N\$ and \$N\$ is an integer larger than 4, is an inverse neighbor pair respect to \$N\$ if \$ab\equiv1\text{ }(\text{mod }N)\$ and \$1\le b-a\le\log_2{N}\$. There may be no such pairs respect to some integers \$N\$.
To illustrate the definition, consider \$... |
Disclaimer: This challenge is inspired by a coding error I once made.
Okay, time for a maths lesson. A normal mean average looks like this:
Work out the sum of all numbers in a list
then divide by the size of the list.
But what if we don't know all the numbers at the time we're working out the average? We need a way ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.