instruction
stringlengths
34
53.1k
Round away from zero Inspired by Round towards zero. Given a number input via any reasonable method, round the number "away from zero" - positive numbers round up, and negative numbers round down. If you intend to take the input as a string (via STDIN, for example), you should be able to handle numbers with or without ...
I don't like typing, so I draw my mazes in a very simple format: # ##### # # # ### # # # # # # # # ##### # Isn't it a-maze-ing? Of course, I think all mazes should look 3d, similar but not he same as this challenge, for maximum a-maze-ingness, so I (grudgingly) manually updated the maze to look like this: +-----...
Draw the Biohazard 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 screen are both all...
A number of programming languages construct large integers through 'concatenating' the digit to the end of the existing number. For example, Labyrinth, or Adapt. By concatenating the digit to the end, I mean that, if the existing number is \$45\$, and the digit is \$7\$, the result number is \$457\:(45 \times 10 + 7)\$...
Since Euclid, we have known that there are infinitely many primes. The argument is by contradiction: If there are only finitely many, let's say \$p_1,p_2,...,p_n\$, then surely \$m:=p_1\cdot p_2\cdot...\cdot p_n+1\$ is not divisible by any of these primes, so its prime factorization must yield a new prime that was not ...
A bit floats from the LSB to the MSB moving one position each time until it floats to the top of the container: 0000 0001 0010 0100 1000 Once one bit floats to the top, another bit begins its journey and it stops when it meets other bit: 1001 1010 1100 This happens until the container is filled with bits: 1101 1110 1...
Task The task is to write a program that outputs a consistent but otherwise arbitrary positive integer \$x\$ (so strictly greater than 0). Here's the catch: when the source is repeated \$N\$ times (the code is appended/concatenated \$N-1\$ to itself), the program should have a \$\dfrac{1}{N}\$ probability of outputting...
We can represent a Rubik's Cube as a net as follows (when solved): WWW WWW WWW GGGRRRBBBOOO GGGRRRBBBOOO GGGRRRBBBOOO YYY YYY YYY Each letter represents the corresponding colour (W is white, G green etc.) It has been shown that there are exactly \$43,252,003,274,489,856,000\$ (~\$43\$ quintillion) di...
The challenge Write a function that returns the nth element of an array even if its out of bound. function safeGet(index, arr) { const safeIndex = ??? return arr[safeIndex] } const arr = ["a", "b", "c"]; safeGet(0, arr) // "a" safeGet(1, arr) // "b" safeGet(2, arr) // "c" safeGet(3, arr) // "a" go back to the be...
Challenge Write a program that takes as input a text and output "That's me!" if the input is equal to the program own source code, and "That's not me!" otherwise. Notes This is codegolf, in each programming language the shortest program wins. The input can be taken from program arguments or function argument, and the ...
I see your BIDMAS and raise you a BADMIS Challenge Given a set of numbers with operators between them: "5 + 4 * 9 / 3 - 8", return all the possible results of the expression for every permutation of the order of basic operations: [/, *, +, -]. Rules Standard loopholes forbidden I/O Input must be ordered with infix o...
The Challenge Write a program or function that takes no input and outputs a 3-dimensional vector of length \$1\$ in a theoretically uniform random direction. This is equivalent to a random point on the sphere described by $$x^2+y^2+z^2=1$$ resulting in a distribution like such Output Three floats from a theoretically ...
Given a positive integer \$n\$ you can always find a tuple \$(k_1,k_2,...,k_m)\$ of integers \$k_i \geqslant 2\$ such that \$k_1 \cdot k_2 \cdot ... \cdot k_m = n\$ and $$k_1 | k_2 \text{ , } k_2 | k_3 \text{ , } \ldots \text{ , }k_{m-1}|k_m.$$ Here \$a|b\$ means \$b\$ is a multiple of \$a\$, say "a divides b". If \$n>...
Leaderboard 154 Calculator 144 Taxman 138 Statistician 137 Solver 137 RandoAggroLawyer 136 Gambler 134 Turncoat 119 Lawyer 119 BloodyMurder 113 Bandit 79 Challenger 74 Mask 64 Random An archive of the latest match, including the log and all output files, is available. Calculator, by Brilli...
A space cleaner is a special character which removes all spaces between it and the first non space character to its left and it is represented by a '!' character. If it reaches the beginning of the string it stops. Given a string output the string in any reasonable format after the cleaning process. Trailing spaces at ...
33 is a simple esolang I created. You may have seen me use it in a few questions. You're not going to be writing a full interpreter. The interpreter you will be writing is for a simplified version of 33. This simplified 33 has two numeric registers: the accumulator and the counter. The accumulator holds all the post-ar...
Interpret Volatile Volatile is a stack-based esolang made by A_/a'_'/A that only has 8 instructions and is turing complete. However, it is also non-deterministic... meaning that programs don't always give the same output. Your task is to interpret this language. Language specs Taken from the esolangs page: ~: Push a r...
You are in fact writing an interpreter for the language "Wrong keyboard position". You can pretend that you are not doing this and just follow the instructions below. I typr re;atively accuratrly, but so,etimes I made a whole nlock of text illegible by shifting a key right. So I need a program that corrects my text ba...
There have been a couple of challenges involving doubling source code: here and here. The task we have here is a bit harder, but should be doable in almost every language. In this challenge, you will take in an arbitrary positive integer. Your program must output that integer doubled. When your source code is doubled, ...
Given a matrix, the goal is to ensure all the values in each column occur at least once, while at the same time doing so requiring the least possible amount of rows. Fastest solution wins. Note: a value in one column (e.g. 1) is considered different from the same value in another column. Expected output: an array/list...
Introduction: Two resistors, R1 and R2, in parallel (denoted R1 || R2) have a combined resistance Rp given as: $$R_{P_2} = \frac{R_1\cdot R_2}{R_1+R_2}$$ or as suggested in comments: $$R_{P_2} = \frac{1}{\frac{1}{R_1} + \frac{1}{R_2}}$$ Three resistors, R1, R2 and R3 in parallel (R1 || R2 || R3) have a combined resist...
A very common need in algorithms classes and computer science in general is to iterate 4-directionally over a grid or matrix (such as in BFS or DFS). This seems to often result in a lot of clunky and verbose code with a lot of arithmetic and comparisons within loops. I've seen many different approaches to this, but I c...
(Randomly inspired by https://mathoverflow.net/q/339890) (Related: 1, 2) Given an input list of distinct prime numbers (e.g., [2, 5, 7]), and a integer n, output all positive integers strictly smaller than n that contain only those primes as divisors. For input [2, 5, 7] and n=15 this means an output of [2, 4, 5, 7, 8,...
This is a problem on Luogu OJ. I decided to post it here because on Luogu OJ, many people, including me and my friend, are interested about how to solve this problem within the fewest characters. Your task is to output the following ASCII-art: ************ ####....#. #..###.....
Given a \$n\$-dimensional vector \$v\$ with real entries, find a closest permutation \$p\$ of \$(1,2,...,n)\$ with respect to the \$l_1\$-distance. Details If it is more convenient, you can use permutations of \$(0,1,...,n-1)\$ instead. If there are multiple closest permutations, you can output any one or alternativel...
The challenge is to write a golf-code program that, given n positive real numbers from 0 to 10 (format x.y, y only can be 0 or 5: 0, 0.5, 1, 1.5, 2, 2.5 … 9.5 and 10), discard the lowest and highest values (only one, even though they are repeated) and shows the average of the remaining, in x.y format (y can be 0 or 5, ...
Output Distinct Factor Cuboids Today's task is very simple: given a positive integer, output a representative of each cuboid formable by its factors. Explanations A cuboid's volume is the product of its three side lengths. For example, a cuboid of volume 4 whose side lengths are integers can have sides [1, 1, 4], [1, 2...
Your task is pretty simple. Given two floats, bitwise xor the binary representation of them, and output that as a float. For example, Normal: 16.7472 ^ 123.61 = 7.13402e-37 Binary: 01000001100001011111101001000100 ^ 01000010111101110011100001010010 = 00000011011100101100001000010110 Normal: 2.2 ^ 4.4 = 1.17549e-38 Bin...
Challenge Given an array of positive integers and a threshold, the algorithm should output a set of consecutive-element-groupings (subarrays) such that each group/subarray has a sum greater than the threshold. Rules The solution should honor two additional criteria: be of highest cardinality of the groups (i.e. highes...
Cleaning the dishes In this task, you will be given a bar of soap with a width of 1 or more units. You will also be given a plate, which you will have to clean, using the soap as few times as you can. The plate will be at least 1 character. You will have to output a plate with the 'clean' character representing the pla...
Given: a 12 hour time t in hours and minutes, a rotation r in degrees, return the time shown when an analog clock that is displaying the time t is rotated r degrees clockwise. After rotation, the hour hand will not line up with the new position of the minute hand. To correct for this, the new hour can be derived fro...
Original: https://james-iry.blogspot.co.at/2009/05/brief-incomplete-and-mostly-wrong.html Alain Colmerauer designed the logic programming language Prolog. His goal was to create a programming language that is as intelligent as a two-year-old child. In order to prove that he had succeeded in his goal, he presented a P...
Many programming language provide operators for manipulating the binary (base-2) digits of integers. Here is one way to generalize these operators to other bases: Let x and y be single-digit numbers in base B. Define the unary operator ~ and binary operators &, |, and ^ such that: ~x = (B - 1) - x x & y = min(x, y) ...
You are trapped in this 5x5 labyrinth - each room is labelled from 1 to 25 and the exit is in room 1. You are given as input the room you are currently in. Your task is to output the shortest sequence of moves (north, east, south, west) needed to reach room 1. Moves can be output in any format you wish (list, string, ...
This question just trended over on code-review and I figured you might like it adapted as a codegolf challenge: You are given a non-empty list of x houses represented as booleans. Each day, the houses compete with adjacent ones. 1 represents an "active" house and 0 represents an "inactive" house. If the neighbors on bo...
Your task, if you wish to accept it, is to write a program that outputs a non-zero number(can be integer or float). The tricky part is that if I reverse your source code, the output must be the original integer negated. Rules You must build a full program. That is, your output has to be printed to STDOUT. Both the num...
This challenge will have you count "creatures" in the tile game Palago. A creature is any closed shape that can be formed by Palago tiles of matching colour in a hexagonal grid. The game Palago consists of tiles like this: These tiles can be rotated \$120^\circ\$, \$240^\circ\$, or not at all and placed anywhere on ...
Blatant rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I reverse your source code, the output must be the original integer negated. Examples Let's say your source code is ABC and its i...
This is my first question in Code golf I found it in stack-overflow (originally in JavaScript however all languages are acceptable): Render on screen NxN (where N in range 1-16) grid where each cell have black boundary and red number inside - cells are numerated in hex starting from left-upper corner to bottom-right. E...
Can you imagine solving the New York Times crossword puzzle without any clues? Maybe not with all of the creativity and new words and phrases appearing in modern crosswords, but with a fixed word list there's some hope. In this challenge, you create a crossword puzzle grid in which this is theoretically possible. The...
INTRODUCTION I like Karma Fields : he's a music producer that creates original music tracks. His artwork also matches up really well his style. He has a logo witch I find really interessing : GOAL Your goal will be to reproduce that logo, graphically or in ASCII. Edit @NahuelFouilleul managed to provide a readable asc...
When making phone calls internationally, phone numbers are prefixed with a code indicating what country the number is located in. These codes are prefix codes, meaning that no code is a prefix of another. Now, earlier today you missed a call, and you're kind of curious where that call might have come from. So you want ...
Your task is to input a string, and output the number of spaces in the string. This is code-golf, so least number of bytes win. Your Test Cases Double quotes are not part of the test cases. "test" => 0 "Hello, World!" => 1 "C O D E G O L F" => 7 " " => 6
Challenge Write a function/program that outputs either the n'th element, or the first n elements, in the well known number sequence: 1, 2, 4, 8, 16 ... Oh, wait... I forgot the first few numbers: 1, 1, 1, 1, 2, 4, 8, 16 ... Heck, I'll add a few more for good measure: 1, 1, 1, 1, 2, 4, 8, 16, 33, 69, 146, 312...
Do you know the book Murderous Maths, in the Horrible Science series? In the book, the Laplace Princess' "ridiculous" cipher might be interesting enough and simple enough to be a code-golf challenge. Task The original cipher looks like this: Please read primes elephant help you me like cold The nth word is only meani...
Stuttering is a problem which many of us might have experienced or at least seen it. Although most of famous speech recognition softwares have serious issues with stuttered speaking, let's imagine a software which understands stuttering, but cannot fix them and only writes them as is. An example written text by such a ...
I recently saw this language in a challenge and it's awesome. Does anyone have some tips for code-golfing in it? Your tips should be at least somewhat specific to MarioLANG. Please post one tip per answer.
Here is continuation of this question, this time lets compress/generate Mario in colors! Image size is 64x64 (above one is zoomed). The required output is valid <img ...> tag with exact same image in dataURI form, working on chrome, firefox and safari (and IE4 - joke ;). In snippet below you can find example tag in r...
In Imperial China, ranks in society were not decided by birth or wealth, but by a person's ability to excel in the Imperial Examinations. The Jade Emperor, divine ruler of the Heavens, has called for all his subjects to be examined to determine their worth, and whom to next give the Divine Mandate to rule China. Rules ...
The problem has 3 inputs. L: a list of all numbers size: the size each set can be max: the max sum amongst each set The challenge is as follows: Given L, size and max, construct as many sets from L such that the number of elements is size and the sum of each of the elements does not exceed max. Examples: func(L=[1,2,3,...
You are given a square \$n \times n\$ matrix \$A\$, and a list (or vector) \$u\$ of length \$n\$ containing the numbers \$1\$ through \$n\$ (or \$0\$ through \$n-1\$). Your task is to reorder the columns and rows of the matrix \$A\$ according to the order specified in \$u\$. That is, you will construct a matrix \$B\$...
Golf Golf! This is my first challenge, so please be gentle! The challenge is to write a program that will output the correct score for a layout in the card game "Golf." The card game Golf has many variations. The house rules I use follow the standard rules for Six-Card Golf given by Pagat, with one slight difference. T...
Yet another blatant rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its string input/argument. The tricky part is that if I reverse your source code, the output must be reversed too. For simplicity, you can assume that the inpu...
Rip-off of a rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its input/argument¹. The tricky part is that if I transpose your source code², the output/result must be transposed too. You may choose which kind of 2D data your so...
Convert a string containing digits as words into an integer, ignoring leading zeros. Examples "four two" -> 42. "zero zero zero one" -> 1. Assumptions Submissions can assume that: The input string is comprised of space-separated digit words. All words are valid (in the range "zero".."nine") and lowercase. Behaviour ...
What is the Ultraradical? The ultraradical, or the Bring radical, of a real number \$a\$ is defined as the only real root of the quintic equation \$x^5+x+a=0\$. Here we use \$\text{UR}(\cdot)\$ to denote the ultraradical function. For example, \$\text{UR}(-100010)=10\$, since \$10^5+10-100010=0\$. Challenge Write a ful...
Sandbox French License Plates French license plates come in a sequential order, following a specific pattern of numbers and letters : AB-012-CD Challenge Write a program or function that, for a given number, outputs the corresponding french license plate number. Your program should not handle any special case as specif...
What general tips do you have for golfing in 1+? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to 1+ (e.g. "remove unnecessary whitespace" is not an answer). Please post one tip per answer.
What general tips do you have for golfing in Keg? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Keg (e.g. "remove comments" is not an answer). Please post one tip per answer.
Here is the (quite scary) Five little ducks song(it is not long): Five little ducks went out one day, over the hills and up away. Mother Duck said, "Quack Quack Quack Quack", but only four little ducks came back. Four little ducks went out one day, over the hills and up away. Mother Duck said, "Quack Quack Quack Quack...
Your task is to create a program that determines whether a given string is a valid regular expression or not using code snippets sourced from sites on the StackExchange network. For the purposes of this challenge, the regular expression dialect will be a stripped down and mostly minimal set of meta-characters: ()*?|\. ...
Starting at 1-TET, give equal temperaments that have better and better approximation of the perfect fifth(just ratio 3/2). (OEIS sequence A060528) The formal description of the sequence, copied from the OEIS: A list of equal temperaments (equal divisions of the octave) whose nearest scale steps are closer and closer a...
Tichu is a card game in which players take turn playing sets of cards from a deck consisting of a standard 52-card deck, plus 4 additional cards: the dragon, which has a greater value than any other card the phoenix, which can act as a wildcard the dog, which passes the turn to your partner the Mah Jong, which has val...
I like card game challenges so I made this one for the Italian card game Scopa. My family has been playing this game since time immemorial. It has a very interesting scoring system that should be fun to golf. I will post an answer in R to get the fun started, that I am sure people will improve upon. The challenge: figu...
Challenge: Add two numbers. In O(n^m) time, where n and m are the two numbers given. Sleeping, or your language equivalent, is not allowed. Input: Two integers, separated by a space. Output: The sum of the two integers. Additional notes: The exact timing doesn't matter, as long as the input 1000 2 takes roughly 1/1000t...
Introduction Some time ago, I need to write function which split string in some specific way. At the first look, task looks trivial, but it was not so easy - especially when I want to decrease code size. Challenge As example we have following input string (it can be arbitrary) Lorem ipsum dolor sit amet consectetur ad...
In Australian Football, goals are worth 6 points and behinds are worth 1 point. Scores may include the number of goals and behinds, as well as the total score. Given the number of goals and behinds for two different teams, determine which team won the game. Take four integers g1, b1, g2, b2 as input, and output two dis...
The previous neural net golfing challenges (this and that) inspired me to pose a new challenge: The challenge Find the smallest feedforward neural network such that, given any 4-dimensional input vector \$(a,b,c,d)\$ with integer entries in \$[-10,10]\$, the network outputs \$\textrm{sort}(a,b,c,d)\$ with a coordinate-...
Given a non-empty list of decimal digits (0, 1, ..., 9), replace each zero by the most recent nonzero, if possible. Example 1: given 1 4 3 0 0 7 5 5 0 3 the output should be 1 4 3 3 3 7 5 5 5 3 Note how the first two zeros are replaced by 3, which is the most recent (i.e. rightmost) nonzero. Similarly, the last zer...
Challenge Write a program that applies an injective function which takes an ordered pair of strings as input and one string as output. In other words, each input must map to a unique output. Specifics The input may be any two strings of arbitrary length, but will consist only of printable ASCII characters (codes \$[32...
I'm new to this site, so I don't know whether this challenge already appeared: Write a piece of source code, so that after running the code, it prints out exactly (i.e. not longer, not shorter) the source code itself. The code can be in any programming language, but preferably in commonly used ones, such as the C famil...
We haven't had any nice, easy challenges in a while, so here we go. Given a list of integers each greater than \$0\$ and an index as input, output the percentage of the item at the given index of the total sum of the list. Output should be whatever the natural representation for floats/integers is in your language (una...
Given a UTF-8 string, give a string that represents byte counts of each characters. Rules: As long as the input string is encoded in UTF-8 (without BOM), its type doesn't matter. In C++, it can be char[] or std::string. In Haskell, it can be [Int8] or [CChar]. The output must be (in usual case) a string of ASCII digit...
The challenge Find the smallest feedforward neural network such that, given any 3-dimensional input vector \$(a,b,c)\$ with integer entries in \$[-10,10]\$, the network outputs the largest (i.e., "most positive") root of the polynomial \$x^3+ax^2+bx+c\$ with error strictly smaller than \$0.1\$. Admissibility The notion...
I just got a job as a postman and I need your help to keep it. I have to order a lot of mails before I go out to deliver them. Streets are numbered strictly sequentially, starting with 1 at the start of the street, and continuing in order skipping no numbers until the end, with odd numbers on the left side and evens on...
There's a little-known secret in Banjo-Kazooie that you can interleave the three Cheato codes on the Treasure Trove Cove Sandcastle floor and it will still recognize all of them. So you could, for instance, enter BLUREEGOLDDFFEEGEAATHTHEEGSRSRS, activating BLUEEGGS, REDFEATHERS, and GOLDFEATHERS all at once. Challenge ...
Introduction During work with BMP (bitmap) generator I face problem of converting number to little endian hex string. Here is function which I create in JavaScript - but wonder how small code can works similarly let liEnd= num => num.toString(16).padStart(8,'0').match(/../g).reverse().join``; console.log(liEnd(304767...
Given a UTF-16 string, test its endianness. Rules: As long as the input is in UTF-16 without BOM, its type doesn't matter. In C++ on Windows, it can be std::wstring or std::u16string. In Haskell, it can be [Int16] or [Word16]. The endianness is tested by noncharacters. If the input contains a noncharacter, it is in wr...
21, 21, 23, 20, 5, 25, 31, 24, ? Inspired by this Puzzle, given an integer \$n>0\$ , print out the following sequence until you reach a non-Integer (spoilered, in case you want to solve the puzzle yourself first) \$a_0 = n\$ \$a_{4k+1} = a_{4k} \cdot(4k+1) \$ \$a_{4k+2} = a_{4k+1} + (4k+2)\$ \$a_{4k+3} = a_{4k+2} - (...
This is essentially the inverse of Generate a US License Plate Challenge: Given a string that matches one of the below license plate formats, output all possible states that match that formatting. In the below table 0 stands for a single digit 0 through 9 inclusive, and A stands for a single letter A through Z inclusiv...
Write a full program or a function taking an unsigned integer number N and doing this cut out work: Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/' Translate the piece above by 3 lines. Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon ...
We seem to never get tired of alphabet-related challenges... The recipe Given a string of letters S, and two positive integers M, N, produce an alphabet soup with the letters of S occupying random positions in a rectangular bowl of size M×N, framed by a non-alphabetic, non-space character to represent the rim of the...
Spreadsheet Columns In most spreadsheet programs, columns go A, B, C, ... X, Y, Z. After this comes AA, AB, AC ... AX, AY, AZ, BA and so on. Your task is to convert one of these strings in to a column number. You must support inputs up to the maximum length of your language, to a minimum of 3. Test Cases: A => 1 B ...
It's simple, simply output text to STDERR containing the string EOF. Input/Output Your input will be none; however, you should output the message to STDERR. Rules Since this is code-golf, the shortest answer wins. No standard loopholes please. Any method approved by Standard I/O is allowed. Your code may not contain t...
In this challenge, your task is to input a rectangle ASCII pattern (You may assume only printable characters need to be handled, and you may assume a trailing newline or not), C4_4 symmetrify, and output it. Here, C4_4 symmetric means symmetric under 90-degree rotation around a corner of the corner character. The corre...
In this challenge, your task is to detect (vertical) Skewer Symmetry. This means that one half of the pattern can be produced by mirroring the other half along a vertical axis, and then moving it vertically. For example, the following pattern has skewer symmetry: asdf jkl;fdsa ;lkj Because if you start from th...
Given an input string of length 2 or longer consisting solely of alphabetical characters [A-Z] or [a-z] (your choice if they're all uppercase or all lowercase), output a continuous string of characters forming a double diamond pattern. The input string starts on the center line and extends down-and-right at a diagonal ...
Display the emoji of the eastern zodiac of given time, according to given country. The eastern zodiac is a classification scheme that assigns an animal and its reputed attributes to each year in a repeating 12-year cycle. It is also assigned to hours. Rules: The country must be given as ISO 3166-1 alpha-3 code. The li...
The objective Given a string of Hangul syllables, sort the characters in North Korean dictionary order. Introduction to Hangul syllables Hangul(한글) is the Korean writing system invented by Sejong the Great. Hangul syllables are allocated in Unicode point U+AC00 – U+D7A3. A Hangul syllable consists of an initial consona...
Code Golf Measurer © 2019 Hexdumps used with xxd look something like this: 00000000: 666f 6f20 6261 7220 7370 616d 2065 6767 foo bar spam egg 00000010: 730a s. Your task is to convert a hexdump in this form in to the number of bytes used. Rules: Usual loopholes forbidden. This is ...
Fermat's polygonal number theorem states that every positive integer can be expressed as the sum of at most \$n\$ \$n\$-gonal numbers. This means that every positive integer can be expressed as the sum of up to three triangle numbers, four square numbers, five pentagonal numbers etc. Your task is to take a positive int...
\$T(n, k)\$ gives the number of permutations of length \$n\$ with up to \$k\$ inversions. This values grows very quickly, for example for \$T(20, 100) = 1551417550117463564\$. The maximum number of inversions possible is \$n\frac{n-1}{2}\$ so for \$k = n\frac{n-1}{2}\$ we know that \$T(n, k) = n!\$. To make this tas...
The newest "nice" OEIS sequence, A328020, was just published a few minutes ago. Number of distinct tilings of an n X n square with free n-polyominoes. This sequence counts tilings up to symmetries of the square. The sequence has six terms, but I'd like to see if folks here can extend it further. Example For n=4 there...
About Hangul As I'm Korean, I'm really proud of Korean character, Hangul(한글). Hangul is a syllabary invented by King Sejong the great, 4th king of Joseon dynasty, in 1443. Because today (October 9th) is Hangul day in Korea, I'll give you a challenge: Make some Hangul ascii-art List of characters So, To make ASCII art, ...
Background You've been given a task to take notes for a meeting. You start typing on your Google Doc, but you don't have enough time during the meeting to look at your keyboard while you type. Fortunately for you, you can type without looking at your keyboard. After the meeting, you realize that everything you typed wa...
What general tips do you have for golfing in MathGolf? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to MathGolf (for tips which can be applied to loads of programming languages, look at the general tips).
NOTE: Since I'm Dutch myself, all dates are in the Dutch dd-MM-yyyy format in the challenge description and test cases. Challenge: Inputs: Start date \$s\$; End date \$e\$; Digit \$n\$ Outputs: All dates within the range \$[s,e]\$ (including on both sides), which contain \$n\$ amount of unique digits in their date. Exa...
Let's assume we've got an imaginary assembler. The assembler supports numerical labels. An infinite loop example: :1 jmp 1 Your task is, to write a preprocessor for this assembler supporting named labels (instead of numerical ones; with up to 8 characters in length), so the label name is replaced to it's numerical...
The objective Given a Russian text, encrypt it with Caesar cipher with key 16. The basic Cyrillic alphabets The basic Cyrillic alphabets are: (U+0410 – U+042F) АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ By the Caesar cipher, they are mapped to: РСТУФХЦЧШЩЪЫЬЭЮЯАБВГДЕЖЗИЙКЛМНОП The small letters (U+0430 – U+044F) are also mappe...
Given (in any structure; flat list, two lists of lists, a tuple of matrices, a 3D array, complex numbers,…) the coordinates for two non-degenerate triangles ABC=[[Ax,Ay],[Bx,By],[Cx,Cy]] and PQR=[[Px,Py],[Qx,Qy],[Rx,Ry]], determine if they are similar, that is, they both have the same shape, or one has the same shape ...