instruction stringlengths 34 53.1k |
|---|
Oops, Auto-correct.
You have a word. But it's wrong. You wonder what word it would be. Thankfully, being a code golfer, You can make a code to take a rough guess.
I/O
You will be given a (wrong, all lowercase) word, and a '(All lowercase)Dictionary list'. You have to output the word with the least Levenshtein distanc... |
Background
The deltas of an array of integers is the array formed by getting the differences of consecutive elements. For example, [1, 2, 4, 7, 3, 9, 6] has the following deltas: [1, 2, 3, -4, 6, -3].
We will now define the deltas of a matrix of integers as the deltas of each row and each column it contains.
As an exam... |
The London Underground A.K.A. The Tube is the oldest underground railway in the world, it currently consists of eleven lines* servicing 267 named stations (strictly 269** stations since "Edgware Road" and "Hammersmith" each occupy two locations)
The challenge
Output the names of the lines servicing a station given by n... |
Related, but this only requires positive integers and does not have to be commutative
The Cantor Pairing Function is described in this Wikipedia article. Essentially, it is an operation such that when it is applied to two values X and Y, one can obtain the original values X and Y given the result.
Your task is to desig... |
note: the string art might look horrible here because of SE font weirdness :P :(
Given a list of four-tuples representing the corners of rectangles, draw translucent rectangles over each other in that order.
For this challenge, you are required to have the smallest coordinate in the top-left corner and the x-axis incre... |
Challenge
Given an integer, n, as input where 36 >= n >= 2, output how many Lynch-Bell numbers there are in base n.
The output must be in base 10.
Lynch-Bell Numbers
A number is a Lynch-Bell numbers if:
All of its digits are unique (no repetition of digits)
The number is divisible by each of its digits
It doesn't cont... |
Given a MM/DD date (12/24) and a start/end date range (11/01 - 06/24), figure out if the date is within the listed date span.
Date ranges can be sequential (05/01 - 11/01) or wrap around to the next year (11/01 - 05/01).
Examples:
12/24 is in 11/01 - 06/24 = True
06/24 is in 11/01 - 06/24 = True
06/24 is in 06/24 - 06... |
Inspired by this
In the linked challenge, we are asked to apply addition to the elements of the original and the reverse of the input array. In this challenge, we are going to make it slightly more difficult, by introducing the other basic math operations.
Given an array of integers, cycle through +, *, -, //, %, ^, wh... |
Recently I've been playing a game called Alcazar. It is a board puzzle game where your goal is to enter from one door, pass through all squares, and exit through another door. The only rules are:
Enter once, leave once;
Pass through all squares;
Do not pass through a square more than once
The image below shows an exa... |
In math, one way to figure out what the type of a given relation (linear, quadratic, etc) is to calculate the differences. To do so you take a list of y values for which the gap between the correspondent x values is the same, and subtract each one from the number above it, creating a list of numbers one shorter then t... |
Specs
You have a cubic 3D space x,y,z of size S integer units, such as 0 <= x,y,z <= S.
You get from default input methods an array of points P represented as x,y,z integer coordinates, in any reasonable format as you like, for example: [x1,y1,z1],[x2,y2,z2],[x3,y3,z3] ... [xn,yn,zn].
All the P values will be in the ... |
Given input n, produce a word grid of size n, in as few bytes as possible.
Details
The number provided will always be odd. The centre square of the grid must always be empty (a space character). The letters that fill the grid must be chosen at random from the English Scrabble letter distribution of letters. That is, ea... |
A completely even number is a positive even integer whose divisors (not including 1) are all even.
Some completely even numbers are:
2 (divisors: 2, 1)
4 (divisors: 4, 2, 1)
16 (divisors: 16, 8, 4, 2, 1)
128 (divisors: 128, 64, 32, 16, 8, 4, 2, 1).
Some non-completely even numbers are:
10 (divisors: 10, 5, 2, 1)
12 ... |
The oldest Polish salt mine, located in Bochnia*, was started in year 1248, which we can consider a magical number. We can see that it's equal to 4 digits from the sequence of exponentiations: .
As the date is actually 4 digits from the sequence, we could make it longer. We could repeat the process until we reach infin... |
Proton is a quite new language created by PPCG user Hyper Neutrino.
It is very similar to Python, and has similar syntax to the language Cheddar, hence there are some clever tricks you can use in order to reduce your byte count. Let's get those cool tricks listed here. As usual, please post one tip per answer and avoid... |
Inspired by this challenge and related to this one.
Background
Badugi [bæduːɡiː] is a low-ball draw-poker variant.
The Pokerstars World Cup Of Online Poker $1K event starts within 3 hours and I'll need to know how good my hands are!
The game uses a standard deck of 52 cards of four suits and thirteen ranks. The suits... |
As a programmer, you've probably heard of forward slashes and backward slashes. But have you heard of downslashes? That's when you take a bunch of slashes, connect their ends and draw them going down.
For today's challenge, you must write a program or function that takes a string consisting purely of slashes, and outpu... |
Given a natural numbers n>1, find the smallest narcissistic number of n digit.
A narcissistic number is a number which is the sum of its own digits, each raised to the power of the number of digits.
For example, for n=3 (3 digits) the out put should be 153:
1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153
For n=4 (4 digits) the ou... |
You know nothing The things I do for "Chaos is a ladder" is a memorable line from the television series Game of Thrones.
The purpose of this challenge is to build a ladder from chaos, in ASCII art.
The challenge
Input
Ladder width, W >= 3 (integer)
Step height, H >= 2 (integer)
Number of rungs, N >= 2 (integer).
Outp... |
This challenge is rather simple:
You are given an array of positive (not including 0) integers, and have to select a random element from this array.
But here's the twist:
The probability of selecting an element is dependent on the value of the integer, meaning as the integer grows larger, the probability of it to get s... |
Inspired by this CMC
Given a positive integer greater than 0, perform the following operation on it:
If all ten single digits (1234567890) are in the number at least once, output the count and exit the program
Otherwise, double the number and repeat, incrementing the count.
The count starts at 0 and is the number of ... |
Given a rectangular matrix of elevations, draw its contours.
Task
Two elements x and y are on the same contour level if floor(x/10) == floor(y/10). For example, 52 and 58 are on the same contour level, but 58 and 64 are not.
The act of drawing contours is defined as follows:
For every element e, replace it with a two-c... |
Objective
Write a program that outputs some printable ASCII characters. The trick is that if the program is reversed byte-by-byte, it must output the same thing in the reverse order, byte-by-byte, too.
Rules
No standard loopholes.
The program must not be a palindrome, nor can it be 1 byte in length (or empty). No rest... |
Your challenge is to print x digits of pi where x is your code length.
Examples:
Source code (length) -> output
foo! (4) 3.141
foobar (6) 3.14159
kinda long (10) 3.141592653
+++++ (5) 3.1415
123456789 (9) 3.14159265
You can use floor(π/10 * 10code_length) / 1... |
Introduction:
Inspired by both Perfect License Plates and How many points does my license plate give?
Just like in the challenges above, me and my little brother had a game of our own with license plates as kids. We tried to create (random/funny) sentences with the (numbers and) letters of the license plates.
For examp... |
Given two positive integers a and b, output two positive integers c and d such that:
c divides a
d divides b
c and d are co-prime
the least common multiple of c and d equals the least common multiple of a and b.
If there are more than one possible answers, you can output only one or all of them.
Test cases:
a b c ... |
Your challenge today is to output a given term of a sequence enumerating all of the integers. The sequence is as follows: If we have a 0-indexed function generating the sequence f(n) and ceil(x) is the ceiling function, then f(0) = 0; abs(f(n)) = ceil(n/2); sign(f(n)) is positive when n and ceil(n/2) are either both ev... |
Given an expression matching the regex /^[-~]*x$/, evaluate it in terms of x and output a string matching the regex /^-?x[+-]\d+$/.
For example, the string -~x evaluates to x+1, while the string -~-x evaluates to -x+1, and the string -~-~--x evaluates to x+2.
We start from x and evaluate the string right to left. - neg... |
I have a stupid old alarm clock with two buttons: hour and minute. The hour button increments the hour of a set alarm, and minute increments the minute time of a set alarm. However, some smart designers realized that pressing both buttons at the same time should have a meaning, and decided that pressing hour and minute... |
Goal
Given a non-negative integer, create a function that returns the starting position of number of largest consecutive 1's in that integer's binary value.
When given an input 0, return 0.
If the number has multiple streaks of equal length, you must return the position of the last streak.
Input
An integer greater than... |
We have a floating point number r between 0 and 1, and an integer p.
Find the fraction of integers with the smallest denominator, which approximates r with at least p-digit precision.
Inputs: r (a floating point number) and p (integer).
Outputs: a and b integers, where
a/b (as float) approximates r until p digits.
b... |
This question is inspired by the fact that I love seeing questions with equal vote and answer counts...
So here's a simple stack-exchange-api challenge for y'all:
Challenge:
Given a codegolf.stackexchange question id, output the ratio between the question's votes and number of answers (e.g. votes/answers).
Specifics:
... |
Your challenge today is to take an array, split it into chunks, and add those chunks.
Here's how this works: Your program or function will be given an array of integers a and a chunk size L. The array should be split into arrays of size L, if the array length is not divisible by L then the array should have 0's appende... |
Given two note names, you are to write a program that determines if the interval formed by these two notes is consonant or dissonant.
Introduction
In Western music, there are only 12 "different" tones. Their names, sorted from lowest to highest, are these: C, C#, D, D#, E, F, F#, G, G#, A, A#, B. The sequence is cyclic... |
Background
In Boggle, a round is scored by adding up the points for each unique word a player has found (i.e. any word that more than one player has found is worth 0 points). The points are calculated based on the number of letters in each word, as follows:
3 letters: 1 point
4 letters: 1 point
5 letters: 2 points
6 le... |
Nichomachus's Theorem relates the square of a sum to the sum of cubes:
and has a beautiful geometric visualization:
Challenge: Create the 2d part of this visualization in ascii.
You will need to ensure that all visual demarcations are upheld by your diagram. This is simplest to do with four "colors," though it's pos... |
Output
# # # # # ##### ## #
## #### ####### # # ##
#### ## ## # ### #######
# # # # ##### ### # #
# # ### ##### ##### # ... |
Challenge
Write code that outputs TeX (LaTeX) math-equation code (given below) that will typeset Sierpinski Triangle Fractal of 5 levels. Shortest code wins.
Details
TeX (and friends like LaTeX, etc.) is a sophisticated typesetting system. It can render arbitrary nested complex expressions for mathematical formulas. Co... |
An insignificant array is an array of positive integers, where the absolute differences between consecutive elements are all smaller than or equal to 1.
For example, the following array is insignificant:
[1, 2, 3, 4, 3, 4, 5, 5, 5, 4]
Because the corresponding (absolute) differences are:
[1, 1, 1, 1, 1, 1, 0, 0, 1]
W... |
Thank you for you help fixing my calculator's multiply function, but I've found another critical error all calculators seem to share. None of them understand that 2+2=fish. So now I need code to properly add 2 numbers.
Challenge
Take 2 numbers as input (Type doesn't matter, but only 2 items will be passed. This is add... |
Background
When I was younger, I was taught a method of drawing a weird "S" shape, that I (along with my classmates) found fascinating. Today, I rediscovered it, and due to its formulaic approach to drawing it, thought it could lead to an interesting challenge :P
Drawing the "S"
The S can be drawn by following these si... |
(No, not this nor any of these)
Given a string and a list of strings, fill in the all blanks in the input string with corresponding strings.
Input/Output
The input string contains only alphabetic characters, spaces, and underscores. It is nonempty and does not start with an underscore. In other words, the input string ... |
We already now how to strip a string from its spaces.
However, as proper gentlemen/ladies, we should rather undress it.
Undressing a string is the same as stripping it, only more delicate. Instead of removing all leading and trailing spaces at once, we remove them one by one. We also alternate between leading and trai... |
There's a satirical song called Little Boxes, originally by Malvina Reynolds, about suburban sprawl that has lyrics as follows:
Little boxes on the hillside,
Little boxes made of ticky-tacky,
Little boxes on the hillside,
Little boxes all the same.
There's a green one and a pink one
And a blue one and a yell... |
I need to go to the bank and withdraw some money. I need to withdraw $30, $22 to pay my roommate for the internet and $8 for laundry. Since neither of these can make change, I need my $30 to be split into two partitions of the two sizes. That means when the teller asks me how I want my $30 I am going to have to make... |
Your task is to take in one integer input and print a zigzag pattern using slashes and backslashes.
The integer input determines the length of each zig and zag, as well as the number of zigs and zags
The pattern always starts from right to left
Test Cases
4->
/
/
/
/
\
\
\
\
/
/
/
/
\
\
\
\
2-... |
Given a matrix of integers, test if it's rank-one, meaning that every row is a multiple of the same vector. For example, in
2 0 -20 10
-3 0 30 -15
0 0 0 0
every row is a multiple of 1 0 -10 5.
The same definition also works with columns in place of rows. Alternatively, a matrix is rank-one if it's ... |
Construct a program or function that takes input in form of
<width>, <height>, <color1>, <color2>
and generates an output such that first row alternates between pixels of color <color1> and <color2> with a period of <height>. For each row that follows, the period shall be <height> - <row number>. Note that <color1> a... |
Let me introduce you to GAU numbers
GAU(1) = 1
GAU(2) = 1122
GAU(3) = 1122122333
GAU(4) = 11221223331223334444
GAU(6) = 11221223331223334444122333444455555122333444455555666666
...
GAU(10) = 112212233312233344441223334444555551223334444555556666661223334444555556666667777777122333444455555666666777777788888... |
Objective
Use any editor or IDE (vim, emacs, IntelliJ, etc) to write a valid "Hello, World" program in any C-like language. The "!" is optional, but you get style points if you use it. You may use publicly available plugins, a publicly available vimrc, etc, but you may not write or make modifications to them specifical... |
Introduction - What is a necklace?
A necklace is something that OEIS people are obsessed with. The OEIS challenge has like 5 necklace sequences.
A binary necklace of length n is a loop with n beads that are either 0 or 1. Two necklaces are the same if one can be rotated to become the other, and two reversible necklaces... |
A menger sponge is a fractal made out of cubes within cubes within cubes...
If you start with a cube, on each face there are 9 squares. The middle square becomes empty (or 0). The other 8 squares iterate this process. They each get split up into 9 squares and the middle square face is taken out.
The goal today is to ge... |
Inspired by this chat message
Your task will be to take a word and find the average position of its letters on the keyboard as a letter.
Keyboard Layout
Since layouts vary from keyboard to keyboard, we will be using a standard based of of my own keyboard in this question.
The keyboard has 3 rows, the top row from lef... |
Introduction
You can skip this part if you already know what a cyclic group is.
A group is defined by a set and an associative binary operation \$\times\$ (that is, \$(a \times b) \times c = a \times (b \times c)\$. There exists exactly one element in the group \$e\$ where \$a \times e = a = e \times a\$ for all \$a\$ ... |
Inspired by Generate Keyboard Friendly Numbers.
Background
Many number pads have the following layout:
789
456
123
0
We define a number's neighborhood as the set of cells orthogonally adjacent to it on the numpad shown, including itself. For example, 2's neighborhood is {1,5,3,0,2} and 0's neighborhood is {1,2,... |
Challenge
Given a binary matrix and a binary string, determine if that binary string can be found starting at any point in the matrix and moving in any direction at any subsequent point to form the binary string. That is, can the string be found folded up however inside the matrix?
The string can only be folded at 90 d... |
Given two positive integers, \$A\$ and \$B\$, illustrate their least common multiple by outputting two lines of dashes (-) with length \$\text{lcm}\$\$(A, B)\$ after replacing every \$A\$th dash in the first line and every \$B\$th dash in the second line with vertical bars (|).
In this way, the end of each line will be... |
Introduction
Cacti come in various different sizes, shapes and colors. However, the most iconic cactus and must-have in every Western has to be the saguaro. Important features are its size and arms, which have defined the stereotypical cactus appearance.
Your task is to bring the saguaro in the ASCII world. However, ... |
This is a simple(ish) web scraping challenge.
Input
Your code should take an MPAA film rating and a number from 0 to 100 as input. It can do this in any way you find convenient.
Output
Your code should return the name of any movie which has a) that film rating and b) the numerical score on the Tomatometer from rottento... |
This is a more difficult version of It's a find-a-movie challenge .
Input
Your code should take a BBFC rating and a number from 1 to 5 as input. It can do this in any way you find convenient.
Output
Your code should return the name of any movie which has a) that film rating and b) that number of stars in a Guardian fi... |
We all know that \$(-a) \times (-a) = a \times a\$ (hopefully), but can you prove it?
Your task is to prove this fact using the ring axioms. What are the ring axioms? The ring axioms are a list of rules that two binary operations on a set have to follow. The two operation are addition, \$+\$, and multiplication, \$\... |
How to spot them
Take a positive integer k. Find its divisors. Find the distinct prime factors of each divisor. Sum all these factors together. If this number (sum) is a divisor of k (if the sum divides k) then, this number k, is a BIU number
Examples
Let's take the number 54
Find all the divisors: [1, 2, 3, 6, 9, 18, ... |
In this polyglot challenge, you will work together to figure out how to output all the 26 letters of the English alphabet!
How does this work?
For each answer, you must pick a new language (or a new major version of a language, for example, python 2 and python 3 are counted separately) that prints the next letter after... |
While doodling around with numbers, I found an interesting permutation you can generate from a list of numbers. If you repeat this same permutation enough times, you will always end up back at the original array. Let's use the following list:
[1, 2, 3, 4, 5]
as an example
Reverse the array. Now our array is
[5, 4, 3,... |
This challenge is inspired by a board game I played some time ago.
The story of this challenge doesn't necessarily have to be read, the goal of the challenge-section should explain everything necessary.
The Story
People are locked inside a large room with a human-devouring monster. The walls of the room are enchanted, ... |
Background (skip to definitions)
Euler proved a beautiful theorem about the complex numbers: \$e^{ix} = \cos(x) + i \sin(x)\$.
This makes de Moivre's theorem easy to prove:
$$
(e^{ix})^n = e^{i(nx)} \\
(\cos(x) + i\sin(x))^n = \cos(nx) + i\sin(nx)
$$
We can plot complex numbers using the two-dimensional Euclidean plane... |
For this challenge you will print the coordinates and color of each piece at the start of a game of checkers.
Enter the x and y (comma seperated) for every square (indexed 0-7) on a checkerboard, followed by a "r" or "b" (for red or black) where the top of the board (closer to y=0) is red and the bottom is black. newl... |
Given a positive integer nesting level n and string s of printable ascii characters( to ~, output a program which, when run in the same language, outputs a program which outputs a program . . . which outputs the string s.
A total of n programs should be generated, all of which should be run in the same language as your... |
Let us consider a regular n-sided polygon where all of the sides are equal in length with n being a natural number larger than or equal to three. All of the vertices lie on the unit circle (circle of radius one centered at the origin) and one of the vertices is always at the coordinate (x,y)=(1,0). Now let's draw all p... |
String Stairs
Disclaimer: This is the first challenge I propose. Any and all feedback is welcome. If this is a duplicate, please point it out.
Here's a link to the sandbox post.
Goal
The goal of this challenge is to, given a string and an integer, print the string into blocks of that integer's size. If a word has more ... |
For this challenge, a list is considered valid if and only if it consists entirely of integers and valid lists (recursive definitions \o/). For this challenge, given a valid list and an integer, return a list of all depths at which the integer can be found.
Example
Let's consider list [1, [2, [3, [1, 2, 3], 4], 1], 1] ... |
This is a tips question for golfing in Python concerning the Evil Numbers question on Anarchy Golf.
An number is evil if its binary expansion has an even number of 1's. The challenge is to print the first 400 evil numbers 0,3,5,...,795,797,798, one per line.
The Python 2 submissions are led by llhuii with a 42-byte so... |
Take two inputs, a non-empty vector/list containing digits 1 and 2 and a string (no, you may not take 0/1 instead). The string will be one of the following (in lowercase, exactly as written below:
increasing
decreasing
ones
twos
all
none
If the string is ____ then you shall return the indices ___:
increasing ... wher... |
Definition:
A number m is called a primitive root of a prime p the condition that the smallest integer k for which p dividies mk-1 is p-1
Your task
Given a tuple (a,b) of positive integers, return the fraction:
(number of primes p equal to or less than a which has b as a primitive root) divided by (number of primes ... |
There are n people on a 2D plane. Using distances between them we're going to find their positions. To get a unique answer you must make four assumptions:
There are at least 3 people.
The first person is at position (0, 0).
The second person is at position (x, 0) for some x > 0.
The third person is at position (x, y) ... |
Given a date, output the X and Y position of the current day of the date on a digital calendar. The digital calendar is sort of the calendar that gets shown when you click on your computers clock (at least on windows), and it looks something like this:
If we assume that the given date is 25.09.2017, the result would b... |
The Challenge
Write a program that takes an integer N as input, and outputs the stage of life or death that a tree is currently in. N will always be between 0 and 10.
The Stages of Life and Death
Life: To draw a stage of life, simply draw a base of size N, consisting of ^ characters, then move up and substract 2 from ... |
Background
Skip to "Task" if you are familiar with Tic-Tac-Toe (I think most are!)
Tic-Tac-Toe is a famous two-player game. It consists of a 3x3 board that is filled gradually by two players (clarifications below); The first player uses the character X and the other one uses O. The winner is the first to get 3 consecut... |
Challenge
You are given two distinct bit strings of the same length. (For example, 000 and 111.) Your goal is to find a path from one to the other such that:
At each step, you change only one bit (you can go from 000 to any of 001, 010, 100).
You cannot visit the same bit string twice.
The path is as long as possible,... |
CHALLENGE
Given a set of grouped letters, arrange them onto the board so that they cover the area entirely.
Board Representation (a.k.a. the SHIP DECK)
The board is a 6x6 grid.
There will always be 36 total squares.
Columns are marked A-F.
Rows are marked 1-6.
Example:
A B C D E F
+---+---+---+---+---... |
Programming is very rigid. You can't tell a program to "output the banana count", you have to tell it to print(bananas).
But when you do that, you end up with a problem: you don't know how many bananas you have beforehand, so you don't know whether to use a plural.
Sometimes, programmers go the lazy way. Instead of che... |
Given two positive integers a and b, output the frequency distribution of rolling a b-sided die a times and summing the results.
A frequency distribution lists the frequency of each possible sum if each possible sequence of dice rolls occurs once. Thus, the frequencies are integers whose sum equals b**a.
Rules
The fre... |
Alpha Decay is a kind of radiation decay where every time the atom "decays", it loses a helium nucleus (an alpha particle). This means that an atom loses 2 protons and 2 neutrons each time. Your task is to simulate this, including the problems that occur during alpha decay.
Given two integers as input, \$m\$ and \$p\$,... |
Given an integer p > 1, find the smallest integer q > p such that the list of exponents in the prime factorization of q is the same of that of p, no matter the order or the value of the prime factors.
Examples
The prime factorization of p = 20 is 22 x 51. The smallest integer greater than p with identical exponents in ... |
For the purposes of this question, the prime factorial of a number n is the result of multiplying all prime numbers smaller than n, and then multiplying the result by n.
Your Task:
Write a program or function to find the prime factorial of a number, as outlined above.
Input:
An integer n where n is greater than one... |
You deal cards labeled 0 to 9 from a deck one a time, forming stacks that start at 0 and count up by 1.
When you deal a 0, you place it on the table to start a new stack.
When you deal any other card, you stack it atop a card that's exactly
one lower in value, covering it. If there's no such card, the deck isn't stac... |
Suppose a new fairy chess piece named the Wazir is introduced to chess. Wazirs can move from a position (x, y) to:
(x+1, y)
(x, y+1)
(x-1, y)
(x, y-1)
That is, they move orthogonally like the rook, but only one step at a time like the king. How many such wazirs can be placed on an N×N chessboard so that no two wazi... |
I guess I'm not the only one who have seen this kind of image on Facebook (and other sites).
The picture above was posted 16 days ago, and has accumulated 51 k comments. Some answers: 0, 4, 8, 48, 88, 120, 124 and so on.
Challenge:
The mathematics in the question doesn't make sense1, so we can't find the correct answ... |
The Bible is one of the most influential books ever written, and commonly cited as the best selling book of all time. It was written by approximately 40 different authors over hundreds of years before being compiled into it's current form. But what's interesting about The Bible is the way it's divided up. It is split u... |
Introduction:
We all know these three basic arithmetic math tables I assume.
ADDITION:
+ | 1 2 3 4 5 6 7 8 9 10
----------------------------------
1 | 2 3 4 5 6 7 8 9 10 11
2 | 3 4 5 6 7 8 9 10 11 12
3 | 4 5 6 7 8 9 10 11 12 13
4 | 5 6 7 8 9 10 11 12 13 14
5 | 6 7 8 9 10 11 ... |
Introduction
Given five points in the plane, your task is to compute the area of the ellipse passing through these points.
You can assume that exactly one non-degenerate ellipse can be constructed with the given input values.
Rules
Input is 10 integers in any convenient form, corresponding to the x and y coordinates of... |
Definition
Narcissistic 1 integers of an array think they are better than their neighbours, because they are strictly higher than their arithmetic mean.
Neighbours are defined as follows:
If the integer is at index 0 (the first), then its neighbours are the last and the second elements of the list.
If the integer is ... |
Given an ordered list of 2 or more 2D cartesian points, output a truthy value if either the path touches itself or self-intersects; otherwise output a falsy value if it does not touch itself or self-intersect.
You may assume that consecutive points in the list are distinct.
Examples:
(0,0), (1,0) -> falsey
(0,0), (1,0)... |
Given a positive integer N, output the innermost N×N square of an ASCII art spiral made of -|/\ that spirals clockwise inward.
The - is used for horizontal portions, | for vertical portions, and / and \ for corners. The first character is - and the spiral proceeds left and down.
Specifically, when N is 1 the output is:... |
Inspired by digital roots, the prime factoral root of a number is the number that emerges when you take the prime factors of a number, add them together, and repeat the process on the resulting number, continuing until you end up with a prime number (which has itself as its only prime factor, and is thus its own prime ... |
Multiplication between 2 integers can be reduced into a series of addition like so
3 * 5 = 3 + 3 + 3 + 3 + 3 = 5 + 5 + 5
Exponentiation (raising a to the power b) can also be reduced into a series of multiplications:
5 ^ 3 = 5 * 5 * 5
Therefore, exponentiation can be reduced into a series of additions, by creating a ... |
Given a positive integer n output the n-th number of the euro-iginal sequence.
Calculating the Sequence
This sequence is equal to OEIS A242491.
A number is part of said sequence if the number can be made up by using as many different euro coins or notes, but only one of each. Note that you don't have to consider cents.... |
Input:
Two strings without newlines or whitespaces.
Output:
Both input strings on separate lines, with spaces where necessary† for one of the two strings. And a third line with the characters A, R, M and , representing added, removed, modified, and unchanged.
† We add spaces to either the top or bottom input string (if... |
I have the following code which I've written to emulate Newton's method for deriving the square root of a number:
r=(x,y)=>
(z=((y=y||x)*y-x)/(2*y)>1e-15)?
r(x,y-(y*y-x)/(2*y)):y
Where r(37) would result in 6.08276253029822 which is great given the limitations of my browser.
I'd like to golf this code further seei... |
Let's imagine we have a matrix of bits (which contains at least one 1):
0 1 0 1 1 0 1 0 0 1 0
0 1 0 1 0 0 1 0 1 1 0
0 0 1 0 1 1 0 1 0 1 0
1 1 0 0 1 0 0 1 1 0 1
0 0 0 1 0 1 1 0 0 1 0
We want to set some of the bits in this matrix such that it forms a contiguous blob of 1s, in which every 1 is directly or indirectly con... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.