instruction stringlengths 34 53.1k |
|---|
A loop is a pretty simple algebraic structure. It is a tuple (G,+) where G is a set and + is a binary operator G × G → G. That is + takes two elements from G and returns a new element. The operator is also required to fulfill two properties
Cancellation: For every a and b in G there exists unique x and y in G such ... |
The optimal matrix (for the rather narrow scope of this challenge) is obtained by "zipping" the elements from the corresponding rows and columns of a square matrix and getting the maximum of each pair.
For instance, given the following matrix:
4 5 6
1 7 2
7 3 0
You can combine it with its transpose to get: [[[4,5,6],[... |
If a positive integer \$N > 2\$ has (strictly) less prime factors (without counting multiplicities) than its successor and its predecessor, we will call it a factor-poor number.
In other words, \$\omega(N) < \omega(N - 1)\$ and \$\omega(N) < \omega(N + 1)\$, where \$\omega(N)\$ is the number of unique prime factors of... |
This is a overhaul of this now deleted question by ar kang. If the OP of that question would like to reclaim this question or has a problem with me posting this I'd be happy to accommodate
Given a list of integers as input find the maximum possible sum of a continuous sublist that starts and ends with the same value.... |
Write a mathematical statement, using the symbols:
There exists at least one non-negative integer (written as E, existential quantifier)
All non-negative integers(written as A, universal quantifier)
+ (addition)
* (multiplication)
= (equality)
>, < (comparison operators)
&(and), |(or), !(not)
(, ) (for grouping)
varia... |
Redivosite is a portmanteau word invented for the sole purpose of this challenge. It's a mix of Reduction, Division and Composite.
Definition
Given an integer N > 6:
If N is prime, N is not a Redivosite Number.
If N is composite:
repeatedly compute N' = N / d + d + 1 until N' is prime, where d is the smallest diviso... |
This post is loosely inspired by this mathoverflow post.
A Vanisher is any pattern in Conway's Game of life that completely disappears after one step. For example the following pattern is a size 9 Vanisher.
An interesting property of Vanishers is that any pattern can be made into a vanishing one by simply adding mo... |
The Task
Given an input positive integer n (from 1 to your language's limit, inclusively), return or output the maximum number of distinct positive integers that sum to n.
Test Cases
Let f define a valid function according to the task:
The sequence for f, starting at 1:
1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5... |
I know it's 1.5 weeks after Christmas but trying to print an isosceles triangle in a monospaced font makes it look weird.
Challenge
Print the alphabet from A to Z so that it forms a filled triangle in the output.
For each line in the output, starting from "A", add the next letter.
No inputs, only outputs. Pad the leadi... |
Introduction:
At home we have a clock that strikes the stated amount at each hour, but also strikes once at every half-hour. So from 0:01 to and including 12:00 it strikes in this order:
1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12
Challenge:
Given an integer n, output a list of time-frame... |
Inspired by We had a unit test once which only failed on Sundays, write a program or function that does nothing but throw an error when it is Sunday, and exit gracefully on any other day.
Rules:
No using input or showing output through the usual IO methods, except to print to STDERR or your language's equivalent. You ... |
A zigzag scan is a method of encoding 2D information in one dimension:
Write a function or program that, given a one-dimensional string of printable ASCII characters, will reverse the zigzag scan to arrange its characters into a square.
For example, given the input string ABeIfCDgJmnKhLop, your program should return:
... |
Thanks to this question for some inspiration
In this challenge we will represent a line of dominoes as a string of |, / and \. You will be given a string of dominoes as input and you must determine what they look like when they have settled. Here are the rules for how dominoes fall over
A standing domino, |, left ... |
Rules
Given an ISO3166-1-Alpha-2 country code your task is to decide on the traffic direction for that country:
Input will be a valid country code (valid as in it's an element of the two lists provided)
Input may be a list of two characters instead of a string if it helps
You may choose to take input in lowercase
You ... |
My brothers and I like to play Cribbage. Now, the scoring rules for Cribbage are somewhat complicated, and I often worry that I'm not counting my score correctly. Therefore, your job is to write a program that will correctly score my hand.
Scoring
There are two ways to score points in Cribbage: during pegging, and wh... |
Challenge
Given a n-dimensional array of integers and a permutation of the first n natural numbers, permute the array dimensions accordingly.
Details
This challenge is inspired by MATLABs permute. demonstration
The permutation is given as a list of integers, e.g. [1,3,2] means 1 gets mapped to 1, 2 gets mapped to 3 and... |
Husk is a quite new golfing language, created by PPCG users Leo and Zgarb. It has begun being more and more competitive, often staying close or even beating languages known to be very terse, such as Jelly and 05AB1E.
Let's list some of the golfing techniques that are somewhat specific to Husk. As always, please post on... |
pannenkoek2012 aims to complete Super Mario 64 with as few presses as possible of the A button, which makes Mario jump. Each "A press" consists of three parts:
Pressing the button
Holding it for any length of time
Releasing it
See this video (1:15 - 3:23) for a great explanation that includes the above image. (Howe... |
The Problem:
Two enemy secret agents have devised a wonderful (for you) method of communication!
Here’s how the encryption process works:
1) Take the ascii equivalents of each letter. (No spaces, numbers, or punctuation are sent)
2) For each letter in the message, the ascii equivalent of it and the letter after it (If ... |
The Collatz conjecture postulates that if you take any positive integer, then repeat the following algorithm enough times:
if number is odd, then multiply by three and add one
if number is even, then divide by two
you'll eventually end up at 1. It seems to always work, but it's never been proven that it always does.
Y... |
The Simplest N-Dimensional shape one can create for any dimension is a Simplex, and this is a set of N+1 points that are all equal distance away from eachother.
For 2 dimensions, this is an equilateral triangle, for 3 dimensions, this is an regular tetrahedron, at 4 dimensions is the 5-Cell and so on.
The Challenge
Giv... |
In Vim, you can repeat a command by preceding it with a number, like 3dd is equivalent to dd dd dd. Well, this repeating pattern is not restricted to Vim commands. String can be replicated in this way, too.
Specification:
Given a string, consisting of only digits, alphabetical characters (both upper-case and lower-case... |
Bertrand's postulate states that there is always at least 1 prime number between n and 2n for all n greater than 1.
Challenge
Your task is to take a positive integer n greater than 1 and find all of the primes between n and 2n (exclusive).
Any default I/O method can be used. Whoever writes the shortest code (in bytes)... |
Ethereum is a blockchain platform. It has its own native cryptocurrency, ether, but in this challenge, we'll be focusing on its ability to run smart contracts.
The ERC-20 standard describes an implementation of fungible tokens within a smart contract. Some examples of this implementation are EOS, OmiseGo, and the Golem... |
Task: convert a HTML page into a mountain!
When HTML pages are indented, they can look like:
<div>
<div>
<div>
</div>
<div>
<div>
</div>
</div>
</div>
</div>
But to be honest, a mountain is more representative of this structure.
So we can rewrite it as:
... |
Given the sequence OEIS A033581, which is the infinite sequence, the n'th term (0-indexing) is given by the closed form formula 6 × n2 .
Your task is to write code, which outputs all the subsets of the set of N first numbers in the sequence, such that the sum of the subset is a perfect square.
Rules
The integer N is g... |
Here is a 1.2Mb ASCII text file containing the text of Herman Melville's Moby-Dick; or, The Whale. Your task is to write a program or function (or class, etc. -- see below) which will be given this file one character at a time, and at each step must guess the next character.
This is code-challenge. Your score will be
2... |
Let's play some code-golf!
The challenge is to find the winner of a game of Tic-Tac-Toe.
This has been done many times by giving a board that has one clear winner but here is the twist:
The cells are numbered like this:
1|2|3
-+-+-
4|5|6
-+-+-
7|8|9
You get an array of exactly 9 moves like that:
{3, 5, 6, 7, 9, 8, 1, ... |
I have a problem at work. I need to compare two numbers that come as strings from two different databases. The numbers may come with leading zeroes and/or leading/trailing spaces. So I may have "0001 " from one database and " 1 " from the other one.
I solved the problem in C# with the following code:
Func<string, st... |
Given two positive integers A and B, return the position p that minimises the number of prime factors (counting multiplicities) of the resulting integer, when B is inserted in A at p.
For example, given A = 1234 and B = 32, these are the possible insertions (with p being 0-indexed) and the corresponding information abo... |
Note: The title of this question should be "Loop It", but because title needs to be at least 15 characters, there are some invisible spaces. This note is such that the challenge can be searched for.
Challenge
Given a finite list of unique integral points in the plane, find a polygon whose vertices are exactly those... |
Given a German string and an indication of a case (lower/upper/title), fold the string to that case.
Specifications
Input will consist only of a–z plus äöüß-,.;:!?'" in uppercase and/or lowercase.
The target case may be taken as any three unique values (please specify what they are) of a consistent type; either three ... |
A positive integer x is a square triangle number iff there are two different positive integers, y and z, which are smaller than x such that all of the sums
x + y
x + z
y + z
are perfect squares.
For example 30 is a square triangle number because
30 + 6 = 62
30 + 19 = 72
6 + 19 = 52
Your task is to write some code that... |
Lonely primes (as I call them) are primes, where given a number grid with width w ≥ 3, are primes which do not have any other primes adjacent to them orthogonally or diagonally.
For example, if we take this grid where w = 12 (primes highlighted in bold):
1 2 3 4 5 6 7 8 9 10 11 12
13 14 15 16 17... |
Definition
An "integer triangle" is one with integer coordinates. For example the following triangle is an integer triangle:
(0, 0), (0, 1), (1, 2) with perimeter 1 + sqrt(2) + sqrt(5) ≈ 4.650.
Task
The goal of this challenge is to count all integer triangles (up to congruence) with perimeter less than n.
Input and Ou... |
Challenge
Write a program that takes an 11x11 array of integers, and constructs a 3D ASCII block building, where each value in the array represents the height of a column of blocks at the coordinates matching the array position. A negative height is a "floating" column - only the top block is visible.
Example
... |
Your task is to write a RoboZZle interpreter. If you're not familiar with the game, please watch the video at robozzle.com or read my description below.
A robot lives on a rectangular grid of squares coloured red, green, blue, or black. Black squares are inaccessible. The others are accessible and some of them contain ... |
Given no input, output this interesting alphabet pattern in either case (the case has to be consistent) via an accepted output method:
A
AB
ACBC
ADBDCD
AEBECEDE
AFBFCFDFEF
AGBGCGDGEGFG
AHBHCHDHEHFHGH
AIBICIDIEIFIGIHI
AJBJCJDJEJFJGJHJIJ
AKBKCKDKEKFKGKHKIKJK
ALBLCLDLELFLGLHLILJLKL
AMBMCMDMEMFMGMHMIMJMKMLM
ANBNCNDNENFNGN... |
Challenge
There are many numbers which can be expressed as the difference of two squares, or as the difference of two cubes, or maybe even higher powers. Talking about squares, there are various ways of writing a number, say 75, as the difference of 2 squares. You can write:
75 = (10)^2 - (5)^2
= (14)^2 - (11)^2
... |
Challenge
Suppose you have a list of numbers, and a target value. Find the set of all combinations of your numbers which add up to the target value, returning them as list indices.
Input and Output
The input will take a list of numbers (not necessarily unique) and a target summation number. The output will be a set of ... |
You know what a palindrome, a prime and a date are.
Your task is to list all dates in 100 thousands of years that fulfill
all three characteristics.
Nevermind anything but the numbers, use the following formats: YYYYMMDD and YYYYYMMDD.
Dates between 0000-01-01 and 9999-12-31 should be printed as 8 digit palindrome... |
Originally the Multiplicative digital root
Challenge
Basically do what the title says
Method
Given a positive integer 1 <= N <= 100000000 through one of our standard input methods, multiply every digit together, ignoring zeroes.
Ex: Take a number, say 361218402:
3 * 6 = 18
18 * 1 = 18
18 * 2 = 36
36 * 1 = 36
36 * 8 =... |
Background
Based on a game my four-year-old got from his rabbi.
The "goal" is to "find" the letters in a given order, e.g. aecdb. You are given a stack of letter cards, e.g. daceb. You can only search through the stack in the order given, albeit cyclically. When you meet a letter you need, you take that out of the stac... |
Your challenge is to write a program to solve a 3x3x3 Rubik's Cube. This challenge is based on this one from 2013, rewritten to adhere to current community standards, and reposted with the original author's permission and help on meta.
Input
The input should represent an unsolved Rubik's Cube.
You may read this input v... |
Background
A matryoshka doll (or Russian nesting doll) is a set of dolls that fit inside of each other. I've accidentally mixed up my collection of matryoshka dolls and I don't remember which one goes inside which.
Objective
Given a list of unique strings, sort them into nested matryoshka dolls. Each string is an indiv... |
Is there a better way to calculate the number of leap years between two given years? I want to make my code shorter (in Python). Do you have any suggestions?
Here is my solution:
i=int
r=raw_input
t=i(r())
while t:
b,d=map(i,r().split())
c=0
for y in range(b,d+1):
if y%400==0 or y%4==0 and y%100:c+=1
print c
t-=... |
You may or may not remember Xeyes, a demo program that came with (and, as far as I know, still comes with) the X window system. Its purpose was to draw a pair of eyes that followed your mouse cursor:
Your challenge is to recreate Xeyes with ASCII art. Write a program or function that draws two ASCII art eyes (specifie... |
Two numbers are considered amicable if the proper divisor sum of the first is the same as the second number, the second number's proper divisor sum is equal to the first number, and the first and second numbers aren't equal.
\$s(x)\$ represents the aliquot sum or proper divisor sum of \$x\$. 220 and 284 are amicable be... |
Prior to the decimalisation of Sterling in February 1971, a pound (£ - from Roman libra) comprised 20 shillings (s - solidus), each of 12 pennies (d - denarius). Additionally, until 1960, each penny could be divided into four farthings (some parts of the Commonwealth also had fractions of farthings, but we'll ignore t... |
There is a site called "Return True to Win" with interesting tasks for Javascript programmers. The goal is to find arguments to a given function that force it to return true.
The following is one of the tasks:
function total(x) {
return (x < x) && (x == x) && (x > x);
}
The users must find snippets for the value of ... |
quintopia has posted here a challenge to compute multinomial coefficients (some of the text here is copied from there). There is a fun algorithm to compute multinomial coefficients mod 2.
Given a list of numbers, k1, k2, ... ,km, output the residue of the multinomial coefficient:
reduced mod 2. The following algorith... |
When multiplying monomials in the Milnor basis for the Steenrod algebra, part of the algorithm involves enumerating certain "allowable matrices".
Given two lists of nonnegative integers r1, ... ,rm and s1, ... ,sn, a matrix of nonnegative integers X
is allowable if
The sum of the jth column is less than or equal to... |
Definition
The rank of a word is defined as the position of the word when all the possible permutations (or arrangements) of its letters are arranged alphabetically, like in a dictionary, no matter if the words are meaningful or not.
Let us consider these two words - "blue" and "seen". To begin with, we would write all... |
Today in my statistics class, I found that some factorials can be simplified when multiplied together! For example: 5! * 3! = 5! *3*2 = 5! *6 = 6!
Your job:
Given a string containing only Arabic numbers and exclamation points, simplify my factorial to its shortest possible string, in the least amount of bytes for your ... |
This is inspired by the excellent Visualize Visual Eyes challenge. It is posted with permission from and credit to @Jordan
We are going to create an ASCII art approximation of the Xeyes challenge but without worrying about the actual mouse movements. Just the positions.
EDIT
I thought about whether this could be seen a... |
The majority function is a boolean function which takes three boolean inputs and returns the most common. For instance if maj(x,y,z) is the majority function and T denotes true and F denotes false then:
maj(T,T,T) = T
maj(T,T,F) = T
maj(T,F,F) = F
maj(F,F,F) = F
This question concerns writing boolean functions as comp... |
Objective
Given a 2D array of any size, write a program or function to shift alternatively the columns and rows
Example
a b c d e
f g h i j
k l m n o
All elements in the first column shift down one row, the second column shift up one row, the third shift down one row and so on, wrapping when they reach the edge.
k g m... |
Background
Here you have another work-inspired challenge, but from my wife's work in this case. Imagine you have a service that returns the list of nodes in a tree structure (much like the files and folders in a file system), but in no particular order. For every node you get a tuple with its name and the name of its p... |
Room Number Locator
I have come across an interesting problem solving technique at my job when given the wrong room number from a colleague for a meeting. Every now and then, while on the way to a meeting, a member on my team will send me the wrong room number, typically because they are in a rush at their desk and fat... |
The objective of this challenge is to take an array of positive integers, and enumerate its indices, grouping like elements.
An enumeration without any duplicates is done by just outputting an array of pairs (value, index), for example, [3, 4, 13, 9, 2] => [[3,1],[4,2],[13,3],[9,4],[2,5]].
However, if a given element a... |
Introduction
In this challenge your task is to generate the ISBN-10 code for books given its ISBN-13 code, assuming that such a code exists. Such an ISBN-13 code consists of several parts separated by -:
978-GG-PPPP-TTT-C
The letters G (group), P (publisher), T (title) and C (checksum) all stand for one digit. For the... |
Take a square matrix containing positive integers as input, and calculate the "rotated sum" of the matrix.
Rotated sum:
Take the sum of the original matrix and the same matrix rotated 90, 180 and 270 degrees.
Suppose the matrix is:
2 5 8
3 12 8
6 6 10
then the rotated sum will be:
2 5 8 8 ... |
Write a function or program that, when given a list of names, outputs or returns a list where duplicates of given names have a unique shortened version of their surname.
Input:
A list of names, where a name is defined by a given name and a last name separated by a space. Names are non-empty strings containing only upp... |
Inspired by a polyglot on the Stack Overflow 404 page:
Goal
Your goal is simple, to create a polyglot that outputs the number 404, and then terminate, in as many languages as possible.
Restrictions
Here's the twist, there's a restriction to make it harder:
You have to write N programs and pick N languages in a particu... |
Background
Many people visit webpages, which require special browsers because of lack of compatibility. So you have to write a script (client sided or server sided), which just prints the name of the browser. Because not everyone has fast internet, the script has to be as short as possible. (This is a joke xD)
Rules
Y... |
Recently I had the pleasure of writing a Haskell program that could detect if the NegativeLiterals extension was engaged. I came up with the following:
data B=B{u::Integer}
instance Num B where{fromInteger=B;negate _=B 1}
main=print$1==u(-1)
Try it online!
This will print True normally and False otherwise.
Now I had ... |
Inspired by this Math.SE question.
Background
The Fibonacci Sequence (called F) is the sequence, starting 0, 1 such that each number (F(n)) (after the first two) is the sum of the two before it (F(n) = F(n-1) + F(n-2)).
A Fibonacci Sequence mod K (called M) is the sequence of the Fibonacci numbers mod K (M(n) = F(n) % ... |
The sequence contains the decimal representation of the binary numbers of the form: 10101..., where the n-th term has n bits.
The sequence is probably easiest to explain by just showing the relationships between the binary and decimal representations of the numbers:
0 -> 0
1 -> 1
10 -> 2
101 -> ... |
Challenge:
Given an index integer n, either output the n'th item in this sequence, or output the sequence up to and including index n:
25,25,7,28,29,20,21,22,23,14,35,26,7,28,29,20,16,29,12,15,28,21,14,17,30,13,16,29,12,15,28,21,10,6,12,18,15,11,7,13,19,17,13,9,15,21,18,14,10,16,22,19,15,11,17,23,20,16,12,18,24,21,17,1... |
Given two different lists of non-negative integers, return the list that has the highest maximum (e.g. [4, 2], [3, 3, 1] -> [4, 2]).
If they both have the same maximum, return the list that contains more instances of this maximum (e.g. [4, 2, 4], [4, 3, 3, 3, 1, 3] -> [4, 2, 4]).
If, after these comparisons, they are e... |
Inspired by the fourth problem from BMO2 2009.
Given a positive integer n as input or a parameter, return the number of positive integers whose binary representations occur as blocks in the binary expansion of n.
For example, 13 -> 6 because 13 in binary is 1101 and it has substrings 1101, 110, 101, 11, 10, 1. We do no... |
Given a list of hole yardages, green sizes, a slice angle and a max distance, compute a golf score.
Assumptions
Earth is flat
All greens are circular
Slice angle will be between -45 and 45 degrees and will be given in degrees
All distances in the same metric (yards or meters, doesn't matter)
No out of bounds, obstruct... |
This question asking us to make a "Cyclic Levenquine" has gone unanswered. So today we will ask a slightly simpler version. In this challenge we will define a K-Levenquine to be a program whose output is Levenshtein distance K from its source.
Task
Your goal in this challenge is to write a program with some output dif... |
Your challenge is to translate a Cubically cube-dump to the format specified in this challenge.
Input
The input will represent a Rubik's Cube, formatted how Cubically prints its memory cube at the end of every program.
This is a solved cube:
000
000
000
111222333444
111222333444
111222333444
555
555
5... |
Sometimes to fall asleep, I'll count as high as I can, whilst skipping numbers that are not square-free. I get a little thrill when I get to skip over several numbers in a row - for example, 48,49,50 are all NOT square-free (48 is divisible by 2^2, 49 by 7^2, and 50 by 5^2).
This led me to wondering about the earliest ... |
Your challenge is simple. Write two programs that share no characters which output each other.
Example
Two programs P and Q are mutually exclusive quines if:
P outputs Q
Q outputs P
There is no character c which belongs to both P and Q
Each program P and Q are proper quines
This counts empty quines and quines that re... |
Inspiration.
Given (by any means):
A two-argument (or single argument consisting of a two-element list) black box function, f: ℤ+ × ℤ+ → ℤ+ (input and output are 1, 2, 3,…)
A strictly positive integer matrix with at least two rows and two columns
return the matrix's function trace.
What is a function trace?
A normal ... |
Challenge
The challenge is to write a program that takes the coefficients of any n-degree polynomial equation as input and returns the integral values of x for which the equation holds true. The coefficients will be provided as input in the order of decreasing or increasing power. You can assume all the coefficients to... |
UBASIC is a freeware basic interpreter written by Yuji Kida at Rikkyo University in Japan, specialized for mathematical computing. It is considered to be a "ready-to-run" language that and is capable of running on DOS and Windows.
What general tips do you have for golfing in uBasic? Any ideas that can be applied to cod... |
What general tips do you have for golfing in Clean? Please post only ideas that can be applied to code golf problems in general, and are at least somewhat specific to Clean.
If you've never heard of Clean, you can find out more here.
Or, you can join the chat room.
|
Challenge:
Input: Three integers: bottom-edge length; starting amount of grains of sand; index
Output: Output the state of the bottom part of an hourglass at the given index, based on the given bottom-edge length and amount of grains of sand.
Challenge rules:
We simulate the grains of sand with digits 1-9
We put the c... |
Try to create a simple ASCII art scissors animation!
Challenge
All inputs will be integers -31 through 31.
The output will be an animation (To be outputted somewhere, as long as the previous frame is replaced. GIFs are allowed.), separated by (approximately) 1 quarter of a second.
If the input (n) is positive:
The ani... |
Introduction
Try to convert words to two different unicode fonts.
Challenge
Your task is to transform your input string into the and unicode characters.
All uppercase words should become lowercase words.
For Example: WORD ->
All lowercase words should become words
For example: other words ->
All mixed ... |
Introduction
Output all the numbers in specific base that would appear in an adapted version of the game of seven.
Challenge
Your task is to output all the numbers in a given base in a given range, skipping the ones matching certain conditions.
You will be given four inputs: base elim start and end. The roles of the f... |
Specification
This challenge is simple to state: your input is a non-empty array of nonnegative integers, and your task is to partition it into as few substrings as possible, such that each substring is a permutation of a consecutive integer range.
More formally, if the input array is A, then the output is minimum numb... |
Input is an r by c matrix of non-negative integers (you may input r and c as other parameters if this helps with golf). This may be inputted as a 2D array or, if you prefer, a 1D array (though taking in r this time is necessary). Strings separated by spaces to distinguish rows and newlines to distinguish columns are al... |
Story
So I have a book that I want to separate from my table with nothing but other books. I want to know how many books do I need to achieve this with \$n\$ book lengths.
Here's a visualization that my friend at Wolfram drew for me:
More information about the topic in Wolfram and Wikipedia.
Challenge
Given an integer... |
Introduction
Suppose you have a list of lists of integers (or any objects really, but let's stick to integers for simplicity).
The lists may be of different lengths, and some of them may be empty.
Let's write the lists in a tabular format:
[[ 1, 2, 3, 4, 5],
[ 6, 7],
[ 8, 9, 10, 11],
[],
[12, 13, 14... |
Introduction
Your goal is to find the least number of ones you need to add or multiply together to get the input value, this is A005245.
Input
One positive integer N.
Output
The smallest number of ones that must be added/multiplied to get N.
Sample Input
7
Sample Output
6
Explanation
(1 + 1 + 1) * (1 + 1) + 1 = 7
... |
Hexcells is a game based off of Minesweeper played on hexagons. (Full disclosure: I have nothing to do with Hexcells. In fact I don't really like the game.) Most of Hexcells rules can be pretty easily expressed in Generalized Minesweeper (Minesweeper played on an arbitrary graph). The one that is most difficult is th... |
Introduction
The Boids Algorithm is a relatively simple demonstration of emergent behavior in a group. It has three main rules, as described by its creator, Craig Reynolds:
The basic flocking model consists of three simple steering behaviors which describe how an individual boid maneuvers based on the positions and ve... |
A radiation-hardened program is a program where, if any character of the code is removed, the program will still function the same. For this question, we'll be writing a program that detects when it is irradiated.
Write a program or function that, when any single byte is removed, the resulting program will output that ... |
A positive integer can be diluted by inserting a 0 between two bits in its binary expansion. This means that an n-bit number has n-1 dilutions, which are not necessarily all distinct.
For example, for 12 (or 1100 in binary), the dilutions are
11000 = 24
^
11000 = 24
^
10100 = 20
^
In this challenge, we're goin... |
Introduction
Write a solver for the Hitori puzzles using least bytes.
Challenge
Your task is write a solver for the Hitori (ひとり, the word for "alone" in Japanese; the meaning of the game name is "Leave me alone") logical puzzles. The rules are as follows:
You are presented with a n-by-n grid of cells, each cell contai... |
Introduction
Given a set of text-based "screenshots" consisting of printable ASCII chars merge them so that all of them form one long screenshot so that nobody has to do it themselves when reading it.
Challenge
Take input as a list of strings (referred to as "screenshots"). Each screenshot consists of several lines of ... |
Given a string as input find the longest contiguous substring that does not have any character twice or more. If there are multiple such substrings you may output either. You may assume that the input is on the printable ASCII range if you wish.
Scoring
Answers will first be ranked by the length of their own longest ... |
Introduction
This challenge is similar to Project Euler problems. I came up with it because I was playing a deceivingly simple board game and couldn't come up with an efficient solution to answer a simple question about its mechanics.
Quarto is a fun variant of 4 in a row. It is played on a 4 by 4 board with 16 unique ... |
Challenge
Write a program that compresses and decompresses ASCII text losslessly. It should be specialized to work well with palindromes, including case-insensitive and punctuation-insensitive palindromes. The best compression with the smallest source wins.
Scoring
total_bytes_saved / sqrt(program_size) - Highest score... |
Your challenge is to expand some brackets in a program's input as shown:
Find a string s between two matching brackets [ and ], with a single digit n after the closing bracket.
Remove the brackets.
Replace s with itself repeated n times. (If n is 0, simply remove s.)
Go to step 1 until there are no more matching brack... |
Input:
A matrix containing integers in the range [0 - 9].
Challenge:
Determine if all non-zero elements are connected to each other vertically and/or horizontally.
Output:
A truthy value if all are connected, and a falsy value if there are non-zero elements/groups that aren't connected to other elements/groups.
Test ca... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.