instruction stringlengths 34 53.1k |
|---|
Task
Your task is to draw these beautiful oak trees:
1 ->
@@@
@@@@@
@|.|@
_|_|_
2 ->
@@
@@@@@@
@@@@@@@@
@@| .|@@
| |
__|__|__
3 ->
@@@@@
@@@@@@@@@
@@@@@@@@@@@
@@@| |@@@
@| .|@
| |
___|___|___
4 ->
@@
@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@@@
@@@@| |@@@@
@@| .|@@
| |
| ... |
Task
Write a function/full program that will be able to produce two different sequences of integers in [0, ..., 9]. You will take an input seed to decide whether to output your specific sequence or the common one. For that matter, you must choose one non-negative integer, let us call it k. When the input seed is equal ... |
In this challenge, all bots are wizards. At the beginning of each round, they create a wand which has a certain chance of successfully stunning another wizard. They then fight, by choosing one bot to attack in each turn. The last bot remaining wins.
Results
500 games, 1000 rounds each
Revenge!: 132101.68886125216
JustE... |
This challenge is inspired by Fortran's idiosyncratic implicit typing rules. Your task will be to determine the data type of the object GOD according to the implicit typing rules explained below.
Background
Fortran 77 has six data types: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL. Any object not e... |
Objective
Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit \$1\$ into SI metric.
What is a Planck unit?
Planck units are a set of units of measurement. It defines five fundamental constants of the universe as dimensionless \$1\$.
What is a dimension?
There are five types of fundam... |
(yes, "generating generating" in the title is correct :) )
Context
In middle (?) school we are taught about sequences and, in particular, we are taught about linear sequences where the nth term is generated with an expression of the form an + b, where a and b are some coefficients. In this challenge, we will deal with ... |
Given a compressed string \$s\$ made of printable ASCII characters (32 to 126), your task is to print or return the original text by applying this simple decompression algorithm:
Start with \$k=0\$
Look for the first occurrence of the digit \$k\$ in \$s\$ and the sub-string \$s'\$ consisting of the \$2\$ characters pr... |
Task
A date can be compactly represented in a 6-character string in the format ddmmyy where the first two characters (dd) represent a day, the 3rd and 4th characters (mm) represent a month and the last two characters (yy) represent a 20XX year. Given a string with 6 characters in [0-9] determine if it represents a vali... |
In this challenge, submissions will be programs or function which, when given an emoticon such as :-), :(, or :D, will rate their happiness from 0 to 3.
An emoticon will be one of the following:
:(: 0
:|: 1
:): 2
:D: 3
Emoticons may also have noses (a - after the :).
Test cases:
:( -> 0
:-| -> 1
:D -> 3
:-) -> 2
:|... |
Inspired by I reverse the source code, ...
Your task, if you wish to accept it, is to reverse text and mirror select characters. Yes, yes, I know. Very surprising.
Input
A string, stdin, an array of characters, or any other source of text. All characters of the input are guaranteed to be in the printable ASCII range (3... |
Objective
Given a nonempty multiset of Rock, Paper, and Scissors, output the winning figure according to the special rule.
Background
For a multiplayer RPS, if all three figures come out, usually it's considered a draw. But by that rule, the probability to draw would dramatically increase when there are many and many p... |
These are the classical puzzles:
You need to boil eggs for exactly 9 minutes, or else the visiting Duchess will complain, and you will lose your job as head chef.
But you have only 2 Hourglasses, one measures 7 minutes, and the other measures 4 minutes. How can you correctly measure 9 minutes?
(taken from here)
Let's... |
Task
A Rotate-Left-Double number in base \$n\$ is a number \$m\$, when its base-\$n\$ digits are rotated left once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeros.
One example in base 7 is the number 480, or \$1254_7\$. When rotated left once, the value becomes \$2541_7 = 960\$.
Given t... |
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 exactly 2 from each other. The twist is that your code must run in l... |
As input you will receive
An integer \$a\$
A list of integers that is infinite and strictly-monotonic1.
Your program should check in finite time if \$a\$ appears the list.
You should output one of two distinct values. One if \$a\$ appears in the list and the other if \$a\$ does not.
This is code-golf so answers wi... |
Objective
Given an Arabic string consisting of ISO/IEC 8859-6 Arabic letters (U+0621–063A, 0640–064A), decode it to Arabic Presentation Forms-B (U+FE70–FEFF).
Behavior of Arabic letters
ISO/IEC 8859-6 Arabic letters change their displayed form to letters in Arabic Presentation Forms-B, which are categorized to isolated... |
Write a program that takes in two non-negative integers S and N in that order. S represents the side length of a square grid of . characters. N represents the number of those .'s that need to be changed to x's. You may assume N is no greater than S squared.
Your program needs to output this S×S square of .'s and N x's ... |
The challenge
Make 2 programs which convert decimal to and from base 94, or a bidirectional program.
Base 94?
Base 94 is like any other base, but instead of 0 to 9 and letters, it uses ASCII characters 33 to 126. Not 127 because chr(127) is DEL. Not 32 because that's a space.
Examples
0 - ! or empty string
1 - "
93 - ~... |
For this challenge, submissions should be a program or function shaped like a right triangle, which produces a right triangle of the same size.
What is a right triangle?
For this challenge, a right triangle consists of 1 or more lines, each containing a number of characters (assume all non-newline characters are the sa... |
The challenge:
Given four coordinates, each in x y form, your job is to find out whether or not the given coordinates form a rectangle, and output a truthy/falsey.
Rules:
For the sake of simplicity, squares, lines (two identical pairs of coordinates) or dots (all four of the coordinates are the same) are all counted a... |
Introduction:
Although it seems challenges scored by least unique characters have been attempted, there are few which were well-received. I think it's a potentially interesting scoring criterion, as long as different languages aren't competing with each other (as with code golf).
Challenge:
Create a basic FizzBuzz prog... |
Task
For a given base \$n \ge 3\$, find the smallest positive integer \$m\$, when written in base \$n\$ and rotated right once, equals \$2m\$. The base-\$n\$ representation of \$m\$ cannot have leading zeroes.
The corresponding OEIS sequence is A087502, and its base-\$n\$ representation is A158877 (this one stops at \$... |
You can depict a triangular number, T(N), by writing one 1 on a line, then two 2's on the line below, then three 3's on the line below that, and so on until N N's. You end up with a triangle of T(N) numbers, hence the name.
For example, T(1) through T(5):
1
1
22
1
22
333
1
22
333
4444
1
22
333
4444
55555
To keep t... |
As we all know, most Pokemon are created by combining some English (or Japanese) words; these words are the Pokemon's "etymology." For example, "charmander" is "char" and "salamander" put together.
Your task is, given a Pokemon's etymology and number, output the original Pokemon name. A short answer will be able to com... |
The goal of this challenge is to extend the On-Line Encyclopedia of Integer Sequences (OEIS) sequence A038375.
Maximal number of spanning paths in tournament on n nodes.
A tournament on \$n\$ vertices is a directed graph where for each pair of vertices \$(v_i, v_j)\$ there is either a directed edge \$v_i \rightarrow ... |
We consider two integers to be similar if, when written in decimal, have the same length, and if we compare characters in any two positions for both decimal strings, the comparison results (less, equal or greater) must be the same in both strings.
Formally, for two number that can be written as decimal strings \$a_1a_2... |
Chat room: https://chat.stackexchange.com/rooms/106513/easter-bunny-challenge
Git repo: https://github.com/AJFaraday/easter_bunny_hunt
The garden is a 2-dimensional grid with 49 rows and 49 columns.
The Easter Bunny™️ is in the center of the garden, minding his own business, holding on to 100 Easter eggs. He'll hop awa... |
A prime number is a positive integer that has exactly two divisors 1 and the number itself. For example number 7 is a prime since it is divisible by 1 and 7. Number 1 is not a prime since it has only one divisor. Write a program or function that produces all even prime numbers.
This is a code golf challenge, shortest a... |
Let's say you have a stack, which at the start contains a b c in this order (a is on the top). You are given the required output stack, in any reasonable format (a list, a string, etc.), e.g. [a, c, b] (here a is on the top, below it c and below it b). You can also take the input reversed if you want, e.g. [b, c, a] wh... |
Your task is to create a program or function which randomly errors. Specifically, there must be a nonzero probability of erroring, but also a nonzero probability of running without error.
An error is anything that causes a program to terminate abnormally, such as dividing by zero or using an uninitialized variable. Thi... |
Here in Russia, we have a little-known card game with the name, when translated directly, means Rooster.
The cards used are two full 54-card decks of playing cards from 2 through aces, with jokers. The game for each player divides into two stages. In the first stage, each player has 14 cards dealt, and with those cards... |
The challenge today is to write a program that outputs a known proverb, Where there is a will, there is a way., that means if someone is determined to do something, he will find a way to accomplish it regardless of obstacles.
Output
It has to be exactly the same, including the space bar and punctuation and excluding th... |
Chat room: https://chat.stackexchange.com/rooms/106513/easter-bunny-challenge
Git repo: https://github.com/ajfaraday/easter_bunny_hunt
The garden is a 2-dimensional grid with 49 rows and 49 columns.
The Easter Bunny™️ is in the center of the garden, minding his own business, holding on to 100 Easter eggs.
Unfortunat... |
Here's an interview question I've seen on a few sites. People claim that an O(n) solution is possible, but I've been racking my brain these last 2 days and I couldn't come up with a solution, nor find one anywhere on the web.
Given an array of integers, find two disjoint, contiguous subarrays such that the absolute dif... |
A very simple challenge today. Output a truthy value whether the ASCII character (or it's code) supplied is a brainfuck instruction (one of +-,.<>[]), and a falsy value if it's a comment (everything else).
Input
+
#
<
>
.
P
,
Output
true
false
true
true
true
false
true
|
Inspired by this glove-themed 538 Riddler Express Puzzle.
Task
You are given a positive integer n, and a list A = [a_1, a_2, ..., a_k] of k distinct positive integers.
Then a restricted composition is an ordered list P = [p_1, p_2, ..., p_m] where each p_i is a (not necessarily distinct) member of A, and p_1 + p_2 + ..... |
Background
An Eisenstein integer is a complex number of the form \$ z = a + b\omega \$ where \$a, b\$ are integers and \$\omega\$ is the third root of unity \$\frac{1-\sqrt3i}{2}\$. The Eisenstein integers can be viewed as the triangular lattice points, as shown in the image below (from Wikipedia):
Following the trian... |
Surprised that we don't have a symmetric difference challenge yet.
Given two lists only containing positive integers, return all items among these two lists that aren't contained in both of the lists.
Rules
From the set definition:
A set is a collection of definite distinct items.
So you can assume the items in the ... |
What is elementary cellular automata?
Since I'm not sure I'll be able to explain this so that somebody who has never heard of this is able to understand, I'm giving an explanation from https://mathworld.wolfram.com/ElementaryCellularAutomaton.html
Elementary cellular automata have two possible values for each cell (0 ... |
Given a word, your task is to compact it by saving its first character and removing any other vowel (aeiou).
Input
Your input can be the word in STDIN, a function argument or any other input format that doesn't break the standard loopholes. You can assume the input only consists of lower characters.
Output
Your output... |
Let's say you have a sentence like:
this is a very long sentence with several words of no significance
It contains only the 26 lowercase letters of the alphabet and spaces.
And you have a dictionary, where each word contains any number of the 26 lowercase letters and nothing else:
henge
renton
Then the output should ... |
Task
Given two positive integers \$m,n\$, imagine a chessboard of size \$m \times n\$. A chess queen is on the upper-left corner. In how many ways can it reach the lower-right corner, by moving only right, down, or diagonally right-down (possibly moving many steps at once, because it's a queen)?
The resulting 2D sequen... |
We've had lots of questions about quines, programs where the source code and output are identical. For compiled languages, there are other combinations: we've already had a question about writing a program where the executable and output are identical. But there's one combination left.
The task
Using a compiled languag... |
Inspired by Make a Rectangle from a Triangle.
Task
There is a famous formula on the sum of first \$n\$ squares:
$$
1^2 + 2^2 + \dots + n^2 = \frac{n(n+1)(2n+1)}{6}
$$
It is known that this number is composite for any \$n \ge 3\$.
Now, imagine a collection of row tiles (a tile of shape \$1 \times k\$ with the number \$k... |
This is my attempt to pair code-shuffleboard with code-golf.
You need to write a full program or function that sums all codepoints of the input string. If there is no input, you can output any number, including 0.
Rules
The input will always be in printable ASCII.
The sum of the codepoints of your source must be exact... |
Help! I printed a bunch of rational numbers with no spaces or other delimiters other than the / in the fractions. There is, however, good news! All the numbers are positive. There are no improper fractions, every numerator is less than its denominator and any integers are represented directly, not as fractions. Any non... |
Today (or tomorrow, depending on your timezone, by the time of posting) is the birthday of the great mathematician and physicist Leonhard Euler. To celebrate his birthday, this challenge is about one of his theorems in geometry.
For a triangle, we define its incircle to be the largest circle inside the triangle and its... |
To be able to challenge the Elite-4 of top programmers, you need to show your badges first, that qualify you as a potential programmer-master. However, there's a twist. Once you show a badge, it is collected, which means you can't re-show it. So better come prepared! There are n badge collectors, each has a known list ... |
Odd prime numbers are either in the form of 4k+1 or 4k+3 where k is a non-negative integer. If we divide the set of odd prime numbers into two such groups like this:
4k+3 | 3 7 11 19 23 31 43 47 59 67 71
|
4k+1 | 5 13 17 29 37 41 ... |
This challenge is in honor of mathematician John Conway who passed away April 11, 2020 due to COVID-19. He was famous for coming up with the Game of Life cellular automaton and many other mathematical contributions such as the surreal numbers and the monster group.
The advanced math of those topics is out scope for thi... |
Modern mathematics has been formalised using set theory by various systems of axioms. Zermelo Frankel set theory with the axiom of choice (ZFC) forms an intuitive set of axioms and is hence most popular, though stronger choices exist.
Inspiration: A Relatively Small Turing Machine Whose Behavior Is Independent
of Set T... |
sandbox
Story
Similar to a newspaper route you have been tasked with delivering bits to the residents of Bin City. Just as certain people like certain newspapers, the citizens of Bin City prefer either \$1\$s or \$0\$s delivered to their doorstep. Unfortunately, your new boss has arranged the deliveries in an awkward... |
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions and substitutions needed to transform one string into the other. Let us call insertions, deletions and substitutions "edit operations". We will say that any sequence of \$k\$ edit operations that transforms on... |
Task
Given two positive integers a, b and a Unicode mathematical inequality symbol c, determine if a c b is true.
You many take the character or its Unicode codepoint for the input c. You may output your language's truthy/falsy values, or two distinct values for true and false respectively.
Standard code-golf rules app... |
In computer science, a suffix automaton is the smallest partial deterministic finite automaton that recognizes the set of suffixes of a given string. (Wikipedia)
Given a string \$S\$ consisting of lowercase letters (a-z), construct the suffix automaton for it.
A suffix automaton is an array of states, 0-indexed or 1-... |
Inspired by this Youtube Video from Tom Scott.
Write a program or function that prints the current amount of views this question has.
That's it.
Your program may only access the stack exchange api, any other websites are disallowed.
Output
An integer with the exact amount of views this question has at the moment. Outpu... |
Note: this problem was inspired by the Unsolved Mathematical Problems for K-12 youtube video, which also features other interesting puzzles.
From the wikipedia article:
The no-three-in-line problem asks for the maximum number of points that can be placed in the n × n grid so that no three points are collinear ..... Al... |
We all know and love the corpulent DDL expressions one can write in PostgreSQL with wording like DEFERRABLE INITIALLY DEFERRED, ALTER FOREIGN DATA WRAPPER, or even DROP TEXT SEARCH CONFIGURATION. But how far can one go? Here comes the definitive challenge for the longest DDL expression, with constraints of course. Mwah... |
There are many generalizations of Conway's Game of Life. One of them is the isotropic non-totalistic rulespace, in which the state of a cell in the next generation depends not just on its state and the amount of alive cells around it, but also the relative positions of the cells around it.
Given an rulestring correspon... |
This challenge is about creating these neat "green spray paint" patterns: (more pictures below)
Loosely explained, they are generated by starting with a black image and a point in the center. That point is successively moved by a randomly chosen offset or delta in x and y. Every pixel the point visits has 1 added t... |
Take an arbitrarily sized string as input. This string represents a baseball plate appearance, in which each character represents a pitch as follows:
Strike: S
Ball: B
Foul ball: F
Hit by pitch: H
Ball in play: X
(For those wondering, this is a very very simplified version of Retrosheet's notation)
Your program must... |
Challenge
Premise
Consider a mosaic of \$m\times n\$ tiles, in \$k\$ unique colours designated by integers. Example (\$3\times6\$, four colours):
4 1 3 2 4 2
1 2 4 2 1 3
4 3 2 1 4 4
My poor man's mirror is a pane of glass of width \$\sqrt{2}\cdot\min(m,n)\$. I stand it diagonally on the mosaic, like so:
4 1 3 M 4 2
1 ... |
John Horton Conway was a brilliant mathematician. Among his contributions were three Turing-complete esolangs: Game of Life (esolangs wiki), FRACTRAN (esolangs wiki), and Collatz function (esolangs wiki).
Because we did an extremely amazing job around GoL, it is time for the challenge with the other two.
Background
A F... |
Your task is to form an expression equaling \$ 11111111111 \text{ (11 ones)} \$ using only the following characters: 1+(). Keep in mind that the result is in base 10, and not some other base like binary. Of course, these expressions should follow the order of operations. Furthermore, the only operations which should be... |
Background
This challenge is about A004001, a.k.a. Hofstadter-Conway $10000 sequence:
$$
a_1 = a_2 = 1, \quad a_n = a_{a_{n-1}} + a_{n-a_{n-1}}
$$
which starts with
1, 1, 2, 2, 3, 4, 4, 4, 5, 6, 7, 7, 8, 8, 8, 8, 9, 10, 11, 12, 12, 13, 14, 14, 15, 15, 15, 16, 16, 16, 16, 16, ...
John Conway proved the following proper... |
The task
Given an image as input, your task is to do the following:
Resize the image so it is At least 2 times smaller, but still has the same width/height ratio by taking every second (if resized to 2x) pixel in both horizontal and vertical directions and using those in the pixel art image. Example:
a 4x4 image
[a... |
Challenge
Premise
Bob is a novice pianist who can only play sequences of single notes. In addition, he does quite an interesting thing: for every note after the first, if it's higher than the previous note was, he uses the finger directly to the right of the previous finger used; if lower, to the left; if the same pitc... |
The goal of this challenge is to check and extend the OEIS sequence A334248: Number of distinct acyclic orientations of the edges of an n-dimensional cube.
Take an n-dimensional cube (if n=1, this is a line; if n=2, a square; if n=3, a cube; if n=4, a hypercube/tesseract; etc), and give a direction to all of its edges ... |
Two Deterministic Finite Automata or DFAs can be checked to see if they accept same set of strings in polynomial time. See section 3.3 of this for a long list of methods and this SO question/answer for a much shorter list.
Input
Your input will be two DFAs. In order to be able to test your code, I have provided DFAs i... |
Background
Penney's game is a two-player game about coin tossing. Player A announces a sequence of heads and tails of length \$n\$, then player B selects a different sequence of same length. The winner is the one whose sequence appears first as a substring (consecutive subsequence) in repeated coin toss.
Conway's algor... |
A recent SO question asks for a convenient one-liner to generate a list of numbers and their negative counterparts in Python.
Given two integers \$1≤a≤b\$, generate all the integers \$x\$ such that \$a≤|x|≤b\$. The result may be printed or returned in any order or structure, as putting the result into a list and sortin... |
Challenge
Premise
Bob lost1 Alice's precious grand piano. Big mistake. Alice has now stolen Bob's low-orbit ion cannon.
Alice refuses to just make up with Bob, so let's help her give him a light tap on the roof. Suppose that from the top Bob's house looks like a lattice polygon, where all points have integer coordinate... |
Background
Given a triangle \$ABC\$, extend its three sides by the opposite side length, as shown in the figure below. Then the six points surprisingly lie on a circle called the Conway circle, whose center coincides with the incenter (the center of incircle, the circle that is tangent to the three sides from the insid... |
The player has to keep guessing a number from 1 to 10 until they guess the correct number to win the game. If they make an incorrect guess, they're told if their guess was too low or too high.
Each line has to render below the previous line for me to accept the solution as the new code for the game (However, you can st... |
Let's say I have a .env file with the following contents:
CF_WORKERS_ACCOUNT_ID=abcdef34632114
CF_WORKERS_API_TOKEN=abcdef34632114def3463def3463
FAB_DEV_ZONE_ID=434932843272439874329
I'm doing a screencast, and I want to quickly cat .env to show what's in the file, without broadcasting the exact values, since they're ... |
Frustration is a solitaire card game which is played by calling out the sequence:
“Ace”, “Two”, “Three”, ... , "Nine", "Ten", “Jack”, “Queen”, “King”, “Ace”, “Two”, etc.
With each call, you simultaneously flip over a card from a shuffled deck of 52 cards. You win the game if you get through the entire deck without ever... |
Task
Given a string as input, generate a "blurred" version of that string.
Input
Your input will be a single-line string of ASCII characters, containing a minimum of 2 alphanumeric characters
Output
A string that is the "blurred" version of the input string.
A blurred string is one where every alphanumeric character fr... |
Given a number N from 2 to 8, place any nonzero number of queens on a grid of any size so that every queen has exactly N queens (counting itself) in each of its row, column, and each diagonal.
This challenge has a significant restricted-time runtime limit. Your code must finish all N from 2 to 8 (combined) within the 6... |
A Bit of Background
The exterior algebra is a central object in topology and physics (for the physics concept cf. fermion). The basic rule dictating the behavior of the exterior algebra is that \$yx = -xy\$ (and consequently \$x^2 = -x^2 = 0\$). Applying this rule twice we see that \$yzx = -yxz = xyz\$.
The product of... |
Challenge
Premise
I've got multiple pretty numbers all in a row. Each is a decimal digit.
0s are weakly attracted to 0s, 1s are attracted to 1s a little more strongly and so on until 9. I don't know why — it must be something I ate. As a result, a sort of two-way sideways sedimentation occurs until the higher values ar... |
Infinite Snake is just like the video game Snake, except for that the snake is infinitely long, there are no items to eat, and the Snake needs to move in a repeating n-step move pattern (e.g. right, up, right, up, right, down). The only constraint is that you can't crash back into yourself.
Challenge
Your goal is to wr... |
Challenge
Premise
Euler diagrams consist of simple closed shapes in a 2-D plane that each depict a set or category. How or whether these shapes overlap demonstrates the relationships between the sets.
I'm a spoilt brat who thinks Euler diagrams are hard to draw. For any Euler diagram, I want to know the minimum number ... |
The Hamming distance between two strings is the number of positions they differ at.
You are given a set of binary strings. The task is to find the length of the shortest route that visits all of them at least once and ends where it started, in a metric space where the distance between two strings is the Hamming distanc... |
Background
Conway's Soldiers is a version of peg solitaire played on an infinite checkerboard. The board is initially full of pegs below an infinite horizontal line, and empty above it. Following the ordinary peg solitaire rules (move a peg by jumping over another one horizontally or vertically, removing the one that w... |
Logic gates are functions which perform basic logic operations. In this problem, we will account for the following 6 logic gates: AND, OR, XOR, NAND, NOR, and XNOR. Each of these takes two boolean inputs \$ a \$ and \$ b \$, and outputs a boolean. Below are the truth tables which show the output of each gate given two ... |
You are employed as Administrator in charge of Road Maintenance and Planning. The intelligence division of the Agency for Road Maintenance and Planning has come up with a brilliant and not at all inefficient way to take random sample pictures of the roads: missiles with cameras on them.
In this genius and not at all w... |
The barfoos, a hypothetical alien species, go about charity in an interesting way.
Every morning, barfoo Specialists come up with an ordered list of causes to donate to, and for each cause they recommend what quantity of resources should be donated.
That wasn't the weird part. Here's the weird part:
A random civilian b... |
A quote from MO.SE answer:
Although it is well known that Conway was able to quickly calculate the day of the week of any given date, it is less well known that one part of the algorithm is easy to remember and useful in practice: In any given year, the following dates all fall on the same day of the week: 4/4, 6/6, 8... |
Convert NFA to DFA as quickly as possible.
Input
Your input will be an NFA. In order to be able to test your code, it needs to be able to handle an NFA in the following format. This is taken directly from GAP (and slightly simplified).
Automaton( Type, Size, Alphabet, TransitionTable, Initial, Accepting )
For the inp... |
Your job is to implement bitwise addition.
To ensure that this is done, you will compute and print the result of addition without carry (or bitwise XOR). Then, you will compute the carry of the addition (bitwise AND) and multiply it by two (bitwise left shift). If the carry is nonzero, then you add the carry and the pr... |
With all the gyms closed down with the COVID-19 situation, we have to exercise with the weight we have lying around at home. The problem is, we have a small selection of plates at varying weights, and can't immediately determine if we can create a setup at the desired weight.
Given an unsorted array of weighted plates... |
Task
Write a function or program that takes n as a parameter and prints the first n self-divisors.
Definition of Self-divisor
A positive integer is called a “self-divisor” if every decimal digit of the number is a divisor of the number, that is, the number is evenly divisible by each and every one of its digits.
Exampl... |
We say two positive integers are anagrams of each other if the digits in one of them (in decimal representation) can be rearranged to form the other. Leading zeros don't count. For example, 110020222 is an anagram of 212102020, but not of 221100011; neither is 22002211 even though it can be written as 022002211.
Intere... |
My dog ate my calendar, and now my days are all mixed up. I tried putting it back together, but I keep mixing up the days of the week! I need some help putting my calendar back together, with the days in the correct order.
And since I need my calendar put together as fast as possible, don't waste my time by sending me ... |
Write a program that outputs the number 0.
That's a bit trivial, isn't it?
Let the length of your program be \$S\$. Write a program that outputs the number 0. When your program is cyclically shifted \$i < S\$ bytes left, it should output \$i\$. To cyclically shift a string \$i\$ bytes left means to move the last \$i\$ ... |
Write a program that outputs the number 0.
That's a bit trivial, isn't it?
Let's sort all distinct permutations of your code in lexicographical order. When any of these codes are run, it should output the its location in the array (0-indexed or 1-indexed).
This means that your code must be the lexicographically smalles... |
You find yourself in a strange place. A frighteningly dark maze, lit only by dim candles resting in the occasional hallway. Numerous paths lie only in impassable darkness, foreboding and-- ...Hm? What? Pick up a candle and carry it with you? No, no, that would be extremely rude.
The Task
Given a maze as input, output t... |
Background
Conway chained arrow notation is a notation to express very large numbers. It consists of zero or more positive integers separated by right arrows, e.g. \$2 \to 3 \to 4 \to 5 \to 6 \$.
Assuming \$p, q, a_1, \dots, a_n\$ are positive integers and \$X\$ is an abbreviation for a nonempty chain \$a_1 \to a_2 \to... |
(This is A065825.) The sequence defaults apply, so you can pick another format other than this one.
Given an input integer n, find the smallest number k so that there exists an n-item subset of {1,...,k} where no three items form an arithmetic progression.
Procedure
Here, we calculate A065825(9).
We assume you have alr... |
The Golden Ratio Bureau is obsessed with this new thing they call base-phi. You see it and decide to code-golf, as is your natural instinct.
To be specific, base-phi is a number system like base 10, except it uses the number phi, or the golden ratio, as its base. A ones digit would be x*10^y, but in base phi 10 is repl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.