instruction stringlengths 34 53.1k |
|---|
In a round of the prisoner's dilemma exercise, two players each decide whether to cooperate or defect for that round. The scoring for a round is:
Player A and Player B both cooperate: 1 point for both
Player A and Player B both defect: 2 points for both
Player A cooperates and Player B defects: 3 points for cooperatin... |
Relevant links here and here, but here is the short version:
You have an input of two integers \$a\$ and \$b\$ between negative infinity and infinity (though if necessary, I can restrict the range, but the function must still accept negative inputs).
Definition of the Kronecker symbol
You must return the Kronecker symb... |
The Bernoulli numbers (specifically, the second Bernoulli numbers) are defined by the following recursive definition:
Where denotes a combination.
Given a nonnegative integer m as input, output the decimal representation OR a reduced fraction for the mth second Bernoulli number. If you output a decimal representation... |
Background
This challenge is about the stochastic block model.
Basically, you are given an undirected graph, where the nodes represent people, and the edges represent social connections between them.
The people are divided into two "communities", and two people are more likely to have a connection if they are in the sa... |
A polynomial is divisible by a factor (x-n) if f(n)=0 for a function f. Your job: to determine if a polynomial function f(x) is divisible by (x-n).
The input
The input is in the form of (x-n), (Polynomial). Remember, if n is negative, (x-n) will be in the input form of (x+n). For the polynomial, all exponents will... |
So, like the title says, today you are going to guess my password (sort of). You need to make a big long list of every possible password I might be using on my 4 digit online vault.
Specifications:
It could contain any 26 letters of the alphabet in UPPER CASE.
It could contain any numbers 0-9.
So, basically, each di... |
The Method of Finite Differences is a technique used to find the next term in a sequence of numbers, given that the sequence is governed by consecutive values of a certain polynomial. Given a list of n terms, the Method will be able to determine the degree of the polynomial, which is a maximum of n+1.
The Method works ... |
Golf a Purple Interpreter
Purple is an esolang which is designed with two main purposes:
To be a minimization of Aubergine, since there just aren't enough self-modifying one-instruction languages around.
To admit the possibility of terrifyingly small golfed interpreters. My first pass at a reasonably full-featured Pyt... |
Can't see emoji? Click here.
You will simulate a vending machine. The items are 56 different emojis, which can be represented as two surrogate UTF-8 characters, from: (U+D83C U+DF45) to
(U+D83C U+DF7C). In HTML these emojis can be represented in UTF-16 form as 🍅 through 🍼. In base 10 the first UTF-8 char... |
This king-of-the-hill challenge is based off of the game show, Weakest Link. For those unfamiliar with the show, the crux of this challenge deals with who you vote off:
If the other players are smarter than you, then you have less of a chance of getting the pot.
If the other players are dumber than you, then you have... |
Introduction
A normal checkers board contains 8 x 8 = 64 squares:
You can see that in total, there are 12 white pieces. Black and white always have the same amount of pieces. If there are any more pieces on the board, the pieces would neighbouring, which is not allowed for this challenge. To clarify things, here are s... |
Time for another maze challenge, but not as you know it.
The rules for this challenge are a little different than most maze challenges. The tile types are defined as follows:
S: The location on the maze you start at
E: The location you are trying to get to
0: Wall that you can't cross
+: Floor that you can cross
You ... |
I recently ordered some new and colorful tiles to replace my boring old white tiling for my kitchen. However, when the tiles arrived, they were all in a weird shape! Therefore, I need a program to figure out how to arrange the tiles so that I need to use as few of my old boring white tiling as possible.
Even though t... |
You are given a nonnegative integer n and an integer p >= 2. You need to add some p-th powers (p=2 means squares, p=3 means cubes) together to get n. This is always for any nonnegative n, but you don't know many p-th powers (of any positive integer) you'll need.
This is your task: find the minimum number of p-th powers... |
Preamble
Integers are always either even or odd. Even integers are divisible by two, odd integers are not.
When you add two integers you can infer whether the result will be even or odd based on whether the summands were even or odd:
Even + Even = Even
Even + Odd = Odd
Odd + Even = Odd
Odd + Odd = Even
Likewise, when... |
You will be given a (possibly empty) string containing brackets ([{()}]) and any other characters (A-Z, a-z, 0-9, punctuation). You need to check if it adheres to the following rules:
Non-bracket characters are ignored.
Every open bracket [{( has a closing bracket )}]. So []( is not allowed.
Brackets are nested proper... |
I love ><>, ><> is life! 2D langages are amazing!
In this challenge, you will have to say if a "fishy" road has an end,
while code-golfing.
Definition
A fishy road is constructed with tiles, including the following ones:
v (go down)
> (go right)
^ (go up)
< (go left)
/ (mirror)
\ (mirror)
Any other character (except -... |
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 is that
T_0 = 0
T_2n = T_n
T_2n+1 = 1 - T_n
A ... |
Background
I have constructed a simple obstacle course by placing boxes in a rectangular room.
Now I want to count the number of essentially different ways in which it can be solved.
I need you to write me a program for that.
Input
Your input is a non-empty rectangular array of the characters .#.
The dots . are empty s... |
Write a program or function that takes an array of non-negative integers as input and outputs a set of vectors/arrays with the elements of the input array in order, split so that each vector sums up to 15. If the sum of the first N elements doesn't "hit 15", then the number that made it pass 15 must be cut off, and the... |
The formatting order of dates is one of the most complex and divisive issues the world faces today. Some of us vehemently argue that Month/Day/Year is appropriate, considering that's how we say dates out loud. Others loudly proclaim that Day/Month/Year is best, because it puts the terms in ascending order of the durati... |
Time for you to implement my new stack based language! It's called StackyMath. This will be a stack based language with 8 operations on the stack and ways to add numbers to the stack.
List of operations:
/: Division. Performed on the top 2 numbers of the stack. Pushes the result back on the stack.
*: Multiplication. P... |
Write a piece of code that is executable in at least three different languages. The code must output the integer 1 in language number one, 2 in language number two, 3 in language number three etc.
Rules:
The output must be only the integer, but trailing newlines are OK.
The code can't take input of any kind
Different... |
Introduction
The International System of Units is a system of measuring all around the world, except for a few countries including the US. The SI system (or metric system) is based on powers of ten, listed below (note that this is an incomplete table):
femto(f) pico(p) nano(n) micro(μ) milli(m) centi(c) (base unit) hec... |
Background
Alice and Bob are creating a golfing language to win every single PPCG challenge.
Alice wants to make a two-dimensional language, like ><>, but Bob prefers a prefix-infix syntax like in J.
As a compromise, they decide to create a two-dimensional prefix-infix language.
The parser is a pain to write, and they ... |
Your task is to analyse the input and output the formula for the n-th term if it is an arithmetic sequence, otherwise it should print "NAAP".
Input
Input (from STDIN) will consist of few numbers, between 4 to 10 numbers where each number will be in the range between -1000 and 1000 inclusive, separated by a delimiter (... |
The idea of this challenge is simple: create a bot to play the card game Euchre.
For those of you who don't already know them, I've written out the rules to Euchre here as they pertain to this challenge.
I recommend using python or something similar, but the only real restriction is that it has to be compatible with th... |
Challenge: make a program that outputs a MD5 hash of its source code.
You should not use tricks that would be considered cheating in a quine sense (discussed here).
Using built-in functions and external libraries is allowed. The program should be a full program (not a function/subroutine). Code-golf: shortest solution ... |
Challenge
¡We're going to give exclamation and question marks inverted buddies!
Given a body of text containing sentences ending in ., ?, or !, prepend inverted question marks, ¿, to interrogative sentences (sentences ending in ?) and inverted exclamation marks, ¡, to exclamatory (sentences ending in !). Sentences endi... |
Inspired by https://puzzling.stackexchange.com/questions/24334/to-catch-a-thief
You are given an n by n (n itself is optional input) grid filled with 0s and 1s (or any other character of your choice). You aim is to make every cell the same (either 0 or 1). You can make a series of moves as defined below (note dissimila... |
The objective of this challenge is to write a program to convert an inputed string of what can be assumed as containing only letters and numbers from as many bases between 2 and 36 as possible, and find the base 10 sum of the results.
The input string will be converted to all the bases in which the number would be defi... |
Inspired by this SO question
As input you will be given a non-empty list of integers, where the first value is guaranteed to be non-zero. To construct the output, walk from the start of the list, outputting each non-zero value along the way. When you encounter a zero, instead repeat the value you most recently added to... |
A numeronym (also known as a "numerical contraction") is when a word is shortened using numbers. A common contraction method is to use the length of the replaced substring to replace all but the first and last characters. For example, use i18n instead of internationalization, or L10n instead of localization. (The L is ... |
Introduction
When solving a rubiks cube, one often write down the times like this
11.91, (11.28), (12.32)
This is called a average of 3, while a average of 5 looks like this
13.36, (11.89), 12.31, (16.44), 12.26
Note how the worst and best times have parenthesis around them. When calculating the average of 5 these ti... |
Elixir is a relatively new functional language, which I've taken a deep interest in. I'd like to get general tips about golfing in Elixir and learn techniques that can be applied to code-golf problems that are somewhat specific to Elixir in general.
Based on so many similar questions about Python, Ruby, Javascript, et... |
Italian zipcodes are 5-digit numbers. Each number is linked to a province. There are 4610 zipcodes and 110 provinces (as of 2015) in Italy.
Given the list of zipcodes and the related province (in this file - Gist here) write a function (any language would be fine) that, accepting in input an Italian zipcode, writes out... |
Given a number N, the challenge is to get the sum of the pyramid of N primes. To clarify things, here is an example:
Input: 4
We will list the first 4 primes, and then compute the sum of them. After that, we will compute the sums of the sums, and so on:
2
> 5
3 > 13
> 8 > 33
5 > 20
> 12
... |
Write a function that takes two parameters: a positive integer n and a list of words.
Given a cube of n-by-n-by-n units, assign a random letter (A-Z) to each surface unit. (For a 3x3x3 cube, there would be 9 surface units on each face.)
Then determine whether it's possible for an ant walking along the surface (with th... |
Following the fine tradition of questions such as Find the largest prime whose length, sum and product is prime , this is a variant on a largest prime challenge.
Input
Your code should not take any input.
Definition
We say a prime p is good if p-1 has exactly 2 distinct prime factors.
Output
Your code should output the... |
A regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length).
Your job is to find out if a given polygon is regular or not.
Specs
You will be given a list of Cartesian coordinate 2-tuples which describe the polygon's vertices.
The points will alw... |
Write a program or function that takes in a nonempty list of integers in any reasonable convenient format such as 4, 0, -1, -6, 2 or [4 0 -1 -6 2].
Print or return a string that depicts the list as an ASCII art forest where each number becomes a tree of proportional height. Each tree takes up four columns of text in t... |
Programming Puzzles & Code Golf has opened a taco truck! The word is out and now users from all over the Stack Exchange network are coming to try our tasty, authentic ASCII tacos. We need your help to ensure that everyone gets their orders in a timely manner. There isn't a whole lot of room inside food trucks, so you'l... |
Pythagoras had his leg blown up in the war. It had to be amputated, and though he nearly died, he pulled through and made a full recovery. Now, after a year of walking with crutches, he gets the privilege of getting a prosthetic leg! Thing is, though, there are several that fit, but which ones?
The Task
Given a positiv... |
Take a look at the sevens multiplication table from 7×0 to 7×9:
0, 7, 14, 21, 28, 35, 42, 49, 56, 63
If we just look at the digits in the one's place we get a permutation of the digits 0 through 9:
0, 7, 4, 1, 8, 5, 2, 9, 6, 3
Consider taking some positive decimal integer N and replacing each digit D in N with the th... |
This challenge is based off a riddle I read in some book a while ago, which I found again here. It is about bullets fired from a gun once per second at varying speeds that travel in a straight line forever. When one bullet hits another, both are destroyed completely. (Feel free to replace all instances of "bullet" with... |
Suppose one day you are digging through your big box of unused computer cords and adapters (USB to USB mini, VGA to DVI, etc.). There are tangled cords everywhere making quite a mess, and you wonder if you could simplify things by attaching all the cords together in one long strand, and then just rolling it up.
The que... |
Hilbert numbers are defined as positive integers of the form 4n + 1 for n >= 0. The first few Hilbert numbers are:
1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97
The Hilbert number sequence is given by OEIS sequence A016813.
A related number sequence, the Hilbert primes... |
Specification
This challenge is simple to state: your input is a non-empty array of nonnegative integers, and your task is to partition it into as few increasing subsequences as possible.
More formally, if the input array is A, then the output is an array of arrays B such that:
Each arrays in B form a partition of A i... |
Given an input n where 3 <= n <= 25, perform the following steps, starting with a single n-sided die (faces in the range [1, n], inclusive):
Print the result of rolling the current n-sided dice in play, in the form kdn: X (where X is the result and k is the number of dice in play).
If X is greater than or equal to n/2... |
Find the Intersection of 2 Sets in Unioned Interval Notation
Given two sets of real numbers described as the union of intervals, output a description of the intersection of these two sets as a union of the same type of interval.
The input sets will always consist of unions of intervals such that each interval begins a... |
The game of Sevens is played as follows: n players sit in a circle, and start counting up from 1, passing to the left (or from player A to player B).
When a number p that has a 7 in it OR is divisible by 7 is reached, then the player who spoke the number p-1, after the next player says p, must say p+1 and the order of ... |
Sometimes when writing brainfuck code, you feel the need to make it longer than needed to encourage debugging. You could do it by just plopping a >< in there, but what fun is that? You'll need something longer and less NOPey to confuse anybody reading your code.
Quick introduction to Brainfuck
Brainfuck is an esoteric... |
The Dal Segno and Da Capo are two very commonly used musical terms. They mean "from the sign" () and "from the beginning" respectively.
There is also the idea of the coda (), which is the very end of a piece of music. It's what's played after the "main section" of the piece.
A D.S. al coda (Dal Segno al coda), for exam... |
Write a programs that reads the file Smart.txt & outputs the order from Most Smart to Least smart.
--Smart.txt
Sam John
John Michael
Taylor Sam
In the above text file the person on the left is smarter than the person on the right. So we have to finally print the output as follows:
Taylor Sam John Michael
There can be... |
I like the concept of 0815, except the interpreter on the creator's website returns an Error 404. So I decided to ask you all to help!
The Basics
0815 is based around three (3) registers and a queue. The registers are named X, Y, and Z, with X being write-only, Z being read-only, and Y being a "helper" register that ca... |
https://en.wikipedia.org/wiki/Connect_Four
Does anyone remember the 2 player game connect 4? For those who don't it was a 6x7 board that stands vertical on a surface. The goal of connect 4 is to, well connect 4! The connection is counted if it is horizontal, diagonal, or vertical. You place your pieces on the board by ... |
The Rules
Each submission must be a full program.
The program must take input as two comma-separated dates in the form YYYY-MM-DD, and print the number of days that has passed since the second date to STDOUT as if today was the first date (if the second date would be in the future, output a negative number) plus an o... |
This little piggy went to market, this little piggy wrote some code...
Ah wait, we're not talking about that bacon, we're talking about Sir Francis Bacon! Specifically, the cipher Bacon devised in the late 1500s, as a method of hiding a message within another message, a method of steganography.
The cipher works by conc... |
Innovation is a card game where players battle through the ages, from prehistory to modern times, in an attempt to earn achievements faster than their opponents.
Each card in Innovation is unique, and provides a player with a number of icons. If we treat each card as a 2x3 grid, then three of the four slots on the left... |
Background
A fractal sequence is an integer sequences where you can remove the first occurrence of every integer and end up with the same sequence as before.
A very simple such sequence is called Kimberling's paraphrases. You start with the positive natural numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9, ...
Then you riffle in so... |
Let's get back to basics!
Your code, a complete program or function, must convert the official Unicode name of a printable Basic Latin character into the corresponding character. For example, for the input LOW LINE your code must output _.
You only need to take a single character name as input.
You cannot use any pre... |
(Literally: "Does this follow/realize the gismu-form?")
Premise
The language Lojban is a constructed language, meaning in part that all of its words have been created rather than allowed to develop naturally. The semantic base of Lojban are its gismu, or root words, which were synthesized by combining roots from widely... |
This question was inspired by this HNQ.
About the series
This question is now part of a series about the AGM method. This first post in the series will be about actually calculating the AGM. You may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is ... |
The challenge below requires you to be familiar with formal parser theory. If you don't know what the question is asking because you don't know what the terms mean, context-free grammars and first/follow sets are covered in a lot of university courses.
I can recommend this Stanford course, in particular handouts 08 and... |
The Catalan numbers (OEIS) are a sequence of natural numbers often appearing in combinatorics.
The nth Catalan number is the number of Dyck words (balanced strings of parenthesis or brackets such as [[][]]; formally defined as a string using two characters a and b such that any substring starting from the beginning has... |
sheesh, is this really the 4th? For all you oldcomers, the core challenge is the same, but we are using Java instead of a custom language. Here are the past three CodeBot challenges, in case you are interested.
The goal of CodeBots is to make your bot as viral as possible. Each bot carries a Flag, and you need to ma... |
I've enjoyed reading this site; this is my first question. Edits are welcome.
Given positive integers \$n\$ and \$m\$, compute all ordered partitions of \$m\$ into exactly \$n\$ positive integer parts, and print them delimited by commas and newlines. Any order is fine, but each partition must appear exactly once.
For e... |
First question here, don't yell at me if this is a duplicate or a bad challenge.
Introduction
I thought of this challenge myself, and it seems to be a good basic puzzle for beginner code-golfers. It also might help me decide which code-golfing language to learn.
Challenge
Given an array of integers that are less than o... |
Before anyone says anything, similar and similar. But this is not a dupe.
Some positive integers can be written as the sum of at least two consecutive positive integers. For example, 9=2+3+4=4+5. Write a function that takes a positive integer as its input and prints as its output the longest sequence of increasing con... |
Write a function or program that takes as its input a string and prints a truthy value if the string is a pangram (a sequence of letters containing at least one of each letter in the English alphabet) and a falsey value otherwise.
Case of letters should be ignored; If the string is abcdefghijklmnopqrstuvwXYZ, then the ... |
Your task is simple: given two integers \$a\$ and \$b\$, output \$\Pi[a,b]\$; that is, the product of the range between \$a\$ and \$b\$. You may take \$a\$ and \$b\$ in any reasonable format, whether that be arguments to a function, a list input, STDIN, et cetera. You may output in any reasonable format, such as a retu... |
A Quat is a combination of a quine and the popular esolang cat program.
Challenge
The challenge is to write a standard cat program. Whatever the user inputs, the program will echo the input to stdout.
However, when the length of the input is greater than 0 and a multiple of 4, the program should output its own source c... |
I don't like strings with more than three vowels in a row. Can you write a program that removes all the vowels I don't want from words?
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest altern... |
Inspired by this question by @CᴏɴᴏʀO'Bʀɪᴇɴ.
Taken from the question:
Your task is simple: given two integers a and b, output ∏[a,b]; that
is, the product of the range between a and b. You may take a and b in
any reasonable format, whether that be arguments to a function, a list
input, STDIN, et cetera. You may ... |
Heavily inspired by Programming a Pristine World. Also closely related to this challenge.
Let's define a pristine prime as a number which is itself prime, but will no longer be prime if you remove any contiguous substring of N base 10 digits, where 0 < N < digits in number.
For example, 409 is a pristine prime because... |
About the Series
First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post.
Although I have a bunch of i... |
Don't you hate it when you want to copy-paste a list of numbers (vector, array ...), from one program to another, but the format you have the numbers on doesn't match the format you need it on?
For instance, in MATLAB you may have a space separated list like this:
[1 2 3 4 5] (you can also have it comma separated, ... |
Background
The convex hull of a finite number of points is the smallest convex polygon that contains all of the points, either as vertices or on the interior. For more information, see this question on PGM which defines it very well.
Input
N+1 2-D coordinates (N >= 3) passed through STDIN (with other usual golf inputs ... |
The task is very simple, when given an input, output one of the following spirals:
Input = 1 gives a spiral with the letter A beginning in the top left corner:
A B C D E F
T U V W X G
S 5 6 7 Y H
R 4 9 8 Z I
Q 3 2 1 0 J
P O N M L K
Input = 2 gives a spiral with the letter A beginning in the top right corner:
P Q R S T... |
Disclaimer: while I have been on this site for entertainment purposes for a little while now, this is my first question, so please forgive any minor errors.
Background
When assigning us homework, my teacher is really annoying and writes out all the problems we have to do individually. As such, it takes me forever to co... |
This is a king of the hill challenge for Dots and Boxes (aka Pen the Pig). The game is simple, on your turn just draw a line on an empty fence. Every time you complete a square you get a point. Also, since we are playing by championship rules, if you complete at least one square on your turn you get an extra turn. This... |
The challenge this time is to find the nth Fibohexaprime. The definition of a Fibohexaprime is as following:
We first observe a list with Fibonacci numbers:
N | Fibonacci number
1 | 1
2 | 1
3 | 2
4 | 3
5 | 5
6 | 8
7 | 13
8 | 21
9 | 34
10 | 55
11 | 89
12 | 144
13 | 233
14 | 377
15 | 610
16 | 987 ... |
Background
Very skilled card handlers are capable of a technique whereby they cut a deck perfectly in half, then perfectly interleave the cards. If they start with a sorted deck and perform this technique flawlessly 52 times in a row, the deck will be restored to sorted order. Your challenge is to take a deck of cards ... |
Rolling the Dice
So, I was rolling dice a while ago and thought of a challenge.
Given the cube with a net taken from input and a list of moves, find the square on the bottom at the end.
I will use this image for the examples here.
Input
You take in a string with a list of moves. The string contains only the capital A... |
Inspiration from Puzzling.SE.
Suppose we have an m × n grid such that each element is a base 10 digit. We can read the numbers from such a grid so that we fix a starting element, go to one of the eight nearest coordinates and maintain that direction for zero to five steps. This allows you to read a one to five digit nu... |
Given a non-negative integer input, write a program that converts the number to hexadecimal and returns a truthy value if the hexadecimal form of the number contains only the characters A through F and a falsey value otherwise.
Test cases
10
==> True (A in hexadecimal)
100
==> False (64 in hexadecimal)
161
==> False... |
Introduction
The task is simple. When given a number, output the most logical rectangle. To explain what a logical rectangle is, I provided some examples:
Input: 24.
All possible rectangles have the form A x B, (A and B are both positive integers). So, all possible rectangles for 24 are:
1 x 24
2 x 12
4 x 6
From this... |
Given a string input, write a program that prints a truthy value to STDOUT or equivalent if the input is a valid UUID, without using regexes.
A valid UUID is
32 hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four h... |
Inspired by Alex's glorious Learn you an R for great good, we are going to humbly recreate Alex's "one true R program" -- but with a twist.
Alex-style Addition works like this -- it has a 90% chance of simply returning the sum of the two numbers given and a 10% chance of recursively Alex-adding the first number and the... |
Here is a list of some common
ligatures in Unicode (the
ones I could create with my Compose key on Debian):
Orig Ascii Lig
ae [ae] æ
AE [AE] Æ
oe [oe] œ
OE [OE] Œ
ij [ij] ij
IJ [IJ] IJ
ff [ff] ff
fi [fi] fi
fl [fl] fl
ffi [ffi] ffi
ffl [ffl] ffl
You have two options in this ... |
After you wake in a dark room, you see a rectangular grid of lights with corresponding switches. You decide to use a coordinate system with the bottom left light representing (1,1) and the coordinates increasing as you go up (y direction) and to the right (x direction). The grids are identical in that flipping the swi... |
Given a string you must move each letter (starting from the first letter) by its position in the alphabet. If you reach the end of the string you must wrap around. Non-letters don't need to be moved.
Example:
Dog
D is the fourth letter in the alphabet so we move it four spots to the right. After wrapping around, that c... |
Create a program that solves a mathematical expression using the elements from alternating sides of the expression. The way it’s done is, instead of reading from left to right, you read the first character, then the last, then the second, then the second to last etc. This will give you a new expression that you must ev... |
The Background
Folks were talking prime factorization in chat and we found ourselves talking about repunits. Repunits are a subset of the numbers known as repdigits, which are numbers consisting of only repeating digits, like 222 or 4444444444444444, but repunits consist only of 1.
The first couple repunits are therefo... |
Why was 6 afraid of 7? Because 7 8 9!
Given a string apply the following transformations:
If there is a 6 next to a 7 remove the 6 (6 is afraid of 7)
If the sequence "789" appears remove the 8 and the 9 (7 ate 9)
(If I'm not mistaken it doesn't matter what order you do the transformations in)
Keep applying these tran... |
Defenestration is the act of throwing someone or something out of a window.
—Wikipedia
Input
The input will consist of two parts:
A floor plan and a person inside the house/building.
v><^ represents a person, pointing in the direction signified by the arrow. The input will contain exactly one person.
- and | repres... |
Goal
You're playing a computerised chess game. The display is in black and white only and the pixels are chunky. White pixels use a lot power compared to black pixels and you're concerned about your carbon footprint.
Given a square and a piece in chess notation, return the number of white pixels displayed in the squa... |
Your input will be a integer between 1970 and 2090 (inclusive), representing a year. Your program should output the next year on which New Years Day falls on the same day of the week as the input year.
Test Cases:
Below are the sample inputs and outputs
2001 => 2007
2047 => 2058
2014 => 2020
1970 => 1976
1971 => 1982
1... |
Stack Exchange automagically detects serial
voting (when one user either
upvotes or downvotes many of another user's posts) and reverses it. In this
challenge, you will implement a very, very simple "serial vote" detector.
Input
The input is a string representing a list of votes. Every group of two
characters represent... |
Challenge: write a single script file foo.cmd which can be invoked from the vanilla Windows cmd.exe prompt (not PowerShell, not in administrator mode), to execute arbitrary Windows-specific code...
> .\foo.cmd
Hello Windows!
...but also be invoked unaltered from a typical POSIX-compliant (Linux/OSX) shell prompt (ba... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.