instruction stringlengths 34 53.1k |
|---|
Write a program to replace all occurrences of "force" with "first" and all occurrences of "first" with "force", keeping the original case for all character positions:
"ForcefoRcefOrcE" -> "FirstfiRstfIrsT"
"FirstfiRstfIrsT" -> "ForcefoRcefOrcE"
The rest of the string must stay unchanged, and so running your program tw... |
Definitions
A subsequence may not be contiguous, e.g. [1, 1, 1] is a subsequence of [1, 2, 1, 2, 1].
An equal subsequence is a subsequence in which every element is equal.
The longest equal subsequence may not be unique, e.g. [1, 1] and [2, 2] are both longest equal subsequences of [2, 1, 1, 2].
Input
A non-empty lis... |
Intro
We have had histograms and counting, but not listing all of them.
Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. This is a language agnostic code-golf edition of this year's sixth problem.
I have explicit permission to post this challenge here from the original... |
This is a CMC (chat mini challenge) that I posted in our chatroom, The Ninteenth Byte, a bit ago.
The Challenge
Given a positive integer x, depending on the last 2 bits of x, do the following:
x & 3 == 0: 0
x & 3 == 1: x + x
x & 3 == 2: x * x
x & 3 == 3: x ^ x (exponentiation)
Input/Output
Single Integer -> Single Int... |
Challenge
Given a user's ID, determine how many times they have hit the repcap.
Specs
On a given day, let's a user has hit the repcap if they had reputation that wasn't gained due to the repcap. Essentially, on any given day, if the user's net reputation change as calculated without any cap was different from their act... |
You must write a program or function that, when given a nonempty string S of N printable ASCII characters†, outputs a program that will exit with exit code C, where C is the ASCII codepoint at position 0 in S. This program you write will additionally output a program P, such that, when run, it exits with exit code C′, ... |
The Australian Apparent Temperature (aka, wind chill) in °C AT is given by this algorithm from the Australian Bureau of Meterology (wp, source):
AT = Ta + (0.33 * e) - (.7 * ws) - 4.0
Where:
Ta = Dry bulb temperature (°C)
e = Water vapour pressure (hPa)
ws = Wind speed (m/s) (at an elevation of 10 meters)
The water ... |
You must take two lists of positive integers as input, let's call these n and m.
You may assume that:
All integers in n are part of m
All integers in m are unique
The lists are non-empty
Challenge: Return the indices of where you find the values in n, in m.
That might be confusing, but I think the test cases will ma... |
Given an integer n, decompose it into a sum of maximal triangular numbers (where Tm represents the mth triangular number, or the sum of the integers from 1 to m) as follows:
while n > 0,
find the largest possible triangular number Tm such that Tm ≤ n.
append m to the triangular-decomposition representation of n.
subt... |
Task
You will be given a string in the input consisting only of the characters from a to z, i.e. the input will match the regex /^[a-z]*$/.
Your output should be a complete program in the same language, whose source code contains the input, and is a proper quine.
Example
Your program would receive the input abc and out... |
Output the device's screen resolution in the specific format of [width]x[height](without the brackets). For example, an output could be 1440x900.
Here's an online tester that you can use to check your own screen resolution.
|
Your task is to write a piece of code that zeros the current cell in the Brainfuck variant that, each cell can contain a signed integer of arbitrarily large magnitude, instead of the normal 0 to 255.
You may assume there are l cells to the left and r cells to the right of the current cell that are initially zero. You p... |
Task
Given a non-negative integer n, output 1 if n is 0, and output the value of n otherwise.
Input
A non-negative integer.
If you would like to accept the string as input, the string would match the following regex: /^(0|[1-9][0-9]*)$/, i.e. it must not have any leading zeroes, except when it is 0.
If you accept a re... |
I'm currently scanning a bunch of handwritten documents and converting them to .txt files. Since I have a terrible handwriting the .jpg->.txt converter converts some of my umlauts to the "normal" letter encased by '
Task
Write a program or a function that:
Is given a string
you can choose any I/O codepage as long as
... |
One of my favorite types of challenges on this site are restricted-source challenges. These challenges impose a computer tractable restriction that the sources of potential answers must pass. I like these challenges so much I have been working on a golfing language designed to win at these challenges for some time no... |
Task
Given an array of positive integers, replace each element with the parity of the sum of the other elements. The array is guaranteed to have at least 2 elements.
Definition
Parity: whether a number is odd or even.
Example
For the array [1,2,3,1]:
Replace 1 with the parity of 2+3+1, i.e. even.
Replace 2 with the ... |
Your challenge is to output this:
https://stackoverflow.com/
https://serverfault.com/
https://superuser.com/
https://meta.stackexchange.com/
https://webapps.stackexchange.com/
https://gaming.stackexchange.com/
https://webmasters.stackexchange.com/
https://cooking.stackexchange.com/
https://gamedev.stackexchange.com/
ht... |
Some text-based rogue-likes don't let you walk into walls, and give you your move back if you try to. Why do that when you can make the player move in the closest valid direction?
The challenge
Write a program of function that, given a direction and a 3 by 3 grid of characters, outputs the same grid after the player ha... |
Introduction
By definition, unique identifiers should be unique. Having multiple identifiers that are the same causes one to retrieve unexpected data. But with data arriving concurrently from multiple sources, it can be difficult to ensure uniqueness. Write a function the uniquifies a list of identifiers.
This is po... |
Task
Given a non-empty array of 0 and 1, halve the lengths of the runs of 0.
Input
An array of 0 and 1. Acceptable format:
Real array in your language
Linefeed-separated string of 0 and 1
Contiguous string of 0 and 1
Any other reasonable format
For example, the following three inputs are all acceptable:
[1, 0, 0, 1]... |
Challenge
Supplied an image, you must determine if the subject of the image is a bird or a plane.
If the image is a bird, your program must output
bird
and if the image is a plane, your program must output
plane
Your program must produce no other output and the testing program will be case sensitive.
Further informat... |
Output terminal dimensions (columns and rows) in any two-number decimal format*. For example, an output could be 80x25.
Inspiration. Prompt.
* Output must have both measures on a single or two consecutive lines, and there may be no more than one leading and/or trailing line of output (optionally followed by a newline)... |
SE will be down/read only today 2017-05-04 at 00:00 UTC until 00:20 UTC.
Your challenge is to output a truthy value if SE is down/read only and a falsy value if SE is not. You may not have any input, and you must use date builtins to determine if SE is down/read only (no actually querying the SE api!) Example output:
1... |
I have trouble remembering everything I have to do when leveling up a D&D character. For whatever reason, one of the things that gives me trouble is figuring out what their new maximum HP value should be. For this challenge, you will write a program or function to calculate the correct value automatically.
Terminology
... |
Challenge
Given the high resolution molecular mass of an organic molecule, output the molecule's molecular formula.
Explanation
The input will be a single number to three decimal places of precision, the relative molecular mass of the molecule.
Here, the molecular mass is defined as the sum of the masses of the atoms i... |
Since tomorrow is the 4th of May, here's a little Star Wars themed post to prepare you mentally to all the bad jokes coming tomorrow.
BACKSTORY
During a session of the galactic senate all the senators are sitting in an n*n grid.
A sudden outbreak of JarJar flu (which lasts forever and causes the infected to speak like ... |
The task
Given any array of integers, e.g.:
[-1,476,578,27,0,1,-1,1,2]
and an index of that array (this example uses 0 based indexing, though you can use 1 based indexing as well.):
index = 5
v
[-1,476,578,27,0,1,-1,1,2]
Then return the nearest number greater than the element at that index. ... |
Write a program (or function) that exhibits four common big O time complexities depending on how it is run. In any form it takes in a positive integer N which you may assume is less than 231.
When the program is run in its original form it should have constant complexity. That is, the complexity should be Θ(1) or, equ... |
At runtime, keep prompting for a line of input until the user inputs something (other than an empty newline), i.e. does not just press Enter or OK. Output or result is neither required nor prohibited.
Pseudo-code 1
myform = new form("GUI")
myform.mytxt = new editfield("")
myform.ok = new button("OK")
repeat
waitfor(m... |
Task
Given a positive integer n, output n+1 if n is odd, and output n-1 if n is even.
Input
A positive integer. You may assume that the integer is within the handling capability of the language.
Output
A positive integer, specified above.
Testcases
input output
1 2
2 1
3 4
4 3
5 ... |
Introduction
Rules of the puzzle:
The puzzle Binary (also known as Takuzu or Subiku) is very simple to understand, and has only a few rules:
Since the name of the game is binary it's pretty obvious, but you can only fill in zeros and ones.
No more than two of the same digit can be vertically or horizontally adjacent t... |
This challenge is very simple:
Given an angle measure in degrees or radians (your choice), output the angle between 0 and 2π non-inclusive [0º, 360º) that is coterminal with it.
Input
A positive or negative angle measure. You can pick if you want to take it in degrees or in radians.
Output
The angle on [0, 2π) that ... |
Your task is to write a program that outputs its own source code in reverse. However, when the reversed code is run, it should output the source code, facing the correct direction.
Example
Say your program is abc. When run, it should output cba. cba, when run, should output abc.
Rules
Your program should follow all the... |
Given a dictionary of 4-letter words that have no repeated characters (from this list of words), you must choose ONE of those words, and output that specific word using the following dictionary of block letters:
.----------------. .----------------. .----------------. .----------------.
| .--------------. || .----... |
Make a program (or a function) that copies the exact text "Hello, World!" to the clipboard, and terminates.
|
Make a Quine.
Seems easy right? Well this quine must output itself plus its first character, which then outputs itself plus its second character, and so on.
This way the quine should in several generations output two copies.
Example:
Lets your code be x. Running it should output x + x[:1]. Running the resulting program... |
Given a list of (key, value) pairs, determine whether it represents a function, meaning that each key maps to a consistent value. In other words, whenever two entries have equal keys, they must also have equal values. Repeated entries are OK.
For example:
# Not a function: 3 maps to both 1 and 6
[(3,1), (2,5), (3,6)]
... |
Explanation of the challenge
Given an input, return what shapes it could be. There are only a couple options.
Square
Triangle
Square
A square is in the following format:
XXXX
XXXX
XXXX
XXXX
So, in this example, the input would be:
16
And the output would be:
1 or "Square"
Triangle
We are only checking for equila... |
Given a positive integer n write some code to take its prime factorization and replace all of its factors of 2 with 3.
For example
12 = 2 * 2 * 3 -> 3 * 3 * 3 = 27
This is code-golf so the goal is to minimize the byte count of your answer.
Test cases
1 -> 1
2 -> 3
3 -> 3
4 -> 9
5 -> 5
6 -> 9
7 -> 7
8 -> 27
9 -> 9
10 -... |
A collection of N dimensional coordinates are provided. An example is below:
{2,3,4}
This can be thought of as a 3 dimensional array with 2x's, 3y's and 4z's; there may be any number of dimensions. In the example, there are 24 total nodes. Each node can be indexed using {x,y,z}. To access the 5th node, the provided in... |
No, not this. And not this either. This question is nothing like those
Write the shortest code to print/return the following output:
/\ /\ /\
/ \ / \ / \
/ /\ \ / /\ \ / /\ \
/ / \ \/ / \ \/ / \ \
\ \ / /\ \ / /\ \ / /
\ \/ / \ \/ / \ \/ /
\ / /\ \ / /\ \ /
\/ / \ \/ / \ \/... |
Note that this is similar to my other challenge, but it is widened to be similar to most challenges (input -> truthy/falsey), instead of asking you all to brute force something. If this makes it a dupe, let me know, but I posted it on Sandbox and asked on chat, and didn't get any negative responses.
Input
Input will be... |
Jill lives in the (magnetic) north pole. One day, Jill decided to go for a walk, travelling in the four directions (north, east, west, south) for some lengths, with the help of a compass. Your task is to find whether Jill ended up where Jill lives, i.e. the magnetic north pole.
Only south is defined at the north pole. ... |
Challenge
Given a the ID for a PPCG user who has existed for at least a month, output the average amount of reputation they gain per month. You can do this by dividing their reputation by the time since their account was created (which you can find on the profile). This should be returned floored; that is, truncate all... |
Your task is to write a function that takes an even-digit integer and compares the 2 halves of the integer. If the sum of the digits in the first half is greater than the sum of the digits in the second half, output a truthy value, otherwise, output falsey.
For example:
12345678
1234 5678
(1+2+3+4)>(5+6+7+8)
10>26
Out... |
Oh no! I'm trapped in a big forest (Okay, not really, but just assume it) and I don't know where I am!
Thankfully, I brought my laptop. But when I searched 'Maps', It said 'No results', and I'm asking this as a last resort.
Please make a program which outputs my location's longitude and latitude in any two number forma... |
What is the shortest way of generating a random string with a given length and with only alphanumeric characters allowed?
example of a random string: with N = 9 output would be aZua7I0Lk
the given length N can be assumed to be always greater than 0
if necessary you can assume 256 as a maximum value for N, but solution... |
Briefing
Given a Fully Qualified Java Class/ Package name, you must shorten it as such:
Each part of the dot separated package will be shortened to its first letter, apart from the last section and the class (if it exists).
package names will be all lower case, and the class (if it exists) will start with a capital let... |
I used to play a game while I was in the car, it consisted in taking the n-1 first numbers of another car plate and use operators and roots on them to get the nth number of the plate.
I could use the following operators and roots :
addition (ex: 1 + 1 = 2)
subtraction (ex: 2 - 4 = -2)
division (ex: 10 / 2 = 5) (Note ... |
I am making a customizable password generator.
But I (for some reason) thought it'd be better to let you guys do it.
Umm.. then?
You only get one integer. That will include all the information about the customization.
The first 4 bits (1,2,4,8) will be used for choosing which charsets will be used.
Each bit correspond... |
A magic square is an n-by-n square grid, filled with distinct positive integers in the range 1,2,...n^2, such that each cell contains a different integer and the sum of the integers in each row, column and diagonal is equal.
Your task is to take an n-by-n matrix consisting of positive numbers, and a placeholder charact... |
Yes is a stack-based language that has a few space-separated instructions:
yes: Push 1 to the stack
no: Push 0 to the stack
what: Push the input to the stack (input is taken at the start of program execution and is the same for the whole execution)
sure: Increment the last item in the stack
nah: Decrement the last item... |
You may know the mathematician von Koch by his famous snowflake. However he has more interesting computer science problems up his sleeves.
Indeed, let's take a look at this conjecture:
Given a tree with n nodes (thus n-1 edges). Find a way to enumerate the nodes from 1 to n and, accordingly, the edges from 1 to n-1 in ... |
Given a non-empty string of lowercase ASCII letters a-z, output that string with each consecutive “run” of the same letter lengthened by one more copy of that letter.
For example, dddogg (3 d’s, 1 o, 2 g’s) turns into ddddooggg (4 d’s, 2 o’s, 3 g’s).
This is code-golf: the shortest answer in bytes wins.
Test cases
aab... |
Wise is a simple bitwise language I designed a while back. It is based around Python's bitwise operations. It has several operations most of these are the same or very similar to the equivalent symbol in Python.
: Duplicate the top of the stack
? Rotate the top of the stack to the bottom
! Rotate the bottom of the s... |
Write a program or function that, given a string, will strip it of zalgo, if any exists.
Zalgo
For this post, zalgo is defined as any character from the following Unicode ranges:
Combining Diacritical Marks (0300–036F)
Combining Diacritical Marks Extended (1AB0–1AFF)
Combining Diacritical Marks Supplement (1DC0–1DFF)
... |
The goal of this challenge is to use Euler's method to approximate the solution of a differential equation of the form f(n)(x) = c.†
The input will be a list of integers in which the nth value represents the value of f(n)(0). The first integer is f(0), the second is f'(0), and so on. The last integer in this list is th... |
Background
While a program is running on a computer, the computer needs to keep track of that program somehow, typically by either copying or mapping the compiled form of the program into memory. (Even interpreted languages do this; a few primitive languages work with source code directly, but in most interpreted langu... |
Generate the following soccer team ASCII art with the least number of bytes possible.
|.| |.| |.| |.| |.| |.| |.| |.|
]^[ ]^[ ]^[ ]^[ ]^[ ]^[ ]^[ ]^[
/~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\ /~`-'~\
{<| 8 |>}{<| 6... |
My father who was a really good APLer and taught me all the basics of APL (and much more), passed away on this day, five years ago. In preparation for 50 Years of APL, I found this patent letter (translated for the convenience of those who do not read Danish) for a handwritten logo. It explains a major reason for APL n... |
This challenge was greatly inspired by this Stack Overflow post.
Challenge
Given a bunch of clients in terms of when they enter a room and when they exit it, determine the period(s) of time when the room has a maximum number of people. The time resolution should be to the minute.
For example, if there are three clients... |
I'm currently cooking us some cup noodles, but we're really sleepy at the moment. They'll be finished in 50 seconds from now, can you wake me up then?
Problem:
Write a program or function that waits 50 seconds of busy waiting (so that you too doesn't sleep) and then outputs at least 1 visible character to wake me up.
B... |
For any positive integer \$k\$, let \$d(k)\$ denote the number of divisors of \$k\$. For example, \$d(6)\$ is \$4\$, because \$6\$ has \$4\$ divisors (namely \$1, 2, 3, 6\$).
Given a positive integer \$N\$, display a "skyline" in ASCII art using a fixed character, such that the height of the "building" located at horiz... |
Given multiple sets, e.g. s1={2,3,7}, s2={1,2,4,7,8} and s3={4,7}, a Venn diagram visualizes each set by a closed curve and set elements which are either inside or outside the curve's perimeter, depending on whether they are element of the set or not. Because all set elements appear only once in the Venn digram, the cu... |
Based on this, but I was asked[1],[2] to do a graphical edition.
Task
Generate a circular display of the text EASIER COMMUNICATION MEANS FASTER CODING MEANS FEWER CODERS MEANS . Any uppercase font goes. The letter tops must face out of the circle. Either the space before FEWER must be at the bottom (6 o'clock) or ... |
Intro
Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. This is a language agnostic code-golf edition of this year's eighth problem.
I have explicit permission to post this challenge here from the original author of the competition. Feel free to verify by following the ... |
Make a program which can fill a 2D space with "pursuit polygons".
The following picture will help you understand better what I mean.
You can also look up "pursuit curves" or mice problem.
You can use any convex n-polygon you like
here are some examples
Triangle:
Square:
Pentagon
notice that for every polygon you ca... |
Today I installed MonoGame and ran the test application, which creates a basic colored window. I was surprised to see that the process was using 32.2 MiB of memory, and I thought it could be improved.
Your challenge is to write a program that creates a 640 by 480 window displaying only black pixels. Whatever program u... |
A Quine is a program which outputs its source when run.
In this challenge, You should make a Fibonacci-quine, a variant of the quine.
What is a Fibonacci-quine?
A Fibonacci-quine is a program, which outputs a modification of the source by the following rule:
The initial source should be ...2.... In other words, the so... |
Challenge
Given an integer, \$s\$, as input where \$s\geq 1\$ output the value of \$\zeta(s)\$ (Where \$\zeta(x)\$ represents the Riemann Zeta Function).
Further information
\$\zeta(s)\$ is defined as:
$$\zeta(s) = \sum\limits^\infty_{n=1}\frac{1}{n^s}$$
You should output your answer to 5 decimal places (no more, no le... |
Write a program which calculates if an inputted monetary value, as an integer, can be represented by a unique combination of coins and/or notes, that meaning the same coin/note cannot be used more than once.
Your program should take a value as input, and can take a list of coin/note values either via input or via your ... |
Your challenge is to print the input, wait any amount of time, print the input, wait twice the time you initially waited, print the input again, and so on. The initial delay must be less than 1 hour, and you must have an accuracy of +/- 5% in the subsequent delays. Other than that, there is no restriction on the delay ... |
In the standard loopholes, the following is forbidden:
Claiming that your answer is written in "MyOwnLanguage", where the command x means "read a sequence of numbers, split them into groups of three, and print the last numbers of those groups where the second number is less than the first"
Here, we are going to do th... |
Task
Given two positive integers:
Draw the rectangle with dimensions specified by the two integers.
Repeat Step 3 until there is no more space.
Draw and fill the largest square touching three sides of the (remaining) rectangle.
Output the resulting rectangle.
Example
For example, our input is 6 and 10.
We draw the ho... |
My dog is called Rex. Every time I scold him, he seems not very impressed and the only times I see him react is when I pronounce his name. If I say
Rex, I told you not to do this! You're making me angry Rex!
all he hears is
Rex, * **** *** *** ** ** ****! ***'** ****** ** ***** Rex!
The challenge : given an input str... |
Disclaimer: No, this is not a joke challenge to reverse a string.
Task
There is only one operation to support: subtraction (-).
You also only have two atoms to support: zero (0) and one (1).
Here, the prefix notation -AB is equivalent to the postfix notation AB-, where A and B are expressions.
Your task is to (recursiv... |
Meta discussion: Is "(The other day) I met a bear" a duplicate?
Your challenge is to output this text:
The other day,
The other day,
I met a bear,
I met a bear,
A great big bear,
A great big bear,
Oh way out there.
Oh way out there.
The other day,
I met a bear,
A great big bear,
Oh way out there.
He looked at me,
H... |
Your task is to, given a map as input, zoom it out or in, depending on the scale. Note that the scale given is the scale by which to zoom out, so a scale between 0 and 1 will actually zoom in.
For example, given the following (badly made) map:
..____....
../OOO\...
..\OO/\...
..........
And a scale factor of 2, you sh... |
Raffaele Cecco is a programmer who produced some of the best video games for the ZX Spectrum computer in the late eighties. Among others, he developed the highly acclaimed Cybernoid and Exolon.
Raffaele is turning 50 on May 10, 2017. This challenge is a small tribute to him, for the happy hours that many of us spent p... |
K-Means Clustering (Wikipedia)
The task here is rather simple, perform a single iteration of a k-means clustering algorithm on a binary matrix. This is essentially the setup task for the main k-means algorithm, I felt the setup might be easier and entice golfing languages to give it a shot as well. The matrix passed to... |
Task
Write some code that can be rearranged into n different programs in n different languages each outputting a distinct number from 1 to n.
No two languages should be the same however different versions of "the same language" will be considered distinct languages, as long as they have different major version numbers.... |
The task
Write a program or function whose input is a list/array X of integers, and whose output is a list of sets of integers Y, such that for each element e in each set Y[i], X[e] = i, and such that the total number of elements in the sets in Y equals the number of elements in X.
(This is basically the same operation... |
Task - The title pretty much sums it up: raise an integer x to power x, where 0<x.
Restrictions:
Use of exponentiation, exp(), ln(), and any other powers-related language built-ins, like pow(), x^x, x**x is forbidden.
You can assume that the given integer fits the limits of the programming language of your choice.
Te... |
This is much more advanced than How to randomize letters in a word and Cambridge Transposition because of the rule about which letters may be swapped with which. A simple regex will not suffice here.
It is well known that a text can still be read while the innards of its words have been scrambled, as long as their fir... |
According to legend, almost everyone is outgolfed by Dennis. If not, they will be.
Now I'm curious if I'm one of those 'almost everyone'.
You will be given a link to an answer in the format of https://codegolf.stackexchange.com/questions/[QUESTION ID]/[QUESTION NAME]/#[ANSWER ID].
Find the length of the code, which we ... |
I know there have been a lot of challenges about "the two best code-golfers in the world", but this one is a bit more unique, being Round 1 in a series of (future) challenges involving the two of them.
Your task is to write a program or function that returns two different non-whitespace ASCII strings, corresponding to... |
Introduction
Yes, it's as simple as that. Download any file from the internet!
Rules
You must use your language's API.
You must output the file you downloaded to STDOUT, the console, a file, etc.
Input should be empty, or the URL you wish to download, but the url must count to byte count..
Good luck!
|
Your challenge is to query the SE API and find out whose rep on PPCG is tied, and output it. If these were all the users on PPCG:
Martin Ender: 10000 rep
Dennis: 10000 rep
xnor: 5000 rep
sp3000: 3000 rep
You should output Martin Ender, Dennis. If these were the only users:
Jon Skeet: 1000000 rep
Martin Ender: 10000 re... |
For those of you who are unfamiliar, Kirkman's Schoolgirl Problem goes as follows:
Fifteen young ladies in a school walk out three abreast for seven days in succession: it is required to arrange them daily so that no two shall walk twice abreast.
We could look at this like a nested 3 by 5 list (or matrix):
[[a,b,c]
... |
Given a string or list, calculate the effects of gravity on that string/list.
The string will be made of 5 characters:
N has a weight of 2
L has a weight of 1
S has a weight of -2
D has a weight of -1
(the 5th character is whatever you want, it means empty space. I use (space) in my examples)
Items with negative we... |
A void list is a list that at no level contains any non-list objects. Or if you prefer a recursive definition
The empty list is void
A list containing only other void lists is void
All void lists have a finite depth.
Here are some examples of void lists (using python syntax):
[]
[[]]
[[],[]]
[[[]]]
[[[]],[]]
[[],[[]... |
Doing code review, I stumbled upon the following code, that tests the status of a checkbox:
if (!isNotUnchecked()) { ... }
I had to brainstorm for 30 minutes to find out what actual checkbox status the code was expecting. Please write me a program that can simplify these silly expressions!
The program should accept a... |
Task
Given one non-whitespace printable character, make a 3x3 square representation of that input. For example, if the input is #, then the output is:
###
# #
###
Rules
The output format is strict, although a trailing newline is allowed. It means that the space in the middle is required, and also that the two newline... |
Challenge
Given a list of integers, show how gravity sort would be done.
Gravity Sort
In gravity sort, imagine the numbers as rows of asterisks. Then, everything falls, and the new rows will be obviously sorted. Let's look at an example:
[2, 7, 4, 6]:
**
*******
****
******
-------
**
****
*******
******
-------
** ... |
Definitions
A perfect square is an integer which can be expressed as the square of another integer. For example, 36 is a perfect square because 6^2 = 36.
A squarefree number is an integer which is not divisible by any perfect square, except by 1. For example, 10 is a squarefree number. However, 12 is not a squarefree ... |
Take a flag, like this one:
-----------------------------
| | |
| | |
|=============+=============|
| | |
| | |
-----------------------------
And a number input: the "wave length"
Say the wave length was 5. Then, every 5 ch... |
Given two lists that contain no duplicate elements a and b, find the crossover between the two lists and output an ASCII-Art Venn Diagram. The Venn Diagram will use a squarified version of the traditional circles for simplicity.
Example
Given:
a = [1, 11, 'Fox', 'Bear', 333, 'Bee']
b = ['1', 333, 'Bee', 'SchwiftyFive'... |
This dear StackExchange site has so many challenges, and so many good answers. But what about the challenges that were never answered?
Task
Write a program or a function that will print a pseudo-random open unanswered (as in, a question with exactly zero answers) challenge from PPCG. All possible challenges should be p... |
Take a matrix of positive integers as input, and output the individual sums of the elements on the diagonal lines through the matrix.
You shall only count the lines that goes diagonally down and to the right. You must start with the diagonal that contains only the bottom-left element, then the length-two diagonal abov... |
In graph-theory a Prüfer code is a unique sequence of integers that denotes a specific tree.
You can find the Prüfer code of a tree with the following algorithm taken from Wikipedia:
Consider a labeled tree T with vertices {1, 2, ..., n}. At step i, remove the leaf with the smallest label and set the ith element of th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.