instruction stringlengths 34 53.1k |
|---|
In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is stable under gravity when placed on the edge of a table which spans from \$x = -\infty\$ to \$0\$ horizontally, with the surf... |
Much harder than Can this pattern be made with dominoes?
Challenge
A grid of width \$w\$ and height \$h\$ is given, filled with 1s and 0s. You can place a domino somewhere on the grid only if both cells are 1. You cannot overlap dominoes. What is the maximum number of dominoes you can fit in the given grid?
The worst-c... |
The Lisp language has a family of functions car, cdr, cadr, etc for accessing arrays. For each one, an a defines taking the first item of an array, and a d defines taking the rest.
For example, running cadr on [[1,3,4],5,7] will return [3,4] as the a gets the first item ([1,3,4]) and the d removes the first item.
We've... |
Given a list of integers find the "trajectory" that results from indefinitely moving the instructed steps to the right (left if negative), wrapping if necessary, starting at the first element.
A "trajectory", here, is defined as a list containing the elements that are visited only one time, in the order they are visite... |
The goal of this challenge is to fill a niche that is mostly lacking on this site. In my observations there most parsing verification challenges fall into two categories:
Super easy parsing. This parsing can usually be done with a regex, and regex based answers usually do well.
Super complex parsing. These are cha... |
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... |
This is a rock:
*
Rocks can be stacked. Apart from the bottom-most layer, each rock must rest on two other rocks, like this:
*
* *
You have a pile of rocks, and your boss wants you to pile them symmetrically, taking up the least horizontal space possible.
Your challenge is to take a number of rocks as input, and out... |
This includes tips for all related derivatives, as coding in these langs often primarily consists of writing the function in the lambda calculus and then compiling it down at the end.
Among others, this includes tips for:
Standard combinator calculi
SKI system
BCKW system
Esolang combinator calculi
Iota/Jot/Zot
La... |
Related: Boustrophedonise, Output the Euler Numbers (Maybe a new golfing opportunity?)
Background
Boustrophedon transform (OEIS Wiki) is a kind of transformation on integer sequences. Given a sequence \$a_n\$, a triangular grid of numbers \$T_{n,k}\$ is formed through the following procedure, generating each row of num... |
Consider a binary tree built the following way:
The root node is \$1\$
For a given node \$n\$:
If \$n\$ is odd, its only child is \$2n\$
If \$n\$ is even, one of its children is \$2n\$. If \$\frac {n-1} 3\$ is an integer and not already part of the tree, its right child is \$\frac {n-1} 3\$
Recursively and infinite... |
Forth is one of the few non-esoteric stack-based languages. For this challenge, we will use a small subset of Forth, which simply executes a sequence of words in a linear fashion — without any definitions or loops.
In good Forth code, each word definition includes a stack effect comment, which explains the layout of th... |
Wheat Wizard has once tried to come up with a parsing problem unsuitable for regex, but it failed due to Anders Kaseorg's Perl regex answer. This is the second attempt. Now that we know that Perl regex is far more powerful than we've imagined, this challenge aims to be un-golfy for it instead.
Introduction
A lambda ter... |
I want you to make a gui window like this:
* if you're thinking, the [quit] button closes the window
in any language using minimum "different" characters..
AND remember that the gui window must use native widgets instead of custom icons and buttons
like I have Windows 8, so my GUI window looks like this:
If you didn'... |
Inspired by this video by Matt Parker
The distances between the letter keys of a QWERTY keyboard are somewhat standardised. The keys are square and both the horizontal and vertical spacing are 19.05mm (so if there were no gaps between the keys, their side lengths would be 19.05mm), and the three rows of keys are offset... |
Write a program that outputs the exact string:
jan ale o, toki!
("Hello, world" but in toki pona to prevent builtins.)
with an optional trailing newline.
Additionally when all copies of any one byte present in your program are removed the program must fail to produce a correct output no matter what byte is selected.
T... |
Story
My local pizza delivery introduced new discount. You get 50% discount from every second item on your order.
But being greedy capitalists, they forgot to mention that they will rearrange items the way they need to give you as little as possible.
Example
Imagine you ordered
- Pizza $20
- Pizza $20
- Coke $2
- Coke ... |
Background
-rot transform (read as "minus-rot transform") is a sequence transformation I just invented. This transform is done by viewing the sequence as a stack in Forth or Factor (first term on the top) and repeatedly applying -rot +. -rot is a command that moves the top of the stack to two places down, and + adds tw... |
The game shapez.io has a huge variety of shapes you can produce, such as:
Each shape has a unique short code, for example the above is CrWbScRu.
This means, going clockwise from top right, red circle (Cr), blue wedge (Wb), cyan star (Sc), uncolored rectangle (Ru).
There are four different shapes:
Rectangle - R
Wedge ... |
Your task is to create a program that outputs the string:
Hello, Toroidal Earth!
with an optional trailing newline.
Additionally if I remove the first line1 of your program and add it as a line after the end of your program the new program should be a valid solution to this challenge in the same programming language.
... |
Given a number \$n ≥ 2\$, a blackbox function \$f\$ that takes no arguments and returns a random integer in the range 0...n-1 inclusive, and a number \$m ≥ n\$, your challenge is to generate a random integer in the range 0...m-1 inclusive. You may not use any nondeterministic builtins or behaviour, your only source of ... |
The edit distance between two strings is the minimum number of single character insertions, deletions and substitutions needed to transform one string into the other.
This task is simply to write code that determines if two strings have edit distance at most 3 from each other. The twist is that your code must run in l... |
The game shapez.io has a lot of shapes. In my previous challenge, the object was to generate a random code for a shape. Now, your challenge is to render a shape.
Specs
Shapes
Each shape has a unique shortcode, for example:
is CrWgRuSp - clockwise from top right, red circle, green wedge, uncolored rectangle, purple sta... |
Write a function that takes in a string and for each character, returns the distance to the nearest vowel in the string. If the character is a vowel itself, return 0.
Vowels are : aeiouAEIOU
For the purposes of this challenge, y is not a vowel.
The input will be a string consisting of uppercase and lowercase letters.
E... |
Let's define a function \$f\$ which, given a positive integer \$x\$, returns the sum of:
\$x\$
the smallest digit in the decimal representation of \$x\$
the highest digit in the decimal representation of \$x\$ (which may be the same as the smallest one)
For instance:
\$f(1)=1+1+1=3\$
\$f(135)=135+1+5=141\$
\$f(209)=... |
Consider the integer set \$S = \{3, 5, 6, 7\}\$. If we list all \$2^n\$ subsets of \$S\$ (its powerset) and calculate their sums, we get
$$
\mathcal{P}(S) = \{\emptyset, \{3\}, \{5\}, \{6\}, \{7\}, \{3, 5\}, \{3, 6\}, \{3, 7\}, \{5, 6\}, \{5, 7\}, \{6, 7\}, \{3, 5, 6\}, \{3, 5, 7\}, \{3, 6, 7\}, \{5, 6, 7\}, \{3, 5, 6,... |
Background
Page 219 of A New Kind of Science (a book by Stephen Wolfram, the creator of Mathematica) shows an interesting 2D pattern generated by constraints. The relevant section in the book starts at page 210; you can browse other pages for more context.
In short, the large binary image is the result generated by 12... |
Since jq is the Language Of The Month for September 2021, what general tips do you have for golfing in jq? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to jq (e.g. "remove comments" is not an answer).
Please post one tip per answer.
|
Task:
Input will consist of some text, with nested [] separating some of it into nested groups:
abc[d[fgijk]nopq]rst[u[v[[w]]]xy[[[z]]]]
Your task is to remove all brackets, and everything wrapped in an odd number of brackets. For example, a[b]c would remove the [], and the b inside of it. a[[b]]c, however, would only... |
The string
abaaba
Is a palindrome, meaning it doesn't change when it's reversed. However we can split it in half to make two palindromes
aba aba
We could also split it up this way:
a baab a
And all three of those are palindromes.
In fact there are only two ways to split the string into smaller strings such that non... |
Content
You count numbers every day (I think), and most of you know how to count properly, the one next to 1 is 2, and the next is 3, so go on, no matter what number you receive, you can easily know what next number is.
Anyway, the program doesn't know, they are incredibly stupid, if I make a program shaped like 1, it ... |
Though challenges involving magic squares abound on this site, none I can find so far ask the golfer to print / output all normal magic squares of a certain size. To be clear, a normal magic square of order \$n\$ is:
An \$n\times n\$ array of numbers.
Each positive integer up to and including \$n^2\$ appears in exactl... |
Euler's numerus idoneus, or idoneal numbers, are a finite set of numbers whose exact number is unknown, as it depends on whether or not the Generalized Riemann hypothesis holds or not. If it does, there are exactly 65 idoneal numbers. If not, there are either 66 or 67. For the purposes of this challenge, we'll revoluti... |
Toki Pona is a constructed language with 137ish words, designed to constrain the speaker to expressing ideas in a simple and straightforward manner, reducing ideas to more essential forms.
Often, people attempt to avoid directly expressing numeric quantities in Toki Pona, opting to express them in more practical terms.... |
When I was a child I used to play a variation of Snap to stake soccer trading cards.
"Game" is an overstatement because the only role of the players is to secretly prepare their starting piles. As the game starts there are no choices other than just perform the game algorithm.
Rules
There is no maximum number of player... |
There are 31 positive integers that cannot be expressed as the sum of 1 or more distinct positive squares:
2, 3, 6, 7, 8, 11, 12, 15, 18, 19, 22, 23, 24, 27, 28, 31, 32, 33, 43, 44, 47, 48, 60, 67, 72, 76, 92, 96, 108, 112, 128
There are 2788 positive integers that cannot be expressed as the sum of 1 or more distinct ... |
A listening party is an event where a bunch of people get together to listen to some music (like a viewing party, but for music). In the age of the internet you can do Listening Parties online with friends, where you just all hit play together.
The problem is on the internet everyone is in different time-zones so you ... |
The fill bucket is a tool available in many drawing tools which replaces a contiguous chunk of one color with a another color.
We are going to define a fill bucket which operates on lists of non-negative integers. When used this replaces a contiguous sub-list of one integer with another selected integer. For example
[... |
Challenge
Implement the "greedy queens" sequence (OEIS: A065188).
Details
Taken from the OEIS page.
This permutation [of natural numbers] is produced by a simple greedy algorithm: starting from the top left corner, walk along each successive antidiagonal of an infinite chessboard and place a queen in the first availabl... |
Background
A Young diagram is a diagram that represents a nonincreasing sequence of positive integers using left-justified rows of squares. As an example, 5, 4, 1 is drawn as
OOOOO
OOOO
O
A Young diagram is said to be symmetric if it is identical to its transpose (reflection along the NW-SE diagonal). The above diagra... |
Unlolify a lolified message!
I had to ask a coworker if they wanted to have lunch with me, but we're both hackers so it could not be in a lame way. The message asking that was roughly this:
please respond with 011110010110010101110011 if you'd like to join lunch today
The colleague being a hacker, just responded with... |
I was wondering if there is any way to assign 2 values (G and H) to say a list of ["egg", "chicken"] in Pyth. In python it would be something along the lines of
G, H = ["egg", "chicken"]
At the moment the shortest way I can think of would be something like
=N["egg""chicken")=G@N0=H@N1
which uses the lookup function t... |
Platforms are stretches of - characters separated by one or more characters.
For example:
------ -- ------ -
The above has 4 platforms sizes 6, 2, 6 and 1.
Platforms that are not supported will fall. To be supported platforms need Jimmies.
Jimmies look like this:
\o/
They are three units wide. Don't ask me what ... |
Problem
Starting with a set of 10 coins at the start where all coins are tails up, and given n number of integers \$x_1, x_2, x_3... x_n\$ representing n rounds of coin flipping.
At each round, we randomly flip \$x_i\$ number of coins at random. i.e Coins that were heads become tails, and vice versa. Within each round,... |
The golfing language Jelly has a very complex and clever string compression system which I'm not going to go into depth about here. You can find a very good explanation here.
Basically, Jelly's string literals are represented as “...», where ... is a string of characters from Jelly's codepage that is decoded into a bas... |
To quote http://brainfuck.org/utm.b:
A tag-system transforms strings over an alphabet A = {a[1], a[2], ... a[n], a[n+1]} as follows: a positive integer m is chosen, and so is a function P that maps each a[i] for 1<=i<=n to a string P(a[i]) over the alphabet A. Now:
if the string being transformed has fewer than m ele... |
Background
K functions have a feature called projection, which is essentially partial application of values to a function. The syntax for projections is a natural extension of the regular function call syntax:
f[1;2;3] / call a ternary function f with three arguments 1, 2, 3
f[1;2;] / the third argument is missi... |
Consider a form of binary where digits can be any of \$1\$, \$0\$ and \$-1\$. We'll still call this "binary" because we convert the digits from base two. For example,
$$\begin{align}
[1, 0, -1, 1]_2 & = 1 \times 2^3 + 0 \times 2^2 + -1 \times 2^1 + 1 \times 2^0 \\
& = 8 - 2 + 1 \\
& = 7
\end{align}$$
We'll call a repre... |
Given a map from arrays of integers of same size to single integers, determine if there is a set of indices such that the output is equal to the maximum of the elements at those indices for every corresponding pair.
You can take the input as a map if your language support, arrays of pairs, separated 2D array of input a... |
Given a string consisting of only upper and lower case letters, output an if it begins with a vowel, and a if not. For the purposes of this challenge, we'll ignore normal grammar rules, and use a very basic rule instead: if the input begins with a vowel (any of AEIOUaeiou), then output an. Otherwise, output a.
Your pro... |
Word equations, but not as you know it! Given a sentence which will include two numbers, numerically, and a spelt operator, in the order seen in the examples, your goal is to give the numerical answer
The operators will be spelt as: "add", "minus", "times" and "divide"
Any real number integer may be used, as suggested ... |
Pascal's triangle is a triangular diagram where the values of two numbers added together produce the one below them.
This is the start of it:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
You can see that the outside is all 1s, and each number is the sum of the two above it. This continues forever.
Your challenge is to chec... |
Background
The 4-8-8 tiling looks like this:
For the purpose of this challenge, we take the orientation of the tiling as exactly shown above. In plain English words, we take the tiling so that it can be seen as a rectangular grid of alternating octagons and squares, the upper left corner being an octagon.
In order to ... |
Inspired by a tweet by Nathan W. Pyle
There is, now, a standard method of converting your boring, normal human name into a mysterious, ethereal Ghost Name™️. Ably described by Mr Pyle...
Use your first name:
a - add “t” after it
e - add “boo” after it
h - becomes “s”
n - add “oo” after it
r - add “eee” after it... |
Consider the following 9 "row patterns", using 0s to represent empty cells and 1s to represent a full cell. Each pattern is associated with an integer \$n\$, such that \$0 \le n \le 8\$ (multiple [1,1,1,1,1,1]s exist as there's some difference that we don't care about):
\$n\$
Pattern
0
[0,0,0,0,0,0]
1
[1,1,1,... |
Al wanted to use my computer to do some simple calculations, so I lent him the use of my R terminal for a bit. He complained though, saying it wasn't set up how he liked it. I said "No problem Al, set it up how you like and I'll just revert it later." This suited Al, and I left him to it. Al isn't a big fan of online R... |
This was inspired by this question.
Given an \$m\times n\$ matrix of \$0\$'s and \$1\$'s, apply "gravity" to it. This means to drop down all the \$1\$'s as if they were affected by gravity.
For example
[[1,0,1,1,0,1,0]
[0,0,0,1,0,0,0]
[1,0,1,1,1,1,1]
[0,1,1,0,1,1,0]
[1,1,0,1,0,0,1]]
Should result in
[[0,0,0,0,0,0,... |
Basically the tron light-cycle game as a king of the hill competition!
Leaderboard
Updated as of 2022-04-05
#1) Player Avoid by Agent Biscutt
#2) Dodge West by Imanton1
#3) Space Finder by Spitemaster
#4) Blind Bot by TheSilican
Judge/Leaderboard Website
The Game
Players will write bots that compete in a light-cyc... |
Context :
Suppose you have a sheet of paper measuring 8 x 10. You want to cut it exactly in half while maintaining its rectangular shape. You can do this in two ways.
You can cut it in half preserving its long dimension of 10 (for our purpose we will refer to this as long cut from now on).
Example :
$$
[8, 10] \right... |
Let's start with the natural numbers
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,... |
Backstory
I was fiddling around with the Evolution of Trust and thought of this.Warning: I recommend you go check it out first before attempting this challenge.
Summary for people who haven’t played
A quick summary of what it says on the site: there is a machine. If you put in one coin, your opponent gets three coins (... |
Recently, I created a binary word search that got me working with grids. It was fun, so I wanted to create some more similar content. Meet Pythagoras' Golfing grid:
Each of d, e, f, g, h, i, j, k and T represent a numeric value.
Now consider an orthogonal triangle along the lower diagonal of this grid (so the vertical... |
Let's go for a rollercodester ride
The objective of this challenge is to create a program that is run recursively through several languages of your choice. The output of the first iteration becomes the code for the second iteration, et. cetera.
You choose the language sequence, but each unique language may be used onl... |
Write a program that groups a string into parentheses cluster. Each cluster should be balanced.
Examples :
split("((())d)") ➞ ["((()))"]
split("(h(e(l)l)o)(w(o)r)l(d)(w)h(a(t)(s)u)p") ➞ ["((()))", "(())", "()", "()", "(()())"]
split("((())())(()(()()))") ➞ ["((())())", "(()(()()))"]
Input may contain letters other t... |
The basis vectors for geometric algebra are
$$(e_0=1), e_1, e_2,\dots,e_n$$
They all square to 1 (we do not consider vectors which square to -1 or zero)
$$e_i \cdot e_i = 1$$
They are associative and anticommutative (except \$e_0=1\$ which is associative and commutative)
$$e_i \cdot e_j =-e_j \cdot e_i \: \; (i\neq j);... |
For the purposes of this challenge a substring \$B\$ of some string \$A\$ is string such that it can be obtained by removing some number of characters (possibly zero) from the front and back of \$A\$. For example \$face\$ is a substring of \$defaced\$
\$
de\color{red}{face}d
\$
This is also called a contiguous substri... |
Pascal's triangle is a triangular diagram where the values of two numbers added together produce the one below them.
This is the start of it:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
You can see that the outside is all 1s, and each number is the sum of the two above it. This continues forever.
Your challenge is to coun... |
Given a permutation of the alphabet and an input string, encrypt the input string by replacing all characters with the one's you've been given.
The capitalization should be kept the same and non-letters are not to be changed.
[hnvwyajzpuetroifqkxmblgcsd], "Hello, World!" -> "Zytti, Giktw!"
As [abcdefghijklmnopqrstuvwx... |
This was inspired by Apply gravity to this matrix
Your challenge is to input a matrix with non-negative one-digit integers and drop down the 1's down 1 column, the 2's down 2 columns, the 3's down 3 columns, and so on. Once a number has been moved down and there is no number to take its original place, replace that slo... |
Given \$n, m\ge 1\$. There are \$n\$ balls. Do \$m\$ moves, each choose a ball (maybe also the first one), and exchange with the one currently on the first place. At the end, the order of balls should be the same as the initial state.
You can either output all possibilities, or a random one provided all possibilities h... |
I have a small pill box of \$n\$ slots. (Think of it as a linear one like the image below, but not necessarily having 7 slots.)
Each slot has at most one pill. Every day, I take one of two actions: take one pill from the pill box, or refill the pill box. The order of taking a pill alternates between left-to-right and ... |
@BeastlyGerbil presents, the world's very first MOBIUS SUDOKU:
Google Sheets version
(The left most square backs onto the right most square, and the middle squares back onto each other. The ends are then attached as indicated.)
RULES:
Normal sudoku rules apply for rows and boxes - boxes are split into groups of 3... |
Given a string containing only the characters -, |, + and newline determine the longest straight line contained in it. A straight line is either an uninterupted run of -s and +s in a single row or an uninterupted run of |s and +s in a single column.
So for example:
|
| ----
|
--+--
... |
Challenge
Given input as a list/array of natural numbers that each represent the floor of a class a student has to go to, sort the numbers in a way such that the MAD (mean average deviation) number of flights between classes is minimized, thus saving energy and preventing the chance of being late to a class.
When sorte... |
An example will easily explain this to you. Suppose an array [1,2,3,4,5]
Step 1
1 2 3 4 5
----+----
Step 2
5/
4/
1 2 3 /
----+/
Step 3
5|
4|
1 2 3|
----+|
Step 4
5\
4\
1 2 3\
----+-\
Step 5 Take the sum of face-to-face elements
6 6 3
You just successfully folded an array 1 time. 2 times f... |
Inspired by How to write down numbers having an infinity of decimals? Link
Background
From Wikipedia: for almost all real numbers \$x\$, coefficients \$a_i\$ of the continued fraction expansion of \$x\$ have a finite geometric mean that is independent of the value of \$x\$ and is known as Khinchin's Constant.
Khinchin... |
Background
Flow Free is a series of puzzle games whose objective is to connect all the same-colored pairs of dots on the grid. In this challenge, we consider the original game on a rectangular grid (no variations like bridges, warps, or hexagonal grids).
A puzzle in Flow Free might look like this:
Puzzle Solution
...... |
Your task is to create a good multiplication table for others to use. Given an integer \$n\$, generate a multiplication table that displays products up to \$n×n\$. You should start with \$2×2\$ as 1 times any number is itself and that is reflected in the row/column indices. Scientific notation and floating-points are N... |
The objective
Given the non-negative integer \$n\$, output the value of the hyperfactorial \$H(n)\$. You don't have to worry about outputs exceeding your language's integer limit.
Background
The hyperfactorial is a variant of the factorial function. is defined as
$$
H(n) = 1^{1} \cdot 2^{2} \cdot 3^{3} \cdot \: \cdots ... |
Getting the area covered by a rectangle is really easy; just multiply its height by its width. However in this challenge we will be getting the area covered by multiple rectangles. This is equally easy ... so long as the rectangles don't overlap.
If the rectangles don't overlap the total area covered is the sum of th... |
Every digital clock contains a small creature that has to advance the time every minute [citation needed]. Due to the popularty of digital clocks and the popularity of catching them in the wild, they are nearly extinct in nature which is why in this challenge we try to automate this task:
Given your string of a given t... |
This question is a part of the lean LotM.
A ring is a type of structure that takes the rules of addition and multiplication we are familiar with and abstracts them, so we can reason about them. To do this we state a number of expected properties as axioms and see what we can say about systems that follow these axioms.... |
There is a "sorting" algorithm often called Stalin Sort, where instead of sorting an array, you just remove any items that are out of order. In this challenge, you'll implement part of a sorting algorithm which recursively sorts the removed items, then merges the arrays to form one (properly sorted) array.
Algorithm
Ta... |
The Pascal's triangle and the Fibonacci sequence have an interesting connection:
Source: Math is Fun - Pascal's triangle
Your job is to prove this property in Lean theorem prover (Lean 3 + mathlib). Shortest code in bytes wins.
import data.nat.choose.basic
import data.nat.fib
import data.list.defs
import data.list.nat... |
Ungolfed, ugly, horrible proof to help you make progress on this challenge: https://gist.github.com/huynhtrankhanh/dff7036a45073735305caedc891dedf2
A bracket sequence is a string that consists of the characters ( and ). There are two definitions of a balanced bracket sequence.
Definition 1
The empty string is balanc... |
Inspired by Is this Flow Free puzzle trivial? by @Bubbler. Lengthy chunks of this challenge are borrowed from there. This may be one step of a solution for the linked challenge, depending on chosen strategy.
Background
Flow Free is a series of puzzle games whose objective is to connect all the same-colored pairs of dot... |
Lean is a theorem prover and programming language. It's also as of writing the Language of the Month!
What tips do people have for golfing in Lean? As always, tips should be specific to to Lean (e.g. "Remove comments" is not an answer), and stick to a single tip per answer.
|
The title is an homage of the Natural Number Game, which is a nice interactive tutorial into proving certain properties of natural numbers in Lean.
Given that the previous two were slightly too involved (either mathematically or technically) for newcomers to Lean (i.e. the vast majority of CGCC community), I decided to... |
Inspired by Is this Flow Free puzzle trivial? by @Bubbler. Lengthy chunks of this challenge are borrowed from there. This may be one step of a solution for the linked challenge, depending on chosen strategy.
Challenge
Given an array of digits 1-9 and a padding character of your choice, output the border of the shape ma... |
The title is an homage of the Natural Number Game, which is a nice interactive tutorial into proving certain properties of natural numbers in Lean.
The definitions used in Lv1 will be reused here. I've done some improvements:
Now it starts with import tactic, which means you can freely use powerful mathlib tactics.
I... |
Background
The number of values for a given type is called the cardinality of that type, and that of type T is written as |T|.
Haskell and a few other languages have a certain set of enum types, each of which has a small finite number of values (the exact names vary, so this challenge uses some arbitrarily chosen names... |
Create a program which prints itself, followed by an additional program. This additional program should print the first program, itself, and then a third program. This continues until the nth program, which prints every program in order up to itself, but fails to print a successor.
All programs output by your code shou... |
Sometimes authors will write (s)he as a stand in for she or he and for some reason they don't want to use singular they. This is ok for the nominative but doesn't work so well when you want to write "her or him". You can write h(er)(im) which covers both cases but gives two extra "pronouns"
h
her
him
herim
In formal... |
Background
A fractal sequence (Wikipedia; MathWorld) is an infinite sequence of positive integers meeting the following conditions:
Each positive integer appears infinitely many times in the sequence.
Before the first occurrence of a number \$i > 1\$, every number smaller than \$i\$ appears at least once.
Between co... |
Part of the lean Language of the Month
A pong* is a set \$P\$ with an operation \$+\$, that satisfies the following properties:
\$
\forall a, b \in P : (b + b) + a = a\\
\forall a, b \in P : a + (b + b) = a\\
\forall a, b, c \in P: a + (b + c) = (a + b) + c \\
\$
This makes a pong*, just a group where every element is ... |
Introduction:
Although we have a lot of challenges where swapping two items in a list is a subtask, like Single swaps of an array; Swap to Sort an Array; \$n\$ swaps into a nop; etc., we don't have the simple challenge of just swapping two items given a list and two indices.
Input:
A list with some positive integers \$... |
Prefix normal words arise in the context of binary jumbled pattern matching. A binary word \$w\$ consisting of \$0\$s and \$1\$s is said to be prefix normal * if, among all of its substrings, none contains more \$1\$s than the prefix of \$w\$ of the same length does. In other words, if \$w\$ contains \$n\$ \$1\$s then ... |
Definition (from Wikipedia)
A Pythagorean triple consists of three positive integers a, b, and c, such that a² + b² = c².
The typical example of a Pythagorean triple is (3,4,5): 3² + 4² = 9 + 16 = 25 which is 5²
Task:
Given an integer number c, write a program or function that returns the list of pythagorean triples wh... |
Background
Scrabble is a word game in which players collaboratively build a board consisting of letter tiles that spell words. Each word must be connected to another word, and players gain points based on the letters they use and where they are placed. Words can be spelled either from left-to-right or top-to-bottom, an... |
Background
One kind of river-crossing problems involves two kinds of animals. One such problem reads like this: (all wordings, including animal species, are arbitrary)
A farmer has to cross a river with three chickens and three dogs. There's a boat which can only fit the farmer and at most two animals. On either side ... |
You are a historian studying a long forgotten language. You have just discovered a clay tablet which seems to list all known words in the language, in alphabetical order. Your task is to find this alphabet's order, if it exists.
The Task
Given an ordered list of words, try to output an ordered list of characters such t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.