instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Notes
This thread is open and unlocked only because the community decided to make an exception. Please do not use this question as evidence that you can ask similar questions here. Please do not create additional showcase questions.
This is no longer a popularity-contest, nor are snippet lengths limited by the vote ... | stackexchange_codegolf |
Watch live | Active answers | Add new answer | Chat room | Source code | Leaderboard
New tournaments whenever needed. New players and new updates very welcome.
Not actual game footage.
Each player starts with one ant - a queen, who collects food. Each piece of food can be held or used to produce a worker. Workers also... | stackexchange_codegolf |
4, 32, 317, 3163, 31623, 316228, 3162278, 31622777, 316227767, 3162277661, 31622776602, 316227766017, 3162277660169, 31622776601684, 316227766016838, 3162277660168380, 31622776601683794, 316227766016837934, 3162277660168379332, 31622776601683793320, 316227766016837933200, 3162277660168379331999, 31622776601683793319989... | stackexchange_codegolf |
Introduction
The arithmetic mean is defined as being equal to the sum of the numerical values of each and every observation divided by the total number of observations. Symbolically, if we have a data set containing the values a1,…,an. The arithmetic mean A is defined by the formula
Objective
The challenge here is, gi... | stackexchange_codegolf |
Posted from sandbox
The Intro
What is an ACU? This challenge is based on the concept of money and since this is an international community, we all use different currencies, so in keeping with our spirit of inclusiveness, I have invented a new currency called Arbitrary Currency Units (ACUs) specifically for this challen... | stackexchange_codegolf |
Similar to this question, but this is a crossword variation!
Instead of only one letter per grid square, you can have one or two.
Input:
A 2d array, or whatever works in your language.
You can assume valid inputs
Any array size must work
Output:
An array of all the words
Across and down
All words must be joined to... | stackexchange_codegolf |
In this challenge we learned a way to encode every positive integer using factor trees.
Here is how it works:
The empty string has value of 1.
(S) where S is any expression with a value of S evaluates to the Sth prime.
AB where A and B are arbirary expressions with values of A and B respectively has value A*B.
For ex... | stackexchange_codegolf |
Background
A ray of light is fired from the top left vertex of an MxN Chamber, where M a denotes the width and N denotes the height of the chamber. The ray of light advances one grid space per second. Given that T is the number of seconds to be simulated, calculate the number of reflections in this time frame.
For exam... | stackexchange_codegolf |
Given an input integer, output the volume corresponding to the value. The value will always be in the range \$[0,100]\$.
Examples
If the input \$=0\$:
_/|
| |\/
|_ |/\
\|
If the input \$>0\$ and \$<33\$:
_/|
| |\
|_ |/
\|
If the input \$\ge33\$ and \$<66\$:
_/| \
| |\ \
|_ |/ /
\| /
If the input \$\ge66... | stackexchange_codegolf |
Someone I know has no coding experience, but has proposed an algorithm* to determine the character limit of text fields they find online. They copy a string containing the numbers from 1 to 1,000 inclusive, not separated in any way, and they read the last few digits it displays.
For example, after pasting, they might s... | stackexchange_codegolf |
I came across this picture the other day: (Credit to Josep M Batlle I Ferrer)
Your job is to generate this picture. This graph is generated by repeatedly applying newton's method to the graph of:
$$f(x)=\cosh(x)-1$$
In other words, repeatedly apply the following function to every point till the rectangular distance is... | stackexchange_codegolf |
Let's assume that
$$
f(x) = \frac{Ax+B}{Cx+D}
$$
Where, \$x\$ is a variable and \$A\$,\$B\$,\$C\$,\$D\$ are constants.
Now we have to find out the inverse function of \$f(x)\$, mathematically \$f^{-1}(x)\$, To do this first we assume,
$$
y = f(x)
\\\rightarrow y=\frac{Ax+B}{Cx+D}
\\\rightarrow Cxy+Dy=Ax+B
\\\rightarrow... | stackexchange_codegolf |
In 256 bytes or fewer write a function, \$f\$, from the positive integers to the positive integers that is:
Monotonic: larger inputs always map to larger outputs. (\$a < b \implies f(a) < f(b)\$)
Non-linear: does not have asymptotic order notation \$O(n)\$. (\$\displaystyle\forall c: \exists n:c\cdot n < f(n)\$)
Your... | stackexchange_codegolf |
Your task
Take a list of strings as the input, and output the maximum average ord.
Example
Given the list ['hello', 'world', 'bye']:
The average ord of 'hello' is:
(ord(h) + ord(e) + ord(l) + ord(l) + ord(o)) / len('hello')
= 106.4
The average ord of 'world' = 110.4
The average ord of 'bye' = 106.7
The maximum ave... | stackexchange_codegolf |
Given a positive number \$n\$ we call another (not same as n) positive number \$m\$ good if we insert same digits in both n and m and the resulting fractional value is same.
$$m/n = m_{\text{transformed}}/n_{\text{transformed}}$$
$$or$$
$$m*n_{\text{transformed}} = m_{\text{transformed}}*n$$
Clarifications:
No leading... | stackexchange_codegolf |
Write a program that outputs the exact string:
jan ale o, toki!
("Hello, world" but in toki pona to prevent builtins.)
with an optional trailing newline.
Additionally when all copies of any one byte present in your program are removed the program must fail to produce a correct output no matter what byte is selected.
T... | stackexchange_codegolf |
A natural number (written in the decimal base) is qualified as digisible if and only if it fulfills the following 3 conditions:
none of its digits is zero,
all the digits that compose it are different,
the number is divisible by all the digits that compose it.
The challenge is to output all the digisibles (there are ... | stackexchange_codegolf |
Introduction
Everyone knows the FizzBuzz sequence. It goes something like this:
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
.
.
.
In case you don't know, if the number is divisible by 3, it's Fizz. If it is divisible by 5, it's Buzz. If it is divisible by both, it's FizzBuzz. If it is not divisible by bo... | stackexchange_codegolf |
Write some code that takes a single string as input and outputs MSB-set aligned ASCII.
Only ASCII characters less than 128 (0x80) will be in the input. The output format is generated as follows:
For each character convert it to its binary representation, remove the MSB (always 0 in the input) and then add a delimiter-... | stackexchange_codegolf |
Given a list of positive integers, partition the list into two sublists such that the absolute value of the difference of the sums over the two sublists is minimal.
The output of the program should be the (non-negative) difference of these sums.
Examples:
[1,2,3] -> 0 # [1,2], [3]
[2,3,5,7,11] -> 0 # [2,5,7], ... | stackexchange_codegolf |
Challenge
In this challenge, we will use a language that is very similar to Brainfuck but slightly different.
This variant of BF does not have any input and output commands; instead, it simply takes a tape as input and modifies it until it halts. The final state of the tape is considered the output of the program.
The... | stackexchange_codegolf |
Challenge
Create a function that takes an string as a parameter. (Easy as far)
This string will contain
Single digit numbers
Letters from the alphabet
Question marks (Of course)
Your function will check if there are exactly 3 question marks between every pair of two numbers that add up to 10 or more. If so, then your... | stackexchange_codegolf |
The knight is a chess piece that, when placed on the o-marked square, can move to any of the x-marked squares (as long as they are inside the board):
.x.x.
x...x
..o..
x...x
.x.x.
Eight knights, numbered from 1 to 8, have been placed on a 3×3 board, leaving one single square empty ..
They can neither attack each other... | stackexchange_codegolf |
Credit goes where credit is due
Given two digits, x, and y, calculate the shortest number of horizontal or vertical jumps to get from x to y on a standard numpad, e.g.
789
456
123
00
You can safely assume that all inputs will be 0-9, and you do not have to handle invalid inputs. The input may be the same number twice... | stackexchange_codegolf |
The system
Assume the Earth is flat and that it extends infinitely in all directions. Now assume we have one infinitely long train railway and n trains in that railway. All trains have different speeds and all trains are going in the same direction. When a faster train reaches a slower train, the two trains connect (be... | stackexchange_codegolf |
A polyomino with \$n\$ cells is a shape consisting of \$n\$ equal squares connected edge to edge.
No free polyomino is the rotation, translation or reflection (or a combination of these transformations, i.e. an isometry) of another (they're equal).
The sequence of free polyominoes with \$n\$ cells is as follows:
1, 1, ... | stackexchange_codegolf |
Given two sets of strings, \$ D \$ and \$ R \$, find the shortest string which contains every string in \$ D \$, but contains none of the strings in \$ R \$.
There are almost always multiple possible outputs; you should output at least one of them, but you can output more.
You can assume this is possible with the input... | stackexchange_codegolf |
This puzzle works for any programming language that has the same // single-line and /* ... */ multi-line comments that C++, C# and Java do.
You are debugging an application. You find a fishy block of code, which you comment out and replace with some new code:
/*
code block A
*/
code block B
After some debugging, you f... | stackexchange_codegolf |
I have this problem where I listen to so much music that I can never remember what songs are called. But even if I remember the lyrics, I won't always know the song's name. But lucky for me, there's a pretty neat formula to determine¹ the title of a song just based on its lyrics.
I'll define the way a song title can be... | stackexchange_codegolf |
A sequel to What dice do I need to display every integer up to X?
Numbers are great, but let's take it to the next level. I'd like to have a set of dice that can be arranged and rotated to display any words I want. Think Boggle:
And not just that; I want to specify the number of sides those dice have. The set should c... | stackexchange_codegolf |
Introduction:
I think we all know it, and it has probably been translated in loads of different languages: the "Head, Shoulders, Knees and Toes" children song:
Head, shoulders, knees and toes, knees and toes
Head, shoulders, knees and toes, knees and toes
And eyes and ears and mouth and nose
Head, shoulders, kne... | stackexchange_codegolf |
Disclaimer: This is heavily inspired by "Polyglot the OEIS!" but fixes the problem that lead to closure (see the output section) and was re-posted as to not invalidate answers.
Introduction
We all know and love the on-line encyclopedia of integer sequences (OEIS). So what if we made an off-line version of the interesti... | stackexchange_codegolf |
This is the first in a series of Island Golf challenges. Next challenge
Given an island in ASCII-art, output an optimal path to circumnavigate it.
Input
Your input will be a rectangular grid consisting of two characters, representing land and water. In the examples below, land is # and water is ., but you may substitut... | stackexchange_codegolf |
Given a number as input, determine how many significant figures it has. This number will should be taken as a string because you have to do some special formatting. You'll see what I mean soon (I think).
A digit is a sig-fig if at least one of the following apply:
Non-zero digits are always significant.
Any zeros bet... | stackexchange_codegolf |
The task here is to read from a Golly .rle or plaintext file (your choice) whose filename is provided (on STDIN or as a command line argument) and identify and count the common patterns in the grid encoded therein.
Alternatively, you may choose to have the contents of the file provided directly over STDIN instead.
Your... | stackexchange_codegolf |
related
What's assignable to what?
In this challenge you will be given two types, A and B and determine if A is assignable to B, B is assignable to A, or neither.
The Type System
(I will use t to represent any type)
Basic Types
Basic types are represented by a single capital letter, such as X. They are basically class... | stackexchange_codegolf |
Introduction
A radix tree, also known as compressed trie or compressed prefix tree, is a tree-like data structure for storing a set of strings.
The edges of the tree are labeled by nonempty strings, and each node is either terminal or nonterminal.
The strings that the tree contains are exactly the labels of all paths f... | stackexchange_codegolf |
Each term in the squaring sequence, \$x_n\$, is created by taking \$x_{n-1}\$, squaring it, and removing all but the first four digits.
The sequence always begins with \$x_1 = 1111\$. Squaring this yields \$1234321\$, so \$x_2 = 1234\$
The first few terms are:
1111
1234
1522
2316
5363
...
The Challenge
Your task is t... | stackexchange_codegolf |
quintopia has posted here a challenge to compute multinomial coefficients (some of the text here is copied from there). There is a fun algorithm to compute multinomial coefficients mod 2.
Given a list of numbers, k1, k2, ... ,km, output the residue of the multinomial coefficient:
reduced mod 2. The following algorith... | stackexchange_codegolf |
We can arrange the positive integers like this:
1_| 2 | 5 | 10
4___3_| 6 | 11
9___8___7_| 12
16 15 14 13
That is, in L-shaped brackets expanding down and right infinitely.
Then, we can read it off with the antidiagonals:
1 2 5 10
/ / /
4 3 6 11
/ / /
9 8 7 12
/ / /
16 15 14 13
For the above, we rea... | stackexchange_codegolf |
Objective
Given a nonempty multiset of Rock, Paper, and Scissors, output the winning figure according to the special rule.
Background
For a multiplayer RPS, if all three figures come out, usually it's considered a draw. But by that rule, the probability to draw would dramatically increase when there are many and many p... | stackexchange_codegolf |
Task
Given the page of a book P on stdin, count all occurrences of the digits 0-9 in each member of the range 1 to P. There is no page zero and your program should handle any number less than 1,000,000. Since putting a constraint on how you can do it is difficult to explain there will be a time limit of 3 seconds inste... | stackexchange_codegolf |
Try it online! currently has 680 listed languages, all of which are searchable. For most of those languages, when searching for it, you don't have to enter the entire string. For example, entering lega results in just 05AB1E (legacy) appearing, and entering d+ results in only Add++. However, for some languages, there i... | stackexchange_codegolf |
Since I am INSANELY hyped for the Final Fantasy XV Uncovered event, I want you to write me a program to tell me when it is!!!
The input
Your take input in the form of HH:MM XDT, where HH is a number in the range 1-12, MM is a number between 0-60, and XDT is a time zone, with X being one of E (eastern, UTC-4), C (centra... | stackexchange_codegolf |
Construct a full program which outputs Hello, World!. The score of your submission will be equal to the sum of all of the ASCII values of the distinct characters. The lowest score wins!
Rules
It must be a full program which takes no input
It must only print to STDOUT, nothing else
It must be strictly less than 1000 by... | stackexchange_codegolf |
I'm new to this stackexchange, but I must say I am very impressed by the knowledge of some here, and the original codegolf answers for some questions.
I'm not even sure if the following is possible, since my programming language knowledge is very limited, but it sounds like a pretty interesting challenge:
Goal:
Output ... | stackexchange_codegolf |
I have a new programming language called Brussels-Sprout. Brussels-Sprout functions in an array of 256 boolean values, all initialized to zero, has one instruction pointer, and one "bit index".
After each (non-branching) instruction is executed, the instruction pointer is incremented by one. If the instruction pointer... | stackexchange_codegolf |
Intro
Reverse and add is as simple as it sounds, take n and add it to its digits in reverse order. (e.g. 234 + 432 = 666).
If you apply this process repeatedly some numbers will eventually hit a prime number, and some will never reach a prime.
Example
I currently have
11431 rep.
11431 is not prime
11431 + 13411 = 2484... | stackexchange_codegolf |
Challenge
Create the image of a pride flag (rainbow flag), i.e. a six coloured striped flag (from top to bottom): red, orange, yellow, green, blue, and violet.
Output
Example (R)
barplot(rep(1, 6), horiz = TRUE, axes = FALSE, space = 0, border = NA, col = c("darkviolet", "blue", "darkgreen", "yellow", "orange", "red")... | stackexchange_codegolf |
Introduction
You started to write a "Hello, World!" program, but after you wrote the part to print the hello, you forgot what your program should actually print. So now, you somehow managed it to write a program which can check if the entered word is what you search.
The task
Your task is to write a program or function... | stackexchange_codegolf |
This is the Robbers thread. For the Cops challenge, see here
As the robbers, your job is to crack the cops' answers. Choose an uncracked, unsafe cop answer and attempt to figure out which languages, in which order, the cop used.
Note that a crack is valid even if the languages are different. So long as the the language... | stackexchange_codegolf |
Let \$p(x)\$ be a polynomial. We say \$a\$ is a root of multiplicity \$k\$ of \$p(x)\$, if there is another polynomial \$s(x)\$ such that \$p(x)=s(x)(x-a)^k\$ and \$s(a)\ne0\$.
For example, the polynomial \$p(x)=x^3+2x^2-7x+4=(x+4)(x-1)^2\$ has \$1\$ and \$-4\$ as roots. \$1\$ is a root of multiplicity \$2\$. \$-4\$ is... | stackexchange_codegolf |
Inspired by my geography class, Sandboxed
Simulate weathering / erosion.
Input
Input will be given as a string of any 2 characters (or see below) you like in the shape of the rock (here i use spaces and hashes):
###
####
#####
#######
#######
########
Or if your language doesn't support strings, a square matrix ... | stackexchange_codegolf |
You should write a 100-byte long brainfuck (BF) program.
One character will removed from it in every possible way the resulting 100 new (99-byte long) programs. E.g. for the program ++.>. the 5 subprograms are +.>., +.>., ++>., ++.. and ++.> .
Your score will be the number of unique outputs the 100 programs generate. ... | stackexchange_codegolf |
Given a positive integer as input, output the smallest positive integer such that appending its digits (in base 10) to the end of the input number will form a prime number.
Examples
1 --> 1
2 --> 3
8 --> 3
9 --> 7
11 --> 3
20 --> 11
43 --> 1
134 --> 11
3492 --> 11
3493 --> ... | stackexchange_codegolf |
Your task: given a number n, generate a '+' sign that is n characters away from its center. If this is confusing, check out the test cases.
Standard methods of input: output must be a string or printed. Standard loopholes apply.
Input: 1
Output: + ] 1 away from center `+`.
Input: 2
Output: + ] 2 a... | stackexchange_codegolf |
A person has two first names if their last name is also a common first name. You are tasked with determining which full names in a list are two first names.
John Smith
John Doe
Luke Ryan
Ryan Johnson
Jenna Jackson
Tom John
Any name that occurs in the first name column is potentially a first name. If the number of occu... | stackexchange_codegolf |
Given a set of two strings guaranteed to be the same length, print their criss cross.
The criss cross of two strings is obtained as follows.
Yield the second character of the second string, then the first character of the first string.
Yield the first character of the second string, then the second character of the fi... | stackexchange_codegolf |
The Challenge
Given a grid of numbers (10 <= N <= 99)
Return number with the highest sum of the four numbers adjacent to it; that is the numbers above, below, right, and left of the number, but not itself.
The number itself does not count, only its four neighbors.
A number on the edge should be treated as though the m... | stackexchange_codegolf |
Inspired by this question about packing into this format.
Occasionally I see a completed crossword and being as I am, I can't be bothered to find out what the solutions to the clues actually were.
Input:
A 2D string (any format, newline separated, 2d list etc.)
Blank squares will be represented with a (space characte... | stackexchange_codegolf |
You have given an array from which we need to remove duplicates.
Rules:
First or immediate duplicates gets removed first.
Array contains natural numbers a[i]>0 for i>=0
no. of elements in the array is greater than 1 i.e. n>1
e.g.
{1,2,3,4,5,5,4,6,6,7,8}=> {1,2,3,7,8}
{1,2,3,3,4,5,6,7,7,8} => {1,2,4,5,6,8}
{1,1,3,3,... | stackexchange_codegolf |
Introduction
A "lobster number", by my own designation, is a number that contains within itself all of its prime factors. The "lobster" description was inspired by the recent question "Speed of Lobsters". The basic idea is that each prime factor can be made by lobsters munching away digits of the number until you are... | stackexchange_codegolf |
Originally sandboxed by @xnor
Left-or-right is a very simple language @xnor made up. Its expressions are made of arrows < (left), > (right), and parentheses. The goal is to evaluate an expression to either < or >.
An expression A<B picks the left item A, while A>B picks the right one B. Think of < and > as arrows point... | stackexchange_codegolf |
Word changer is a game where you are trying to turn one word into another via single-character edits, with each step being its own word. For this challenge, edits may be replacements, insertions, or deletions. For example, WINNER → LOSER can be done with this route (there may be others):
WINNER
DINNER
DINER
DINE
LINE
L... | stackexchange_codegolf |
Implement a function or program that can run simplified BitCycle code. The functions you must implement are:
<^>v: Change the direction of a bit to the direction this is pointing.
+: Turn all 0s left and all 1s right.
\ and /: Reflect one bit 90 degrees, then become inactive. In regular BitCycle, this is displayed as -... | stackexchange_codegolf |
Task
Write a polyglot in two languages that when run, outputs the name of the language it is run in. Additionally, this program must also output the other language's name if the source code is reversed
Example:
Program ABC in language foo outputs foo. ABC in language bar outputs bar. CBA in language foo outputs bar, an... | stackexchange_codegolf |
In Elixir, (linked) lists are in the format [head | tail] where head can be anything and tail is a list of the rest of the list, and [] - the empty list - is the only exception to this.
Lists can also be written like [1, 2, 3] which is equivalent to [1 | [2 | [3 | []]]]
Your task is to convert a list as described. The ... | stackexchange_codegolf |
Given an integer n, your task is to determine whether it is a perfect square that when reversed, is still a perfect square. You may assume n is always positive.
When numbers such as 100 (10x10) are reversed the result may have leading zeros (001) In this case, ignore the leading zeros and treat it as 1 (1x1).
Test case... | stackexchange_codegolf |
As in this challenge, the task is to generate the vertices of a polyhedron. The polyhedron here is the one obtained by dividing a regular icosahedron's triangular faces into smaller triangles so that each edge is divided into \$b\$ segments (denoted \$\{3,5+\}_{b,0}\$ here) and projecting onto the unit sphere. Your pro... | stackexchange_codegolf |
Lets say your job is to paint poles, and a client asks you to paint a pole with 4 red sections and 3 yellow sections. You can do that pretty easily as follows:
r y r y r y r
With just yellow and red stripes. Now lets say your client asks you to paint a pole with 2 red sections, 2 yellow sections, and 1 green section... | stackexchange_codegolf |
Alice, Bob, Carol, Dave, and Eve are going out for a nice game of golf and need your help to decide in what order they will play.
Your program will input some statements, which are defined as a condition, and then one or more optional logical boolean operators followed by another condition. (That's [Condition]([Logical... | stackexchange_codegolf |
Stackylogic is a logic-based programming language I made up that take in 0's and 1's for input and outputs a single 0 or 1 upon completion.
A Stackylogic program consists of lines that can only contain the three characters 01? as well as exactly one < at the end of one of the lines. Lines may not be empty and the line ... | stackexchange_codegolf |
Problem
You are given a binary string A of length N.
You can perform the following type of operation on the string A:
Choose two different indices \$i\$ and \$j\$ (\$1 \le i\$, \$j \le N\$)
Change \$A_i\$ and \$A_j\$ to \$Ai \oplus Aj\$. Here \$\oplus\$ represents the bitwise XOR operation.
Input
A binary string con... | stackexchange_codegolf |
Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of the detailed cases below. You must remove non-alphabetic characters except (space), _ (underscore) and - (hyphen), then ... | stackexchange_codegolf |
What general tips do you have for golfing in Haxe? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Haxe (e.g. "remove comments" is not an answer).
Please post one tip per answer.
Haxe can be run online here!
| stackexchange_codegolf |
Fortress was a language being developed by the Sun Programming Language Research Group (R.I.P. Fortress) that had a unique property to it, it was possible to render ("Fortify") programs in different font-styles (i.e. blackboard bold, bold, italics, roman, etc. ). The goal is to represent a one-char Fortress variable in... | stackexchange_codegolf |
This question brought to you by a game I like to play when stuck in long phone meetings.
Given any two times from a 24 hour clock (from 00:00 to 23:59), how many valid mathematical equations can be generated with all of the times in between using only basic arithmetic operations?
Input: two four digit strings (no colon... | stackexchange_codegolf |
This is a repost of Evolution of “Hello World!”, originally written by user Helka Homba
It should not be closed as a duplicated, due to meta consensus here.
The original was asked over two years ago and was last active more than six months ago. I have permission from Helka Homba to post this here
Since the original, ma... | stackexchange_codegolf |
Introduction
Just on Hacker news, John Resig contemplates
transforming a query “foo=1&foo=2&foo=3&blah=a&blah=b” into one that looks like this: “foo=1,2,3&blah=a,b", https://johnresig.com/blog/search-and-dont-replace/.
He claims "being 10 lines shorter than Mark’s solution".
Query strings consist of sequences of name-v... | stackexchange_codegolf |
You are the electoral strategist for a sudden late entrant in the 2020 US presidental election.
Your task: print out the names of states* your candidate will win, totalling at least 270 electoral college votes.
Background
Each state (and Washington DC) in the US system has an arbitrary number of "electoral college vot... | stackexchange_codegolf |
Inspired by this building (United States Air Force Academy Cadet Chapel, Colorado)
Your task is simple, given a positive integer n, output the spiked building to size n
Testcases
1
->
^
/|\
/.|.\
/..|..\
_______
2
->
^ ^
/|\/|\
/.|..|.\
/..|..|..\
__________
7
->
^ ^ ^ ^ ^ ^ ^
/|\/|\/|\/|\/... | stackexchange_codegolf |
V1.1: Added criterion to help with tiebreakers, a bit overkill but still.
Task: Crack the scrambled code for calculating the argument of a complex number \$z=x+iy\$ given two inputs.
You must post a comment in the cops’ thread with a link to your working source, mentioning clearly that you have cracked it. In your ans... | stackexchange_codegolf |
How many of you that still use your own knuckle to determine whether a month is having a full 31 days or less?
You job is to write a program to count how many months, in a month range, are having a full 31 days and how many are having less than 31 days by "counting the knuckles".
Courtesy: amsi.org.au
Input
A pair of... | stackexchange_codegolf |
Related
You are a manager at a large number factory. You want to show everyone your business is doing well, by showing randomly chosen samples. Unfortunately, your business is not doing that well. But luckily, you have a bit of ingenuity...
Write a program or function that when given an array of unique, positive numbe... | stackexchange_codegolf |
You are a historian studying a long forgotten language. You have just discovered a clay tablet which seems to list all known words in the language, in alphabetical order. Your task is to find this alphabet's order, if it exists.
The Task
Given an ordered list of words, try to output an ordered list of characters such t... | stackexchange_codegolf |
This is a cops-and-robbers challenge based around defining languages and proving they are Turing complete.
This is the cops' thread. The robbers' thread is here.
Cops
As a cop, you will prepare two things:
A formal specification of a programming language, or other computational system. (Computational systems are defin... | stackexchange_codegolf |
Introduction
Let's say that S1 = a...b and S2 = ..c... If we place them on top of each other, we get:
a...b
..c..
We merge both strings, with the . as the liquid character (which can overlapped). We get this:
a.c.b
If one of the string is longer than the other, we just apply the same algorithm:
a.....b
..c..
becom... | stackexchange_codegolf |
Given a non-empty set of strings and a list of strings, find out how many times the set occurs in the list, i.e. how many times you could create the set with items from the list. Every element from the list can only be used once.
Hint: a set is an unordered list of unique items.
Default input/output rules apply.
No e... | stackexchange_codegolf |
Objective
Given an unlabelled binary tree, decide whether it is contiguous in indices.
Indices
This challenge gives one-indexing on binary trees. The exact definition expresses all indices in binary numeral:
The root is indexed 1.
For every node, to get the index of its left child, replace the most significant 1 by 1... | stackexchange_codegolf |
Problem:
You must make a program that does the following:
takes a large string of lowercase text, and counts all the occurrences of each letter.
then you put the letters in order from greatest to least occurences.
then you take that list and turns it into an encoder/decoder for the text.
then encodes the text with tha... | stackexchange_codegolf |
In Map inputted ASCII characters, I asked you to .. map inputted ASCII characters. This time, you will do the opposite, by immediately mapping all ASCII characters, and then mapping spaces over them.
This program will have practical uses, such as seeing what characters you have left in a restricted-source challenge sub... | stackexchange_codegolf |
Specifically, Conway's PRIMEGAME.
This is an algorithm devised by John H. Conway to generate primes using a sequence of 14 rational numbers:
A B C D E F G H I J K L M N
17 78 19 23 29 77 95 77 1 11 13 15 15 55
-- -- -- -- -- -- -- -- -- -- -- -- -- --
91 85 51 38... | stackexchange_codegolf |
As some of you may know, to get a language onto Dennis's wonderful Try It Online!, a Hello, World! program is required. Recently, Dennis pushed up a way to load these programs from the website. Here is a JSON pastebin of the characters used in those programs, by frequency, as of July 27, 2017.
Some of those characters ... | stackexchange_codegolf |
I was trying to write a short MIPS32 code for computing the median of three registers.
The rules:
Assume that some values are pre-loaded into $t0, $t1, $t2.
The median of the three values should be placed in $t0.
No branches are allowed, but otherwise any instruction is okay.
You may arbitrarily modify the values of a... | stackexchange_codegolf |
For today's task, we have two programs, P and Q, both in the same language. Each of them receives a single-character input.
If P receives character K, P says how many times K appeared in Q. (You can use any output format for P or Q; they need not be the same, the only requirement is that your format can represent any n... | stackexchange_codegolf |
We've all been burned by the grammar police on the internet. What we need is a regex that can be used in place of "there", "their", and "they're". This would shift burden of grammar parsing from the writer to the reader (a sort of "client-side" grammar, if we you will). So, here's what I have to start with:
the([re]|[i... | stackexchange_codegolf |
Challenge:
Given two inputs, x and y, round x to one less significant figure, then repeat until it has y number of unrounded digits left. (the decimal point does not count as a digit)
Input & Output
Input can be a combination of strings and integers, e.g. you can have the input as a string and the output as an int, o... | stackexchange_codegolf |
Can the Tune be Played?
Explanation
A broken musical keyboard has keys labelled with positive integers. It is broken in two ways:
It takes a long time to process key presses: after pressing the key labelled with the number \$n\$, there is a gap of \$n\$ seconds before the \$n\$th note is heard.
So, for example, the \$... | stackexchange_codegolf |
You know those letterboards outside old-style cinemas which show upcoming films - perhaps you have a miniature one in your home?
If you've operated one, you'll know that you can normally add letters from either side of a row. But the slots (in which you slide letters) are thin, so it's impossible to swap the order of ... | stackexchange_codegolf |
Background
Hamiltonian circuit problem is a decision problem which asks whether a given graph has a Hamiltonian circuit, i.e. a cycle that visits every vertex exactly once. This problem is one of the well-known NP-complete problems.
It is also known that it remains so when restricted to grid graphs. Here, a grid graph ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.