instruction stringlengths 34 53.1k |
|---|
A game of 2048 goes like this:
Every move you get another piece - either 2 90% of the time, or 4 10% of the time
for each 2 equal pieces combined you get a piece of the sum of the two and the sum gets added to your score
Your task
given a board of a 4x4 game, give the average score of what A game like that would resu... |
I was playing around with some numbers and found a sequence that, of course, is on OEIS. It is A005823: Numbers whose ternary expansion contains no 1's. It goes:
a(2n) = 3*a(n)+2
a(2n+1) = 3*a(n+1)
a(1) = 0
a = 0,2,6,8,18,20,24,26,54....
I wrote a CJam program that generates the first n of these numbers by convertin... |
Inspired by this.
Given a string as input consisting of only upper and lowercase alphabet characters, wicka-wub it.
How do I wicka-wub a string?
The example text used is "DJMcMayhem".
Split the string before each capital letter, so you get ["D", "J", "Mc", "Mayhem"].
Next, take the two halves of the list as sublists. T... |
Inspired by Braille graphics
Given a Boolean matrix (i.e., consisting of only 1s and 0s), output an ASCII-art-style Unicode representation of the closed-polygon shape created by the 1s in the matrix, using the Unicode drawing characters ┌ ─ ┐ │ └ ┘ (code points 0x250c, 0x2500, 0x2510, 0x2502, 0x2514, and 0x2518, respec... |
Does your language have a maximum recursion depth (MRD)?
Let's say your language has MRD=500
Write a code that finds the recursion depth and outputs the exact value
For the case above your program (or function) should output 500
Code-Golf
Shortest answer wins!
|
Given a string representing a number and the base that number is in, shift each positional value upward, wrapping back to zero if the value cannot increase. You will never be provided invalid input, nor a base larger than 36.
For example, you may be provided ['5f6', '16'], which represents the number 1526 in base 16. T... |
Takuzu is a logic game in which you have to complete a grid with cells containing 0s and 1s. The grid must follow 3 rules:
No three horizontal or vertical consecutive cells can be the same.
There must be an equal number of 0s and 1s in each row and column.
No two rows can be the same, and no two columns can be the sam... |
Six is a number perfect in itself, and not because God created all things in six days; rather, the converse is true. God created all things in six days because the number six is perfect.
I am fascinated by numbers. As were Sophie Germain and Marin Mersenne. To be more specific, these two were fascinated by primes: a ... |
Write a program or function that draws an ASCII star, given the size of the arms as input.
Here's a star of size 1
_/\_
\ /
|/\|
Here's a star of size 2
/\
__/ \__
\ /
\ /
| /\ |
|/ \|
Here's a star of size 3
/\
/ \
___/ \___
\ /
\ /
\ /
| /\ |
| / \ |
|/... |
Your task here will be to implement a function1 that forms a permutation on the positive integers (A bijection from the positive integers onto themselves). This means that each positive integer should appear exactly once in the permutation. The catch is your function should have a larger probability of outputting an ... |
Background
You're an attractive code golfer and quite a few people are asking you out.
You don't have time to think about which days exactly you're available, so you decide to create a function the accepts a date and returns the days of that week.
You then take those days of the week, insert it into your calendar progr... |
Background
The Collatz Conjecture is quite well-known. Take any natural number. Triple and increment if odd; cut in half if even. Repeat, and it will reach 1 eventually. This famous conjecture, however, is only that, for it is yet unproven.
Little-known to the world, that was not Lothar Collatz's first attempt at fame.... |
Consider the following triangle.
1
23
456
7891
01112
131415
1617181
92021222
324252627
2829303132
33343536373
839404142434
4454647484950
51525354555657
585960616263646
5666768697071727
37475767778798081
As you probably noticed, the first row is of length 1, and each row thereafter is 1 digit longer than to the previo... |
Inspired by a meme I saw earlier today.
Challenge description
Consider an infinite alphabet grid:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
...
Take a word (CODEGOLF in this example) and make it a subsequence of the grid, repl... |
As the majority of nations using the Euro have the , as the decimal separator, you must use it also.
The task is to output all the values of the Euro coins and notes in ascending order. You must also put the trailing ,00 on the integer values.
0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,0... |
In number theory, a strong prime is a prime number that is greater than the arithmetic mean of the nearest prime above and below (in other words, it's closer to the following than to the preceding prime).
Given an input integer, n, where n >= 0, your task is to generate the first n strong primes. For example, the six... |
Taking in Input
Define a function f as follows:
IF x < 0:
f(x) = -√|x|
ELSE:
f(x) = √x
In your programs/functions, each point (x, y) given as input will correspond to the point (f(x), f(y)). For example, if the points (4, -2) and (-1, 5) are given as input, your program will be dealing with the points (2, -√2)... |
Task
Given an integer, n, where 3 <= n < 2^32, calculate the area of a regular n-gon, with an apothem of 1, using the formula A = n * tan(π / n).
The apothem of a regular polygon is a line segment from the center to the midpoint of one of its sides.
Output the area of this regular polygon as a floating point value sh... |
Introduction
My calculator is behaving weird. Sometimes when I type in an 8 it displays a 2. And sometimes when I type in a 6 it displays a +. Some buttons are mixed up!
Could anyone help me determine which?
Challenge:
Input: List of incorrect equations, with correct results.
Output: The two buttons that are swapped.
F... |
In The Settlers of Catan board game, there are five resource types: Brick, Log, Ore, Wheat, and Sheep. Building a settlement costs a Brick, a Log, a Wheat, and a Sheep. However, you can also trade in four identical resources to get a resource of a different type. For instance, if you had four ores in your hand, you cou... |
Haskell has tuples that can be written as
(a,b,c)
However this is just syntactic sugar for
(,,)a b c
In general an n tuple can be formed with n-1 ,s between (...) followed by its elements separated by spaces. For example the 7-tuple, (1,2,3,4,5,6,7) can be formed by
(,,,,,,)1 2 3 4 5 6 7
Since Haskell does not have... |
Given a positive integer n, compute the nth Wilson number W(n) where
and e = 1 if n has a primitive root modulo n, otherwise e = -1. In other words, n has a primitive root if there does not exist an integer x where 1 < x < n-1 and x2 = 1 mod n.
This is code-golf so create the shortest code for a function or program t... |
Given a string that consists entirely of printable ASCII, convert all lowercase letters to their uppercase equivalent. Non-lowercase characters are left untouched.
I am not going to outright ban builtin solutions, but if you are going to post a solution that uses the builtin, please also post one that doesn't in your a... |
(This is my first code-golf question)
When I was a child, my dad and I invented a game where the license plate we see on cars can give certain points based on some rather simple rules:
X amount of the same letter or number give X-1 points, examples:
22 = 1 point
aa = 1 point
5555 = 3 points
The numbers must be next to... |
Sales taxes in the United States are complicated, to say the least. Generally, there's a state sales tax (there are a handful of states that do not collect a state sales tax), but there could also be a county sales tax, a school district sales tax, a municipal (city) sales tax, or a metropolitan area sales tax. There c... |
Given one of the following inputs: Sweet Onion Chicken Teriyaki
Oven Roasted Chicken
Turkey Breast
Italian BMT
Tuna
Black Forest Ham
Meatball Marinara output a number from 1-7 (or 0-6) representing the day of the week that you get that deal, starting with Monday as the lowest number. Input can be all lowercase or uppe... |
Help! My device malfunctions and whenever I try to repeat a String, I get a messy results. Instead of repeating the same string N times, it fills an NxN square with each of its characters, and stacks the squares up.
For example, given the String "Test" and the number 2, instead of "TestTest", I get:
TT
TT
ee
ee
ss
ss
t... |
I recently watched The Wizard Of Oz and thought that when Dorothy taps her shoes together three times, it would be easier if she used a program to do it. So let's help her.
Task
Output slippers being tapped together 3 times.
Output
Slippers being tapped together. A pair of slippers not being tapped looks like this:
_... |
Inspired by a bug in a solution to this challenge, your challenge is to produce this exact text:
ZYXWVUTSRQPONMLKJIHGFEDCBA
YXWVUTSRQPONMLKJIHGFEDCBA
XWVUTSRQPONMLKJIHGFEDCBA
WVUTSRQPONMLKJIHGFEDCBA
VUTSRQ... |
Given an integer n > 2, print or return the smallest non-negative integer k such that a(n, k) = 9, where a(n, k) is defined by:
a(n, 0) = n
a(n, k+1) =
a(n, k) / 2 + 1 if a(n, k) is even
the sum of the digits of a(n, k)² (in base 10) if a(n, k) is odd
Examples
For n = 5, the expected output is k = 4:
a(5, 0) = 5
a(... |
Write a quine that outputs the complement of the source code from the smallest containing power of two. Here's an example:
IN : source
OUT: \r\x11\x0b\x0e\x1d\x1b
The largest code point in the string "source" is the letter u, which is 117. The smallest containing power of 2 would be 128, so all the code points are tak... |
Input:
A positive integer N.
Challenge:
Suppose you have a list of integers n = 1, 2 ... N. Output a list of integers, where each number is the maximum power of 2, m, such that 2^m divides each number of n.
Test cases:
1
0
15
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
100
0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, ... |
In prefix notation, the operator comes before the arguments, so you can kind of imagine that the operator calls next() which is recursively called. In infix notation, the operator goes between the arguments, so you can imagine it simply as a parse tree. In postfix notation, the operator comes after the arguments, so yo... |
Given a "T" shape on an x * y number grid, with length W on the top bar and H on the stem of the T, with the bottom of the T on the square numbered n: calculate the total of all of the numbers in the T shape. W must be an odd number and all must be positive integers.
Here are some examples of valid T's on a 9*9 grid:
... |
When you edit a post on SE, any further edits within a 5-minute grace period are merged into it. Given a list of times you edit a post, count the edits not in a grace period.
Say you edit at minutes [0,3,4,7,9,10,11,12]. This results in 3 edits at times [0,7,12], with the rest happening in their grace periods.
0: [3,4... |
Introduction
This is a log of length 5:
#####
I want to pile a bunch of these logs on top of each other.
How I do this is that I slide a new log onto the topmost one from the right, and stop sliding when their left or right ends align (don't ask why).
If the new log is longer, it slides all the way to the left end of ... |
Background
We all know the famous Fibonacci sequence, where each term is the sum of the previous two, with the first term being 0 and the second one being 1. The first few elements are:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765
What we are going to implement today is a si... |
Challenge:
Take a list, L containing positive integers as input:
3 5 2 1 6
and create a matrix where the n'th column contains the vector 1:L(n), where shorter rows are padded with zeros.
Test cases:
3 5 2 1 6
-----------------
1 1 1 1 1
2 2 2 0 2
3 3 0 0 3
0 4 0 0 4
0 5 0 ... |
In one of this question's bonuses I asked you to design a permutation on the natural numbers such that the probability of a random term being odd was \$1\$. Now let's kick it up a notch. I want you to design and implement a permutation, \$f\$, on the natural numbers such that, for every integer \$n\$ greater than 0,... |
Specifications
For this challenge, you will be given a matrix of some sort in any reasonable format for a 2-D array. For each row except the last, in order from top (first) to bottom (last), rotate the row below it by x to either direction (you choose a consistent direction to use) where x is the first element in the c... |
Based on this Math.SE question; number copied from this answer. Number originally from a Numberphile video, of course.
Your task is to output the following 1350-digit prime number:
8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888881111111111111111111111118888881111111111111111... |
Write a program that displays on the screen the sum of the divisors of a number (1 ≤ N ≤ 100) entered by the user in the range of 1 to N.
This is OEIS A000203.
Examples:
Input: 7
7 / 1 = 7
7 / 7 = 1
7 + 1 = 8
Output: 8
Input: 15
15 / 1 = 15
15 / 3 = 5
15 / 5 = 3
15 / 15 = 1
15 + 5 + 3 + 1 = 24
Output: 24
Input: ... |
My job is stacking pebbles into triangular piles. I've only been doing this for a century and it is already pretty boring. The worst part is that I label every pile. I know how to decompose pebbles into piles of maximal size, but I want to minimize the number of piles. Can you help?
Task
Given an integer, decompose it ... |
This question is inspired by this answer. Coincidentally, I used to use Ethiopian Multiplication when I was a kid, but had never known the name of the method until recently.
Ethiopian multiplication is a method of multiplying integers using only addition, doubling, and halving.
Method:
Take two numbers to be multiplie... |
Based on this challenge and this Math.SE question. Idea originally come from a Numberphile video. The goal is to reproduce the logic of Professor McKee when he builds this prime.
Your task is to build the Trinity Hall Prime, at a much lower scale. You are given a single number N greater than 2, representing the length ... |
This is how the Kolakoski sequence (OEIS A000002) is defined:
The Kolakoski sequence is a sequence that contains 1 and 2, and the nth element of the sequence is the length of the nth group of equal elements (run) in the sequence itself. The first 20 terms of the sequence and the respective lengths are:
1 2 2 1 1 2 1 2... |
Based on a chat message
The Challenge
Given an input number \$n > 9\$, construct its reverse, ignoring leading zeros. Then, construct a list of all prime factors that the number and its reverse don't have in common. Multiply those factors together to create the Uncommon Factor Number of the input.
Or, to put it another... |
I'm one of the authors of Gimli. We already have a 2-tweet (280 chars) version in C but I would like to see how small it can get.
Gimli (paper,website) is a high speed with high security level cryptographic permutation design that will be presented at the Conference on Cryptographic Hardware and Embedded Systems (CHES)... |
Weirdo Incorporates have a weird way of grading their staffs by the number of days they were present in the office:
0 - 13 : F
14 - 170 : E
171 - 180 : D
181 - 294 : C
295 - 300 : B
301 - 365 : A
Note: The range is inclusive (i.e. 0-13 means 0 days and 13 days both will evaluate
as grade 'F').
Objective:
Write ... |
Background
Inspired by I'm a palindrome. Are you?, where it is presented the shocking fact that “()() is not a palindrome, but ())(”, I asked myself what instead is ()() and the answer is simply: it is a string with a vertical symmetry axis!
The task
Write a program or function that takes a string S (or the appropriate... |
They say that hate is a strong word. I wanted to find out why, so I had a good look at the word.
I noticed that every consonant had a vowel after it. That made it look quite strong to me, so I decided that that's what makes a word strong.
I want to find more strong words, so I'll need a program for it!
Finding strong w... |
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.