text
stringlengths
180
608k
[Question] [ [Logic gates](https://en.wikipedia.org/wiki/Logic_gate) are functions which perform basic logic operations. In this problem, we will account for the following 6 logic gates: `AND`, `OR`, `XOR`, `NAND`, `NOR`, and `XNOR`. Each of these takes two boolean inputs \$ a \$ and \$ b \$, and outputs a boolean....
[Question] [ I was messing around with Pyth's url request feature, and noticed that google always gave a response with a slightly different length for me, usually `~10500` characters. So your task in this challenge is to print out the average length of the html response from `http://google.com`. # Specs * You will ...
[Question] [ # Summary Given a list of integers, return the index each integer would end up at when sorted. For example, if the list was `[0,8,-1,5,8]`, you should return `[1,3,0,2,4]`. Note that the two `8`s maintain their order relative to each other (the sort is stable). Put another way: For each element in the ...
[Question] [ There's quite a few challenges on this site that ask you to print out a sequence, and this is no exception. (The following explanation of the sequence for this challenge assumes the symbols in the sequence are `0` and `1`.) The recursive definition of the [Thue-Morse sequence](https://en.wikipedia.org/...
[Question] [ ## Description The Gameboy stores tiles as 2 bit-per-pixel 8x8 images, thus 16 bytes. Every two bytes is a complete row with all of the Low-bits of each pixel in the first byte, and all of the High-bits of each pixel in the second. ## Input Input will be exactly 16 bytes, received through [Standard IO]...
[Question] [ ## Challenge Calculate the strange sum of two natural numbers (also known as lunar addition): Given \$A=...a\_2 a\_1 a\_0\$ and \$B=... b\_2 b\_1 b\_0\$ two natural numbers written in the decimal base, the **strange sum** is defined, based on the **maximum** operation, as: \$A+B=... \max(a\_2,b\_2) \ma...
[Question] [ If a compiled language is used, the program must delete the compiled executable (but need not delete the source file). If an interpreted language is used, the program must delete the source file. My opening bid: ## Python (29 characters) ``` import os;os.remove(__file__) ``` Edit: to prevent solutions ...
[Question] [ Two-dimensional programming languages often have mirror commands like `/` and `\` to redirect the instruction pointer on the grid: ``` >>>>\ v v <<<</ ``` In this challenge, you're given an incoming direction and a mirror and you need to determine the outgoing direction. ## Rules The incoming d...
[Question] [ See the [cop thread](https://codegolf.stackexchange.com/questions/61804/create-a-programming-language-that-only-appears-to-be-unusable) for more information. Each answer to this question should crack an answer there. That is to say, it should be code to find the third-largest integer in the input when ...
[Question] [ #### Story My local pizza delivery introduced new discount. You get 50% discount from every second item on your order. But being greedy capitalists, they forgot to mention that they will rearrange items the way they need to give you as little as possible. #### Example Imagine you ordered ``` - Pizza $2...
[Question] [ *Taken from [this question](https://stackoverflow.com/q/38739122/2586922) at Stack Overflow. Thanks also to @miles and @Dada for suggesting test inputs that address some corner cases.* ### The challenge Given an array of integer values, remove all zeros that are not flanked by some nonzero value. Equiv...
[Question] [ [Sandbox](https://codegolf.meta.stackexchange.com/a/18360/78850) *Adapted from exercise 4 of [100 little Keg exercises](https://github.com/JonoCode9374/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 importa...
[Question] [ ## Golf a Venn Diagram generator ![enter image description here](https://i.stack.imgur.com/k9uMD.jpg) In order to properly celebrate [John Venn's 180th birthday](http://www.google.com/doodles/john-venns-180th-birthday), today your task will be creating a program that outputs a [Venn Diagram](http://en....
[Question] [ Given a string of ASCII characters, output the character that is in the middle. If there is no middle character (when the string has an even length), output the ASCII character whose ordinal is the floored average of the two center characters. If the string is empty, an empty string should be output. T...
[Question] [ You know—they look like this: [![](https://i.stack.imgur.com/t4uJx.jpg)](https://i.stack.imgur.com/t4uJx.jpg) [source](http://covers8.com/sound-equalizer-rhythm-music-beats/) The goal is to draw a music beats illustration like the following: ``` = = = = = = = = == = == = == ...
[Question] [ ### Task > > Find all the non-negative integers up to and including a given non-zero positive integer *n*, that are prime and the count of `1's` and `0's` in their binary representation (having no leading zeroes) are prime too. > > > Here are the first five such primes, ``` 17, 19, 37, 41, 79 10001...
[Question] [ A [stochastic matrix](https://en.wikipedia.org/wiki/Stochastic_matrix) is a matrix of probabilities used in the context of Markov chains. A *right* stochastic matrix is a matrix where each row sums to `1`. A *left* stochastic matrix is a matrix where each column sums to `1`. A *doubly* stochastic matri...
[Question] [ This is a code golf challenge. Just like the title says, write a program to covert a string of ascii characters into binary. For example: `"Hello World!"` should turn into `1001000 1100101 1101100 1101100 1101111 100000 1010111 1101111 1110010 1101100 1100100 100001`. Note: I am particularly interest...
[Question] [ Inspired by [a polyglot](https://meta.stackexchange.com/a/27846/344102) ~~on the [Stack Overflow 404 page](https://stackoverflow.com/error-404)~~: ![](https://cdn.sstatic.net/Sites/stackoverflow/img/polyglot-404.png) # Goal Your goal is simple, to create a polyglot that outputs the number **404**, and ...
[Question] [ As the majority of nations using the Euro have the `,` as the decimal separator, you must use it also. The task is to output all the values of the Euro coins and notes in ascending order. You must also put the trailing `,00` on the integer values. `0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,...
[Question] [ A prime power is a positive integer *n* that can be written in the form *n* = *pk* where *p* is a prime and *k* is a positive integer. For example, some prime powers are `[2, 3, 5, 4, 9, 25, 8, 27, 125]`. Next, consider prime powers of 2. These are `[2, 4, 8, 16, ...]` and can be written in the form 2*...
[Question] [ To check whether a decimal number is divisible by 7: > > Erase the last digit. Multiply it by 2 and subtract from what is left. If the result is divisible by 7, the original number is divisible by 7. > > > (also described e.g. [here](https://www.easycalculation.com/divisibility-rule-by-7.php)) This...
[Question] [ *This question was inspired by [this HNQ](https://math.stackexchange.com/questions/1566017/what-happens-if-you-repeatedly-take-the-arithmetic-mean-and-geometric-mean/1566049#1566049).* ## About the series This question is now part of a series about the AGM method. This first post in the series will be ...
[Question] [ # Task Write a polyglot in two languages that when run, outputs the name of the language it is run in. Additionally, this program must *also* output the **other** language's name if the source code is reversed # Example: Program `ABC` in language `foo` outputs `foo`. `ABC` in language `bar` outputs `ba...
[Question] [ You want to make a string where the (**1-indexed**) character at index `n` is `n`. When `n` is less than 10, this is easy: `"123456789"`. When `n` is 12, for example, it becomes impossible, since numbers greater than 9 (in base 10) take up more than one character. We can compromise by dividing the stri...
[Question] [ # File Permissions [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") *Adapted from the UIL - Computer Science Programming free response question "Carla" for 2018 District.* # Introduction In UNIX-like operating systems, each file, directory, or link is "owned" by a "user", wh...
[Question] [ **Background:** Take this input as an example: ``` 1 1 2 1 1 2 1 3 1 3 ``` If you look only at the first few digits, between `1 1 2` and `1 1 2 1 1 2 1`, this input appears to consist of the pattern `1 1 2` repeating indefinitely. This would make its period 3, as there are 3 numbers in the pattern. Giv...
[Question] [ This is the logo for [LAPACK, a widely used software library for numerical linear algebra](http://www.netlib.org/lapack/). [![enter image description here](https://i.stack.imgur.com/zpKoi.png)](https://i.stack.imgur.com/zpKoi.png) Your task is to print the logo (color and matrix brackets not required) ...
[Question] [ We all know of different fancy sorting algorithms, but none of these give us numbers in a way that's easy to pronounce. To remedy this, I propose using PronunciationSort™, the most natural way to sort lists of numbers. ## Pronunciation The official rules for pronouncing numbers (in this challenge) is t...
[Question] [ Our boolean operators are `AND`, `OR`, `XOR`, `NAND`, `NOR`, `XNOR` and, in conjunction with one of those operators, `NOT`. Our numbers are \$1\$ and \$0\$. The challenge is to write a program or function that calculates the results of the input. ## Input A string, array or other input format of your c...
[Question] [ Who doesn't love a good fractal? The [Sierpinski Carpet](http://en.wikipedia.org/wiki/Sierpinski_carpet) is a classic example of a fractal. To complete this task, you will be required to generate a carpet of type \$n\$ and print the resulting image to the `stdout` (see example below for formatting) \$n...
[Question] [ Using the fewest Unicode characters, write a function that accepts three parameters: * Total number of dominoes * `n`th affected domino * Topple direction of the affected domino (`0` or `L` for left, `1` or `R` for right) Once a domino is toppled, it must also topple the remaining dominoes in the same ...
[Question] [ ### Backstory Disclaimer: May contain made up information about kangaroos. Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry. In stage **1**, the kangaroo is very little and cannot jump...
[Question] [ This is an [answer-chaining](/questions/tagged/answer-chaining "show questions tagged '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](https://codego...
[Question] [ An **[Abecedarian Word](https://english.stackexchange.com/questions/208852/is-there-a-name-for-a-word-where-all-the-letters-are-in-alphabetical-order#:%7E:text=You%20can%20call%20them%20abecedarian,letters%20of%20the%20Latin%20alphabet.)** is a word whose letters are in alphabetical order. Your goal is...
[Question] [ Take the decimal number \$0.70710678\$. As a fraction, it'd be \$\frac{70710678}{100000000}\$, which simplifies to \$\frac{35355339}{50000000}\$. If you were to make the denominator \$1\$, the closest fraction is \$\frac{1}{1}\$. With \$2\$, it'd be \$\frac{1}{2}\$, and with \$3\$ it's \$\frac{2}{3}\$....
[Question] [ Frequently while I'm code-golfing, I'll want to know what the ASCII value of a certain character is. One of my favorite resources for quickly looking up all of the [printable ASCII characters](https://en.wikipedia.org/wiki/ASCII#Printable_characters) is [ASCIItable.com](http://www.asciitable.com/). Thi...
[Question] [ # Introduction Number theory is full of wonders, in the form of unexpected connections. Here's one of them. Two integers are [co-prime](https://en.wikipedia.org/wiki/Coprime_integers) if they have no factors in common other than 1. Given a number \$N\$, consider all integers from 1 to \$N\$. Draw two s...
[Question] [ # Background Sometimes in calculus you're expected to calculate the sum of an infinite series. Sometimes these series are very friendly, like a geometric series, but add anything else onto it and it can quickly get complicated to solve by hand. Sometimes I like to be lazy - a lot of sums can be found s...
[Question] [ Part of [**Advent of Code Golf 2021**](https://codegolf.meta.stackexchange.com/q/24068/78410) event. See the linked meta post for details. Related to [AoC2015 Day 20](https://adventofcode.com/2015/day/20), Part 1. *[Here's why I'm posting instead of Bubbler](https://chat.stackexchange.com/transcript/24...
[Question] [ # Challenge In this challenge, you will be writing the first program, p1, of an infinite sequence of programs, in which running pn outputs/generates program pn+1. When concatenating the first n >= 2 programs, the sequence should output `n`. # Example Let's say the first 4 programs are: ``` p1 p2 p3 p4 ...
[Question] [ You task here is very simple: Given a positive integer `n` without leading zeroes as input, split it in all possible ways ## Examples **Input->Output** ``` 111 -> {{111}, {1, 11}, {11, 1}, {1, 1, 1}} 123 -> {{123}, {12, 3}, {1, 23}, {1, 2, 3}} 8451 -> {{8451}, {845, 1}, {8, 451}, {84, 51}, {84...
[Question] [ A prime is weak if the closest other prime is smaller than it. If there is a tie the prime is not weak. For example **73** is a weak prime because **71** is prime but **75** is composite. ## Task Write some computer code that when given a prime greater than **2** as input will determine if it is a weak...
[Question] [ # Challenge Given a string and a number, divide the string into *that many* equal-sized parts. For example, if the number is 3, you should divide the string into 3 pieces no matter how long the string is. If the length of the string does not divide evenly into the number provided, you should round down...
[Question] [ [Negadecimal](https://en.wikipedia.org/wiki/Negative_base), also known as base -10, is a non-standard positional numeral system. Take the number \$1337\_{10}\$. In decimal, this has the value one thousand three hundred thirty seven, and can be expanded to: $$1\cdot10^3+3\cdot10^2+3\cdot10^1+7\cdot10^0$...
[Question] [ Write a program that accepts as input an emoticon and ouputs if the emoticon is happy or sad. The program accepts a string as input or parameter, and should display the string "happy" if the input is in the happy emoticon list, or "sad" if the input is in the sad emoticon list. You can assume the input...
[Question] [ Let's consider the sequence \$S\$ consisting of one \$1\$ and one \$0\$, followed by two \$1\$'s and two \$0\$'s, and so on: $$1,0,1,1,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,0,...$$ (This is [A118175](https://oeis.org/A118175): *Binary representation of n-th iteration of the Rule 220 elementary cellular automat...
[Question] [ This challenge is simply to return a list of lists of integers, similar to the Python range function, except that each successive number must be that deep in lists. **Rules**: * Create a program or a non-anonymous function * It should return or print the result * The result should be returned in a list...
[Question] [ **Final results available** # Introduction After my previous KOTH with heavy themes ([fantasy war](https://codegolf.stackexchange.com/questions/44978/koth-warring-towns), [worldwide pandemic](https://codegolf.stackexchange.com/questions/70135/koth-a-world-wide-pandemic)...), I'm back with a new lighthe...
[Question] [ Write two programs, each taking a string `s` and a number `n` ≥ 0, such that: * The first program prints `s` `n` times, separated by newlines. * The second program prints each character of `s` `n` times, with repeated characters separated by newlines. * Every character at column `x`, line `y` in one pr...
[Question] [ The [infinite Fibonacci word](https://en.wikipedia.org/wiki/Fibonacci_word) is a specific, infinite sequence of binary digits, which are calculated by repeated concatenation of finite binary words. Let us define that a *Fibonacci-type word sequence* (or *FTW sequence*) is any sequence **⟨Wn⟩** that is ...
[Question] [ This [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge will give you an integer `n`, and ask you to count the number of positive integer sequences \$S = (a\_1, a\_2, \dots, a\_t)\$ such that 1. \$a\_1 + a\_2 + \cdots + a\_t = n\$, and 2. \$\displaystyle \sqrt{a\_1+\...
[Question] [ Why is the number 6174 so interesting? As [defined](http://en.wikipedia.org/wiki/Kaprekar%27s_constant) by Wikipedia > > 1. Take any four-digit number, using at > least two different digits. (Leading > zeros are allowed.) > 2. Arrange the digits in ascending and > then in descending order to get tw...
[Question] [ ### Snaking Number Challenge I wonder how many snaking numbers there are between 1 and 50,000? [![Snake on a Nokia](https://i.stack.imgur.com/oOche.gif)](https://i.stack.imgur.com/oOche.gif) Snaking Numbers, in this game, are numbers which can be typed out on a traditional numberpad (format below) by m...
[Question] [ ### Task Given (by any means) a sorted floating point dataset, return (by any means and within 1‰ of the correct value) the [interquartile mean](https://en.wikipedia.org/wiki/Interquartile_mean). ### One possible algorithm 1. Discard the lowest and highest quarters of the data points. 2. Calculate the ...
[Question] [ # Introduction I want to build a ladder. For this, I have scavenged from the junkyard two long boards with holes in them, and I want to place the steps into these holes. However, the holes are not evenly placed, so the steps will be a little wonky, and I find it hard to estimate the amount of rod I nee...
[Question] [ \* and don't have a word processor with top-left align support :D Take several lines of input, with at least four unique characters of your choice including newline and space. The input can also be taken as a space-padded matrix of characters. Squash it upwards, then squash it left. Output this, with a...
[Question] [ Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; generate all possible permutations of uppercase/lowercase for a given input. ## Input A string of printabl...
[Question] [ [Laguerre polynomials](https://en.wikipedia.org/wiki/Laguerre_polynomials) are nontrivial solutions to Laguerre's equation, a second-order linear differential equation: \$xy''+(1-x)y'+ny=0\$. For a given value of \$n\$, the solution, \$y\$, is named \$L\_n(x)\$. To avoid trivial solutions, the polynomi...
[Question] [ ## Challenge: **Input:** A positive integer \$n\$ **Output:** Create a list in the range \$[1,n]\$, and join it together to a string (i.e. \$n=13\$ would be the string `12345678910111213`). Now we output a triangle using the prefixes or suffixes of this string, in one of the following four orientations...
[Question] [ Your task is to take in one integer input and print a zigzag pattern using slashes and backslashes. * The integer input determines the length of each zig and zag, as well as the number of zigs and zags * The pattern always starts from right to left # Test Cases ``` 4-> / / / / \ \ \ \ / ...
[Question] [ In cryptography, [PKCS#7 padding](https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7) is a padding scheme which adds a number of bytes N ≥ 1, where the value of each added byte is equal to N. For example, `Hello, World!`, which has 13 bytes, is the following in hex: ``` 48 65 6C 6C 6F 2C 20 57 ...
[Question] [ Write the shortest possible assembly-language [quine](http://en.wikipedia.org/wiki/Quine_%28computing%29). Use any ISA you want, unless it has a `print-quine` instruction or equivalent. Examples include x86, MIPS, SPARC, MMIX, IBM BAL, MIX, VAX, JVM, ARM, etc. You may link against the C standard librar...
[Question] [ *[Sandbox post (deleted)](https://codegolf.meta.stackexchange.com/a/16701/78039)* The old roman army formations are very famous around the world. In these formations roman legionaries grouped in a geometric shape (usually a rectangle) protecting the flanks and the superior part of it using their shield...
[Question] [ # Satan-Primes who are they? they are `Primes` containing `666` these are Satan-Primes:`[46663,266677,666599,666683,616669]` these are **NOT** :`[462667,665669,36363631,555]` # Plot *Every number bigger than 6661 has Satan-Primes behind him* # The Challenge Given an integer `n>6661` find the Sata...
[Question] [ ## The Sequence Everyone knows the only even prime number is `2`. Ho-hum. But, there are certain even numbers `n` where, when concatenated with `n-1`, they *become* a prime number. For starters, `1` isn't in the list, because `10` isn't prime. Similarly with `2` (`21`), and `3` (`32`). However, `4` wor...
[Question] [ You know those stackable shelves that are basically just [wooden boxes](http://bangsboutique.com.au/mock/wp-content/uploads/bangs-shelves-storage-cube-01.jpg) that can be stacked together? We're going to simulate building some bookshelves out of those with some ASCII art. Our books are all *convenientl...
[Question] [ While ><> is not a popular language, it can be good for golfing and has been used on this website. It was inspired by [Befunge](https://codegolf.stackexchange.com/questions/634/interpret-befunge-93) and has some similarities in its instructions. **Required Commands:** > > `> < ^ v` > > Changes the ...
[Question] [ in my country we have a children's song which goes like this: ``` Priletela muha na zid, muha na zid, muha na zid. Priletela muha na zid, muha na zid. Pralatala maha na zad, maha na zad, maha na zad. Pralatala maha na zad, maha na zad. Preletele mehe ne zed, mehe ne zed, mehe ne zed. Preletele mehe ne ...
[Question] [ [Brun's constant](https://en.wikipedia.org/wiki/Brun%27s_theorem) is the value to which the sum of the reciprocals of [twin prime](https://en.wikipedia.org/wiki/Twin_prime) pairs (`1/p` and `1/(p+2)` where `p` and `p+2` are both prime) converges. It is approximately `1.902160583104`. Given a positive i...
[Question] [ **Input:** * An array containing three integers: `0`, `1` and `2` in any order (i.e. `[2, 0, 1]`) * And a string of length >= 2 only containing alphabetic letters (both lower- and uppercase) and digits (i.e. `a1B2c3`) **Output:** Based on the array we sort and output the string. How does this work? *...
[Question] [ Oh, No! the sentences are out of balance. Quick! balance them. --- A word is defined as follows: > > A sequence of letters [A-Za-z] separated by **any** non-letter character ([0-9] ~+- etc.) > > > A word is BaLanCeD if its capitalization is the same forwards as it is backwards. Given a sentence...
[Question] [ As [TIO can show](https://tio.run/#), every letter of the Latin alphabet is represented when it comes to languages. For every letter there is at least 1 programming language whose name begins with that letter. Your task is to create a polyglot in order to demonstrate that. Your program should be runnab...
[Question] [ I noticed a certain game had a peculiar life counter, which instead of stopping at `999`, gained a new digit ‚Äì the next number was *crown* hundred or `üëë00`. After `üëë99` came *crown hundred crownty* (`üëëüëë0`) and the last number, after `üëëüëë9`, was *crown hundred crownty crown* or `üëë...
[Question] [ ## Summary Inspired by the recent popularity of ASCII art challenges, this challenge's purpose is to draw an ASCII checkerboard, like one on which Chess can be played. Write a program that takes a positive integer `n` as an argument, in `stdin`, or as user input, and output an checkerboard with `n`x`n`...
[Question] [ If you think this could be fun, but too much work, consider participating in [this](https://codegolf.stackexchange.com/q/66921/43319) much smaller challenge. --- A bit of fun (and possibly frustration!) for 2016... [Dyalog's "puzzle of the year"](http://dyalog.com/2016-year-game.htm). Enjoy! # The Obje...
[Question] [ Sometimes in chat, if someone says something you agree with, you'll send a message with an `^`, which points at the message above: ``` Radvylf: Cats are far superior to JavaScript You: ^ ``` Sometimes you'll also add some text: ``` Radvylf: I sure do like integers You: I mostly agree with ^ but floats ...
[Question] [ Repost and improvement of [this](https://codegolf.stackexchange.com/questions/125/test-if-a-given-number-is-a-vampire-number) challenge from 2011 A [vampire number](http://en.wikipedia.org/wiki/Vampire_number) is a positive integer \$v\$ with an even number of digits that can be split into 2 smaller in...
[Question] [ ## Background My user ID is 78410, or \$1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 1 0\_2\$. One interesting property of this number is that, in binary, * it doesn't have three consecutive identical digits, and yet * it has a substring \$100100100\$ which is three copies of \$100\$. So, I define a **Bubbler number*...
[Question] [ Let's have a function \$f\$ that takes a string and removes all pairs of adjacent identical characters. For example \$f(a\color{red}{bb}ba\color{red}{cc}) = aba\$ Note that when two pairs overlap we only remove one of them. We will call a string perfectly paired if repeated application eventually yield...
[Question] [ You have a square board with a bunch of items laid out on it in one of a \$3 \times 3\$ grid of cells and you want to lift it up using balloons, but you can only attach balloons to the corners of the board. Your task is to determine the minimum number of balloons in each corner to make sure the board w...
[Question] [ A positive integer can be *diluted* by inserting a `0` between two bits in its binary expansion. This means that an `n`-bit number has `n-1` dilutions, which are not necessarily all distinct. For example, for `12` (or `1100` in binary), the dilutions are ``` 11000 = 24 ^ 11000 = 24 ^ 10100 = 20 ^...
[Question] [ I have a stupid old alarm clock with two buttons: `hour` and `minute`. The `hour` button increments the hour of a set alarm, and `minute` increments the minute time of a set alarm. However, some smart designers realized that pressing both buttons at the same time should have a meaning, and decided that...
[Question] [ Here is the sequence I'm talking about: ``` {1, 4, 5, 9, 10, 11, 16, 17, 18, 19, 25, 26, 27...} ``` Starting from 1, keep 1, drop the next 2, keep the next 2, drop 3, keep 3 and so on. Yes, it's on [OEIS (A064801)](https://oeis.org/A064801), too! **The Challenge** Given an integer `n>0`, find the nth t...
[Question] [ Given a string of ASCII letters (upper and/or lower case), output the raw MathJax required to display that string bifurcating at each character, into superscripts and subscripts. For example, the inputs `cat` and `horse` would result in outputs which MathJax renders as the following, respectively: [![i...
[Question] [ Given an positive integer as input determine if it is a magnanimous number. A magnanimous number is a number such that any insertion of a `+` sign between any two digits in base 10 results in an expression of a prime integer. For example 40427 is magnanimous because ``` 4+0427 = 431 is prime 40+427 ...
[Question] [ ## Introduction Suppose you want to compute the tail maxima of a list of numbers, that is, the maximum of each nonempty suffix. One way to do it is to repeatedly choose one number and replace it by a higher number occurring after it, until this is not possible anymore. In this challenge, your task is t...
[Question] [ > > To find the *digital hardness* of an integer, take its binary representation, and count the number of times both a leading *and* trailing `1` can be removed until it either start or ends with a `0`. The total number of bits removed is its digital hardness. > > > That's quite a wordy explanation...
[Question] [ Your challenge is to take some source code as input, and output which programming language it is written in. For example, you could have the input ``` class A{public static void main(String[]a){System.out.println("Hello, World!");}} ``` And output ``` Java ``` Your two main goals are **diversity** (how...
[Question] [ # Task Your task is to draw these beautiful oak trees: ``` 1 -> @@@ @@@@@ @|.|@ _|_|_ 2 -> @@ @@@@@@ @@@@@@@@ @@| .|@@ | | __|__|__ 3 -> @@@@@ @@@@@@@@@ @@@@@@@@@@@ @@@| |@@@ @| .|@ | | ___|___|___ 4 -> @@ @@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@| |@@@@ @@| .|@@ ...
[Question] [ Your task is to print this exact text: ``` z yz xyz wxyz vwxyz uvwxyz tuvwxyz stuvwxyz rstuvwxyz qrstuvwxyz pqrstuvwxyz opqrstuvwxyz nopqrstuvwxyz mnopqrstuvwxyz lmnopqrstu...
[Question] [ Given \$k\$ arrays of length \$n\$, output the maximum sum possible using one element from each array such that no two elements are from the same index. It is guaranteed that \$k\le n\$. # Input A nonempty list of nonempty arrays of integers. # Output An integer that represents the maximum sum. # Examp...
[Question] [ Let an 8x8 chessboard be represented by any two distinct values, with one value being an empty square and the other being a queen. In the following examples, I use 0s as the empty squares and 1s as queens. For example: [![Queens on a chessboard](https://i.stack.imgur.com/oa2Ze.png)](https://i.stack.img...
[Question] [ # Goal: Given an array of strings, create abbreviated​ versions of each string. # Specification: For this challenge, an abbreviation is the first N characters of a string. For the string `abc`: `a`, `ab`, and `abc` are all valid abbreviations, while `bc`, and `ac` are not. Given an array of strings, we...
[Question] [ This time, you are working on a regex. Your regex is meant to approximately full-match the base-10 representations of primes \$0 \le p < 1000\$, while ignoring any non-numeric string or composite in the range. You can full-match 2, 53 or 419, but not 0, 82 or example. The approximately is important -- ...
[Question] [ Given an integer \$N>3\$, you have to find the minimum number of bits that need to be inverted in \$N\$ to turn it into a [square number](https://en.wikipedia.org/wiki/Square_number). You are only allowed to invert bits **below the most significant one**. ## Examples * \$N=4\$ already is a square numbe...
[Question] [ I think most people around here know what a 7-segment display for digits is: ``` _ _ _ _ _ _ _ _ | | | _| _| |_| |_ |_ | |_| |_| |_| | |_ _| | _| |_| | |_| _| ``` We can define the **7-segment difference** (7SD) between two *digits* to b...
[Question] [ Python string parsing has quite a few edge cases. This is a string: ``` "a" ``` Putting 2 strings immediately after each other implicitly concatenates them, so this is also a string: ``` "a""a" ``` However, if you put 3 quotes in a row, it will create a "triple quoted string" which can only be ended by...
[Question] [ An analog clock has 2 hands\*: Hour and minute. These hands circle the clock's face as time goes by. Each full rotation of the minute hand results in 1/12th of a rotation of the hour hand. 2 full rotations of the hour hand signifies a full day. As these hands are fixed to the same central point, and ...
[Question] [ Randomness is fun. Challenges with no point are fun. Write a function that, given integer input `n`, will output a **set** (unordered, unique) of exactly `n` random integers between `1` and `n^2` (inclusive) such that the sum of all integers is equal to `n^2`. Randomness does *not* have to be uniform, ...