instruction
stringlengths
34
53.1k
Quarterstaff repo here with additional quarterbf interpreter: rather bereft of documentation, however, but it does contain the two interpreters you can go to https://tio.run/#quarterstaff to run quarterstaff programs online. however, the TIO BF implementation seems to have limited cells, according to the documentation ...
Overview Given the integer representation of three elements in GF(2^64), give the product of the first two elements over GF(2^64) with the reducing polynomial defined as the polynomial m such that m(x) = x^64 + n(x), where n is the polynomial representation of the third element. You want me to what? A finite field GF(...
Most people here are familiar with seven segment displays, which are also used in matchstick puzzles. Below are the digits 0 through 9 and letters a through z, except k,m,t,v,w, written in this format. _ _ _ _ _ _ _ _ | | | _| _| |_| |_ |_ | |_| |_| |_| | |_ _| | _...
Your task is to write a non-empty program / function of byte count L, which, when repeated M times, checks whether a given positive integer N is equal to L × M. You should, in theory, support an arbitrary number of repetitions (an arbitrary positive integer value of M), but it's fine if, due to language limitations, it...
Grid: +---------------+---------------+---------------+---------------+---------------+ | id: 20 | id: 19 | id: 18 | id: 17 | id: 16 | | pos: (-2, -2) | pos: (-1, -2) | pos: (0, -2) | pos: (1, -2) | pos: (2, -2) | +---------------+---------------+---------------+---------------+---...
Challenge Your challenge is to make a simple program that takes the [input] and formats it as "Hello, [input]!" Input Either a function call variable or STDIN, this is the name. Can contain any character, UTF-8, and can be empty - would result in Hello,!. Also newlines in the input are fine - On a new line -> Hello, O...
Your task is to accept as input two gene sequences, and a sequence of "cross over points", and return the gene sequence that results from the indicated cross overs. What I mean by this is, say you have the sequences [A, A, A, A, A, A, A] and [Z, Z, Z, Z, Z, Z, Z], and cross over points of 2 and 5. The resulting sequenc...
Example Input -> 5 Output -> 55555 Input -> 12 Output -> 121212121212121212121212 Criteria Least number of bytes wins!
Introduction For a given rational number r, find a pair of integers p,q so that p/q=r and the number of less used bits in p and q are minimized (details below). Challenge A positive rational number r can be expressed as the ratio of two positive integers, r=p/q. The representation is not unique. For each of these repre...
Find a maximally profitable sequence of exchanges given an exchange rate table. As an example consider the currencies Ariary (your home currency), Baht, Cedi, and Denar where the rate from one to another (after any transaction rate has been levied) is given by the (row, column) entry in the exchange rate table below: ...
Drunkard's Journey Home In this challenge you are to write a program which simulates a drunkard stumbling his way home from the bar. Input: The input will be an adjacency matrix (representing a directed graph) which represents paths the drunkard can take. At each location, the drunkard will choose one path at random (E...
Background Stack Cats is a reversible esoteric language made by Martin Ender. Each command in Stack Cats is either the inverse of itself (represented as a symmetric character, such as -_:T|), or has its inverse command (represented as the mirror image, such as () {} [] <>). Stack Cats has a strong syntactic requirement...
Given positive integer n and e, knowing that e<n and that n is the product of two different odd primes(but the primes are not directly given to you), find such a positive integer d smaller than n that, for each integer m, (me)d ≡ m (mod n). Your program should handle n up to 24096 in 1TB space, but not necessary reaso...
World Bowling scoring Many people have gone to their local bowling center to play a few games of bowling, and many people continue to struggle to calculate their scores. World Bowling has introduced a simplified scoring system in order to attract more people to the sport. This scoring system is utilized in internation...
Let's say I'm ten steps away from my destination. I walk there following the old saying, "Two steps forward and one step back". I take two steps forward, one back, until I'm standing exactly on my destination. (This might involve stepping past my destination, and returning to it). How many steps did I walk? Of course, ...
The three-dimensional Levi-Civita symbol is a function f taking triples of numbers (i,j,k) each in {1,2,3}, to {-1,0,1}, defined as: f(i,j,k) = 0 when i,j,k are not distinct, i.e. i=j or j=k or k=i f(i,j,k) = 1 when (i,j,k) is a cyclic shift of (1,2,3), that is one of (1,2,3), (2,3,1), (3,1,2). f(i,j,k) = -1 when (i,j...
Given integers 0<x<10106 and 0<n<106, work out x(1/n) under 15 seconds(TIO or your computer), 1GB memory. You can assume the result is integer smaller than 50000. Shortest code in bytes in each language win. Sample: x n result 121 2 11 123 1 123 1024 10 2 A larger sample can be seen here
Description Let a permutation of the integers {1, 2, ..., n} be called minimally interpolable if no set of k+2 points (together with their indices) fall on a polynomial of degree k. That is, No two points fall on a horizontal line (0-degree polynomial) No three points fall on a line (1-degree polynomial) No four poi...
Challenge: Create a program or function that takes an integer input, which outputs a new program/function as specified below. Input: Integer n: Time in seconds before the Time Bomb explodes. Output: The original program which had the time in seconds n as input, will output a new program/function that does the following...
Input: A list of integers Output: Put each digit (and the minus sign) in its own lane, in the order -0123456789, ignoring any duplicated digits. Example: Input: [1,729,4728510,-3832,748129321,89842,-938744,0,11111] Output: -0123456789 <- Added as clarification only, it's not part of the output 1 2 7 ...
Your task is to find two missing characters in a Columbo episode title. Input One of the 69 Columbo episode titles (as listed below), with exactly two characters replaced with *. Example: "Ran*om for a *ead Man" Output You may either return the full episode title, or just the two missing characters in any reasonable f...
Anyone remember Boaty? You could totally make any old word, right? Write a function to turn a string into Somethingy McSomethingface. It should accept one string as input. Ignore the case of the input. If the word ends in 'y', your function should not add an additional 'y' to the first instance, but should remove it i...
In this simple challenge you are given an input array L of non-negative integers and a number of bins b greater than 0 but no more than the length of L. Your code must return a new array M whose length is b and which has binned the array L. This is easiest explained with examples. L = [1,0,5,1] and b = 2 returns M = [1...
Related: Determine the position of a non-negative number in the infinite spiral Wind me a number snake! Challenge: Given a grid, with an ID starting at the center and spiraling out, what is the ID given a position in the fewest number of bytes? Grid: +---------------+---------------+---------------+---------------+--...
Inspired by Digits in their lanes and 1, 2, Fizz, 4, Buzz Introduction Your task is to generate exactly the following output: 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz ...
Given a positive integer n, do the following (and output every stage): start with a list containing n copies of n. do the following n times: at the ith step, gradually decrement the ith entry of the list until it reaches i So, for example, if the given n is 4, then you start with [4,4,4,4], and then at the first step...
Given an integer n ≥ 0 , output it in a non-positional base-3 notation, using digits 139ABCDE… and a 1-character separator. Every digit is a consecutive power of 3 and the digits on the left side of the separator are negated, e.g. A931|B → 81−(1+3+9+27) → 41. A digit may appear only once. Rigorously, let ...
API Easter egg hunt! There's an API at http://easter_egg_hunt.andrewfaraday.com which will provide a special Easter egg hunt, just for you... You can see the API docs at the above address, or try it from here. The API: All calls to this API are GET requests, which will return a JSON string. These examples are in a 5x5 ...
The objective is to print a graph from an array of numbers, of the design below. Printing the X and Y scale exactly as in the "design", with padding, is part of the challenge. The input array of numbers can be of virtually any range of integers in X and Y, but not 0 and not negative - though I would suggest keeping it ...
The goal of this challenge is to write a program or function that returns the least amount of strikes needed to complete a given course. Input The layout of the course can be passed in any suitable way and format you prefer. (read from the console, passed as an input parameter, read from a file or any other, multilin...
The Challenge Given an input string (or array) consisting of < and >, output a sequence (array or string) of integers such that: the operators are all correct when applied in order between consecutive numbers in the output all integers are positive (1 or greater) the sum of the integers is as small as is mathematicall...
Challenge: The concept is simple enough: write a full program to output its own code golf score! Output should only be the byte count of your program and a trailing bytes. BUT WAIT..... there is one restriction: Your source code can not include any of the digits from your byte count So if your score is 186 bytes, you...
A piggy bank is a container used to collect coins in. For this challenge use the four US coins: quarter, dime, nickel, and penny. Challenge Your challenge is to create an electronic piggy bank. Write a program (or function) that when run (or called), outputs (or returns) the count of each coin you have, as well as the ...
Inspired by The Great API Easter Egg Hunt! Summary Your task is to search for a predetermined integer in the "Collatz space" (to be explained later) using the fewest step possible. Introduction This challenge is based on the famous Collatz conjecture that hopefully everyone here at least heard of. Here is a recap taken...
Introduction For as long as programmers have been programming and as long as English teachers have been teaching, there's a controversy over the datasets called Arrays and Lists (or hashes). Arrays have almost always had their first index at 0. Which, for the programmer, is understandable because of math. But along the...
The task in this challenge is to put elements of an array into time bins. The input will be a non-decreasing array of positive integers representing the time of events, and an integer which represents the size of each bin. Let us start with an example. We call the input array A and the output array O. `A = [1,1,1,2,7,...
Challenge You need to generate a program or function that takes in a positive integer N, calculates the first N terms of the Fibonacci sequence in binary, concatenates it into a single binary number, converts that number back to decimal, and then outputs the decimal as an integer. For example 1 -> [0] -> 0 to decimal o...
A well known song by the Irish rock band U2 starts with the singer Bono saying "1, 2, 3, 14" in Spanish ("uno, dos, tres, catorce"). There are various theories as to the significance of those numbers. Apparently the official explanation is "we drank too much that night". But there's a more interesting hypothesis: Bono ...
Introduction I have some ASCII cars that have velocity and direction. Their velocity is represented by their number. If a car is <> then it has stopped. For example: <> 1> 2> 3> After one second, I get <> 1> 2> 3> After two, I get <> 1> 2> 3> If two cars are too close, they crash. 1> <1 1> <2 Afte...
Background IEEE 754 Double-precision floating-point format is a way to represent real numbers with 64 bits. It looks like the following: A real number n is converted to a double in the following manner: The sign bit s is 0 if the number is positive, 1 otherwise. The absolute value of n is represented in the form 2**y...
Introduction I have a lot of ASCII rocks. They are built with dashes, pipes, Vs, carets, angle brackets, slashes and spaces. Example: /--\ | | | | \--/ I want to erode them, like this: /\ / \ \ / \/ All of the corners have become rounder. A more complicated example: /----\ | \------\ | | | ...
Introduction Some months are completely symmetric, meaning they have central symmetry as well as reflection symmetry, like February of 2010: February 2010 ┌──┬──┬──┬──┬──┬──┬──┐ │ │ │ │ │ │ │ │ ├──┼──┼──┼──┼──┼──┼──┤ │ │ │ │ │ │ │ │ ├──┼──┼──┼──┼──┼──┼──┤ │ │ │ │ │ │ │ │ ├──┼──┼──┼──┼──┼...
Given the spiral of size S and the step N, output the "square" S*S spiral having N asterisks, built from the outer to inner radius clockwise. Test cases (examples) below. Input: 4 3 Output: *** Input: 4 6 Output: **** * * Input: 4 11 Output: **** * * * **** Input: 6 18 Output: ****** * * * * ...
Given a positive integer N ("virality"), your program should create an ASCII-art drawing of a tree with two branches of length N extending downwards and/or rightwards from the top-left corner. The direction taken by each branch after the first asterisk can be either rightwards or downwards, and this choice should be ma...
This challenge was posted as part of the April 2018 LotM challenge, as well as for Brain-flak's 2nd birthday I was thinking about what the most efficient way to encode brain-flak programs would be. The obvious thing to do, since there are only 8 valid characters, is to map each character to a 3-bit sequence. This is c...
Roguelike pathfinding Your task will be, given a two-dimensional array of the elements described below, which represents a dungeon, to output or return a single number representing the amount of gold pieces the rogue can collect without waking up any monsters. The elements of the array are as follows: Empty spaces are...
For the purposes of this challenge, we define a postfix regex dialect with alphabet {1, 0} and the following operations: 1 and 0 match themselves literally. _ matches the empty string. ! always fails (i.e. it does not match anything). ab; matches a, followed by b. ab| matches both a and b. a+ matches one or more insta...
Write a program or function that given n ≥ 1 returns the number of solutions to ±1 ± 2 ± 3 ± ... ± n = 0. For n = 6 there are no solutions, so the answer is 0. For n = 4 there are two solutions, so the answer is 2 (the two solutions are 1 - 2 - 3 + 4 = -1 + 2 + 3 - 4 = 0). This is OEIS sequence A063865. Some example in...
Challenge : \$\pi\$ is supposed to be infinite. That means every number is contained inside the decimal part of \$\pi\$. Your task will be to take a positive integer on input and return the position of this number in \$\pi\$ digits on output. For example, if the input is 59, we'll return 4 Here is why : we will look fo...
Inspired by Digits in their lanes Input: An ASCII-art of width ≤ 11, consisting of spaces and #. (You can choose any two distinct characters instead.) Example: # ### # # # # # # # # # ### # # ### # ########### # # # # # ### # # ...
Well I think it is about time we have another proof-golf question. This time we are going to prove the well known logical truth \$(A \rightarrow B) \rightarrow (\neg B \rightarrow \neg A)\$ To do this we will use Łukasiewicz's third Axiom Schema, an incredibly elegant set of three axioms that are complete over proposit...
I have recently thought of a wonderful relatively old mobile game, called Tower Bloxx. Alhough I'm not really old myself, but it reminded me of childhood and school :) So this my challenge is a kind of a reference to that good game! I have (hopefully) looked into any tower question on PPCG and this won't be a dupe. ...
Background: Pi (π) is a transcendental number, and therefore it has a non-terminating decimal representation. Similar, the representation doesn't terminate if written in any other integer base. But what if we wrote it in base π? Digits in decimal represent powers of 10, so: π = 3.14… = (3 * 10^0) + (1 * 10^-1) + (4 * 1...
As of ECMAScript 2015, JavaScript has 33 reserved keywords, such as break, const and new, as well as 10 future reserved keywords, such as let and await. Your task is to chain together the largest number of consecutive1 distinct reserved keywords2 while writing functional JavaScript code3. Consecutive reserved keywor...
Given an integer, output five perfect cubes whose sum is that integer. Note that cubes can be positive, negative, or zero. For example, -10 == -64 - 64 + 64 + 27 + 27 so for input -10 you could output [-64, -64, 64, 27, 27], though other solutions are possible. Note that you should output the cubes, not the numbers be...
Challenge: Input: Two integer parameters a and b (where a<b and the difference is at least 2) Output: Output or return this text, where a and b are filled in: (a,b) = ]a,b[ = {a<x<b} = {a<x&&x<b} = a+1..b-1 [a,b) = [a,b[ = {a<=x<b} = {a<=x&&x<b} = a..b-1 (a,b] = ]a,b] = {a<x<=b} = {a<x&&x<=b} = a+1..b [a,b] = [...
In some nations there are recommendations or laws on how to form emergency corridors on streets that have multiple lanes per direction. (In the following we only consider the lanes going in the direction we are travelling.) These are the rules that hold in Germany: If there is only one lane, everyone should drive to t...
So, here's a map of, let's say, a dungeon... ########## # ##### # ##### ########## ########## ########## ########## #### ## #### ## ########## Let's say that the hero is in Room A (at the top left) and their goal (a prince in distress?) is in Room B (to the bottom right). Our map does not allow the hero to...
Input A non-empty array of positive integers. Task Convert each integer to either binary, octal, decimal or hexadecimal in such a way that each digit (0 to F) is used at most once. Output The list of bases that were used to solve the puzzle. Detailed example The expected output for [ 16, 17 ] is [ octal, decimal ]. Her...
The following problem is a common interview question, thus dull answers are discouraged. Go short or creative, best if both: Create the following pattern ########### ## ## # # # # # # # # # # # # # # # # # # # # # # # # # # # ## ## ########### In case you cry "dupe", I see y...
For an integer n that satisfies n > 0, write its value as a right-descending path based on its binary representation. Rules The first (most significant) set bit is always in the top-left corner. When the next bit is set (a 1), draw a character ("filled") on the next line in the same column as the previous character dr...
Trigonometry has LOTS of identities. So many that you can expand most functions into sines and cosines of a few values. The task here is to do that in the fewest bytes possible. Identity list Well, the ones we're using here. sin(-x)=-sin(x) sin(π)=0 cos(-x)=cos(x) cos(π)=-1 sin(a+b)=sin(a)*cos(b)+sin(b)*cos(a) cos(a+b)...
A number theory expression contains: 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) variable names(all ...
Input The board: A 2D container (matrix, list of lists, etc.) of letters like: ["B", "C", "C", "C", "C", "B", "B", "C", "A", "A"], ["B", "A", "C", "B", "B", "A", "B", "B", "A", "A"], ["B", "C", "B", "C", "A", "A", "A", "B", "C", "B"], ["B", "B", "B", "A", "C", "B", "A", "C", "B", "A"], ["A", "A", "A", "C", "A...
So your task is to take a 3x3 block where -'s mean blank spaces, and *'s mean filled spaces, for example: -** -*- *-* and rearrange the block so that the *'s form an X, like this: *-* -*- *-* Input: 3x3 squares like above, they can be 3 lines, an array, or however you want. Output: The shortest amount of moves to rea...
Given an integer N perform the following steps: (using 9 as an example). Receive input N. (9) Convert N from base10 to base2. (1001) Increase every bit by 1. (2112) Treat the result as base3 and convert it back to base10. (68) Return/Output the result. Input May be received in any reasonable number format. You only ...
What if we have a corridor comprised of two parallel mirrors? | | | | | | | | | | | | | | | | | | | | Now, we shine a laser down it... | \ | | \ | | \ | | \ | | \ | | \ | | \ | | ...
Recreational languages win at code golf too much. This challenge is simple, when using higher level functions. The task is as follows: Given any valid url, which is guaranteed to result in a valid HTML document (for example https://en.wikipedia.org/wiki/Ruby_on_Rails, which has 9 images), count the number of images di...
Given a list of two or more spelled-out serial numbers of equal length greater than two, e.g. [[ "three" , "one" , "four" ], [ "one" , "five" , "nine" ], [ "two" , "six" , "five" ], [ "three" , "five" , "eight" ]] sort the list by the numbers that the words represent: [[ "one" , "five" , "nine" ], [ "t...
In the context of quines, an intron (or payload) is a part of a quine that serves no purpose in producing output, but is still included in the data section. For example: function quine() { const data = "function quine() {\n const data=\"@\";\n // Arr! This be an intron!\n return data.replace(\"@\", JSON.s...
Using your language of choice, write a function that takes a variable number of arguments and returns the number of arguments it was called with. Specifics: Your language needs to support variadic argument functions: something callable that takes an arbitrary number of arguments and returns a value. Parameters must be...
A certain well-known cable company has a somewhat clumsy 'Search for Program' feature that works through the remote. It takes muchly much button pushing; so, being an admirer of economy of motion, I thought I'd seek out a programmer's help to minimize the number of finger movements I have to make. The Craptastic Search...
This is an answer-chaining challenge in which each answer builds on the previous answer. Taking no input, you are to output the most recent submission to this thread. I would HIGHLY suggest sorting by oldest and skipping to the last page to find the most recent answer. Scoring The winner will be chosen based on a point...
Input: A 2D array containing two distinct (optional) values. I'll use 0 and 1 when explaining the rules. The input format is of course flexible. Challenge: Zeros are water, and ones are islands. In order to ensure loneliness, your task is to surround all islands with water by inserting rows and columns of zeros. You d...
Premise So recently I was about half an hour early to an appointment, and decided to wait outside. I also determined that it would look strange if I just stood motionlessly in front of the house. Therefore, I decided to go on a quick walk, within a limited area. I also concluded that if I started walking in circles tha...
Given latitude/longitude of two points on the Moon (lat1, lon1) and (lat2, lon2), compute the distance between the two points in kilometers, by using any formula that gives the same result as the haversine formula. Input Four integer values lat1, lon1, lat2, lon2 in degree (angle) or four decimal values ϕ1, λ1, ϕ2, λ2...
I have a series of binary switches, which I can represent as a bit string. The last person who used my switches left them in some arbitrary state without cleaning up, and it bugs me. I always keep the switches in one of four possible "tidy" configurations: All 1: e.g., 111111111 All 0: e.g., 000000000 Alternating 1 an...
Not sure if this is the correct community to post this is. But as I see this problem as an interesting puzzle to solve, I'd thought to give it a shot... Problem Statement: Let`s say we have: N collections of parts: A, B,C,D,...etc Each collection consists of n parts: 1,2,3,4,5 ... All these parts are randomly present...
Input: A list of integers (which will never contain a zero) Output: A list of the same size with counts based on the following: If the current item is negative: Look at all items before this item, and count how many times the digits occurred in those other numbers If the current item is positive instead: Look at all i...
Challenge Predict the distance between the Sun and the nth planet when using any formula that gives the same result as the Titius–Bode law: d=(3*2^n+4)/10. BUT WAIT... there is one restriction: Your source code can not include any of the Titius–Bode law's digits So, your program can not contain the characters 0, 1, 2,...
Given an input sentence consisting of one or more words [a-z]+ and zero or more spaces , output an ASCII-art histogram (bar graph) of the letter distribution of the input sentence. The histogram must be laid out horizontally, i.e. with the letter key along the bottom in alphabetical order from left to right, with a Y-a...
So what might be the shortest language for this simple task? Task: You are given an input of type String - the string is a valid hexadecimal number ([0-9A-F]). Convert it to a decimal number and print it to the console. Tests: HEX -> DEC 1 -> 1 98 -> 152 539 -> 1337 1337 -> 4919 A5F9 > 42489 F -> 15 Win Condition: Th...
Write a program that, when run in different languages, outputs a different byte permutation of the code in each language. The exact source code is counted as one permutation. Here "different language" can be different version(Py 2 and Py 3) or different standard flags. It's different output that forces different versio...
So, there's a famous children's rhyme... This is the house that Jack built. This is the malt That lay in the house that Jack built. This is the rat That ate the malt That lay in the house that Jack built. This is the cat That killed the rat That ate the malt That lay in the house that Jack built. This is the do...
Description : You are given a string of numbers (positive and negative but not decimals) along with the number of entries like so. Like so 8 '1 2 5 0 7 -9 12 -8' Task : Your job is to return the number closest to zero be it +ve or -ve. Your input will be separated by spaces only. You are free to return the answer in a...
Given an arbitrary sequence consisting of 1 and A split this sequence up so that A is at the beginning of each sub sequence. Sequences without a leading A and Sequences without 1 before the next A will be self contained. Example Input 111A11A1111111A1A1AA should result in 111 A11 A1111111 A1 A1 A A Above already cont...
Description : Given an array of strings representing a grid of cells With the key : 0 = 'dead cell' 1 = 'live cell' write a function that returns the next iteration following the rules of Conway's Game of Life . Rules Any live cell with fewer than two live neighbours dies, as if caused by underpopulation. Any live ...
Assignment is simple to explain: write the shortest code you need to determine whether an executable binary program supplied as parameter is 32 or 64 bits. If there is a different kind of bitness, you can also do for it, but is not mandatory. What I really don't want is telling me you support other bitnesses and after ...
A lot of PPCG users helped with the creation of this challenge, both in chat and the Sandbox, specifically Martin Ender, AdmBorkBork, Emigna and user202729 Our community has found it necessary to create a set of languages designed specifically for golfing, "golfing languages" as we call them. Such languages have evolve...
Input: Integer n which is >=0 or >=1 (f(0) is optional) Output: The n'th number in the sequence below, OR the sequence up to and including the n'th number. Sequence: (0),1,-1,-3,0,5,-1,-7,0,9,-1,-11,0,13,-1,-15,0,17,-1,-19,0,21,-1,-23,0,25,-1,-27,0,29,-1,-31,0,33,-1,-35,0,37,-1,-39,0,41,-1,-43,0,45,-1,-47,0,49,-1,-51,0...
Description : Given a string of space separated binary digits or space separated booleans or an array of binary digits or array of booleans . Your job is to find the xor of each until you end up with one answer either 0 or 1. The inputs will always be valid and will only be either 0 or 1. Example : 1 0 0 1 0 --> 0 1 0 ...
(Inspired by last week's Riddler on FiveThirtyEight.com. Sandbox post.) Given a year between 2001 and 2099, calculate and return the number of days during that calendar year where mm * dd = yy (where yy is the 2-digit year). 2018, for example, has 5: January 18th (1 * 18 = 18) February 9th (2 * 9 = 18) March 6th (3 *...
Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible. Wikipedia for more information For example you can be given a max weight of 15 and objects with ...
Due to technical limitations of Stack Exchange, the title is rendered incorrectly. The correct title for this challenge is Make a Word Icicle! Word Icicle Word cicle ord cicle ord icle ord i le or i le or i l or l or r Today's challenge is to make icicles out of t...
Description : Given an input (a string , array , integer) , Your job is to append one of the following to it. st , nd , rd , th . Examples : 1 ---> 1st 2 ---> 2nd 3 ---> 3rd 4 ---> 4th 11 ---> 11th 12 ---> 12th 13 ---> 13th 14 ---> 14th and so on and so forth This is code golf so shortest code will win in each langua...
Having a function f that takes arguments x1, x2, …, xn                                                – ie.  f : X1 × X2 × … × Xn → Y – currying redefines f as a function taking a single argument a1 which maps to yet another function. This technique is useful for partial application, for example with a curried pow func...
This is a code golf puzzle: shortest byte count wins. The program should do the following (standard loopholes obviously forbidden): Input a hexadecimal number Convert to octal Then interpret the digits as if in decimal (765 octal -> 765 decimal) Divide the number by two Convert to hexadecimal Example: Input: 4a3d Out...
Description : Given a string as input, check if it is a valid ordinal number in English or not. If it is valid return truthy value otherwise return falsy value. (Suggested by @Arnauld. Thanks . Also by @JoKing) For users who want to know about ordinal numbers go here : https://www.mathsisfun.com/numbers/cardinal-ordina...
In this task you are given an odd number of white balls and the same number of black balls. The task is to count all the ways of putting the balls into bins so that in each bin there is an odd number of each color. For example, say we have 3 white balls. The different ways are: (wwwbbb) (wb)(wb)(wb) for the two differ...
A Walsh matrix is a special kind of square matrix with applications in quantum computing (and probably elsewhere, but I only care about quantum computing). Properties of Walsh matrices The dimensions are the same power of 2. Therefore, we can refer to these matrices by two's exponent here, calling themW(0), W(1), W(2)....