instruction stringlengths 34 53.1k |
|---|
This thinking exercise is inspired from Super Chafouin's question "Just Repeat Yourself" in which the phrase "Do not repeat yourself!" had to be outputted using code that was basically a series of doubled characters, inclusive of newlines, so code like:
((zz==0011))&&((mm++&&mm++&&mm++&&mm++&&mm++&&nn--&&nn--&&nn--&&n... |
Given a positive integer n, compute the value of the Mertens function \$M(n)\$ where:
$$M(n) = \Sigma_{k=1}^{n}\mu(k)$$
and \$\mu(k)\$ is the Möbius function where \$μ(k) = 1\$ if \$k\$ has an even number of distinct prime factors, \$-1\$ if \$k\$ has an odd number of distinct prime factors, and \$0\$ if the prime fact... |
I think we've all done this as a kid: some websites require a minimum age of 18, so we just subtract a few years from the year of birth and voilà, we 'are' 18+.
In addition, for most rides at amusement parks the minimum height to enter is 1.40 meters (here in The Netherlands it as at least). Of course this can be cheat... |
Being a Haskell hacker, I prefer pointfree notation over pointful. Unfortunately some people find pointfree notation hard to read, and I find it hard to get the correct number of parentheses when I write in pointful.
Help me convert code written in pointfree to pointful notation!
About
In pointfree notation we use poin... |
Given a list of indices and zero or more lists of integers, output the lists of integers, sorted in ascending order, with the key priority from the first input.
Example
Let the keys input be [1, 0, 2], and the lists input be [[5, 3, 4], [6, 2, 1], [5, 2, 1]]. Those lists need to be sorted by their second element, then ... |
Notice the pattern in the below sequence:
0.1, 0.01, 0.001, 0.0001, 0.00001 and so on, until reaching 0.{one hundred zeros}1
Then, continued:
0.2, 0.02, 0.002, 0.0002, 0.00002 and so on, until reaching 0.{two hundred zeros}2
Continued:
0.3, 0.03, etc, until 0.{three hundred zeros}3
Continued:
0.4, 0.04, etc, until 0... |
I was challenged by one of my friends to solve this coding problem:
Given a non-negative number represented as an array of digits, add one to the number. The digits are stored such that the most significant digit is at the head of the list. Return the value as a new list.
This was my solution, which does not work if [9... |
The official release of the Nintendo 64 in North America was on September 29, 1996.[1] I figured that this anniversary deserved an ASCII art challenge. There's one small twist though, you have to output a different ASCII art for each of three different inputs.
If the input is 1, output this ASCII art of an N64 Controll... |
Interpret loose ranges
ListSharp is an interpreted programming language that has many features, one of those features is a 1 index based range creator that works like this:
You define a range as (INT) TO (INT) or just (INT) where both or the single int can go from min to max int32 value
Then you can use those ranges to... |
Make 2d ASCII buildings depending on what the input is. The submissions can either be a program that takes input, or a function that accepts input via its parameters.
e.g. An input of 5,3,6 would output
┌──┐
│┌┐│
┌──┐ │└┘│
│┌┐│ │┌┐│
│└┘│ │└┘│
│┌┐│ │┌┐│
│└┘│ ┌──┐ │└┘│
│┌┐│ │┌┐│ │┌... |
Your task is to regulate traffic on a crossroads. There are 4 roads coming from north, east, south and west.
The input is a string representing the upcoming traffic on each road. For example, NNNWS indicates there is a total of 5 cars: three at the north, one at the west and one at the south. The order of characters ha... |
PPCG user and elected mod, @Dennis just became the second ever user to earn over 100k rep!
This is a totally original idea, that I did not get from anybody else, but let's make a challenge based off of his user ID, 12012 as a tribute!
Looking at it, you'll notice that there are two distinct "sections" to his ID.
12
... |
Write a program or function that outputs this exact text, case-insensitive:
A, B, C, D, E, F, G,
H, I, J, K, L, M, N, O, P,
Q, R, S,
T, U, V,
W, X, Y, Z.
(Based on the alphabet song that many American kids learn to help memorize the alphabet, though edited for more compressibility.)
The output must look exactly the sa... |
The least common multiple of a set of positive integers A is the smallest postive integer B such that, for each k in A, there exists a positive integer n such that k*n = B.
Given at least two positive integers as input, output their least common multiple.
Rules
Builtins are allowed, but if your solution uses one, you ... |
The natural numbers including 0 are formally defined as sets, in the following way:
Number 0 is defined as the empty set, {}
For n ≥ 0, number n+1 is defined as n ∪ {n}.
As a consequence, n = {0, 1, ..., n-1}.
The first numbers, defined by this procedure, are:
0 = {}
1 = {{}}
2 = {{}, {{}}}
3 = {{}, {{}}, {{}, {{}}}... |
Challenge
I've recently gotten into 8-bit computers and are fascinated with the workings of them and others alike; thus the objective of this code golf, is to replicate a portion of the Woz Monitor, designed by Steve Wozniak for the Apple I.
You are to store an array of 22 hexadecimal values with a width of two bytes... |
Task
Produce this 24kB ASCII art output:
________
\ \
________ \____ \ ... |
I'm tired, but I can't seem to fall asleep. Help me count sheep.
Given an input N (positive integer), make N sheep jump over an ascii fence, like the sample below. Only one frame should be displayed at once:
o |-|
──|-|── 0
o|-|
──|-|── 0
o
|-|
──|-|── 0
|-|o
──|-|── 0
|-| o
──|-|── 0
o |-|
──|... |
An aesthetically pleasing divisor tree is a tree of divisors of input n that, for any composite number m, has two children nodes that are the pair of divisors that are closest to the square root of m. The left node should be the smaller divisor of m and the right node should be the larger divisor of m. A prime number i... |
Your task is to print the following:
I have a pen
I have an apple
Uh! Apple pen!
I have a pen
I have pineapple
Uh! Pineapple pen!
Apple pen...
Pineapple pen...
Uh! Pen Pineapple Apple Pen!
Remember, this is code-golf, so the code with the smallest number of bytes wins.
Leaderboards
Here is a Stack Snippet to generat... |
Given N items (0 < N <= 50) with prices (which are always integers) P0 ... PN-1 and given amounts of each item A0 ... AN-1, determine how much the total cost will be.
Examples
N: 2
P0: 2
P1: 3
A0: 1
A1: 4
Result: 14
N: 5
P0: 2
P1: 7
P2: 5
P3: 1
P4: 9
A0: 1
A1: 2
A2: 3
A3: 2
A4: 3
Result: 60
Remember, this is code-golf,... |
It is currently December 31, 2015, 11:59:00pm, and you must be at least 1324900 seconds old to be able to go to the New Year Celebration. Given the year, month, day, hour, minute, and second of your birth, determine if you are old enough to go.
Notes:
Assume that you are in the same timezone.
Leap years are every 4 ye... |
Given a ray with a point and a vector and a plane with a point and a normal vector to the plane. You have to find the intersection point of the plane and the ray..
So your job if you choose to accept is to write a shortest function that will do the job.
RULES:
The submission must be a complete program
And that's all
I... |
Introduction
A Gray Code is an alternative to binary representation in which a number is incremented by toggling only one bit, rather than a variable amount of bits. Here are some gray codes along with their decimal and binary equivalents:
decimal | binary | gray
-------------------------
0 | 0 | 0
----... |
In a smallish class, some lectures are set aside for working in groups. The instructors don't want people to group themselves together with the same people every time; instead, they create the groups beforehand, trying to make sure that all students work with one another as equally as possible. Your job is to write a p... |
Goal
Create a program/function that takes an input N, check if N random pairs of integers are relatively prime, and returns sqrt(6 * N / #coprime).
TL;DR
These challenges are simulations of algorithms that only require nature and your brain (and maybe some re-usable resources) to approximate Pi. If you really need Pi d... |
Introduction
A bell tower will ring its bells every hour, n times, with n being the the current hour on a 12 hour clock.
For example, a bell will ring 5 times at 5pm, and 10 times at 10am.
Task
Given two times in a suitable format, output the number of times the bell will ring, inclusive of the start and end times
Exam... |
Challenge
Given a fraction with a surd (an irrational number) as the denominator, output the rationalised fraction.
Rationalising the Denominator
To rationalise the denominator, what you have to do is take the fraction and make one which is equal which does not have an irrational number in the denominator. Generally, t... |
Introduction
The Atari ST was a rather popular personal computer from the mid 80's to early 90's era, powered by a Motorola 68000 microprocessor. On this machine, the default behavior of the operating system for uncaught CPU exceptions was to display a row of bombs on the screen, as shown in the following picture:
Sou... |
Found this picture on the web today. Being a lazy programmer, I don't want to actually open google and type a couple of characters. Way too much work! This is such an important task that it should be automated.
Challenge
Everyone knows that the first image in a google search result is always the best. Hence it should ... |
Introduction
This is one is pretty straightforward. We will be drawing a snake in ascii. This was inspired by that old snake game where you have to collect the fruit and you continuously grow.
Definition
Given a positive integer N that represents the snake's length, draw a snake so that it has a body of n plus a head a... |
Given a Sudoku puzzle, find all possible marks that can be filled into each empty cell.
Test case
Input:
[
[
// Top left:
[
0, 0, 0,
3, 4, 0,
0, 0, 2
],
// Top middle:
[
7, 4, 0,
0, 0, 0,
0, 0, 3
... |
This was inspired by a now removed CS.SE question.
Task
Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).
Restrictions
Sensible input: a palindrome exists. This m... |
Here are all the 2x2 binary matrices
#0 #1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 #12 #13 #14 #15
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
00 00 00 00 01 01 01 01 10 10 10 10 11 11 11 11
00 01 10 11 00 01 10 11 00 01 10 11 00 01 10 11
Two binary square matri... |
Inspired by Hyperprogramming: N+N, N×N, N^N all in one.
Thanks to @MartinEnder and @trichoplax for their help in the sandbox.
Definitions
Hyperquines
Define a hyperquine of order n as a quine-like full program or function P that satisfies all rules that apply to proper quines and, in addition, has the following struct... |
Brain-flak is a stack-based turing-tarpit language, written collaboratively between me, DJMcMayhem, and 1000000000.
Some users are very experienced in the mysterious ways of Brain-Flak. So I thought it a good idea to set up this question as a way for us, and hopefully others too, to share our knowledge with the commun... |
Assume we want to shift an array like it is done in the 2048 game: if we have two equal consecutive elements in array, merge them into twice the value element.
Shift must return a new array, where every pair of consecutive equal elements is replaced with their sum, and pairs should not intersect.
Shifting is performed... |
Given a number determine if it is a folding number.
A folding number is a number such that if you take it binary representation and "fold" it in half, That is take the result of XNOR multiplication of the first half of the number and the second half with it digits in reverse, you will get zero.
If the number has a odd... |
Find out the dimension of a simple nested list:
[] -> 1
[[]] -> 2
[[[]]] -> 3
...
List taken as input, dimension as output.
No counting length of strings - list manipulation and loops only.
i.e. no getting the length of the input and dividing by 2.
Any language is permitted. Get golfing!
|
Don't ask me how or why but while coding on a project I noticed that the characters of a couple of words had a particular pattern referred to the alphabet, I connected each character of the words with the pencil on the alphabet and I obtained two spirals, then I noticed that the first spiral was clockwise and the other... |
The 80's TV series Knight Rider featured an intelligent, self-aware car called KITT. One distinctive aspect of the car was a front-mounted scanner bar that allowed KITT to "see" (and that looked suspiciously familiar to fans of another, earlier TV series).
The scanner had eight lights as seen in this picture:
The ligh... |
Challenge
Ever seen those movie trailer titles (namely Martian, Interstellar, etc) where they have huge gaps in between letters slowly spreading out?
The challenge is to recreate this effect given a string, gap multiplier and direction, by inserting appropriate amount of spaces in between the letters.
Example
Input: '... |
Your task is to make a histogram given a sample of arbitrary size.
Input
A float array or any other reasonable form of input with an arbitrary number of elements.
Output
The histogram; more to follow.
How to make a histogram
We'll use the sample: [1.1, 3, 5, 13, 15.5, 21, 29.7, 63, 16, 5, 5.1, 5.01, 51, 61, 13]
To ma... |
Challenge
Given an integer n, calculate the sum of all even numbers between 0 and n
Examples
n output
-------------
100 2550
255 16256
1000 2502500
Shortest code in bytes wins
|
We have already defined a folding number here.
But now we are going to define a Super Folding Number. A Super Folding number is a number that if folded enough times it will eventually reach one less than a power of two. The method of folding is slightly different than in the folding number question.
The folding algor... |
Input:
A string (the wave-snippet) with a length >= 2.
A positive integer n >= 1.
Output:
We output a single-line wave. We do this by repeating the input string n times.
Challenge rules:
If the first and last character of the input string matches, we only output it once in the total output (i.e. ^_^ of length 2 beco... |
Challenge
Inspired by this challenge and the nasty Hurricane Matthew, we will be generating some lightning bolts dynamically.
n = 15:
\
/\
/ \
/ /
/\ /\
/ \ \
/ / /\
/\ \
/ / \
/\ \ /\
/ \ \
/\ /
\
\
/\
Input
Positive Integer n determines the depth of the lightning round.
Rul... |
For this challenge, the objective is to take a list of integers, and output the sum of every unique integer in that list, i.e. count multiples of the same integer only once.
Your input will be a string in the format "{1,2,3,4}" with any amount of elements. The string will never have whitespace or be in a format that do... |
The Wythoff matrix is an infinite matrix consisting of the Grundy numbers of each square on a chessboard in Wythoff's game.
Each entry in this matrix is equal to the smallest nonnegative number that does not appear anywhere above, to the left, or diagonally northwest of the position of the entry.
The top-left 20-by-20 ... |
String Similarity
String similarity is basically a ratio of how similar one string is to another. This can be calculated in many ways, and there are various algorithms out there for implementing a ratio calculation for string similarity, some being more accurate than others. It's actually very useful to use these metho... |
Here is a tic-tac-toe board:
a b c
| |
1 - | - | -
_____|_____|_____
| |
2 - | - | -
_____|_____|_____
| |
3 - | - | -
| |
Given a set of moves, print the board with the tokens on.
Input will be taken in as moves separated by... |
You have probably seen these signs on the doors of various shops:
OPENING HOURS
mon-fri 0900-1800
sat-sun 1100-1530
The task here is to generate a sign like that, grouping consecutive days with the same opening hours, from a list of opening hours for the whole week. Note that the week "wraps around" for what is con... |
We shall soon have a new logo & site design, let us use this last breath of the simple times and golf this ASCII version of the speech bubble beta logo:
+-------------------------------------------+
| .---------------------------------. |
| .EPEpEpBPEpEGCXCgCgCGJgCgP&PWP&P&P&Y` |
| .RSRsRWRSRsRsHoNoNONxNONON... |
This is going to be relatively quick...
Challenge
Given a lower-case word as input, calculate the Pearson's Correlation Coefficient between the letter position of the word (nth letter within the word, x), and the letter position within the alphabet (nth letter of the alphabet, y).
Background
Pearson's Correlation Coeff... |
Say I have a list such as [3, 0, 4, 2, 1], and I use selection sort to sort it, I could visualize it like this:
3,0,4,2,1
|-|
0,3,4,2,1
|-----|
0,1,4,2,3
|-|
0,1,2,4,3
|-|
0,1,2,3,4
This challenge is about visualizing sorting like this.
Input
Your input will be a list of positive integers, in any format yo... |
Your job is to simulate a couple of keystrokes that a user types in.
Input
A string array or string with a delimiter of your choice (outside the range 32-126) containing at least one 'keystroke'.
This array will only contain two types of string: passive keystrokes (single chars) and commands (chars within brackets [ ... |
Introduction
To draw a Fibonacci series of square, you start by drawing a one-unit square:
_
|_|
Then another one to the left:
_ _
|_|_|
Then a two-unit one on top:
_ _
| |
|_ _|
|_|_|
Then a three-unit one on the right:
_ _ _ _ _
| | |
|_ _| |
|_|_|_ _ _|
Then a five-unit one on the bottom:
_ _ _ ... |
Here is a simple challenge for you: You must produce this ASCII representation of a chess board. White is represented by uppercase characters, and black is represented by lowercase. Empty tiles are represented by a .. Here is the full board:
rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR
Since... |
Inspired by a task for Programming 101, here's a challenge that hopefully isn't too easy (or a duplicate).
Input:
A positive integer n >= 1.
Output:
n lines of asterisks, where every new line has one asterisk more than the line before, and starting with one asterisk in the first line.
Test case (n=5):
*
**
... |
Introduction
Braincopter is an esoteric Brainf*** derivative that encodes a Brainf***
program as an image. As a 2D language, it uses two additional commands; they
rotate the instruction pointer (initially pointing right) clockwise and
counterclockwise. Braincopter is very similar to Brainloller, except that
instead of ... |
Introduction
The lexicographical permutations of a list with n elements can be numbered from 0 to n! - 1. For example, the 3! = 6 permutations of (1,2,3) would be (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), (3,2,1).
When a permutation is applied to a list, its elements are ordered in the same order as the numbers in t... |
Your task make a bot that plays Atomas, with the highest score.
How the game works:
The gameboard starts with a ring of 6 "atoms", with numbers ranging from 1 to 3. You can "play" an atom between two atoms, or on another atom, depending on the atom itself.
You can either have a normal atom, or a special atom.
The norma... |
Introduction
A decimal is terminating if it has a finite number of decimal digits. For example, 0.4 (2/5) is terminating because it has one decimal digit.
A decimal is purely periodic if it has an infinite number of decimal digits and has no decimal digits before its repetent (the part of the decimal that repeats.) For... |
Given positive integer n < 10, create a 2 dimensional matrix where each location is filled with its x and y index (starting from the top left).
For example:
Input: 2
00 10
10 11
Input: 3
00 10 20
01 11 21
02 12 22
Once the grid is created, randomly fill each index. This can be with an 'x' or any other way to denote a... |
Write a program or function that takes in a positive integer N, and outputs an N×N pixel image of Google's "G" logo according to this* construction:
For example, if N is 400, a 400×400 pixel logo should be output, with correct dimensions and colors:
It should look accurate regardless of how large or small N is. e.g... |
Challenge: Write a piece of code that only runs when the code is not being altered. If you change anything, the code should detect this and deny running. Of course, it should not be possible to just alter the detection mechanism (since this is a change in itself).
|
I was walking through a pumpkin patch the other day for a birthday party, and noticed the pumpkin vines making a nifty pattern, with whirls, loops, and offshoots. We're going to simulate that here with some ASCII art.
(())
\
p--q p-----q
/ \ / \
(()) b--d (())
Vine ... |
Write a program or function that takes in positive integers a, b and c, and prints or returns a/b to c decimal places, using the operations +-*/% [add, subtract, multiply, divide, modulate] on the positive integers: you can use all that your language allows, but not on floating point numbers. The range of a,b,c would b... |
Task
Given a non-empty string of lowercase ASCII letters a-z, take its first character, and:
Surround it with a square of copies of the second character,
Surround that with a diamond of copies of the third character,
Surround that with a square of copies of the fourth character…
…alternating between square and diamon... |
An 'Even string' is any string where the parity of the ASCII values of the characters is always alternating. For example, the string EvenSt-ring$! is an even-string because the ASCII values of the characters are:
69 118 101 110 83 116 45 114 105 110 103 36 33
And the parities of these numbers are:
Odd Even Odd Even Od... |
The Halloween is upon us, and I haven't decorated my house yet, so I gonna need your help to do this task
Input
The input will be a list of 4 digits numbers, where each digit represent a portion of decoration:
EMBU
||||
|||+-upper decoration
||+-bottom decoration
|+-mouth/nose
+-eyes
Eyes:
0 - °
1 - ¯
2 - -
3 - ^
4 - ... |
Inspired by Bake a slice of Pi
Challenge
Given input 3 <= n <= 100 and 3 <= y <= n, construct an n x n matrix of the decimal portion of pi (14159...), starting in the top left. Then, take the upper-right triangle of size y x y and concatenate it together. Output the resulting number.
For example, for input n = 5, y = 3... |
World Time Conversion
Challenge:
Given an initial clock time in UTC and a list of countries: for each country in the list, output the local time it is in that country based on the initial time. In cases where a country is big enough to have multiple local time zones (like the United States), you may output any valid l... |
The Cashier's Algorithm is an algorithm for making change in the minimal number of coins that works quite well for most currency systems. However like most greedy algorithms it is not without its flaws. If a currency system is set up just right (or just wrong) there are certain values in which the Cashier's Algorithm... |
Related
Explanation
Given a string such as DCBA, convert it to ASCII ordinals, such as 68 67 66 65. Then, take the differences between each value, eg 67 - 68 = -1, 66 - 67 = -1... giving -1 -1 -1 Now as long as there is more than 1 left over value, repeat getting the differences.
For a 3 letter string, your pathway sho... |
Input:
A positive integer n which is 1 <= n <= 25000.
Output:
In this sequence we start with the decimal number 1/n.
Then we take the sum of digits up until the n'th digit after the comma (1-indexed); followed by the sum of digits up until the (n-1)'th, then (n-2)'th, etc. Continue until n is 1.
The output is the sum ... |
This should be a fairly simple challenge.
For an array of numbers, generate an array where for every element all neighbouring elements are added to itself, and return the sum of that array.
Here is the transformation which occurs on the input array [1,2,3,4,5]
[1,2,3,4,5] => [1+2, 2+1+3, 3+2+4, 4+3+5, 5+4] => [3,6,9,12... |
Referencing xkcd 1688:
Your task is to deduct the age of a map by asking the user questions. These question must be exactly the same as in the xkcd guide, except from the capitalisation and additional newline(s). Additionally, you should give the user some options to choose from, which don't have to be in the order as... |
A positive integer may be represented in an integer base \$1 \le b < \infty\$.
When converted to that base it has some number of distinct digits.
Any positive integer in base \$1\$ has \$1\$ distinct digit.
Most positive integers in base \$2\$ have \$2\$ distinct digits, the exceptions being those of the form \$2^n - 1... |
In Javascript you can recover the complete language using only the symbols ()[]!+. Here's the basics:
false => ![]
true => !![]
undefined => [][[]]
NaN => +[![]]
0 => +[]
1 => +!+[]
2 => !+[]+!+[]
10 => [+!+[]]+[+[]]
Array => []
Number =>... |
Given an ASCII string, output the exploded suffixes of it. For example, if the string was abcde, there are 5 suffixes, ordered longest to shortest:
abcde
bcde
cde
de
e
Each suffix is then exploded, meaning each character is copied as many times as its one-indexed location in that suffix. For example, exploding the suf... |
Goal
Generate (N) random line segments of uniform length (l), check if they cross the equidistant (t) parallel lines.
Simulation
What are we simulating? Buffon's needle. Smooth out the sand in your sandbox, draw a set of equally spaced parallel lines (call the distance in between t). Take a straight stick of length l a... |
Write a program or a function that outputs the integer number of answers this question has. Your solution should still work as more answers are added.
Languages that run in a browser may be run from the js console while on this page. Otherwise, you'd probably have to download this page. Multi-language solutions, e.g. w... |
In one of our projects at work, we recently discovered a particularly large method for generating a 6 character string from a 15 character alphabet. A few of us claimed "I bet we can get that in one line" which started a little internal game of code golf.
Your task is to beat us, which I have no doubt won't take long!
... |
Inspired by this question on AskUbuntu.
Your job is extremely simple. Take the PATH environment variable (echo $PATH) and export it such that each entry (separated by the : character) is on its own line.
For example, if the PATH is /bin:/usr/bin:/usr/local/bin, your program should output:
/bin
/usr/bin
/usr/local/bin
... |
The 3x3 Hexa Prime Square Puzzle
Introduction
We consider 3x3 squares of hexadecimal digits (from 0 to F) such as:
2 E 3 1 F 3
8 1 5 7 2 7
D D 5 B B 9
We define a 3x3 Hexa Prime Square (HPS3) as such a square for which all hexadecimal numbers read from left to right and from top to bottom are odd primes (i.e.... |
A standard (but disputed) test of self-awareness is the mirror test: An animal is considered self aware if it can recognize itself in the mirror.
Your task is to write a program that is self-aware according to this test. More exactly:
The program reads input in whatever form is suitable for your language.
If the input... |
Do you have any tips for code-golfing in 05AB1E, a golfing language created by Adnan?
Your tips should be at least somewhat specific to 05AB1E.
Please post one tip per answer.
|
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 at all. Despite this, is... |
Using the the ten inferences of the Natural Deduction System prove DeMorgan's laws.
The Rules of Natural Deduction
Negation Introduction: {(P → Q), (P → ¬Q)} ⊢ ¬P
Negation Elimination: {(¬P → Q), (¬P → ¬Q)} ⊢ P
And Introduction: {P, Q} ⊢ P ʌ Q
And Elimination: P ʌ Q ⊢ {P, Q}
Or Introduction: P ⊢ ... |
Consider a regular grid, where each cell has integer coordinates. We can group the cells into (square-shaped) "rings" where the cells in each ring have the same Chebyshev distance (or chessboard distance) from the origin. Your task is to take such a cell coordinate and rotate that cell by one position counter-clockwise... |
This is a challenge inspired by Chebyshev Rotation. I suggest looking at answers there to get inspiration for this challenge.
Given a point on the plane there is a unique square (a rectangle with equal sides) that is centered on the origin and intersects that point (interactive demo):
Given a point p and a distance d,... |
The idea is simple. You've to create a "visualised" letter-replacement, by providing 3 strings (input can be comma separated, separate inputs, or as an array). The first segment is the word you want to correct, and the second segment is the letters you want to replace, and the third segment is the replacement for the l... |
You must produce a function which nests a string s inside an array, n times
>>> N("stackoverflow",2)
[['stackoverflow']]
Parameters:
s - An ascii string
n - An integer >= 0
Rules
Shortest code wins.
The output will be a nested array, list or tuple (or similar type based off an array)
Test Cases
>>> N("stackoverflo... |
Connect Four is a game where two players take turns to drop disks into columns of a vertically mounted grid, and attempt to connect four disks orthogonally or diagonally. When a column is chosen, the disk falls to the lowest empty position in that column, so any game may be completely specified by the size of the grid ... |
Input into your program a black and white image. (png, jpg, etc)
Convert the image to a 2D matrix of pixels, where each index is the grayscale value of the image.
Take each index of the matrix and average the 8 pixels around it. Then replace that index with the average.
For example if you had:
120 80 60
20 10 30
40 ... |
(Note: This is a spin-off of my previous challenge Find the Swirling Words!)
Definition of Infinity Word:
If you connect with curves all the characters of an Infinity Word on the alphabet (A-Z) you obtain the infinity symbol ∞ like in the diagrams below.
All the even connection must be down, all the odd connections mu... |
Background
Here is a Halloween related challenge.
As you may have seen from my last challenge I quite like what I term as ascii art animations, that is not just draw a pattern but draw a pattern that progresses. This idea came to me after I was asked a couple of years ago to liven up a (rather dull) presentation by mak... |
In the game Yahtzee, players take turns rolling 5 6-sided dice up to three times per turn, possibly saving dice between rolls, and then selecting a category they wish to use for their roll. This continues until there are no more categories (which happens after 13 turns). Then, players' scores are tallied, and the playe... |
Given a list of N non-negative integers, output those numbers with each left-padded by spaces to a length of N. (Alternatively, return a character/string list.) You may assume that N is greater than or equal to the number of digits of the largest number in the list. Trailing spaces are allowed in the output.
You may al... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.