instruction stringlengths 34 53.1k |
|---|
Task
The user inputs a sentence - words only. Any input other than letters or spaces, including integers and punctuation, should throw an exception: "Sentence must only use letters".
The output has a pattern, where some
words are reversed and others words are normal.
The pattern starts as
a normal word, the next two ... |
Write a program that takes an input string of length 2 or more characters and adds the string ~BOO!~ (that string has a leading and ending space) in a uniformly random spot in the string that is not on either end.
Disallowed sample inputs: 2 or (an empty input)
Disallowed sample outputs: Hello ~BOO!~ or ~BOO!~ H... |
A current internet meme is to type 2spooky4me, with a second person typing 3spooky5me, following the (n)spooky(n+2)me pattern.
Your mission is to implement this pattern in your chosen language. You should write a program or function that takes a value n (from standard input, as a function argument, or closest alternati... |
Question
You have a 50 by 50 character array. Each cell has an arrow pointing in any one of four directions. No cell is empty. On entering a cell, you must exit it in the direction specified by the arrow. The arrow may also point in the same direction you came from, resulting in a dead end.
You may start from any cell ... |
Intoroduction
If you've ever been to Epcot at Disney World, you've probably been to the world showcase: a lake surrounded by various country-themed locations. One thing that's always bothered me about it is that the countries don't appear in the order you would run into them around the world. There are officially eleve... |
Proto space invaders
This is a graphical output challenge where the task is to give the shortest code per language.
Task
Your code should allow the user to move the following alien around the screen/window.
Your code can simply load it from a local file. Feel free to convert it to another standard image format or e... |
Your challenge is to write 5 different full programs for the 5 following tasks:
Print Hello, World!.
Given an input on STDIN, output the factorial (you can assume that the input is an integer ≥ 0).
Given an integer N, calculate the sum of the primes ≤ N.
Given an input on STDIN, output the letters used in the input.
F... |
Well... there are 59 (now 60) questions tagged sorting, but no simple quicksorts.
That must be fixed.
For those unfamiliar with quicksort, here is a breakdown, courtesy of Wikipedia-
Pick an element, called a pivot, from the array.
Reorder the array so that all elements with values less than the pivot come before the... |
Write a program that generates a sequence of numbers starting with zero and then 100 random integers between -9 and 9.
That sequence will be displayed like a roller coaster.
Any increasing number in the sequence will go up and any decreasing number will go down
Sample sequence:
0 1 8 5 -1 -5 7 1 3 3 4 6 9 -2 ...
Sampl... |
Given the number of vertices N of a convex polygon and each of their (x, y) calculate the polygon's area. vertexes are in clockwise order
You must handle all N <= 45 ,-600 <= x,y <= 600, and your answer must be accurate to at least 2 decimal places.
Example:
3
1 6
1 2
-4 2
The area is 10.00.
This is code-golf, fewe... |
cat goes "Meow"
We are all familiar with the concept of a cat program. The user types something in, it is echoed back to the user. Easy. But all cat programs I've seen so far have missed one fact: a cat goes "Meow". So your task is to write a program that copies all STDIN to STDOUT UNLESS the input is cat, in which ca... |
Design a random number generator where the i th number has i% chance
of occurring for all 0 < i < 14. 0 should have exactly 9% chance of
occurring. The seed for the generator should be the system time.
You cannot use a pre-defined function for random number generation.
Basically 1 has 1% chance of occurring, 2 ... |
Is this Q too easy to ask, or has it just never been thought of?
Generate a random number, either 0 or 1 using a program
You may use a pre-defined function. The code must be executable. (It can't be just a function that requires more code to execute.) Randomness of the output will be verified by showing that it is no... |
Given two lists of numbers, a source and a pattern, reorder the source to match the relative ordering of the pattern. Any two entries of the reordered source should compare the same way as the entries at those same positions of the pattern.
For example, the input
s = [-5, 9, 4, 13, 11, -6, 0]
p = [7, -4, 1, -8, 4, -3, ... |
There is a game I like to play. It happens on a grid of finite size (but it's wrapped, like a sphere). On that grid, a random (integer-only) point is selected. Then, I, the user, am prompted for a coordinate input. If my input matches the random point exactly, I am told that I have won. Otherwise, I am told the point-w... |
Print or return these lyrics:
Dea Mortis, iuravi
Carissimam servaturum.
Dea Mortis, servabo
Ut tempora recte ducam.
Etsi cor in Chaos,
Aut Fortuna bella ferat,
Occurram et obviam ibo.
The line break must be preserved, and trailing newlines are allowed.
+20% if you omit the end-of-line punctuation, +30% if you omit al... |
Introduction
Given an ASCII tower and the force of the wind, write a program or function to determine if the tower will balance or which way it will fall.
For example the first tower balances but the second falls over toward the left.
# # # #
### ###
### ###
# # # #
... |
Your task is to create a program that will, given an input image, create an output image of the same size, where all pixels are ordered by hex value.
Your program may:
Sort the pixels from left to right and then down or first sort down in columns and then right. In any case, the top left pixel is the smallest, and the... |
Valve's KV file format is as follows (in pseudo-EBNF):
<pair> ::= <text> <value>
<value> ::= <text> | <block>
<text> ::= "\"" <char>* "\""
<block> ::= "{" <pair>* "}"
The parsing starts on <pair> state. Whitespace is allowed anywhere, but is only required between two consecutive <text> tokens ("a""b" is invalid, but "... |
Your task is make program that do following:
You should take number. (Positive, negative, fraction is possible input)
If it is negative, you reverse the quine. and negate that number (Become positive)
Then you repeat <integer part of the input number> times and print first <floor(fraction part of the input number*leng... |
Input
A list of between 1 and 255 positive integers (inclusive), each in the range 1 to 232 - 1 (inclusive).
Your input format does not need to be identical to the test cases.
Input without leading zeroes is required to be accepted.
Input with leading zeroes is not required to be accepted.
You may use whatever delimit... |
Write a program that takes two integers as an input; the first can be any integer and the second is less than or equal to the number of digits in the first number. Let these numbers be a and b respectively.
The program will do the following
Concatenate a minimal number of 1s to the end of a so the number of digits in ... |
The world is a five by five array of cells. It wraps on all sides. It can be visualized like...
XXXXX
XXXXX
XXOXX
XXXXX
XXXXX
You are an O. You love to travel the world, and you do so according to the following rules (let C be the current day):
On prime days, you feel nostalgic. Return to where you started yesterday... |
A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:
Gets a number (either 0 or 1) from STDIN.
If that number is 0, print out 0 and terminate.
If that number is 1, print out 1 forever.... |
Introduction
In this challenge, you are given a list of nonnegative floating point numbers drawn independently from some probability distribution.
Your task is to infer that distribution from the numbers.
To make the challenge feasible, you only have five distributions to choose from.
U, the uniform distribution on th... |
Write a program that takes 2 strings as input, and returns the longest common prefix. This is code-golf, so the answer with the shortest amount of bytes wins.
Test Case 1:
"global" , "glossary"
"glo"
Test Case 2:
"department" , "depart"
"depart"
Test Case 3:
"glove", "dove"
""
|
Objective: Given a positive integer n:
If n is odd, output the list of n numbers closest to 0 in increasing order
If n is even, output a Falsey value.
Test cases:
5 -> [-2,-1,0,1,2]
4 -> false (or any Falsey value)
1 -> [0]
Reference implementation
function update(){
var num = +document.getElementById("yield")... |
The barbells at my gym look like this:
=========[]-----------------------[]=========
They can hold plates of five different sizes, 2.5 pounds, five pounds, ten pounds, 25 pounds, and 45 pounds:
.
. ! |
. ! | | |
| | | | |
' ! | | |
' ! |
'... |
Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.
Sorry it's late; I realized 90% of the way through writing out a different idea that it was a duplicate.
My family is rather large, so we eat a lot of food. We usually need to double, triple, or even quadruple recipes to make en... |
Introduction
Write a program or function that adds a drop capital to a paragraph. The program will input the text to format, the column width, and the number of lines to drop the capital. The drop capitals look like this:
Lines: 2 3 4
Drop capital: A| A.| A..|
~' ..| ...| e... |
Lisp programmers boast that Lisp is a powerful language which can be built up from a very small set of primitive operations. Let's put that idea into practice by golfing an interpreter for a dialect called tinylisp.
Language specification
In this specification, any condition whose result is described as "undefined" may... |
Write a program or function that takes in three integers, a width w, a height h, and a step count s. You will be drawing a non-self-intersecting random walk s steps long on a 5*w by 5*h pixel image where every 5 by 5 pixel cell is either empty (pure beige) or one of these twelve simple "pipes":
The image above is enla... |
Let \$\mathbb{B} = \mathbb{Z}_2 = \{0, 1\}\$ be the set of booleans. A symmetric boolean function in \$n\$ arguments is a function \$f_S : \mathbb{B}^n \to \mathbb{B}\$ that checks if the number of its true arguments is in \$S\$, i. e. a function \$f_S\$ such that
$$f_S(\alpha_1, \alpha_2, \ldots, \alpha_n) = \left(\su... |
The Challenge
Given a valid regex, output a regex that that matches the same set of strings, but reversed.
The Task
This challenge uses the most basic regex operations: ^, $, ?, +, *, [], {}, |. There's no such thing as capture groups or any of that complicated stuff. Special characters can be escaped.
Sample Input/O... |
You have n coins which each weigh either -1 or 1. Each is labelled from 0 to n-1 so you can tell the coins apart. You have one (magic) weighing device as well. At the first turn you can put as many coins as you like on the weighing device which is able to measure both negative and positive weights and it will tell yo... |
Write a program that takes as its input a string consisting of printable characters (ASCII 20-7E) and an integer n in [2,16] and performs the following modification to the string.
Each character in the string is converted to its ASCII code (the examples given are in hexadecimal, though base 10 is also acceptable).
The... |
One nice property of a Turing-complete language is that it can be used to write any program, up to and including the simulation of the entire Universe.
Your job is to do exactly that: write a program which simulates the Universe.
Note: although I don't doubt you'll be able to accomplish this task, nowadays I don't hav... |
Create a program, that outputs a hello world string ("Hello world", "Hello, World" etc.), and source code. Output is written to stdout or equivalent. Hello world string is embedded in the source code.
For example, the output for might be
(some source code here)hello world(some source code here)
When the output is comp... |
3var is a variant of deadfish which uses three variables called A, B and R.
A and B are accumulators, while R is used as a result variable.
In this code-golf challenge, you need to make an interpreter for a stripped-down version of this language.
Required Commands:
i Increments A
d Decrements A
s Squares A
p ... |
The Interview: The Front Nine
This is the first of a series of challenges inspired by programming job interview questions.
You walk into the office where your potential future boss sits. "Come on in and sit down", he says. You nervously sit down, making sure your snappy yet professional attire is free of wrinkles. He a... |
Can you think of a regular expression that does not match itself?
|
Given an input date, your entry will output the full list of supported versions of the Ubuntu Linux distro on that date.
The full list of all releases is as follows:
Version Code name Release date Supported until
4.10 Warty Warthog 2004-10-20 2006-04-30
5.04 Hoary Hedgehog 2005-04-08... |
In a preference ballot there are many ways to decide who won. One of which is the Borda count method, where we give everyone point based on their places on the ballot.
For example, in these results:
10 5 7 2
_____________
1 a d a c
2 b a d b
3 c c b a
4 d b c d
The results are
1: a : 87
2: d : 60... |
In Vernor Vinge's excellent and fascinating book A Deepness in the Sky
(which, by the way, I highly recommend1), the Qeng Ho, a culture
that spans various star systems, has no notion of "days," "months," "years,"
etc., and hence has a unique timekeeping system that measures time entirely in
seconds. The most commonly ... |
Reverse and Invert a String
Challenge
In this challenge. You'll be writing a program which will output or return the input, reversed and inverted.
First, each character should be converted to its character code. Then, that should be converted to base-2. Following, that string should be reversed. After, the string shou... |
A Lyndon word is a string that is strictly lexicographically smaller than any of its cyclic rotations. Given a binary string, determine if it's a Lyndon word in as few bytes as possible.
For example, 001011 is a Lyndon word. Its rotations, listed below, are obtained by repeatedly moving the first symbol to the end.
00... |
Write a program or function that takes in a positive integer \$N\$ and a grid of decimal digits (\$0\$ to \$9\$) with width \$W\$ and height \$H\$ (which are also positive integers). You can assume that \$N\$ will be less than or equal to the larger of \$W\$ and \$H\$ (\$N \le \max(W,H)\$).
Print or return the largest ... |
Christmas is fast approaching and along with it, arranging the annual family Secret Santa. I'd like to try and get a head start on this, but making sure couples don't buy for each other keeps causing problems and despite doing this for years there's still the problem that Bob is pretty rubbish at buying gifts for most ... |
Quining has a long history - if you haven't heard of it, click the tag and read up a little on it.
Your Task
Output an infinite series of 1s (with no other spacing [newlines, spaces, etc.]) UNTIL SIGINT (typically CTRL-C) is called. When it is called, output the program source.
Rules
It must be a valid quine:
No rea... |
The infinite Fibonacci word is a specific, infinite sequence of binary digits, which are calculated by repeated concatenation of finite binary words.
Let us define that a Fibonacci-type word sequence (or FTW sequence) is any sequence ⟨Wn⟩ that is formed as follows.
Commence with two arbitrary arrays of binary digits.... |
When you round a number, if the next digit is >= 5 you add 1. For example:
3.1415926535 rounded to 1dp is 3.1
3.1415926535 rounded to 4dp is 3.1416 <-- Note the 5 changed to 6
3.1415926535 rounded to 5dp is 3.14159
3.1415926535 rounded to 9dp is 3.141592654 <-- Note the 3 changed to 4
You challenge is to receive ... |
Define that the natural number p is a +1 prime of the natural number n if p is a prime number and the standard binary representation (i.e., without leading zeroes) of p can be obtained by adding (i.e., prepending, appending or inserting) a single 1 to the standard binary representation of n.
For example, the binary rep... |
Who doesn't absolutely love permutations, right? I know, they are amazing––so much fun!
Well, why not take this fun and make it funner?
Here's the challenge:
Given an input in the exact form: nPr, where n is the pool taken from and r is the number of selections from that pool (and n and r are integers), output/return t... |
You saved the day with your prime sequence code, and the math teacher loved it. So much so that a new challenge was posed to the librarian (a/k/a, your boss). Congratulations, you get to code the solution so the librarian can once again impress the math teacher.
Start with the sequence of natural numbers in base-10, \$... |
Pick six cities or villages, one from each of the populated continents, Asia, Africa, North America, South America, Europe and Australia. The forecasts cover 8351174 places, more than 2 million in the US, 150000 in Pakistan, 10000 in Uganda, and 16 places in the Shefa province in Vanuatu, so I think you'll find a place... |
You have been employed by a data analysis company, and have been appointed the task of finding the average character of a string of characters. However, this company has limited funding for code storage, so your code must be as small as possible.
Task
Write a program or function that takes one string of characters as i... |
Your task is to give three different languages A, B, C, and write two different programs P and Q such that:
P is a quine in language A, but not a quine in B nor C;
Q is a quine in language B, but not a quine in A nor C; and
Q concatenated after P (without any new characters added in between) is a quine in language C... |
Across the alphabet
In this challenge, you have trouble remembering the letters of the alphabet. To circumvent this, you go up and down the alphabet, till you get to the letter.
Because you want your code to be portable, you'll be writing it with letter blocks. You have a limited amount of letter blocks because most o... |
These are raindrops:
! | . " :
These are clouds particles:
( ) _ @ $ &
I want you to verify, when given a block of text, whether or not it is raining. It is raining if, for every raindrop, there is a cloud particle somewhere above it. There must be one cloud particle for every raindrop. Output a truthy or falsy value... |
Write a program or function that:
takes in a string from stdio or arguments
replaces all occurrences of true with false and false with true
reverses it, but does not reverse true and false
returns or prints result
Examples (left side is input):
"true" "false"
"2false" "true2"
"tr... |
Lots of people like to play music for fun and entertainment. Unfortunately, music is pretty difficult sometimes. That is why you're here!
Task
It's your job to make reading music much easier for those struggling with it. You need to write a program or function that takes as input a musical staff, and outputs the names ... |
Write a program that accepts a single lowercase word as input and outputs the number of pairs of letters that have the same number of letters between them in the word as in the alphabet.
For example, in the word 'nature', we have 4 pairs:
nr: since there are three letters between them inside the word (a, t, u) and thr... |
In a steam-punk multidimensional world, our boss wants to affix printed index labels to each drawer in our conglomerate's multidimensional file cabinet.
The boss wants to typeset the entire label sheet as a single form, using a font bought only for this purpose, so we have to order the sorts (metal symbol pieces). Sinc... |
Anyone remember these things?
Your challenge today is to make the shortest program that involves your pet growing into 1 of at least 7 different creatures.
Your creature will grow into different forms depending on a random percentage from an RNG and the name you give it (from STDIN or equivalent for your language) a... |
Blade is a PHP templating engine. For this challenge, you only need to implement a modified version one feature -- text replacement.
Challenge Description
Given an input file and a map of keys to their replacements, write an interpreter that reads through the file to find double open braces ({{) followed by a key, foll... |
Write a program or function that takes in a string only containing the characters ^ and v (you can assume there will be no other characters). Read from left to right this string represents the sequence of mouse clicks a single user made while viewing a Stack Exchange question or answer for the first time.
Every ^ repre... |
You're playing TF2, and you want to make a bot that will just put voice commands into the chat box. Typically, to "call" a voice command, one would press a key (Z, X, or C) and a number (1-8) to create an audio dialogue. Here are the text equivalents of the audios displayed when pressing these keys:
Voice Menu 1
Defaul... |
Write the shortest program that takes one input (n) from STDIN (or equivalent) and outputs a simple incrementing function with one argument (x) that returns x + n but the function must be in a different language. Pretty simple!
This is code-golf, normal rules apply, shortest program wins.
Example: ><> to Python (Ungolf... |
Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of \$N\$ characters, where \$1 \le N < \text{program length}\$.
For example, the three character Python 2 program
`8`
is a pristine program (thanks, Sp) because all the... |
Fibonacci + FizzBuzz = Fibo Nacci!
Your challenge is to create a Fibo Nacci program!
A Fibo Nacci program outputs the first 100 Fibonacci numbers (starting from 1).
If the Fibonacci number is divisible by both 2 and 3 (i.e. it is divisible by 6), then output FiboNacci instead of the number.
Otherwise, if the Fibonac... |
Executive summary
Given input k, find a partition of integers 1 to n into k sum-free subsets for the largest n you can within 10 minutes.
Background: Schur numbers
A set A is sum-free if its self-sum A + A = { x + y | x, y in A} has no elements in common with it.
For every positive integer k there is a largest integer ... |
Write a program or function that takes no input but prints or returns a constant textual depiction of a rectangle made of the 12 distinct pentominoes:
The rectangle may have any dimensions and be in any orientation, but all 12 pentominoes must be used exactly once, so it will have area 60. Each different pentomino mus... |
Your Task
Write a program using ASCII characters. Five alphanumeric (0-9, A-Z, a-z) characters will be inserted at random into your program's source code. Your task is to detect and output these characters inserted into your program.
Conditions
Your code cannot use any form of backup file.
Your code may produce any un... |
Introduction
In this challenge, your task is to write a program that decides whether two given trees are isomorphic.
A tree means a directed acyclic graph where every node has exactly one outgoing edge, except the root, which has none.
Two trees are isomorphic if one can be transformed into the other by renaming the no... |
In my Economics class, my friends and I like to come up with ways to rearrange the digits in the date (in MM/DD/YY) format to create a valid mathematical equation. For the most part, we are allowed to use addition, subtraction, multiplication, division, parentheses, and exponentiation in addition to concatenation.
Your... |
Calculate a product or ratio of SI units.
For example, kg m / s s (kilogram-meter per second squared) should return N (newton).
The input will always be either:
A list of symbols for SI units, space-separated (representing a product) or
The above, /, and the above (representing a ratio).
The input will never contain ... |
Challenge
Given a binary number as input through any means, "simplify" the number using a full program or a function.
Input
[binary]
binary is a number in binary that is over 0.
Output
Take the input, convert it to base 10 without using a builtin, then if that number contains only 1s and 0s, convert it into a base 1... |
Introduction
Write a complete program that rotates a rectangular block of ASCII characters 90 degrees clockwise. When the program itself is rotated 90 degrees clockwise, it rotates a block of ASCII characters 90 counterclockwise.
Rules
You many not use built-ins that rotate or transpose matrices. For example, in MATLA... |
You are given a partially filled Connect 4 grid (7x6).
O X
O X
X O X O O
X O X O X X
O X X X O O X
O O O X X O X
(Input can be given as a 1D or 2D array and as letters or numbers, etc.)
Assume that
X started the game.
Nobody has won yet.
Players may not have played well until now, but now... |
Given a positive integer k > 1 and a non-negative integer i, generate a k-tuple (or k-dimensional vector) of non-negative integers. For every k, the map from ℕ to ℕk, must be bijective. That is, every input i should produce a different tuple, and every possible tuple must be produced by some input i.
You may write a pr... |
Welcome to my first code-golf challenge! :) Let's hop right into it.
Challenge:
Given two floating point vectors, O (origin) and T (target), you have to create a program to print the values L and R to STDOUT.
O is one corner of the square
T is one corner of the square that is located opposite to O
L is the 2D point (c... |
Keep Talking and Nobody Explodes is a local multiplayer game where one player has control over a virtual "bomb", and has to be guided by another player, the "expert", who has access to a bomb defusal manual. One of the modules to be disarmed in the game is the keypad module, which is what we'll be dealing with in this ... |
Today, November 11, 2015, is Veterans Day in the United States. "Taps" is the bugle call played at U.S. military funerals:
("Taps" on SoundCloud from vtmiller)
It is a simple melody, only twenty-four notes long and using only four different notes. Here is the sheet music:
(source)
Challenge
Write a program or funct... |
Your task is to write a program that takes an input image and run it through edge-detection to become an output image.
The edge-detection works as follows (if unclear, see sobel edge detection):
The value for a pixel is the total brightness of a pixel, so if it is in color, you will need to convert it to grayscale fir... |
Calculate the p-adic norm of a rational number
Write a function or a program, that takes 3 integers m,n,p (where p is a positive prime) as input, that outputs the p-adic norm (denoted by |m/n|_p) as a (completely reduced) fraction. Fermat is known to have only very small margins, but what is rather unknown is that he o... |
The Task
I guess everybody loves automatic code generation and saving some time during work. You have to create a lot of classes and members during the day and you don't want to create all those getters manually.
The task is to write a program or function, that generates getters for all class members automatically for ... |
The task
In this challenge, your task is to write three programs that form a kind of mutual quine-like system.
Let's call the programs A, B and C.
If one of the programs is given the source of another program as input, it shall output the source of the third program.
For example, if A is given B as input, it outputs C.... |
You must use one language to write programs that perform the following nine tasks, in any order you want.
Convert an inputted number from base 10 to base 36.
Sample input: 1000
Sample output: RS (output must be upper case)
Convert each character in a string to its base 10 decimal ASCII codes and print the codes con... |
You sit at home, rubbing your hands in a most evil fashion. This time, I'll be able to set the community A-SPIN! I'll merely claim that I have proven this problem (which is of no doubt improvable) inside this book here… You open to the first relevant page. You scrawl those words…
You are, of course, the evil Fermat! Ha... |
I was recently adding up the ages of myself and my wife and kids and realised that at some point in the not-too-distant future our ages will all add up to exactly 100 years.
Challenge
For an input consisting of a combined (total) age and a list of birth dates, output the date on which the combined ages all add up to th... |
Background
It's late Friday afternoon and you and your friends decide to hit the pub later that evening, but before going to the pub you figure you should have a few beverages.
However, things escalate quickly; your friend Shaddock Pamplemousse won the lottery earlier this week and decided to bring crates upon crates w... |
No, I don't mean \$\phi = 1.618...\$ and \$π = 3.14159...\$. I mean the functions.
\$\phi(x)\$ is the number of integers less than or equal to \$x\$ that are relatively prime to \$x\$.
\$π(x)\$ is the number of primes less than or equal to \$x\$.
Let's say that "not pi" is then \$\bar{\pi}(x)\$ and define it to be the... |
Binary search is an algorithm that looks for an element in a sorted data-structure by constantly dividing the search space in half.
Rosetta Code
A binary search divides a range of values into halves, and continues to narrow down the field of search until the unknown value is found. It is the classic example of a "divi... |
First post here! I recently participated in a small friendly competition and this was one of the questions:
A positive integer whose only prime factors are 2, 3, 5 or 7 is called a humble number.
The first 20 humble numbers are:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27
Write a program of... |
Background
In most reasonable programming languages, it's very easy to rotate the rows or columns of a 2D array.
In this challenge, your task is to rotate the anti-diagonals instead.
Recall that the anti-diagonals of a 2D array are its 1D slices taken in the northeast direction ↗.
Input
A non-empty rectangular 2D array... |
Premise
One night, I was just contemplating on numbers. I found out about something unique about numbers like 7, 10, 12, 13, and more. They are squares of squares! Meaning, that when squared, are comprised of squares themselves. The OEIS calls them Squares which are a decimal concatenation of two or more squares.
Exam... |
Your challenge is to write a program that outputs the color of a given square from the chessboard. This is how a chessboard looks:
You can see that the square a1 is dark, and h1 is a light square. Your program needs to output dark or light, when given a square. Some examples:
STDIN: b1
STDOUT: light
STDIN: g6
STDOU... |
Write a program that counts up forever, starting from one.
Rules:
Your program must log to STDOUT or an acceptable alternative, if STDOUT is not available.
Your program must be a full, runnable program, and not a function or snippet.
Your program must output each number with a separating character in between (a newlin... |
Spherical excess of a triangle
As we all know, the sum of angles of any planar triangle is equal to 180 degrees.
However, for a spherical triangle, the sum of angles is always greater than 180 degrees. The difference between the sum of the spherical triangle angles and 180 degrees is called spherical excess . The task ... |
Given a real number t in (-10^9,13) (not including -10^9 or 13) as input, output Γ(t), also known as the Gamma function, which is defined as follows:
You may not use a built-in Gamma function to solve this task, nor may you use built-in numeric or symbolic integration functions. Your output should be accurate to 6 sig... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.