instruction stringlengths 34 53.1k |
|---|
Gravity Guy is a game where the only user input is a single key that flips the direction of gravity. Given an ASCII art level, determine if it is possible for Gravity Guy to reach the end.
Rules
The initial direction of gravity is down.
The first column of the input will always contain only one #, which Gravity Guy s... |
Write a function to convert CamelCased text to snake_case: FunctionForHTMLManipulation becomes function_for_html_manipulation
The input text will be a single suitable identifier in many languages. It must start with an English letter, then be followed by any number of English letters or digits. No other characters (spa... |
A person has to complete N units of work; the nature of work is the same.
In order to get the hang of the work, he completes only one unit of work in the first day.
He wishes to celebrate the completion of work, so he decides to complete one unit of work in the last day.
He is only allowed to complete x, x+1 or x-1 uni... |
Introduction
You must create a function to convert Greek numerals into Arabic numerals. The input will be a Greek numeral less than 1000 and more than 0. This is the reverse of my previous challenge.
Algorithm
Split input into letters (e.g. ΡΚΓ -> Ρ, Κ, Γ)
Take each letter, and change to character found in table below... |
There is an N x N square of numbers.
All columns increase strictly monotonically from top to down
All rows increase strictly monotonically from left to right
There is exactly one valid answer for each input.
You are given 2N-1 rows of N numbers representing rows or columns in this square. The task is to find the row ... |
In mountaineering terminology, a "14er" is any mountain with an elevation of 14 000 feet or more. However, there is another distinction. For a peak to count as a 14er, it must also have a "geographic prominence" of 300 or more feet. This means that to move from one 14er to another, you must first descend at least 300 f... |
Programming Puzzles and Code Golf has graduated from beta. Soon we will get a custom site design, and with that the reputation boundaries for privileges will go up. A lot of users will lose privileges on the site. So your task is to write a program that tells us how much extra reputation we'll need to keep our privileg... |
Introduction
You are sitting with your coworker, having lunch, and bragging to him/her about the latest and supposedly greatest project you've been working on. Getting sick and tired of your constant showcase of egoism, he/she gives you a challenge just so you'll shut up. Being the egoistic and happy-go-lucky person yo... |
In chess, Forsyth-Edwards Notation, more commonly called "FEN", is a textual way of transcribing boards. It describes each of the board's eight rows (called "ranks" in chess) from top to bottom from White's perspective. The pieces are written as K (king), Q (queen), R (rook), B (bishop), N (knight), and P (pawn). Black... |
Given two polynomials f,g of arbitrary degree over the integers, your program/function should evaluate the first polynomial in the second polynomial. f(g(x)) (a.k.a. the composition (fog)(x) of the two polynomials)
Details
Builtins are allowed. You can assume any reasonable formatting as input/output, but the input and... |
While the binomial coefficient are the coefficients of \$(1+x)^n\$, m-nomial coefficients are the coefficients of \$(1+x+x^2+...+x^{m-1})^n\$.
For example, \$m(3,5,6)\$ is the coefficient of \$x^6\$ in the expansion of \$(1+x+x^2)^5\$.
Write a program/function that takes 3 numbers as input and outputs the corresponding... |
Continuation of this challenge because the author is gone and the question is closed.
What you need to do is create a Boolean parser.
Boolean expressions, in case you haven't heard of them yet, have two inputs and one output.
There are four "gates" in boolean arithmetic, namely:
OR (represented by |) (binary operato... |
Given a list of integers, output the number of permutations of the integers, with indistinguishable permutations counted once. If there are n integers, and each group of indistinguishable numbers has length n_i, this is n! / (n_1! * n_2! * ...)
Rules
Input will be some form of list as arguments to a function or the pr... |
Problem
Create a function that can determine whether or not an arbitrary DNA string is a Watson-Crick palindrome. The function will take a DNA string and output a true value if the string is a Watson-Crick palindrome and a false value if it is not. (True and False can also be represented as 1 and 0, respectively.)
The... |
Taylor series are a very useful tool in calculating values of analytic functions that cannot be expressed in terms of elementary functions, using only information about that function at a single point.
In this challenge, you won't be actually doing any math with them, but merely making string representations of taylor ... |
Introduction
It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.
This is not the same thing. That one is a (closed) not well-explained challenge.
This is not the same thing. That one is about counting up indefinitely.
Challenge
Write a program or function that prints every intege... |
Jolf is a procedural golfing language made by @CᴏɴᴏʀO'Bʀɪᴇɴ.
What tips do you have for golfing in Jolf?
Please post one tip per answer.
These tips should be at least somewhat specific to Jolf, e.g. remove comments is an answer, but not a very good one.
|
Write a program or function that estimates the Shannon entropy of a given string.
If a string has n characters, d distinct characters, xi is the i th distinct character, and P(xi) is the probability of that character occuring in the string, then our Shannon entropy estimate for that string is given by:
For the estimat... |
Input
Your input is a list of single-digit numbers in any reasonable format, including a string of digits.
The input will not be empty.
Output
Your output shall be the input list, but with each maximal run of nonzero digits being reversed.
Example
Consider the input
95883007414830
<---> <---->
where the nonzero runs ... |
A parity bit, is one of the simplest forms of a checksum. First, you have to pick the parity, even or odd. Let's say we pick even. Now, we need a message to transmit. Let's say our message is "Foo". This is written in binary as:
01000110 01101111 01101111
Now, we count the total number of 1's in there, which is 15. Si... |
Write a single line program two or more characters long that contains no line terminators and takes no input. For example, your program might be:
MyProgram
When your program is arranged into the shapes a clock's hands make at 12, 3, 6, and 9 o'clock, it needs to output the corresponding hour number. No other times nee... |
It is well-known that there are one-to-one correspondences between pairs of integers and the positive integers. Your task is to write code defining such a correspondence (by defining a pair of functions/programs that are inverses of each other) in your programming language of choice, plus a correctness check (see below... |
In the examples below, A and B will be 2-by-2 matrices, and the matrices are one-indexed.
A Kronecker product has the following properties:
A⊗B = A(1,1)*B A(1,2)*B
A(2,1)*B A(2,2)*B
= A(1,1)*B(1,1) A(1,1)*B(1,2) A(1,2)*B(1,1) A(1,2)*B(1,2)
A(1,1)*B(2,1) A(1,1)*B(2,2) A(1,2)*B(2,1)... |
Write a program or function where a matrix A (maximum value of dimensions of the matrix is 100) is transformed to a new matrix B. Each element of the new matrix B is the sum of the positive neighbors of the corresponding element of the matrix A.
Only neighbors in the four orthogonal directions are considered, and the e... |
We already have a base conversion question, but not one with negative bases (nope, this doesn't count).
(Corresponding wiki article.)
You will receive a number (may be negative) and a base (must be negative), and your task is to convert the number into the base.
The base will only be from -10 to -2.
Specs
You may rece... |
Your challenge, should you choose to accept it, is simple:
Implement RFC 862, also known as the Echo Protocol:
The Echo protocol
An echo service simply sends back to the originating source any data it receives.
TCP Based Echo Service
One echo service is defined as a connection based application on TCP. A server listens... |
Introduction
Let's observe the string abc. The substrings that can be made from this are:
a, ab, abc, b, bc, c
We now need to align them under the initial string, like this:
abc
a
b
c
ab
bc
abc
The order of the string doesn't matter, so this is also perfectly valid:
abc
a
ab
abc
b
bc
c
So, the substring is p... |
A string whose length is a positive triangular number (1, 3, 6, 10, 15...) can be arranged into an "equilateral text triangle" by adding some spaces and newlines (and keeping it in the same reading order).
For example, the length 10 string ABCDEFGHIJ becomes:
A
B C
D E F
G H I J
Write a program or function that ... |
Challenge
Create a quine, that instead of outputting it's source, output's it's source QWERTY-sorted.
What is QWERTY sorting?
QWERTY sorting is sorting code by the QWERTY keyboard. Anything higher or more left is greater (q > Q, \ > /) with presedence on higher. To check, find the locations of the two characters to com... |
Introduction
Consider two strings A and B of the same length L, and an integer K ≥ 0.
For the purposes of this challenge, we say that the strings are K-compatible, if there exists a string C of length K such that A is a contiguous substring of the concatenation BCB.
Note that A is a substring of BAB, so A and B are alw... |
Imagine a path made up of < and > and ending in a @, e.g.
><>@
A walker starts on the left-most cell. He will traverse the path as follows:
If the walker is on a @ cell, he's reached the goal and is done.
If the walker is on a > cell, the entire path shifts one step to the right, cyclically, taking the walker with it... |
Problem
Create a program or function that can calculate the result of a matrix raised to the nth power. Your code will take an arbitrary square matrix A and a non-negative integer n, and return a matrix with the value An.
Restrictions
Built-in functions that compute the matrix power and matrix product are not allowed.
... |
Specification
For this challenge you will:
Take an array of positive integers.
For each overlapping pair in the array, calculate the difference of it's integers. If the difference is a common divisor of the integers (they are both divisible by their difference), swap their positions in the array. The values of the nex... |
Introduction
Gijswijt's sequence (A090822) is famously really, REALLY slow. To illustrate:
The first 3 appears in the 9th term (alright).
The first 4 appears in the 220th term (a long way away, but feasible).
The first 5 appears at (approximately) the 10^(10^23)th term (just no).
No one really even knows where the fir... |
Related, but very different.
In the examples below, \$A\$ and \$B\$ will be \$2\times2\$ matrices, and the matrices are one-indexed.
A Kronecker product has the following properties:
A⊗B = A(1,1)*B A(1,2)*B
A(2,1)*B A(2,2)*B
= A(1,1)*B(1,1) A(1,1)*B(1,2) A(1,2)*B(1,1) A(1,2)*B(1,2)
A(... |
We don't have a single challenge about drawing a real 3 dimensional cube, so here it goes:
Challenge
Your task is to draw a rotated, cube with perspective. It can be in a separate window or as an image.
Input
Your input is 3 separate numbers between 0 and 359.99... These represent the rotation around the x, y and z axi... |
This challenge is simple. Given a number, output a ascii-art representation of the number, using the Mayan Base-20 numeral system.
What is the Mayan system?
The Mayans used base 20 to store numbers, so the first position was the 1s place, the next the 20s place, then the 400s, etc.
So Mayan number 1 is 1 in base 10, b... |
Given (on STDIN, as command line arguments, or as function arguments) two distinct non-empty strings, find and return the shortest substring of the first string which is not a substring of the second. If no such substring exists, you may return the empty string, return any string which isn't a substring of the original... |
We all often hear the idiom "walk through the array" to mean "map the function over the following array". However, I need it done (now!), so I want you to run through the array.
How do I run?
Imagine there's a wild pack of wolves behind you
Running through an array is like walking through one, except you can skip over... |
In this challenge 2 years ago, we found the period of a unit fraction (1/n where n is a natural number).
Now, your task is to write a program/function to find the repetend of a unit fraction.
The repetend is the part of the decimal expansion which repeats infinitely, like:
The decimal representation of 1/6 is 0.16666.... |
Introduction
hackertyper.net is a website that simulates "hacking" (as the media portrays it) by outputting complicated code from the crypto section of the Linux kernel onto the screen as you type at a rate of 3 characters per one inputted.
Challenge
Your program/function should either accept a file as a command-line a... |
Background
Adler-32 is a 32-bit checksum invented by Mark Adler in 1995 which is part of the widely used zlib library (also developed by Adler). Adler-32 is not as reliable as a 32-bit cyclic redundancy check, but – at least in software – it is much faster and easier to implement.
Definition
Let B = [b1, ⋯, bn] be a b... |
Children are very good at classifying objects and counting them. Computers seem to have more trouble. This is a simplified version of this problem. Can you write a small program that can classify and count objects in an image?
The problem: Given an image containing one or more circles and rectangles, return 2 integers
... |
Your goal is to calculate the exponential of a float (e**x) up to 2 decimal places for any float within 1 to 10. The accepted error range is 0.01.
However, you must not use the built-in exponential function or the logarithm function.
In fact, attempts to circumvent this by (2**x)**(1/ln(2)) are prohibited, even if you ... |
Challenge
Your goal is, given two positive integer numbers a and b, to calculate (and output) a ^ b without using either multiplication, division and the power itself (not directly, at least).
And, of course, built-in exponentiation functions.
Scoring
This is code-golf, so the shorter, the better.
Test cases
Input => O... |
The challenge
Given a 2d string representing the bottom of a boat as an input, you must determine whether or not the boat will float. This 2D string can be in whatever format is most convenient. (String with newlines, list of string, list of list of chars, etc.) Print a truthy value if it will float, and a falsey value... |
Credits
This challenge originated from @miles.
Create a function that computes the CRC32 hash of an input string. The input will be an ASCII string of any length. The output will be the CRC32 hash of that input string.
Explanation
The algorithm of CRC32 and other CRC are essentially the same, so only CRC3 will be demo... |
Your task is to decompose a number using the format below.
This is similar to base conversion, except that instead of listing the digits in the base, you list the values, such that the list adds up to the input.
If the given base is \$n\$, then each number in the list must be in the form of \$k\times n^m\$, where \$0\l... |
Your task is to create a program/function to replicate this word generator.
Details
Your program/function take two input. One input is the categories. The other input is the syllable types.
Categories
categories will consist of classes of letters.
For example, V=aeiou means that the letters a, e, i, o, and u will be cl... |
It is well known, in the field of Mathematics studying infinity, that the Cartesian product of any finite amount of countable sets is also countable.
Your task is to write two programs to implement this, one to map from list to integer, one to map from integer to list.
Your function must be bijective and deterministic,... |
Definition
A number is positive if it is greater than zero.
A number (A) is the divisor of another number (B) if A can divide B with no remainder.
For example, 2 is a divisor of 6 because 2 can divide 6 with no remainder.
Goal
Your task is to write a program/function that takes a positive number and then find all of it... |
A perfect power is a number of the form \$a^b\$, where \$a>0\$ and \$b>1\$.
For example, \$125\$ is a perfect power because it can be expressed as \$5^3\$.
Goal
Your task is to write a program/function that finds the \$n\$-th perfect power, given a positive integer \$n\$.
Specs
The first perfect power is \$1\$ (which... |
This challenge is a harder version of this one.
A variable number of trits is an array of 0 or more trits (a trit is a ternary digit). So [0, 2, 2, 1] is a variable number of trits, but so is [].
Write a function or program that, given an non-negative integer returns a variable number of trits such that every integer h... |
For example, if n is 5 and r is 2, it would mean the number of lists below:
[1,1,1,1,1]
[1,1,1,2,2]
[1,1,2,2,2]
[2,2,1,1,1]
[2,2,2,1,1]
[2,2,2,2,2]
which is 6.
If n is 4 and r is 3:
[1,1,1,1]
[1,1,2,2]
[1,1,3,3]
[2,2,1,1]
...
[3,3,3,3]
which is 9.
where each item has a neighbour whose value is the same.
For example, ... |
Mary has given John two sticks of lengths a and b respectively, where a and b are positive integers.
John is very curious.
He would like to know how many triangles with integer perimeter can be formed, by having one additional side.
Please help him find it out.
(This is my first time composing this kind of stupid stori... |
A polygonal number is the number of dots in a k-gon of size n.
You will be given n and k, and your task is to write a program/function that outputs/prints the corresponding number.
Scoring
This is code-golf. Shortest solution in bytes wins.
Example
The 3rd hexagon number (k=6, n=3) is 28 because there are 28 dots abov... |
This question got me nostalgic: Build a word generator!
In the '80s I wrote a simple word generator in under 42kB (code and working memory) that would take a collection of strings and use them to create new words and phrases.
Your task is to recreate this program in as few bytes as possible, with a few minor updates.
Y... |
You are trying to guess my emotion.
I will give you an adjective, as the input to the function/program.
Your task is to output my emotion, either :) for happy, or :( for sad.
Details
For these adjectives, you must output the happy face :)
contented
delighted
merry
overjoyed
pleased
blessed
chipper
content
convivial
gle... |
Automatic house building nanobots have been fabricated, and it's your job to code them.
Here is the house created by input 7 4 2
/-----/|
/ / |
|-----| |
| | |
| | /
|_____|/
The input is a string containing the house's dimensions.
7 is the width.
|_____|
---7---
4 is the height.
|
|
|
|
2 is the d... |
Introduction
Let's observe the following array:
[1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1]
A group consists of the same digits next to each other. In the above array, there are 5 different groups:
[1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1]
1, 1, 1
2, 2
1, 1, 1, 1
... |
You are trying to guess my emotion.
I will give you an adjective, as the input to the function/program.
Your task is to output the state of my eyes, either O_O for open, or ._. for closed.
Details
For these adjectives, you must output open eyes O_O
animated
breezy
brisk
driving
enterprising
fresh
indefatigable
industri... |
Congratulations!
You have just been hired by a Fortune 499 company specializing in oil drilling.
Your job is to write a program to determine the optimum placement of OilRUs' drill (represented by a single alphabetical character of your choice, I use a capital "O" in the examples), given a length of piping, and a two-di... |
Clarification: Basically, you need to make this
Euler's totient function has the name phi.
Let's try to calculate phi(8)
First, list all numbers 8 and under backwards, not including 0 or under
8
7
6
5
4
3
2
1
Now find which numbers don't share a factor with 8 (1 doesn't count), and place a # in their place.
8
#
6
#
4
... |
In information theory, a "prefix code" is a dictionary where none of the keys are a prefix of another. In other words, this means that none of the strings starts with any of the other.
For example, {"9", "55"} is a prefix code, but {"5", "9", "55"} is not.
The biggest advantage of this, is that the encoded text can be... |
In this challenge about prefix code, we learnt that prefix codes are uniquely concatenable.
That means, they can be joined together without separator, and without ambiguity.
For example, since [1,2,45] is a prefix code, I can join them together without separator as such: 1245245112145, and there will be no ambiguity.
H... |
Your task is to write a program/function to scale up an image (list of strings) by a factor of n.
Specs
You will receive two inputs: an image, and a positive integer.
The image will only contain ASCII printable characters (U+0020-U+007F).
Scoring
This is code-golf. Shortest solution in bytes wins.
Testcases
Testcase ... |
Final results available
Introduction
After my previous KOTH with heavy themes (fantasy war, worldwide pandemic...), I'm back with a new lighthearted game. This time, you are facing off in a "board game-like" situation. A pile of upside down coins is placed at the center of a really big table, and you are determined to ... |
Encrypting Challenge
Your encrypting program must be able to do following things:
Input password
Generate random key
Encrypt random key with set key
Then, the decrypting program must be able to these things:
Input encrypted password
Input encrypted random key
Decrypt random key
Decrypt password with decrypted random ... |
Note: This challenge is not the same.
Challenge
Believe it or not, we haven't got ONE challenge for reversing one-dimensional arrays (although we've got one for n-dimensional ones)! This should operate only on the 1st dimension, not on all dimensions of an array.
Rules
Standard loopholes are denied
[[1, 2], [3, 4]] be... |
Text to DNA golf
Challenge
Convert input into a DNA output.
Algorithm
Convert text into ASCII code points (e.g. codegolf -> [99, 111, 100, 101, 103, 111, 108, 102])
String the ASCII codes together (e.g. 99111100101103111108102)
Convert to binary (e.g. 1010011111100110100101101000100001100110101101111000011001011111101... |
This challenge is about gradually shifting hues in an image to make pretty pictures like this:
(original)
Challenge
Write a program or function that takes in two non-negative integers and an image in any common image file format of your choosing (you can take a path to the image or the raw image data).
We'll call the ... |
What are some tips for code-golfing in Swift? Its focus on safety seems to make it difficult to golf in, but that makes little tips and even more useful. Are there any features in Swift that may help it excel in code-golf in certain applications?
Please post one tip per answer.
|
Your task is to build a natural number using the fewest number of ones and only the operators + or -. For example, the number seven can be written 1+1+1+1+1+1+1=7, but it can also be written as 11-1-1-1-1=7. The first one uses 7 ones, while the latter only uses 6. Your task is to return the minimum number of ones that ... |
Look at these photographs of natural scenes, with one of the RGB channels taken out of them:
Source (with red): https://en.wikipedia.org/wiki/File:Altja_j%C3%B5gi_Lahemaal.jpg
Source (with green): https://commons.wikimedia.org/wiki/File:2007_mather-lake_hg.jpg
Source (with blue): https://commons.wikimedia.org/wiki/F... |
Write a program or function, that given a success probability p, a number n and a number of trials m returns the chance of at least n successes out of m trials.
Your answer must be precise to at least 5 digits after the decimal.
Test cases:
0.1, 10, 100 -> 0.54871
0.2, 10, 100 -> 0.99767
0.5, 13, 20 -> 0.13159
0.5... |
An Indian legend tells the story of the alleged inventor of the chess game, who impressed the emperor of India with his game so much that he would get rewarded with anything asked.
The man said he wanted to be paid in rice. He wanted a grain of rice for the first square of the chessboard, two for the second, four for t... |
A palindromic number (in case you don't know) is a number which reads the same backwards and forwards (example, 11). The first 15 non-palindromic numbers are: 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26. This is A029742. I constantly need these numbers, but my sticky note pad is very small, so your code ... |
This was inspired by a Minecraft mini-game. The rules are pretty simple: you run and jump around, and every block you step on disappears once you've stepped on it. The goal is to be the last one left.
Your bot should be a complete program. It should accept input as a command line argument. The input will be a map of th... |
While doodling around on square-ruled paper the other day, I came up with the above negative-space font for digits. In case you haven't spotted it yet, the spaces between the above shapes yield the golden ratio 1.618033988749. In this challenge, your task is to take a number as input and render it exactly as the examp... |
Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins!
Output must look like this:
Enter String: Input
Vowel Count: a: #, e: #, i: #, o: #, u: #
Remaining characters: Vowel-less Input
For example:
Enter String: LoremIpsumDolorSitAmetConsecuteurA... |
I am a very casual code golfer, and don't often see posts until they show up in the "Hot Network Questions" sidebar over on StackOverflow. Usually, I'm late to the game, and since the only language I know is Python, there is little point in me answering as there are already several Python answers. Your challenge is t... |
Gamma function is defined as
It is a well-known fact that for positive integers it coincides with a properly shifted factorial function: Γ(n) = (n - 1)!. However, a less famous fact is
Γ(1/2) = π1/2
Actually, the Gamma function can be evaluated for all half-integer arguments, and the result is a rational number mult... |
The task is to generate all the strings from 'a' to '999' including upper case characters like so:
'a', 'b', 'c' ... 'y', 'z', 'A', 'B', 'C' ... 'Y', 'Z', '0', '1', 2' ...
'8', '9', 'aa', 'ab', 'ac' ... 'az', 'aA', 'aB' ... 'aZ', 'a0' ... 'a9', 'ba'
and so on (filling in the gaps), optionally starting with the empty ... |
Your task is to write a program that will filter out some characters in a string, so that the remaining spells out (part of) the other string.
Let's say we received the string "123456781234567812345678", and the second string is "314159".
First, we put a pointer on the second string:
314159
^
So the pointer is now on ... |
Piano keys are 3 characters wide, and 7 characters tall. However, if every key was 3 charactes wide, there wouldn't be enough room for the black keys. That's why some of the white keys have parts of them cut out. There are 3 types of white keys.
Keys with the right half missing (R):
____
| |
| |
| |
| |
| |
|... |
K-means is a standard unsupervised clustering algorithm, which, given a set of "points" and a number of clusters K, will assign each "point" to one of K clusters.
Pseudo-Code of K-means
Note that there are many variants of K-means. You have to implement the algorithm I am describing below. You may have some variation o... |
Interpret DOGO
DOGO is a lesser known programming language. While the original DOGO (a joke language from a Usenet post) has never been implemented, a language resembling it has been created. The commands for the language are:
+===========+================================================================+
| Command | ... |
Coordinates in the flat-Earth world consist of latitude (x) and longitude (y), which are integers in the range 0...9999. Much like Gaussian integers, but they are always written using this notation:
411S 370E
That is, with S or N appended to the latitude, and E or W appended to the longitude, with space(s) between the... |
EDIT: The incorrect A rhomb substitution has been fixed. Apologies to anoyone who had started working on a solution.
Consider the following substitutions, where the substituted rhomb(us) is scaled up and shown in red:
EDIT: Note the anchor points (circle) created where a corner of each new rhomb touches the substituted... |
(Taken from https://en.wikipedia.org/wiki/File:Tangential_quadrilateral.svg)
A tangential quadrilateral (see example above) is a quadrilateral in which a circle can be inscribed.
Your task is to find the possible value of d given a, b, and c.
Specs
a, b, c will all be positive integers.
If no possible value of d exis... |
Your task is to build a bridge to connect two cliffs given an input d, the distance apart. d will always be even
However, the bridge needs columns to hold it up. Each column can hold a max of 6 spaces on each side.
For this example:
________ ________
| |
A | ... |
This challenge is about reading random lines from a potentially huge file without reading the whole file into memory.
Input
An integer n and the name of a text file.
Output
n lines of the text file chosen uniformly at random without replacement.
You can assume that n is in the range 1 to the number of lines in the f... |
You are given a string composed with the characters 0123456789+*(). You can assume that string is always a valid mathematical expression.
Your task is to remove the unnecessary parentheses, assuming multiplication has higher priority than addition.
The parentheses should be removed only when they are not needed structu... |
Intro (semi fictional)
I'm the solo developer of a game, I'm already struggling with character design as is. Hence I've thought of a smart solution, I'll just use images for regular monsters, outline them a bit and suddenly they are boss monsters! That will save me from thinking up new bosses yay.
However, I have appro... |
Given a list of N integers, each with N digits, output a number which differs from the first number because of the first digit, the second number because of the second digit, etc.
Example
Given this list:
1234
4815
1623
4211
The number 2932's first digit is different from the first number's first digit, its second dig... |
Introduction
The two most common trigonometric functions, sine and cosine (or sin and cos for short), can be extended to be matrix-valued functions. One way to compute the matrix-valued analogs is as follows:
Consider these two important trigonometric identities:
$$
e^{i x} = \cos(x) + i \sin(x) \\
\sin^2(x) + \cos^2(x... |
Challenge
Write a program P, taking no input, such that the proposition “the execution of P eventually terminates” is independent of Peano arithmetic.
Formal rules
(In case you are a mathematical logician who thinks the above description is too informal.)
One can, in principle, convert some Universal Turing machine U (... |
The continued fraction of a number n is a fraction of the following form:
which converges to n.
The sequence a in a continued fraction is typically written as: [a0; a1, a2, a3, ..., an].
Your goal is to return the continued fraction of the given rational number (positive or negative), whether it is an:
integer x
frac... |
Background
I want to buy an plot of land and build my house on it.
My house should be rectangular, and as large as possible; however, the available plots have lots of rocky areas that I cannot build on, and I'm having trouble fitting a potential house on the plots.
I want you to write a program that analyzes the plots ... |
You have to write a function/program that will draw an ASCII art of a square made with numbers.
Challenge
This program will take one input n as a positive integer and draw a hollow square using this number. The inside must be filled with spaces. The borders also must have the same width. The width and height of the squ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.