instruction
stringlengths
34
53.1k
In as few bytes as possible, sort the input, a delimited string OR list/vector/array of words, words contain printable ASCII except space (ASCII values 33-126) into a numbered list, table, or something resembling a table, by length. Table rules are as follows: Order is mandatory, direction is optional, either labelled...
Description Your input is a list of integers \$[a_1, \dots, a_n]\$. A magic triplet is a triplet \$(a_i, a_j, a_k)\$ of values from this list, such that the indices \$\{i, j, k\}\$ are all distinct, the values are in ascending order (\$a_i \leq a_j \leq a_k\$), and the sum of two of the values equals the third. Your ...
Write a function or a full program that applies an ASCII texture to a 2d shape. Inputs: shape, texture, dimensions(optionally). Both Shape and Texture can be given by any convenient method (2d matrix, array of strings or string with newlines) Shape data have a rectangular shape and contains 2 possible values: [truth...
This simple challenge is very similar to this one: How many days in a month? The only difference is you yield the number of days in a month given the index of the month instead of its name. The reason I ask this near-duplicate is curiosity about mathematical patterns in the sequence of numbers. For example, a simple ob...
The quaint hamlet of Кодгольф in the Russian far east has a problem: their population is low (below 66), and no new people have arrived for years. Moreover, after centuries of near-isolation, just about everybody is related to each other. Mayor Стекобмен has a solution that should keep the morale high: organise a weddi...
Introduction The Cartesian product of two lists is calculated by iterating over every element in the first and second list and outputting points. This is not a very good definition, so here are some examples: the Cartesian product of [1, 2] and [3, 4] is [(1, 3), (1, 4), (2, 3), (2, 4)]. The product of [1] and [2] is [...
Your task is to write the shortest algorithm in a language of your choosing that accomplishes the following: Given two matrices it must return the euclidean distance matrix. The euclidean distance between two points in the same coordinate system can be described by the following equation: \$D = \sqrt{ (x_2-x_1)^2 + (y_...
Your task is to convert Chinese numerals into Arabic numerals. A problem similar to Convert Chinese numbers, however, more complex. Also, answers given there mostly don't satisfy all the conditions. Chinese digits/numbers are as follows: 0 零 1 一 2 二 2 两 3 三 4 四 5 五 6 六 7 七 8 八 9 九 10 十 100 百 1000 千 10000 万 10^8 亿 Multi...
Sandbox Have y'all ever written an answer with unprintable ASCII characters in it and wished that there was an easy way to represent those characters in a printable way? Well, that's why the Control Pictures Unicode block was invented. However, manually substituting these characters into one's answer is time-consumin...
This is the exact same question I asked earlier, but without the annoying Cyrillic factor which many found superfluous. I hope this is a better puzzle! The quaint hamlet of North Codetown in the Scottish far north has a problem: their population is low (below 52), and no new people have arrived for years. Moreover, af...
I want to be down with the kids of the 1990's and start speaking this L33T speak of their's. For any given input I would like the resulting L33T speech as an output. I don't want to go to far down the rabbit hole so let's start simple. Consider the following replacements: B or b = 8 E or e = 3 I or i = 1 S or s = 5 Let...
Background An almost regular hexagon is a hexagon where all of its internal angles are 120 degrees, and pairs of the opposite sides are parallel and have equal lengths (i.e. a zonogon). The following is an example of an almost regular hexagon, with side lengths 2 (red), 4 (blue), and 3 (yellow). A triangular domino ...
Introduction All these snakes everywhere! I've had enough, and have decided that I much prefer camels. Therefore, I want you to convert my snakes to camels for me. Challenge Turn any snake_case string into a camelCase string. Capitals should be returned to lowercase before the conversion occurs. Test Cases In: camel_c...
Gaussian integer is a complex number in the form \$x+yi\$, where \$x,y\$ are integer and \$i^2=-1\$. The task is to perform such operation for Gaussian integers \$a,b\$, that \$a=q \cdot b+r\$ and \$|r|<|b|\$ (\$q,r\$ are Gaussian integers, \$|z|\$ is defined as \$\sqrt{a^2+b^2}\$ for \$a+bi=z\$). Need to output only ...
Part 2 of the challenge is here Flags Mashup Bot is a small Twitter bot that generates a new flag based on two random flags and tweets the result every couple of minutes. Task Your task is to replicate what the bot does by writing a script or a function based on the following criteria: The input is any two lossless i...
Background The Look and Say Sequence is built up by reading off the digits of previous entries in the sequence, counting the number of digits in groups of the same digit. For example: 1 => 11 # (one 1) 11 => 21 # (two 1s) 21 => 1211 # (one 2, then one 1) 1211 => 111221 # (one 1, then one 2, then two 1s) This sequence ...
Reproductive strategy of oozes can be summarized as follows: o O 8 oo A population of oozes at generation N is described by a string, for example: ooooo88ooOoOo8Ooooo8OOoo8Oo8Oo8oo8oooooo8OOooO88o To compute the population at generation N+1, take one character randomly, and replace it by the result of ooze evolution...
Disclaimer: This challenge inspired by me spending the morning debugging recursive functions, which have been frying my brain a little. Here's an example of recursion, from a letter, we keep going to the previous letter of the alphabet, printing out each one as we go, until we hit the letter a, then we print that and s...
Disclaimer: This challenge inspired by me trying to find pairs in a large pile of socks. Disclaimer: This is looking for a very different process and output to Help me sort my socks!. Please don't claim it as a duplicate until you've read both ;) So, I have a huge pile of socks. Of course I keep them categorized by c...
Your task is, given a family tree, to calculate the Coefficient of Inbreeding for a given person in it. Definition The Coefficient of Inbreeding is equal to the Coefficient of Relationship of the parents. The Coefficient of Relationship between two people is defined as weighed sum over all common ancestry as follows: E...
You are to write a program that, when given an integer between 1 and 5 (or 0 and 4 if you wish to use 0-indexing), outputs one of Code, Golf, and, Coding or Challenges. Each input can map to any of the five outputs. However, the mapping must be one to one (each input goes to a different output) and consistent when runn...
Although what is a Pascal's triangle is well-known and we already can generate it, the task is now different: Output \$n\$ first lines of the Pascal's triangle as colored bricks. Color number is computed as maximal power of \$d\$, that divides the needed-to-color element or \$7\$ if power is more than \$7\$. Numbered c...
Draw the ionising-radiation-hazard-symbol in an arbitrary colour on a distinctly coloured background. The specific proportions were published in the June 27th 1974 issue of the Federal Register of the US Government. Details As output, writing to a file (raster and vector formats are permitted) or displaying on the scr...
This wasn't originally intended for code-golf, just as a little debugging routine to roughly visualize something "goofy" going on in a model of some (irrelevant here) physical process. But when I saw how surprisingly short it was, compared to my expectations, I just wondered if it can be further shortened. And that's p...
Part 1 of the task is here Flags Mashup Bot is a small Twitter bot that generates a new country name based on two random country names and tweets the result every couple of minutes. Task Your task is to replicate what the bot does by writing a script or a function based on the following criteria: The input is two cou...
Introduction Each Unicode codepoint can be represented as a sequence of up to 4 bytes. Because of this, it is possible to interpret some 2, 3, or 4-byte characters as multiple 1-byte characters. (See here for a UTF-8 to bytes converter). Challenge Given a UTF-8 character, output it split into a sequence of 1-byte chara...
Please note: this is a restricted-source challenge — see details below! Each natural number \$n\$ has 10 faces: its decimal representations in bases \$1\$ through to \$10\$. For example, the 10 faces of \$12\$ are \$[111111111111, 1100, 110, 30, 22, 20, 15, 14, 13, 12]\$, and the 10 faces of \$4\$ are \$[1111, 100, 11,...
This challenge is based on Project Euler problem 208. Also related to my Math Stack Exchange question, Non-self-intersecting "Robot Walks". You have a robot that moves in arcs which are \$1/n\$ of a circle, with each step turning toward the left or to the right. The robot takes in an array of instructions of the form \...
Create three programs, which we'll call Rock, Paper, and Scissors. Each program must be unique, and accept input. If a program gets any input which is not one of the programs Rock, Paper or Scissors, it must print itself. RPS style, the programs will each print one of the following four outputs: "win" if the running ...
The title pretty much describes it all. Given as input a \$n \times m\$ matrix and an integer \$i\$ create a complete function/program that returns the matrix \$i\$ times clockwise rotated by \$90^\circ\$. Rules: as matrix you can use any convenient representation you like e.g. a list of lists etc... matrix values can...
I have a fixed length vector of 4 elements. The inputs of which are always 0 or 2^n for n = 1 to 15 (so n = 0 excluded i.e. 2^0 = 1 will not appear) x = [32, 4, 4, 8] the result should be x = [32, 8, 8, 0] The way it works is that values that are the same will get combined, but one it's combined it can not be combined...
Oof! You've been coding the whole day and you even had no time for Stack Exchange! Now, you just want to rest and answer some questions. You have T minutes of free time. You enter the site and see N new questions. To write an answer for each you'll need ti minutes. Of course, as a dedicated reputation gatherer, you wa...
This challenge is inspired by one of my other challenges: Pointlessly make your way down the alphabet That challenge asked you to take a string of text, and for each letter produce a sequence of letters moving down the alphabet to 'a'. For this challenge I'd like to decode the output of that challenge (minus the line b...
Can Alice win the game? The game's rules are as follows. First, a finite non empty set of positive integers \$X\$ is defined. Then, Alice and Bob take turns choosing positive integers, with Alice going first. Each integer must be strictly less than the previous one, and the game ends when one of the players chooses \$1...
Consider a positive integer N written in base b. A sequence is generated from this number by finding the largest digit d in the expansion of N and writing N in base d+1, repeating until the base the number is written in can be decreased no further. For example, the sequence generated by 346 (10) in starting base 16 has...
This challenge is inspired by turn based videogames like "Heroes of Might and Magic" Implement this game mechanic: There is some units(Imps, Swordsmans etc...) in our game Every unit have an integer "initiative" Your program must decide which unit's turn now - based on unit's initiative The more initiative means mor...
I can see that it is 101 'moving to the right' but I cannot think of a short way to generate it in R language. \$\begin{bmatrix} 0 & 1 & 0 & 0 & 0 & 0 \\ 1 & 0 & 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 & 0 & 1 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ \end{bmatrix}\$
You are to create a program which, when given a positive integer \$n\$, outputs a second program. This second program, when run, must take a second positive integer \$x\$ and output one of two distinct values depending on whether \$x\$ is divisible by \$n\$. Those values must be consistent for a given \$n\$ but can be ...
You are given three parameters: start(int), end(int) and list(of int); Make a function that returns the amount of times all the numbers between start and end are multiples of the elements in the list. example: start = 15; end = 18; list = [2, 4, 3]; 15 => 1 (is multiple of 3) 16 => 2 (is multiple of 2 and 4) 17 => 0 18...
Given a level from a simple platform game, your task is to make a program or function to determine if a level is winnable. Platform game levels are 4 characters tall and any number of characters wide. There is exactly one platform for each horizontal space in a level: ======= = == = = ...
(Note: this challenge is distinct from my other challenge (Draw a path made from direction changers) because of it's rendering of direction (horizontal or vertical), crossing points and single or double paths.) Let's start with a frame drawn in Ascii characters. For this challenge it will always be 20 characters wide ...
What are some tips on how to shorten this code even further? The code is meant to compute the parallel resistance of an electric circuit. Using scanf float r;main(){float a;scanf("%f",&a);r+=1/a;printf("%f",1/r);main();} Using command-line arguments #include<stdlib.h> float r;main(c,v)char**v;{for(int i=1;i<c;)r+=1/at...
The totient function \$\phi(n)\$, also called Euler's totient function, is defined as the number of positive integers \$\le n\$ that are relatively prime to (i.e., do not contain any factor in common with) \$n\$, where \$1\$ is counted as being relatively prime to all numbers. (from WolframMathworld) Challenge Given an...
Inspired by Flow Fit: Sudoku, a brand-new mobile puzzle game (as of Nov 2019). Background A Latin square is a square grid of side length \$ n \$ filled with \$ n \$ different symbols, where each row and column contains each symbol exactly once. Let's define a row (resp. a column) as a maximally consecutive group of cel...
You get a string which contains an integer between 1000 and 99999999 as input. The input string might contain leading zeroes but cannot be longer than 8 characters. Your goal is to output all dates between 6th of December 1919 and 5th of December 2019 which fit the input in these formats: day - month - year (dmy) mont...
How many atoms in the hydrocarbon? A hydrocarbon is a chemical compound which consists of only hydrogen and carbon atoms. For this challenge, we will only consider the three simplest kinds of hydrocarbons: alkanes, alkenes, and alkynes with no branches. An alkane with \$n\$ carbon atoms contains \$2n+2\$ hydrogen atoms...
Morpion solitaire This is a game that I remember having learnt from my grandparents in my childhood. Initially I didn't know the name. G B has found it to be Join Five (or less ambiguously - Morpion solitaire) with a slightly different starting position. NOTE: it seems that it's kinda known and this problem formulation...
Sandbox Given two positive integers a and b, return the smallest multiple of b that is greater than or equal to a. Examples Definitions: true = is a multiple of b, false = is not a multiple of b. f(1,3) = 3 because 1 is false, 1+1 is false, but 1+1+1 is true. Therefore 3 is returned. f(5,3) = 6 because 5 is false, but...
The permanent of an \$n\$-by-\$n\$ matrix \$A = (a_{i,j})\$ is defined as: $$\operatorname{perm}(A)=\sum_{\sigma\in S_n}\prod_{i=1}^n a_{i,\sigma(i)}$$ For a fixed \$n\$, consider the \$n\$-by-\$n\$ matrices whose entries are taken from \$\{-1, 0, +1\}\$ . Task For each \$n\$ from 1 upwards, output the number of \$n\$-...
Roll for Initiative! Introduction In tabletop games like Dungeons and Dragons, when you begin a battle, all involved parties roll for initiative. In DnD 5e, this is 1d20 + DEX + Other bonuses, where DEX is the bonus given by your Dexterity stat. The characters that roll higher numbers go first. We'll use a similar, det...
Problem 4 in the 2019 BMO, Round 1 describes the following setup: There are \$2019\$ penguins waddling towards their favourite restaurant. As the penguins arrive, they are handed tickets numbered in ascending order from \$1\$ to \$2019\$, and told to join the queue. The first penguin starts the queue. For each \...
Write a function or program which takes as input a set of distinct, non-negative integers \$\{x_1, \ldots, x_n\}\$ and outputs the smallest gap between any two values in the set, i.e. \$\min_{i\neq j}|x_i-x_j|\$. Scoring This is not code golf. Your score is the smallest gap of the set of code points of characters in yo...
Once upon a time I wanted to order custom tokens for a board game. They say they can do it, and then they present me their price list. I was confused because they charge per inch of head movement, and I have no idea how much will my tokens cost. INPUT: a 2d grid: |,-,\,/ are straight cuts. Each has a length of 1. ┌,┐,...
The code: function L(){N=null;E=[N,N];t=this;h=E;t.u=i=>h=[i,h]; t.o=_=>h==E?N:h[+!(h=h[1])];t.e=(i,l)=>h=(l||h)==E?[i, E]:[(l||h)[0],t.e(i,(l||h)[1])];t.s=_=>{o="";while(i=t.o()) {o+=i+","}return o}} For my response to this (old) question: https://codegolf.stackexchange.com/a/196783/72421 (my linked answer has a com...
Let me know if this task has already been posed. I haven't found it when I looked. Input master sequence \$\ X = x_1\dots x_n\$: sequence of characters, eg. \$\rm international\$ subsequence \$\ Y = y_1\dots y_m\$: sequence of characters, eg. \$\rm intl\$ Output Number of possible mappings \$\mu: [1\dots m] \righta...
Create a program that outputs Hello, World! The winner is the source code that is the biggest, subject to the constraint that it is irreducible For this challenge, irreducible means there does not exist a program that outputs Hello, World! that can be constructed by removing characters from the original program. For ex...
Inspired by Help me pair my socks, and the fact that I have some pairs of socks where the left sock is distinct from the right. Background Again, I have a huge pile of socks. And a machine that can give the list of labels of the socks for me. This time, the labels follow these rules: Some socks have left and right ve...
Introduction An elementary cellular automaton is a cellular automaton that is 1-dimensional and has 2 states, 1 and 0. These cellular automata are categorized based on a simple code: the Wolfram code, invented by Stephen Wolfram (yes, the Wolfram | Alpha guy). It works like this: First, you the set of all possible sta...
Introduction Big 2 is a card game popular in East Asia and South East Asia, in which 4 players are dealt 13 cards each (ie, an equal division of a standard deck without jokers). The goal is to empty your hand before any of the other players. Players take turns playing combinations of a Big 2 subset of standard poker ha...
Sandbox A spin-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you accept it, is to write a program/function that outputs/returns its input/argument. The tricky part is that if I left shift your source code, the output must be left shifted too. Likewise, if I right shift your so...
Sandbox Background (not necessary for the challenge) A standard number theory result using the pigeonhole principle is the fact that given any natural number k, there is a Fibonacci number that is a multiple of k. We can see this by considering modular pairs (F(n-1) % k, F(n) % k), and noting that there are only a fini...
Sandbox post In this code-golf challenge, you are provided with a series of y values at even x-values as well as a console width and height. The desired output is an ASCII-art representation of a ribbon plot of the y-values scaled to the desired size. If all values are positive or negative, the x-axis should be display...
Some sleep commands implement a delay of an integer number of seconds. However, 2³² seconds is only about 100 years. Bug! What if you need a larger delay? Make a program or a function which waits for 1000 years, with an error of less than ±10%. Because it's too time-consuming to test, please explain how/why your soluti...
Introduction A polyglot is a program that is valid in multiple languages at once. An iterative quine is a program that outputs another program that outputs another program that outputs the source of the original program. Note that the number of chained programs does not have to be 3; it could be 2, 4, or 97384. Challen...
Sandbox There are special sets S of primes such that \$\sum\limits_{p\in S}\frac1{p-1}=1\$. In this challenge, your goal is to find the largest possible set of primes that satisfies this condition. Input: None Output: A set of primes which satisfies the conditions above. This challenge is a code-challenge, where your s...
Simple question! Given a string that contains a date in ISO8601 format, print the first of the next month in ISO8601 format. Example inputs: 2018-05-06 2019-12-20 Their respective outputs: 2018-06-01 2020-01-01 The rules: Imports are free and don't count towards your score. The date will be stored in a string called s...
In this challenge you will be asked to take a knot and determine if it can be colored in a particular way. First we draw a diagram of the knot. We use the standard way of drawing knots where we put gaps in strands where they pass under each other. Here is an example of some knots drawn this way: Taken with permissio...
This challenge is from a game called Keep Talking And Nobody Explodes. Memory is a fragile thing but so is everything else when a bomb goes off, so pay attention! – from the manual The Objective A number from 1–4 is given as the "display", along with scrambled numbers 1–4 as the "buttons." The output must be the label ...
The task here is pretty simple. You should write a program that takes a string as input and outputs it (that is a cat program). Additionally when the \$n\$th byte of your program is removed (without replacement) the augmented program should take a string as input and remove the \$n\$th character. If the input to your...
A simple regex is either: _ (which matches the empty string) Any lowercase letter a to z (which matches that letter) r*, where r is a regex (which matches r any number of times) (r|s), where r and s are regexes (which matches either r or s) (r+s), where r and s are regexes (which matches r followed by s) Note that du...
Let's build an advent Calendar for this Christmas! Many Advent calendars for children take the form of a large rectangular card with numbered windows for each day of December starting from 1 ( although advent time begins on Advent Sunday, which is the fourth Sunday before Christmas day and often happens to be on Novemb...
Sandbox What is Hexagonification™? Hexagonification™ is a transformation that creates a hexagon with 3 copies of a rectangle block, each skewed to the right by 30 degrees and then rotated by 0, 120 and 240 degrees respectively, as shown in the following image. A triangle hole may appear in the middle, but that isn't a ...
This is kept fairly original: Write a program that creates a standard blackjack game: input "h" means hit or draw another card input "s" means stand, or take what you have already Rules: cards values are as follows: 2-9 = face value of card 10, J, Q, K = 10 aces = 11 unless player busts, then it's only a 1 if 2 or m...
Dowker notation is a common way of representing mathematical knots. Dowker notation can be derived from a knot diagram in the following way (based on the description from the wikipedium): We will label each of the \$n\$ intersections with two numbers whose absolute value is on the range \$1, \dots 2n\$ (one odd one ev...
Lost is a 2-Dimensional programming language where the instruction pointer starts at a random location, moving in a random direction. A description of the language can be found at the bottom of the post for completeness' sake and a tutorial for the language can be found in the above link. The task here is simple to de...
Golfeek is the working name of an esolang I'm occasionally working on. One distinctive feature of this language is that each statement is encoded as a sequence of bits rather than a sequence of bytes. Instead of just showing a long binary sequence, the 'gutter' of the source editor contains a representation of each sta...
Sandbox Adapted from exercise 4 of 100 little Keg exercises The ability to repeat chunks of code within a program is an important part of any programming language. Also just as important is the ability to make decisions based on different values. The Challenge I want you to write a program that: Starts at the number ...
In a challenge of CodingGame, there is a challenge that ask you to decode a string composed by reversed words ('Hello world' > 'olleH dlrow') then each characters converted into ascii value separeted by space: >>> decode('111 108 108 101 72 32 100 108 114 111 119 32 41 58') Hello world :) The challenge is to be the fa...
This challenge is inspired by the same task I read some time ago in CACM. There are many ways to sort stuff. Most attempt to sort in as few operations as possible (= as fast as possible). However, it is also possible to consider how few resources you might require to sort stuff, which seems more fitting for a codegolf ...
The goal is simple, print out each day of the twelve days of Christmas, the text should match this exactly On the first day of Christmas my true love gave to me A partridge in a pear tree On the second day of Christmas my true love gave to me Two turtle doves, and A partridge in a pear tree On the third day of Christ...
Flip flop is a memory / arithmetic game that I played in high school. Some number of players stand in a circle. The players take turns. On the nth turn, the current player checks: What is the largest power of 7 dividing n? How many instances of the digit 7 does the decimal representation of n contain? What is the larg...
The \$d\$-dimensional vector space \$\mathbb{F}_2^d\$ over the field with two elements \$\mathbb{F}_2\$ is the set of vectors of \$d\$ bits. Addition of vectors is bitwise xor. A linear dependence is a set of vectors whose total (xor them all together) is \$0\$. Every set of \$d+1\$ vectors in \$\mathbb{F}_2^d\$ contai...
The Challenge Given a finite list of integers, split it into the fewest partitions possible such that no partition contains a number more than once. Rules Input can be in any format and any order. Output can be in any format, as long as it's clear that each group is separate. This is code-golf, so lowest score wins! Ex...
(This is not a duplicate of Follow the path, as this challenge have invalid path detection and use ><^v in the output.) Task So your task is to take in the description of the path and draw it out in a "Befunge(or a lot of other 2D esolangs)-like" format, and detect if it is invalid. Note that if the path is invalid, yo...
\$GF(9)\$ or \$GF(3^2)\$ is the smallest finite field whose order isn't a prime or a power of two. Finite fields of prime order aren't particurlarly interesting and there are already challenges for \$GF(2^8)\$ (link) and \$GF(2^{64})\$ (link). Challenge First define nine elements of the field. These must be distinct in...
Is there any javascript-like language? Something that can be interpreted by browsers?
(Inspired by the Keg utility of this challenge) Given a non-empty input string, e.g. s c 1= e(a"E"), split the input into even-odd chunks. Example (Feel free to suggest more) I can only think of this test case, fee free to suggest more. This input string, when mapped to its code points, yields the list [115, 32, 99, 32...
Every so often I have a function of type a -> b and a function of type b -> b -> c and I would like a function of type a -> a -> c. For example if I wanted to check the second element of each two tuples were equal snd :: (a , b) -> b (==) :: Eq a => a -> a -> Bool And I want something of type Eq b => (a, b) -> (c, b)...
If \$f,g\colon \mathbb{Z}_{\geq 1} \to \mathbb{R}\$, the Dirichlet convolution of \$f\$ and \$g\$ is defined by \$ \qquad\qquad\qquad \displaystyle (f*g)(n) = \sum_{d|n}f(d)g(n/d).\$ This question asked about computing Dirchlet convolution of functions. The identity element of the Dirichlet convolution is the functi...
Introduction Adam (A) and Bubbler (B) are playing coin toss, where the one who wins 5 times first would win the prize of $32. If the game is aborted when the scores are A:B = 4:3, how should they distribute the prize? Assume the coin toss is fair, so the winning chance of either player is 1/2 for each game. The answe...
On CodingGame, there is a Puzzle that ask to write words with ascii art. I solve the puzzle then tried to golf it. What improvement can I do on it? INPUT >>> 20 >>> 11 >>> MANHATTAN >>> .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------...
The challenge Given a positive integer N, compute the proportion of N-step walks on a plane that don't intersect themselves. Each step can have any of the 4 possible directions North, East, South, West. A walk intersects itself if it visits a previously visited point. Examples N=1: a single-step walk obviously doesn'...
I often have to take character data and categorize it numerically at work. A common thing I do is to take character type variables and convert them to numeric type characters, keeping same categories according to the level of work I'm doing. (The longer the substring, the more in depth and specific, shorter substrings ...
Sandbox Adapted from exercise 8 of 100 little Keg exercises String manipulation is a very important part of any programming language. Consequently, that is what this challenge is about. The Challenge I want you to write a program that: Takes a series of characters as input and, Then takes another input (integer/letter...
As the trip through the solar system on your way to rescue Santa gets a little droll, so perhaps some optimizations to your Intcode Computer are in order. Namely, making it as small as possible because you've got nothing better to do with your time. Check out Advent of Code if you haven't already, the guy that makes th...
You are given an countable ordinal \$1 < r < \varepsilon_0\$. Determine whether or not it is prime. If not, provide exactly two ordinals \$r_0, r_1 < r\$ such that \$r_0r_1 = r\$, following rules of ordinal multiplication, and furthermore satisfy at least one (not necessarily both) of the following: \$r_0\$ is a limit...
Can you recover a sequence of letters from a sequence of dots and dashes? In Morse code, x is represented by -..-, but without the help of spaces, -..---.-... could represent xmas, or dole, or teettteteee, etc. I took the lyrics from "Rudolph, the Red-Nosed Reindeer" to make the following sequence of letters: youknowda...
In the plane (\$\mathbb R^2\$) we can have at most five distinct points such that the distances from each point to every other point (except itself) can assume at most two distinct values. An example of such an arrangement is a regular pentagon - the two different distances are marked with red and blue: Challenge Give...
Intro/Background I was looking at "You Had One Job" pictures lately, and noticed an old favourite of mine: And I said to myself: "I need a program that can generate text like that". So I devised a set of rules for character swapping and wrote a CGCC challenge! The Challenge Given a single string as input, output a str...
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions, or substitutions to convert one string into the other one. Given a binary string \$S\$ of length \$n\$, we are a interested in the number of different strings of length \$n\$ which have distance at most \$3\$ ...