instruction
stringlengths
34
53.1k
(There exists some challenges that require to use the best strategy, but here we don't. Even if you are able to win, you are allowed to make a tie) Challenge Write a program which plays the game tic-tac-toe. It must not lose (therefore, it should end the game either with a tie or by winning). Allowed I/O methods Input...
Left and right Riemann sums are approximations to definite integrals. Of course, in mathematics we need to be very accurate, so we aim to calculate them with a number of subdivisions that approaches infinity, but that's not needed for the purposes of this challenge. You should instead try to write the shortest program,...
Imagine enumerating the elements of rhombi which grow [1],[1,3,1],[1,3,5,3,1],… (only odd numbers such that they align nicely). This would look like as follows, note that you always begin enumerating with 1: 01 1 02 03 04 1 2 3 4 05 06 07 08 09 … 5 10 11 12 ...
A doubly linked list is a data structure in which each node has a value as well as "links" to both the previous and next nodes in the list. For example, consider the following nodes with values 12, 99, and 37: Here, the nodes with values 12 and 99 point to their respective next nodes, with values 99 and 37. The node w...
What is the shortest way we can express the function f(a,b)(c,d)=(a+c,b+d) in point-free notation? pointfree.io gives us uncurry (flip flip snd . (ap .) . flip flip fst . ((.) .) . (. (+)) . flip . (((.) . (,)) .) . (+)) which with a little bit of work can be shortened to uncurry$(`flip`snd).((<*>).).(`flip`fst).((....
The idea of this is mainly from BIO 2017 q1. I got the idea for posting this challenge from my Binary Sequences challenge, since lots of people seemed to like it. Also, this is the first challenge I've posted without posting on the sandbox. I'll delete it if no one likes it. Rules Take in a sequence of digits in ternar...
Rules Given a list of integer coordinates, l, with a length of at least 4, and an integer n such that n is smaller than the length of l (but at least 3), return the largest area of an n-sided polygon satisfies: is simple (not self-intersecting). has all the coordinates of its n vertices in the list l. has no three con...
Today while playing with my kids I noticed that an apparently simple toy in the park hid a challenge. The wheel has a triangle that points to a number, but also has three circles that point to the numbers every 90 degrees from the first one. So: Challenge (really simple) Given an integer between 1 and 12 (the one poi...
It is the year MDLXVII in a world in which the Roman Empire never fell, and the collapse into the dark ages never occurred. Due to the extended period of Pax Romana, the empire's economic stability enabled technology to progress at a rapid rate. The Romans have begun to dabble with circuitry, and have invented an inge...
Challenge Given a non-negative integer, output whether it is possible for two dates (of the Gregorian calendar) differing by exactly that many years to share a day of the week. A year is assumed to be a leap year either if it is divisible by 4 but not by 100, or if it is divisible by 400. Output may be: falsey/truthy ...
So you want to create a haiku, but you're not sure if it follows the syllable rules for a haiku. I couldn't be bothered to write a proper blurb like I usually do, so you'll have to make do with this. Let's get stuck right in. Finding a haiku out in the wild For the purposes of this challenge, we will be checking if the...
Robbers post A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle shuffle a string: Split the string into equal sections. Reverse the strings, and starting from the start of each string. Pu...
Cops post A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle shuffle a string: Split the string into equal sections. Reverse the string, and starting from the start of each string. Put ru...
It is well known that odd primes will appear in Pascal's triangle exactly twice. However, not all numbers that appear exactly twice in Pascal's triangle are prime. We'll call these numbers Pascal primes. Pascal primes are composite numbers that appear exactly twice in Pascal's triangle. The first few Pascal primes are...
I really like times that follow certain patterns. In particular, I like times where all the digits are the same, or all of the digits increase arithmetically by one from left to right. Further, I viscerally hate when people put letters in my times, so all of that AM/PM nonsense is dead to me. Thus, my favorite times ar...
A riffle shuffle is a type of shuffle where the deck is split into two partitions and the partitions are then spliced back together to create a new shuffled deck. The cards are spliced together in such a way that cards maintain their relative order within the partition they are a member of. For example, if card A is b...
Inspired by Taken from a question at Stack Overflow. The challenge Given an integer n>1, output all arrays that can be obtained by swapping exactly two entries in the array [1, 2, ..., n]. The arrays can be produced in any order. You can consistently use [0, 1, ..., n-1] (0-based) instead of [1, 2, ..., n] (1-based). A...
Challenge Given a grid like this, 1 2 3 4 5 6 7 8 1 . . . . . . . . 2 . # . . . # . . 3 . . . . . . . . 4 . . . . . . . . 5 . . . . . . . . 6 . . # . . . . . 7 . . . . . . . . 8 . . . . . . . . write a piece of code that can determine the size of the largest square that does not include a '#'. (The answer to this in...
Balanced ternary logic Ternary is normally another name for base 3, that is to say, each digit is 0, 1, or 2, and each place is worth 3 times as much as the next place. Balanced ternary is a modification of ternary which uses digits of -1, 0 and 1. This has the advantage of not needing a sign. Each place is still worth...
Challenge Given any positive integer supported by your language: Take the input and divide it into two halves. For all divisions in this program, if the input is odd, round one half up and one half down (ex: 7 -> 3,4, not 7 -> 3.5,3.5). Divide either number in half, then take the larger of these two new halves and add...
Yesterday I asked this question about riffle shuffles. It seems that yesterdays question was a bit too hard so this question is a related but much easier task. Today you are asked to determine if a permutation is in fact a riffle shuffle. Our definition of riffle shuffle is adapted from our last question: The first ...
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...