instruction stringlengths 34 53.1k |
|---|
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... |
Given an array of numbers, find out how many iterations of averaging* it takes for the average of every element to be no more than 1 higher or lower than the first element (absolute difference between the array's average and the first element is less than or equal to 1).
*Array averaging
To "average" a number in our ar... |
Definitions
Two numbers are co-prime if their only positive common divisor is 1.
A list of numbers is mutually co-prime if every pair of numbers within that list are co-prime with each other.
A factorization of number n is a list of numbers whose product is n.
Task
Given a positive number n, output the mutually co-pr... |
Make a Windows style Loading bar by the following instructions.
(notice that this is different than Loading... Forever)
Your output should start by [.... ].
Every tick, you should wait 100 ms, then move each dots by one character right. if the dot is on the tenth character, move it to the first. Notice that you s... |
Create a progress bar indicating year progress
Your code has to output the percentage of the year already passed form 1st of January of the current year.
You have to display a progress bar and the figure.
Input
You may use builtins to get the current date, if your language doesen't have it you can get date as input but... |
TL;DR: Solve this particular challenge, a robot simulation, by stepping on all of the white pads, and avoiding the gray pads. You can step on a white pad any number of times, as long as you step on each white pad at least once. Solutions in languages like Befunge with a 2D instruction pointer would also be accepted, bu... |
Challenge
Write a program that outputs the lyrics to 99 Bottles of Beer, but instead of "beer", output "fizz" if the number of bottles on the wall is a multiple of 3, "buzz" if it is a multiple of 5, and "fizzbuzz" if it is a multiple of 3 and a multiple of 5. If the number of bottles on the wall is not a multiple of 3... |
Given a linear equation mx+n, return n and m. However, the equation may be in any of the following formats:
5x+2 -> 5 2
5x-2 -> 5 -2
5x -> 5 0
-2 -> 0 -2
x -> 1 0
Here are the formats, where each ? stands for a positive integer written without leading zeroes
?x+?
?x-?
-?x+?
-?x-?
x+?
x-?
?
-?
?x
-?x
x
All of t... |
What general tips do you have for golfing in ///? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to /// (e.g. "remove unnecessary whitespace" is not an answer). Tips for itflabtijtslwi and Lines are on-topic and valid here as well.
Please post one tip per ... |
Implement the Discrete Cosine Transform (DCT). This may implemented as either a function or a program and the sequence can be given as either an argument or using standard input. Your program must be able to handle sequences of any length (assuming a hypothetical version of your language which has no limits on things l... |
Challenge
Given a valid goo.gl shortened link, output the original URL.
Example
goo.gl/qIwi3N would give something like https://codegolf.stackexchange.com/. For input, you can choose to have the https?:// at the beginning, you can choose to have www. before the goo.gl, and you can also choose to get rid of the goo.gl i... |
Take an array which consists of positive integers or arrays, output if it only contains 2s.
Output should be a truthy or falsey value (Sorry if this destroys answers)
Truthy Test Cases
[2]
[2,2]
[[2],[2,2],2]
[]
[[],[]]
Falsey Test Cases
[1]
[22]
[2,2,2,1]
[[1,2],2]
Standard Loopholes Are forbidden.
Default IO rules ... |
Given a string s and a non-negative number n less than the length of s, output the character at the n-th position of s.
0-indexing and 1-indexing are allowed. For 1-indexing, n will be positive and less than or equal to the length of s.
s will consist of printable characters only.
Any reasonable input/output is permitt... |
For those who didn't know, Sigma is a Greek letter which is heavily used in mathematics as the summation sign. Given a string representing an expression depending on \$k\$ that we will denote \$E(k)\$, compute the sum of the results for \$E(k)\$, for each \$k\in\{1,2,3,4,5\}\$. Concisely, you should find \$S\$ such th... |
The Task
In this challenge, your task is to write a program or function which takes in a String and outputs a truthy or falsey value based on whether the first character and the last character of the input String are equal.
Input
You may take input in any way reasonable way. However, assuming that the input is present... |
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.
Hole 8: Shuffle an infinite ... |
Given a positive integer N, your task is to return the number of steps required by the following algorithm to reach N:
Find the smallest triangular number Ti such that Ti ≥ N. Build the corresponding list L = [ 1, 2, ..., i ].
While the sum of the terms of L is greater than N, remove the first term from the list.
If t... |
Suppose we start with the infinite list of prime numbers:
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, ...
Then, we take the absolute differences between each pair of numbers, repeatedly:
[1, 2, 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, ...
[1, 0, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, ... |
Challenge
Given a quark composition of a particle as input, output the corresponding hadron's name.
Quarks will be represented by a capital letter and antiquarks by a lowercase letter.
The quarks may be in any order, not necessarily the order given below.
Built-in functions the access data about particles and/or quarks... |
Given a nonzero polynomial with integer coefficients and roots that are on the imaginary and on the real line such that if a is a root then so is -a, return another polynomial with the roots rotated by 90 degrees.
Details
The polynomial can be given in any reasonable format, e.g. as a list of coefficients. The symmetry... |
In graph theory, a Cactus is a connected graph such that any distinct two simple cycles in the graph share at most one vertex.
Here is a Cactus with 3 simple cycles outlined with dashed lines.
The following graph is similar to the one pictured above but is not a Cactus because the two vertices labeled in red are share... |
Take a string, s containing printable ASCII-characters as input, and output its "binary split sum". Need an explanation?
How do you get the binary split sum?
We'll use the string A4 as an example in the following explanation.
Convert the characters to binary, treating each letters as a 7-bit ASCII character
A -> ASCII... |
Definitions
An algebraic number is a number that is a zero of a non-zero polynomial with integer coefficients. For example, the square root of 2 is algebraic, because it is a zero of x^2 - 2.
A transcendental number is a real number which is not algebraic.
Task
You are to choose a transcendental number.
Then, write a... |
Intro
More complex than A square of text since this requires padding and input has unknown data type.
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 tenth problem.
I have explicit permission to post this ch... |
Given a non-empty 2D array consisting of 0 and 1, find the number of squares whose 4 corners are all 1. The squares do not need to be "upright". All the rows are guaranteed to have the same length.
Reasonable input/output methods are allowed.
Testcases:
0001000
1000000
0000000
0000100
0100000
This returns 1.
10101
000... |
I'll start off by saying I checked and checked again that this question should be on topic.
I will also clearly state that this is a tips question about further golfing a certain set of code not a challenge.
I recently answered the following challenge: Scramble words while preserving their outlines:
It is well know... |
Introduction
For my 5th KOTH, I present to you a challenge based on the well-known game Battleship with a few twists. You'll only command one ship, whose type you'll be able to select between the 5 "traditionnal" classes, but you'll be able to undertake multiple actions each turn, including moving! This is played as a ... |
A lawn is defined as a rectangular field with of one character surrounded by two layers of visible whitespace. This means two lines above and twos lines below, and a two space padding on the left (the right has visible whitespace, so you do not need to include it).
|||||
|||||
|||||
A mowed lawn is... |
Results (May 22 2017 21:40:37 UTC)
Master won 18 rounds, lost 2 rounds, and tied 0 rounds
Save One won 15 rounds, lost 3 rounds, and tied 2 rounds
Machine Gun won 14 rounds, lost 3 rounds, and tied 3 rounds
Monte Bot won 14 rounds, lost 3 rounds, and tied 3 rounds
Amb Bot won 12 rounds, lost 8 rounds, and tied 0 rounds... |
Definitions
An algebraic number is a number that is a zero of a non-zero polynomial with integer coefficients. For example, the square root of 2 is algebraic, because it is a zero of x^2 - 2.
The corresponding polynomial is called the minimal polynomial of the algebraic number, provided that the polynomial is irreduci... |
Challenge
Given a plot with broken paths, return the plot with all paths connected in the minimum number of changes.
Explanation
This problem deals with graphs on the Cartesian plane. Every node has 8 possible edges, extending vertically, horizontally, or diagonally. Each direction is represented by a number 0-7 as fol... |
What general tips do you have for golfing in Mini-Flak? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Mini-Flak (e.g. "remove comments" is not an answer).
Please post one tip per answer.
Mini-Flak is just Brain-flak without [], <...> or <> so tips for ... |
Introduction
Unlike English, German is considered to have quite a phonemic writing system. That means that the correspondence between spelling and pronunciation is close. Given any word you aren't familiar with, you would still know how to pronounce it because of the spelling system. This means a computer should be abl... |
Task:
Given sample index, x, calculate sample value f(x) of triangular wave, with period of 4 samples and amplitude 1. Offset can be negative and sample value could be either {0, 1, -1}.
Test cases:
-5 -> -1
-4 -> 0
-3 -> 1
-2 -> 0
-1 -> -1
0 -> 0
1 -> 1
2 -> 0
3 -> -1
4 -> 0
5 ->... |
Given two numbers, print a page with an "X" in the specified location (±10%).
The numbers must be either percentages or fractions of the page's print area dimensions, e.g. [25,75] or ["15%","0%"] or [0.33,1]. You do not have to consider margins. Just remember to state which number is width, and which is height, and whi... |
Warning
The answers to this challenge test for a specific version of the patch that helps stop WannaCrypt/WannaCry attacks. Depending on your operating system, you may have a different patch. The best way to protect yourself is to make sure your PC is fully up to date and be careful when opening attachments and web lin... |
Wikipedia: Zeno's Dichotomy Paradox
An infinite number of mathematicians walk into a bar. The first one orders a beer. The second one orders half a beer. The third one orders a fourth of a beer. The bartender stops them, pours two beers and says, "You're all a bunch of idiots."
Reddit
Print the following series for a... |
The Task
This is my first challenge so apologies if it is very simple! In this challenge, your task is to write a program or function which takes in a list of integers and a desired sum and outputs a truthy or falsey value based on whether the list contains two numbers that can be summed together to achieve the desire... |
Objective
Create a function to reverse string concatenation
Input
Two strings (alphanumeric + spaces), where one should be subtracted for the other.
You can assume that the string to be subtracted will never be larger than the other one.
Output
The result from the subtraction
Subtraction
You should remove one strin... |
Challenge
Given an integer \$Q\$ in the range \$-2^{100} ≤ Q ≤ 2^{100}\$, output the number of digits in that number (in base 10).
Rules
Yes, you may take the number as a string and find its length.
All mathematical functions are allowed.
You may take input in any base, but the output must be the length of the number i... |
The task:
Output a value for x, where a mod x = b for two given values a,b.
Assumption
a and b will always be positive integers
There won't always be a solution for x
If multiple solutions exist, output at least one of them.
If there aren't any solutions, output nothing or some indication that no solutions exist.
Buil... |
Your challenge is to find the file extension of a provided filename:
hi.txt -> txt or .txt
carrot.meme -> meme or .meme
lol (undefined behavior)
what..is..this..file -> file or .file
.bashrc -> bashrc or .bashrc
T00M@n3KaPZ.h0wC[]h -> h0wC[]h or .h0wC[]h
agent.000 -> 000 or .000
You must get the text from the last . ... |
What general tips do you have for golfing in 2 dimensional programming languages? I'm looking for tips which can be applied to code-golf problems and are specific to 2D programming languages, but not specific to any one language (Responses like "remove comments" and "use the M operation" are not answers).
Please post ... |
Challenge
Given the phase of the moon, draw it using ASCII art.
Your program must handle new moon, waxing crescent, first quarter, waxing gibbous, full moon, waning gibbous, last quarter, and waning crescent. Your input will be an integer.
0 -> new moon
1 -> waxing crescent
2 -> first quarter
3 -> waxing gibbous
4 -> f... |
Now that other users have helped Trump build the wall, its time for you to climb it.
This is an ascii art challenge where you need to output a climbing wall with randomly placed holds.
A climbing wall is made up of panels each of which has between 3 and 10 holds and is 5 panels high. Each panel is 4 characters high and... |
In this challenge, you should write a program or function which takes no input and prints or returns a string with the same number of bytes as the program itself. There are a few rules:
You may only output bytes in the printable ASCII range (0x20 to 0x7E, inclusive), or newlines (0x0A or 0x0D).
Your code must not be a... |
The Fibonacci sequence is a fairly well known thing around here. Heck, it even has its own tag. However, for all that, we sure like to stick to our roots of 1, 1, ... (or is it 0, 1, ...? We may never know...). In this challenge, the rules are the same, but instead of getting the nth item in the Fibonacci sequence, you... |
Sona is in her house with her 10 year old daughter. She needs to go to school to bring back another child from school, as school is over at 2 pm. It's hot outside, so she wants to leave her younger child at home.
She gave a bunch of strings to her child to keep her busy while she is gone. She asked her to reverse the w... |
The day of the week and month of the year seem to get a lot of attention but no one seems to care about the week of the year. I believe it's time to change that, so your job is to write a program or function that when given a date outputs an integer between 1 and 53 corresponding to the current week of the year.
For th... |
OUTPUT: The number of seconds since midnight on January 1, 1 A.D., as an integer.
INPUT: None, you must pull the current timestamp yourself.
TASK: This is code-golf, shortest answer in bytes wins.
Standard loopholes apply.
|
(yes, that title was intentional)
Your task is to correct common grammatical mistakes.
You must:
Capitalise the first letter of each sentence, ie the first non-whitespace letter after any of .!? and, additionally, capitalise the first letter of the input
Remove repeating punctuation, such as !!! -> !. Ellipses (...) a... |
Now that I'm thoroughly addicted to Code Golf, it's probably about time that I try to pick up a few golfing languages.
Given that I play almost exclusively in JavaScript, Japt seems like the logical language to start with. I'll be diving into the documentation at the next opportunity I get but, in the meantime, please ... |
There was recently (a few years back) some buzz on programming websites about an implementation of Tetris in 140 Bytes.
...
It turns out that although it is small, it is a simplified version of Tetris, and not even a complete implementation. Only the core logic function fits in 140 bytes of Javascript. To actually run ... |
I have an expression that could be expressed as either of :
a += (A ? B ? x : C ? y : D : D);
a += (A && B ? x : A && C ? y : D);
where A,B,C are expressions of 5-10 bytes each, and x and y are single character literals (3-4 bytes). D is another chain of ternaries (without the branching problem).
I'm getting stuck tr... |
You will be given a two-dimensional array and a number and you are asked to find whether the given matrix is Toeplitz or not. A matrix is a Toeplitz matrix if every descending diagonal, going from left to right, has only one distinct element. That is, it should be in the form:
Input Format:
You will be given a functio... |
I saw this recent Puzzling question:
Add parentheses to make this true
And saw that one answer used a Python script to try all possibilities.
Your challenge is, given an expression (as a string) and an integer, is to make a program that can tell whether you can add parens to make the expression equal the integer.
For ... |
Given a non-empty list of integers, output every possible partitioning of the list where each partition is a non-empty sublist.
So for the list [1, 2, 3, 4] the result is:
[[1, 2, 3, 4]]
[[1, 2, 3], [4]]
[[1, 2], [3, 4]]
[[1, 2], [3], [4]]
[[1], [2, 3, 4]]
[[1], [2, 3], [4]]
[[1], [2], [3, 4]]
[[1], [2], [3], [4]]
The... |
Take a non-empty matrix / numeric array containing positive integers as input. Return, in this order, the sums of the first row and column, then the second row and column and continue until there aren't any more rows or columns.
Suppose the input is:
2 10 10 2 4
9 7 7 2 9
1 7 6 2 4
7 ... |
For this challenge, you must create a programme which takes an integer x and outputs its source x many times.
Rules
This is codegolf, the aim is to golf your programme to have the least amount of bytes
If you submit a function, the function must take x as a parameter and either return or print the entirety of your co... |
A digit word is a word where, after possibly removing some letters, you are left with one of the single digits:
ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT or NINE (not ZERO).
For example, BOUNCE and ANNOUNCE are digit words, since they contain the digit one.
ENCODE is not a digit word, even though it contains an O,... |
You will be given a number x, where 0 <= x <= 2^32 - 1.
You should output a list of numbers in decimal, after recursive splitting in binary format.
Examples:
Example 1:
255 -> 255 15 15 3 3 3 3 1 1 1 1 1 1 1 1
The current list is just 255.
The binary representation of 255 is 1111 1111. Splitting it, we get 1111 and 1... |
In the video game Minecraft, you can obtain beacons and put them on pyramid-like structures to give you special effects, such as speed or jump boost.
Your task is to, given an effect, construct the beacon pyramid required for it.
There are multiple sizes of beacon pyramids, required for different effects. The largest h... |
Write a proper quine whose every rotation is itself a proper quine.
For example, if your source code is abcdef, then:
abcdef would output abcdef
bcdefa would output bcdefa
cdefab would output cdefab
defabc would output defabc
efabcd would output efabcd
fabcde would output fabcde
A rotation "is made by splitting a str... |
A rotation "is made by splitting a string into two pieces and reversing their order". An object is symmetrical under an operation if the object is unchanged after applying said operation. So, a "rotational symmetry" is the fact that a string remains unchanged after "rotation".
Given a non-empty string s consisting of o... |
Write a program or a function that takes two non-empty lists of the same length as input and does the following:
uses elements of first list to get numerators,
uses elements of the second list to get denominators,
displays resulting fractions after simplification (2/4=>1/2), separated by "+"s,
displays "=" and result ... |
Yesterday, I left my sandwich on the table. When I got up today, there was a bite in it... Was it mine? I can't remember...
Problem:
Take a representation of the sandwich and my bite pattern and tell me if it was my bite or not.
Examples:
Example 1:
My bite pattern:
..
.
Sandwich:
#####
.####
..###
Output:
truthy
Ex... |
Find the original challenge here
Challenge
Given an integer, Z in the range -2^31 < Z < 2^31, output the number of digits in that number (in base 10).
Rules
You must not use any string functions (in the case of overloading, you must not pass a string into functions which act as both string and integer functions). You a... |
(heavily inspired by Element of string at specified index)
Given a string s and an integer n representing an index in s, output s with the character at the n-th position removed.
0-indexing and 1-indexing are allowed.
For 0-indexing, n will be non-negative and less than the length of s.
For 1-indexing, n will be posit... |
Based on this: Make me a square!
You need to output this:
####
# # #
### #
# # #
####
Where "#" is replaced with the input.
If you input "A", you should get
AAAA
A A A
AAA A
A A A
AAAA
If you input "&", you should get
&&&&
& & &
&&& &
& & &
&&&&
Leaderboard
Here is a Stack Snippet to generate both a reg... |
*What is a transmogrifier?
In the C programming language, there are formations called digraphs and trigraphs that are two and three characters sequences that evaluate to less common characters. For example, you can use ??- if your keyboard doesn't have ~.
Given text, replace all instances of the following digraphs and ... |
Disclaimer
It is bad practice to draw out your molecules in 2 dimensions because that is not how they are. I chose to do this in 2D because it is easier to explain.
Note that the bond angles are wrong too: the angle in CH4 is 109.5°, not 90° as I said and the bond angle in NH4 is 107°. BHCl2 does have a bond angle of ... |
The Task
Given a natural number as input, your task is to output a truthy or falsey value based on whether the input is a factorial of any natural number. You can assume that the input number will always be in the range of numbers supported by your language, but you must not abuse native number types to trivialize the ... |
Given text, remove leading and trailing whitespace (spaces, tabs, and newlines).
Alternate title: Implement your own string trimming.
Input
ASCII text (printable + spaces, tabs (\t), and newlines (\n)), in whatever format you would like. Carriage returns (\r) are outside of the scope of the input.
Output
The same text ... |
Task
When running the program must show the season according to the host computer's current time.
Rules
The output must be either: Spring, Winter, Summer or Autumn.
The capitalization does not matter.
The output must not contain anything else the the season names stated above.
A season is 3 months and january is in th... |
This is a cake:
_========_
| |
+________+
| |
+________+
| |
+________+
It is 8 wide, 3 tall, and 1 deep.
You must write a program that makes a cake from 3 inputs. The first input controls how many underscores there are in the middle and =s on the top. Here's the first cake with a width of 10 inst... |
Task: Given the area of a triangle, find a Heronian triangle with that area. Any Heronian triangle with the specified area is allowed.
A Heronian triangle is a triangle with integer sides and integer area. By Heron's formula, a triangle with sides lengths a,b,c has area
sqrt(s*(s-a)*(s-b)*(s-c))
where s=(a+b+c)/2 is ... |
A convenient and useful way to represent topological surfaces is with a fundamental polygon. Each side on a polygon matches to another side and can be either parallel or anti-parallel. For instance the here is the fundamental polygon of a torus:
To figure out why this is a torus we could imagine our polygon being a ... |
Challenge
Given a rectangular area arrange a group of rectangles such that they cover the rectangular area entirely.
Input
An integer denoting the height.
An integer denoting the width.
The dimensions of the rectangles consisting
of the following form: axb,cxd,... where a,b,c, and d are integers - any reasonable for... |
Background
The tabs versus spaces war in programming has been going on a long time, basically because spaces are too low-level to have all the properties you'd want for alignment and indentation, but tabs can't be relied upon to work in all contexts (with some programs optimizing the use of tabs for indentation whilst ... |
A demonic number is a positive integer whose decimal representation consists of only 6. The list of demonic numbers starts with 6, 66, 666, 6666.
Given a positive integer, output the nearest demonic number. If there are two, output the bigger one.
Testcases:
n output
1 6
2 6
3 6
6 6
35 6
36 66
37 66
100 66... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.