instruction stringlengths 34 53.1k |
|---|
Inspired by Nicola Sap's Challenge
Goal
Your challenge is to simply produce π with 232-1 digits. However today's twist, like the title implies, is to produce it without using any numbers or any π constants in your source-code.
Input/Output
Your program will not be provided usable input. It can output in any reasonable ... |
Introduction
In mathematics, the hyperoperation sequence is an infinite sequence of arithmetic operations (called hyperoperations) that starts with the unary operation of successor (n = 0), then continues with the binary operations of addition (n = 1), multiplication (n = 2), and exponentiation (n = 3), after which th... |
Introduction
For the purposes of this challenge, we will define the neighbours of an element \$E\$ in a square matrix \$A\$ (such that \$E=A_{i,j}\$) as all the entries of \$A\$ that are immediately adjacent diagonally, horizontally or vertically to \$E\$ (i.e. they "surround" \$E\$, without wrapping around).
For peda... |
The problem with the Caesar cipher is the resulting words are often unpronounceable. The problem with Pig Latin is that it is easy to decode. Why not combine them?
Input
A word consisting of the 26 english letters.
Output
First, change every consonant in the word to the next consonant in the alphabet. So, b goe... |
Challenge:
Given a positive integer, output the longest single-digit subsequence that occurs at least twice, AND has boundaries of another digit (or the start/end of the integer).
An example:
Input: 7888885466662716666
The longest subsequence of a single digit would be 88888 (7[88888]5466662716666) with a length of 5. ... |
Make a program that takes the word you input, and adds that word to the back of itself minus its first letter, then repeats until all letters are gone. For example, cat would become catatt, and hello would become helloellolloloo.
Input
Any of the 26 letters of the English alphabet. There may be multiple words separat... |
pylint has no lower bound on the scores it will give your code. It uses the following metric to score code, with the maximum score being 10:
10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
With python 3.6, try and write a program that:
Outputs "Hello World" when run from the command lin... |
Introduction
Brainstract, a newly created dialect of Brainfuck adds a bit more elements to the syntax. In addition to the normal Brainfuck syntax, there are macros. To define a macro:
{macro_name ++++}
Then use it:
{macro_name} Adds 4 to the current cell
Challenge
Your challenge is to take a valid Brainstract progra... |
The least weird fact about the US presidency right now is that there have been two unrelated presidents whose last names start with T-R-U-M.
That made me think, how many US presidents share other combinations of characters? There are obviously two presidents that share the characters "BUSH", and "ROOSEVELT". But did yo... |
Input
A non-empty shuffled string consisting of ASCII characters in the range \$[32..126]\$.
Output
The output is obtained by applying successive rotations to the input string.
For each letter ([a-zA-Z]) in the input string, going from left to right:
if the letter is in upper case, rotate all characters before it by o... |
Today's challenge is simple: Without taking any input, output any valid sudoku board.
In case you are unfamiliar with sudoku, Wikipedia describes what a valid board should look like:
The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 subgrids that compose the grid (... |
I'm sure most of us have heard of zip bombs and similar decompression bomb tricks, where a maliciously crafted input creates a massively disproportionate output. We even had a question on here to do that to a compiler at one point.
Well, it occurs to me that Markdown is a compression format of sorts, replacing bulky H... |
Edit: I haven't played D&D before so when I initially made this question I didn't properly research it. I apologize for this, and I'm making a few edits that might invalidate answers to stay as true as possible to the dnd 5e rules. Sorry.
A D&D fan from a recent Hot Network Question seems to have some trouble working ... |
I have a combinatorics problem that I'd like to put on the OEIS—the problem is that I don't have enough terms. This code challenge is to help me compute more terms, and the winner will be the user with the submission containing the greatest number of terms.
The Problem
Suppose I give you a triangular array of light bu... |
Your goal is simple: to fail everything. More precisely, you should write the shortest code that triggers a compilation/interpretation error, or a runtime error.
What does not count
Failing with symbols that are not covered by the language syntax and are meant to appear only in string literals, comments and other ways... |
We've all seen the pictures captioned "How many squares are in this image? 98% will not get this right!" Well, here's your chance to laugh at that 98%.
Input
A rectangular block made of only 2 characters. In a general form, this is defined by m lines, each containing n characters.
Example:
0000xxx
00x00xx
00000xx
xxxxx... |
Background
Puzzlang is a derivative of Brainfuck, where the symbol X executes a BF command based on three characters on top of it, and anything else does nothing.
The following is the translation table for Puzzlang, where X is the literal X and . stands for anything else:
> < + - . , [ ... |
This proposal had few attention for 8 months (though an answer was posted in the sandbox at that time), so I decided to post it anyway.
Introduction
Napier's bones is a calculation tool, which helps speeding up the calculation of multiplication, division and digit-by-digit square root extraction by turning n-digit-by... |
This challenge was inspired by Yeah But No But Yeah.
maxb´s colleague recently sent him the following piece of JavaScript as a joke:
let butScript = (nrOfButs) => {
for(var i = 0; i < nrOfButs; i++){
if(i % 3 == 0){
console.log("Yeah")
}
if(i % 2 == 0){
console.log("... |
Definitions
Quadratic residues
An integer \$r\$ is called a quadratic residue modulo \$n\$ if there exists an integer \$x\$ such that:
$$x^2\equiv r \pmod n$$
The set of quadratic residues modulo \$n\$ can be simply computed by looking at the results of \$x^2 \bmod n\$ for \$0 \le x \le \lfloor n/2\rfloor\$.
The challe... |
The goal is to simplify sentences containing multiple negatives.
Like with multiplying negative numbers, two negative words annihilate each other until at most one is left (doesn't matter which one). While some words disappear without a trace, other leave behind a positive part
The affected words are:
no
not
couldn't ... |
The ChatRoom is here
I love playing the card game BS, but sometimes, it just doesn't have enough oomph for my short attention span. Instead, let's play some Russian BS.
Rules
Here is a quick guide to the rules.
The game begins with a random player declaring the card type of the round (out of 14 options: A,2,3...10,J,Q... |
Game
In this challenge you will play a made-up turn-based game.
The game is made up of the following elements:
A 8x8 grid with each spot containing nothing (space), a robot (*), a wall (#), or HP (@)
A public stack
Robots
In this challenge, you will be playing as a robot. Each robot has health (starts at 10HP and ca... |
I am quite surprised that a variant of linear regression has been proposed for a challenge, whereas an estimation via ordinary least squares regression has not, despite the fact the this is arguably the most widely used method in applied economics, biology, psychology, and social sciences!
For details, check out the W... |
Let n be a positive integer then n = a + b + c for some a, b, and c that are palindrome integers. What is the largest possible integer a for k = 1 to 1_000_000?
Golf this or have the fastest running time.
NOTE: it's NOT the same as this question as I am asking for the largest palindrome component. The question just ask... |
Introduction
Today we're gonna take care of the bane of first-year linear algebra students: matrix definiteness! Apparently this doesn't yet have a challenge so here we go:
Input
A \$n\times n\$ symmetric Matrix \$A\$ in any convenient format (you may also of course only take the upper or the lower part of the matrix)... |
Challenge
Your task is to encode an integer as a string of ASCII characters, then successfully decode it after said string has been randomly shuffled.
You will write two programs/functions, which will be referred to as Encoder and Decoder.
Encoder
Input: an integer \$n\$ in the range \$[0,2^{31}-1]\$.
Output: a string... |
Tomorrow is the Mid-Autumn festival, and in the spirit of that holiday, I will introduce a gambling game that we (people from Xiamen) play during the holiday!
Rules
The game is played with six 6-sided dice. Different combinations of numbers have different ranks, with a special emphasis on fours and ones. Your job is to... |
True color (24-bit) at Wikipedia is described in pertinent part as
24 bits almost always uses 8 bits of each of R, G, B. As of 2018
24-bit color depth is used by virtually every computer and phone
display and the vast majority of image storage formats. Almost all
cases where there are 32 bits per pixel mean that... |
Requirement: Write a program (in any language) that counts the number of lines of code in files matching *.sh in the directory tree starting from the directory that the program is executed in, excluding lines that are empty, only contain whitespace, or are just single-line comments (a line which the first character tha... |
Awhile back I encountered a simple programming puzzle to determine whether a string was a pangram, or a perfect pangram. (Although it's worth noting that this particular challenge gave a different meaning than the standard definition of a "perfect pangram," to mean any sentence where every letter appears n times for so... |
The idea for this code-challenge is simple: given a matrix of integers, let's sort it by applying Rubik-style movements. This means that you can select a single row or column and rotate its elements in any direction:
[1, 3, 2, 4] => [3, 2, 4, 1] (rotate left for rows/up for columns)
[1, 3, 2, 4] => [4, 1, 3, 2] (rota... |
Description
The task of this challenge is to devise a program or function that tracks a given object in an \$n×n\$ space.
I/O
Your program will be given 3 inputs, which may be taken in any sensible way:
n will be the size of the plane's side. (so, for \$n=5\$, your plane will be \$5×5\$). You may assume n will always b... |
Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.
An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered speci... |
Given a word, treat every letter as its number in English alphabet (so a becomes 1, b becomes 2, z becomes 26 and so on), and check if all of them, including duplicates, are pairwise coprime.
The input is exactly one word of lowercase English letters. The output is the fact if the word is coprime: any truthy/falsey val... |
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 that the digits are p... |
In this task your code will be given an integer \$n\$ as input. Your code should then output the greatest number of multiples of \$3\$ that can be concatenated (in base \$10\$) to form \$3n\$ (with no leading zeros). For example if you were given \$26042\$ as input,
\$26042\times3=78126\$
and \$78126\$ can be made ... |
Your task here is simple:
Given a list of integer sets, find the set union. In other words, find the shortest list of integer sets that contain all the elements in the original list of sets (but no other elements). For example:
[1,5] and [3,9] becomes [1,9] as it contains all of the elements in both [1,5] and [3,9]
[... |
Given a value x find the smallest numerical value greater than y that is capable of being multiplied and divided by x while retaining all original digits.
The new numbers do not lose digits.
The new numbers do not gain digits.
For example:
Input: x = 2, y = 250000
Original: 285714
Division: 142857
Multiplicat... |
We've recently reached the threshold of 10,000 questions on PPCG. Hooray! Let's celebrate this with a simple challenge.
Input
Two integers \$A\$ and \$B\$, both in \$[1..9999]\$, such that \$A+B<10000\$.
Task
Your task is to add one single digit to one of these integers or one single digit to both of them such that \$A... |
We have a challenge to output your own score, but it seems like all the answers there just hardcode the output and that's boring1. So lets have a new challenge. Your program must output its own length in bytes followed by the string " bytes", but in order to prevent hardcoded solutions if we reduce its size by removi... |
Challenge
You are given an array \$a\$ of integers. With a move you can increase or decrease an element of the array by 1. Your task is to equalize the array, that is make all the elements of the array equal by performing some moves. But that's not enough! You also want to make as few moves as possible.
Input
A non-em... |
In this challenge, you will write a bot that play's the prisoner's dilemma. Here's the catch: you will not have access to the history of previous games. Instead, you will have access to the opponent itself. In this version, both players get +2 points if they both cooperate, +1 points if they both defect, and if one coo... |
Problem
Given a value n, imagine a mountain landscape inscribed in a reference (0, 0) to (2n, 0).
There musn't be white spaces between slopes and also the mountain musn't descend below the x axis.
The problem to be solved is: given n (which defines the size of the landscape) and the number k of peaks
(k always less tha... |
I just had a genius idea for making the work-life easier - a countdown to a specific date which only counts workdays.
The basic task is to create a countdown to a specific date which only includes the workdays in the countdown.
As workday counts Monday, Tuesday, Wednesday, Thursday and Friday.
The Input should be a sp... |
You have 2 numbers, both stored separate as numeric data type.
First number is always 6 digits long.
Second number can vary between 1 and 4 digits. If it's less than 4 digits, it needs to be padded with numeric value 0.
End result always needs to be 10 digits number.
Order has to be respected. n1|n2
Example #1:
n1 = 11... |
Using the word “conemon” print each character 2 times more than the last. The first letter, “c”, should be printed 10 times, the second 12 and so on. Each repeated-letter-string should be printed on a new line.
So the end-result becomes:
cccccccccc
oooooooooooo
nnnnnnnnnnnnnn
eeeeeeeeeeeeeeee
mmmmmmmmmmmmmmmmmm
ooooooo... |
This challenge is created in celebration of my first esoteric language, Backhand!
Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only executing every third instruction.
The program 1..1..+..O..@ will add 1+1 and output 2 before terminating. The intermedia... |
Display numbers from one to one-hundred (in increasing order), but number 2 shouldn’t appear anywhere in the sequence. So, for example, the numbers two (2) or twenty-three (23) shouldn't be in the sequence.
Here is an example output, with newlines separating the numbers:
1
3
4
5
6
7
8
9
10
11
13
14
15
16
17
18
19
30
31... |
Final Standings
+----------------------------------+---------+---------+---------+----------------------------+
| Name | Score | WinRate | TieRate | Elimination Probability |
+----------------------------------+---------+---------+---------+----------------------------+
| 1. SarcomaBo... |
Letters of the words want fairness.
They decided to appear same number of times in a sentence equally.
Example:
Priorities
Will become:
Ppprrioooritttieeesss
Each letter appears 3 times, as the most common letter was i, appearing 3 times.
It does not matter where you put the repeated letters, as long as they are next... |
You are given a string of terrain, with molehills and mountains:
/\
/ \
_/\__ / \
___/ \_/ \_
____/\___/ \___
Your job is to replace every molehill in the string with an equivalent mountain centered in the same col... |
This is the Cops' thread. Robbers' thread is here.
Background
Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) A... |
This is the Robbers' thread. Cops' thread is here.
Background
Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) A... |
Supreme Sum String
Given an input string, return the word with the highest sum of each of its unicode characters.
Rules
The input should be seperated by whitespace
The value of each word is based on the sum of each character in the word's UTF-16 code
The output should be the first word with the highest value (in case... |
Inspired by this Stack Overflow question.
The challenge
Input
An array of square matrices containing non-negative integers.
Output
A square matrix built from the input matrices as follows.
Let \$N \times N\$ be the size of each input matrix, and \$P\$ the number of input matrices.
For clarity, consider the following ex... |
Intro
A friend posed this question today in a slightly different way - "Can a single [Python] command determine the largest of some integers AND that they aren't equal?".
While we didn't find a way to do this within reasonable definitions of "a single command", I thought it might be a fun problem to golf.
Challenge
"R... |
Make a program that simulates the basic logic gates.
Input: An all-caps word followed by 2 1 digit binary numbers, separated by spaces, such as OR 1 0. The gates OR, AND, NOR, NAND, XOR, and XNOR are needed.
Output: What the output of the entered logic gate would be given the two numbers: either 1 or 0.
Examples:
AND ... |
Determine the length of a UTF-8 byte sequence given its first byte. The following table shows which ranges map to each possible length:
Range Length
--------- ------
0x00-0x7F 1
0xC2-0xDF 2
0xE0-0xEF 3
0xF0-0xF4 4
Notes on gaps in the table: 0x80-0xBF are continuation bytes, 0xC0-0xC1 would start an ... |
If you have ever had any exposure to Japanese or East Asian culture you will have surely encountered the Amidakuji game:
As Wikipedia explains, it is a type of lottery drawn on paper and used to randomly select a permutation of N items.
For example, it may be used to randomly assign a starting sequence to N people, o... |
Let us define the "multiplicative deltas" of values \$[\; a_0, \cdots a_N, \;]\$ as:
$$
[\; a_1 / a_0, \cdots, a_{i+1} / a_i, \cdots, a_N / a_{N-1} \;]
$$
The reverse operation - namely "multiplicative undelta" - returns values such that the above operation results in the given values.
Example
Given values \$[\; 1, 5, ... |
Your task is to create the given target string. Starting with an string that is empty, you will have to add characters to it, until your string is the same as the one we want. You can either add a character to the end of you string with cost x, or you can clone you string with cost y. What we want is the cheapest way t... |
Given a random coordinate (x,y), determine in which square (squares are referenced by their sidelength) it is (or the borders of which squares).
The squares are drawn in a counter clockwise direction, that is, the first square is drawn in the first quadrant, the one after is to the right, the one after that above, th... |
Chinese Hearts, also known as Gong Zhu (拱猪, Chase the Pig), is a variance of the Hearts game. It is a 4 player card game with the aim to earn the highest amount of points. You may read more about it on Wikipedia. This time, we want implement a program (full or function) to calculate ones score.
Scoring
The player who p... |
Given a list of positive integers, write code that finds the length of longest contiguous sub-list that is increasing (not strictly). That is the longest sublist such that each element is greater than or equal to the last.
For example if the input was:
\$[1,1,2,1,1,4,5,3,2,1,1]\$
The longest increasing sub-list would ... |
About Zeckendorf Representations/Base Fibonacci Numbers
This is a number system which uses Fibonacci numbers as its base. The numbers consist of 0 and 1's and each 1 means that the number contains the corresponding Fibonacci number, and 0 means it does not.
For example, let's convert all natural numbers <=10 to base Fi... |
You are given a list, L, with the length N. L contains N random positive integer values. You are only able to select from the outer edges of the list (left/right), and after each selection every value in the remaining list increase by a factor of the current selection. The goal is to maximize the total sum of the selec... |
Sometimes when you're lying in bed and reading a message, your phone screen will pop into landscape mode right in the middle of a sentence. Only being able to read left to right, you find yourself incapacitated, unable to process the text in front of you.
To ensure that this won't happen again, you decide to make every... |
Input:
An integer n in the range 2 <= n <= 10
A list of positive integers
Output:
Convert the integers to their binary representation (without any leading zeroes), and join them all together.
Then determine all binary substrings that form a 'binary fence' using n amount of fence posts. The spaces (zeros) between each... |
In Java/.NET/C/JavaScript/etc. you can use ternary-ifs to shorten if-statements.
For example (in Java):
// there is a String `s` and an int `i`
if(i<0)s="Neg";else if(i>0)s="Pos";else s="Neut";
Can be shortened with a ternary-if to:
s=i<0?"Neg":i>0?"Pos":"Neut";
Challenge:
Input: A regular if-else (possible with nes... |
The Challenge
The goal of this challenge is to determine whether a given String can be typed using only one line of a standard UK QWERTY keyboard.
This is code golf, so shortest solution in bytes wins!
IO
Input will be a single String of zero or more characters in the ASCII decimal range of 32-126 inclusive.
You may ... |
Introduction
Large meetings waste working time. Our aim is to split a large meeting into a number of smaller meetings, so the average number topics that a person discusses is minimized but every person has to be in every meeting they are interested in.
Input
Given is a function from a set of topics \$T\$ to a set of pe... |
Given a list of activities and their start time/date, output an ASCII-art calendar showing the activities on the appropriate days. All activities are guaranteed to be in the same month, no two activities will be on the same day, and all activities are guaranteed to fit within the calendar box.
The calendar has the date... |
Consider you have a hash function \$\mathcal{H}\$ which takes strings of length \$2n\$ and returns strings of length \$n\$ and has the nice property that it is collision resistant, i.e. it is hard to find two different strings \$s \neq s'\$ with the same hash \$\mathcal{H}(s) = \mathcal{H}(s')\$.
You would now like to ... |
Yesterday while playing with my kid I noticed the number in his toy train:
So we have $$4281$$ that can be split into $$4-2-8-1$$ or $$2^2-2^1-2^3-2^0$$
So simple challenge: given a non-negative number as input, return consistent truthy and falsey values that represent whether or not the string representation of the n... |
This question was inspired by Tom Scott's video here.
The English language has plenty of words, but what's the longest one that can be displayed on a seven segment display? Your challenge is given a list of letters that may not be displayed, display the longest English word in a 7 segment display format?
Input
Input w... |
Introduction:
Unfortunately an Accordion Solitaire Solver challenge already exists (Solve a game of Accordion), so instead this easier related challenge.
Let's start by explaining how Accordion Solitaire works:
You start with all 52 cards (or 53 if you add a Joker) in one big row.
You pile up cards from right to left ... |
From this stackoverflow question
Given a 2D array of size \$ M \times N \$, output the values in a anti-clockwise fashion. The output must start from the outside to the inside and the initial point always is going to be \$(0,0)\$.
Example Given:
$$ \begin{bmatrix} \color{blue}1&\color{red}2&\color{red}3&\color{red}4 \\... |
As you most probably now, there are 2339 solutions to pentomino puzzle in a 6x10 grid. There are different labeling schemes for the 12 pentominoes, two of them are shown on the image below:
Image credit: Wikipedia
For the purposes of the current task we will say that a normalized pentomino solution is a solution that ... |
Input
A string s of printable ASCII characters, newlines, and spaces (0x20 ( ) to 0x7E (~)), and a non-negative integer n.
Challenge
To write a program that outputs either another program, or s depending on n. If n = 1, Then your code should output code which outputs s. If n = 2, Your code should output code which outp... |
Two dimensional chiral objects are not chiral in three dimensional space. This is because you can flip them over which is equivalent to taking the mirror image unlike in two dimensions where only rotations in the plane of the object are allowed which cannot reproduce the effect of a mirror operation. In this challenge,... |
While I was writing numbers I noticed after a while that my keyboard had the Shift key pressed and blocked and all I wrote was $%&-like characters. And even worse, I had been switching between the English and Spanish keyboard layouts so I don't know which one I used for each number.
Challenge
Given a string containing ... |
Background
Tatamibari is a logic puzzle designed by Nikoli.
A Tatamibari puzzle is played on a rectangular grid with three different kinds of symbols in it: +, -. and |. The solver must partition the grid into rectangular or square regions according to the following rules:
Every partition must contain exactly one symb... |
With the given text below, there are some words in the text that repeats several times in the text. Use any programming language to write a short code that compresses the text to display it. Or in other words, use the smallest number of bytes to display the text.
The Text is:
Peter Piper picked a peck of pickled peppe... |
(language-specific challenge)
Specification:
Language: ECMAScript, any version[1]
Challenge: Somewhat like python's itertools.groupBy: Your function Array.group(f) should take as input an "equivalence function" f whose output defines our notion of an "equivalence key" for array elements (like a sort key). The return va... |
Idea:
Consider a 2-bit bitmap of arbitrary side-lengths overlaid on a coordinate grid and imaged with random data (1's represent an element of the image, 0's represent the "blank" canvas background):
y x—0 2 4 6 8 10 14 18
|
0 0000000000111100000000
0000000011111110000000
2 0000111111111111000000
0000... |
A numerical polynomial is a polynomial \$p\$ in one variable with rational coefficients such that for every integer \$i\$, \$p(i)\$ is also an integer. The numerical polynomials have a basis given by the binomial coefficients:
$$p_n = {x \choose n} = \frac{x(x-1)\cdots(x-n+1)}{n!}$$
For instance:
\$p_0 = 1\$
\$p_1 = x\... |
The minimal power iteration of a number \$n\$ is defined as follows:
$$\text{MPI}(n):=n^{\text{min}(\text{digits}(n))}$$
That is, \$n\$ raised to the lowest digit in \$n\$. For example, \$\text{MPI}(32)=32^2=1024\$ and \$\text{MPI}(1234)=1234^1=1234\$.
The minimal power root of a number \$n\$ is defined as the number o... |
Write two programs A and B.
Program A (the encoder) takes 1024 pairs of integers \$(k,v)\$, where \$0≤k<2^{32}\$ and \$0≤v<1024\$, and all \$k\$ will be different. It will output a single positive integer (likely a few thousand digits long).
Program B (the decoder) takes two inputs: the output-integer of program A, a... |
In the Anno video game series there are 6 games with a 7th one announced for early 2019. Their titles always feature a year in a specific pattern:
Anno 1602, Anno 1503, Anno 1701, Anno 1404, Anno 2070, Anno 2205, Anno 1800
The digital sum is always 9.
The years are four digits long.
They contain at least one zero.
Wi... |
An palindrome is a word that is its own reverse.
Now there are some words that might look like palindromes but are not. For example consider the word sheesh, sheesh is not a palindrome because its reverse is hseehs which is different, however if we consider sh to be a single letter, then it's reverse is sheesh. This... |
Challenge
Write a program or function that takes in a string s and integer n as parameters. Your program should print (or return) the string when transformed as follows:
Starting in the top-left and moving down and to the right, write s as a wave of height n. Then, from top to bottom, combine each row as a string (with... |
Your challenge is to turn a Japanese word and a dictionary pitch accent number into a new string where the rises and falls in pitch are marked: e.g. (2, ウシロ) → ウ/シ\ロ.
To help you out with this, I'll explain a little about Japanese phonology.
Background: on moras
For the purpose of this challenge, we will write Japane... |
Here's a pretty common pattern for sorting algorithms:
def sort(l):
while not is_sorted(l):
choose indices i, j
assert i < j
if l[i] > l[j]:
l[i], l[j] = l[j], l[i]
These algorithms work well because the indices i and j are chosen carefully, based on the state of the list l.... |
Use any programming language to display "AWSALILAND" in such a way, so that each letter is in a new line and repeated as many times as its position in the English alphabet. For example letter, (A) should be displayed just once because it is the first letter of the alphabet. Letter D should be displayed 4 times because ... |
When I write documentation, comments, etc. I love making ASCII tables. They usually end up looking pretty good, but I always feel that they could look even better - especially since UTF-8/Unicode includes the box drawing characters. However, these characters are very burdensome to use, requiring several key presses to ... |
Consider an array A of length n. The array contains only positive integers. For example A = (1,1,2,2). Let us define f(A) as the set of sums of all the non-empty contiguous subarrays of A. In this case f(A) = {1,2,3,4,5,6}. The steps to produce f(A) are as follows:
The subarrays of A are (1), (1), (2), (2), (1,1), ... |
Background
A binary tree is a rooted tree whose every node has at most two children.
A labelled binary tree is a binary tree whose every node is labelled with a positive integer; moreover, all labels are distinct.
A BST (binary search tree) is a labelled binary tree in which the label of each node is greater than the l... |
Challenge
Inspired by this video.
As you may know, a palindrome is a word that is spelled the same forward as it is backward. The word "PULP" is not a palindrome, but when translated into Morse Code (with the spacing between letters removed), "PULP" becomes ".--...-.-...--." which is a palindrome. Your task is to write... |
You have to make something that takes in one input from a default I/O method (as an integer), and prints out the sum of all the permutations of that number (not necessarily unique)
For example:
10 would return 11 because 10 can have 2 permutations (10 and 01), and the sum of those two numbers would be 11
202 would have... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.