instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Write a program or function that, given an integer n, construct an array with n dimensions of n length, where each element is an identifier of its own coordinates. That is, starting with one array, populate it with n arrays, where each of those contain n more arrays, up to a depth of n-1. The elements of the deepest ar... | stackexchange_codegolf |
Github
You have probably played, and may even have written a program to play, a simple number guessing game. If so, this probably looks familiar:
Try to guess my number (1 to 100)!
Please enter a guess: 50
Too small, guess again!
Please enter a guess: 75
Too big, guess again!
Please enter a guess: 63
Correct!
(Obvious... | stackexchange_codegolf |
Inspired by this
Task
Your task is to output the average character of your code.
What is an average character?
Say we have a string golf().
We then take the ASCII value of each separate symbol, so our string is 103 111 108 102 40 41, and calculate the average of those values, rounded to an integer. In our case the aver... | stackexchange_codegolf |
Challenge
Giving a valid arithmetic sum with some missing numbers, output the full expression.
Example:
1#3 123
+ 45# => + 456
-------- --------
579 579
Input
Expression format can be an array ["1#3", "45#", "579"], a string "1#3+45#=579", or 3 inputs f... | stackexchange_codegolf |
In this programming-puzzle, your goal is to write the following function in JavaScript, using (essentially) point-free (tacit) programming:
(f) => void(f())
Your submission should be an expression which returns a function which behaves like the above (taking a function as an argument and calling it, and returning unde... | stackexchange_codegolf |
The world is full of Turing-complete programming languages. Just about every useful language (and most useless ones) are Turing-complete. Some even became Turing-complete by accident. Often this is great, since every Turing-complete language supports the same power of universal computation. But the power of Turing ... | stackexchange_codegolf |
Kids-related intro
Whenever I take my kids to an amusement park, the kids get more nervous the closer we are to the park, with the nerve peak when we are in the parking lot and find no place to park. So I've decided I need a method to find the closest free parking space to minimise the time spent parking.
Technical int... | stackexchange_codegolf |
Problem:
Given a set of integers, find the sum of all positive integers in it.
Input:
t – number of test cases [t < 1000]
On each of next t lines, an integer N [-1000 ≤ N ≤ 1000]
Output
The program should output the sum of all the positive integers.
Check your code in online judge
Score
Score is equal to size of sour... | stackexchange_codegolf |
In mathematics, matrix multiplication or the matrix product is a binary operation that produces a matrix from two matrices. The definition is motivated by linear equations and linear transformations on vectors, which have numerous applications in applied mathematics, physics, and engineering. In more detail, if A is an... | stackexchange_codegolf |
The challenge is to write a golf-code program that, given n positive real numbers from 0 to 10 (format x.y, y only can be 0 or 5: 0, 0.5, 1, 1.5, 2, 2.5 … 9.5 and 10), discard the lowest and highest values (only one, even though they are repeated) and shows the average of the remaining, in x.y format (y can be 0 or 5, ... | stackexchange_codegolf |
I keep hearing that thinking outside the box is a goal worth achieving, but how can I tell if I'm successfully doing it?
To solve this dilemma I have already wrote a Brainwave-to-ASCII-translator which in theory should produce outputs like
#
+------------+ #
| thinking | #
| ... | stackexchange_codegolf |
Challenge
So, um, it seems that, while we have plenty of challenges that work with square numbers or numbers of other shapes, we don't have one that simply asks:
Given an integer n (where n>=0) as input return a truthy value if n is a perfect square or a falsey value if not.
Rules
You may take input by any reasonable... | stackexchange_codegolf |
Consider a permutation of the integer values from 1 to N. E.g. this example for N = 4:
[1, 3, 4, 2]
We'll consider this list to be cyclic, such that 1 and 2 are treated as adjacent. One quantity we can compute for such a list is the total squared difference of adjacent values:
(1-3)² + (3-4)² + (4-2)² + (2-1)² = 10
Y... | stackexchange_codegolf |
Shocking news: Dr. Mad J Scientist has released a proof of P = NP to the world. But the proof is nonconstructive, and she's keeping the algorithm to herself.
Worry not. Without even looking at her proof, we can still (almost) write a computer program that solves NP-complete problems in polynomial time.
The Problem
Inpu... | stackexchange_codegolf |
Your task
Randomly pick and print "Joe Mama" or "Joe Biden" in as little bytes as possible.
Rules
No trailing lines, spaces, or anything else weird like that
No election fraud! Both "Joe Mama" and "Joe Biden" must have equal chaces of winning
Prize
The winner will get a spot in https://github.com/Sid220/joe-mama-or-j... | stackexchange_codegolf |
Task
Given two positive integers a, b and a Unicode mathematical inequality symbol c, determine if a c b is true.
You many take the character or its Unicode codepoint for the input c. You may output your language's truthy/falsy values, or two distinct values for true and false respectively.
Standard code-golf rules app... | stackexchange_codegolf |
Minesweeper is a logic game found on most OS's. The goal of the game is to determine where the mines are on a grid, given numbers indicating the number of mines around that spot.
Given a grid size, and a set of mines, generate the Minesweeper grid for that set of mines.
Input: Two integers indicating the grid size, and... | stackexchange_codegolf |
This is my 12th question, so I thought of this idea.
Goal:
Output 12, with any preceding or trailing whitespace permitted
In as many languages as possible (where different versions or flags count as the same language)
Without using any numbers
The criteria for a valid programming language are the same as those of The ... | stackexchange_codegolf |
Objective
Given a positive integer, spell it out in the conlang I made.
Specification
Let \$n\$ be the inputted integer. \$n\$ shall be spelled out in the following specification. The entire spelling is case sensitive.
With the decimal expansion of \$n\$, let d be the least significant nonzero digit of \$n\$.
First, d ... | stackexchange_codegolf |
The Challenge
Given a string, output the text in the shape of a square.
You can assume that the text will always fit in a square, and that it will never be an empty string.
You can also assume it will never have newlines.
Example
Input:
Hi, world
Output:
Hi,
wo
rld
Test Cases
Input:
Hi, world! Hello
Output:
Hi,
wo... | stackexchange_codegolf |
The gambler's fallacy is a cognitive bias where we mistakenly expect things that have occurred often to be less likely to occur in the future and things that have not occurred in a while to be more likely to happen soon. Your task is to implement a specific version of this.
Challenge Explanation
Write a function that r... | stackexchange_codegolf |
Objective
Given input r and n find the first n natural numbers x such that if we rotate the first digit to the last place we obtain x/r.
You may assume that 2 <= r <= 9 and 1 <= n <= 65535.
You may write a program which takes input from stdin or command-line arguments; or you may write a function which takes r and n as... | stackexchange_codegolf |
Background
Complex floor is a domain extension of the mathematical floor function for complex numbers. This is used in some APL languages to implement floor ⌊, ceiling ⌈, residue |, GCD ∨, and LCM ∧ on complex numbers.
For the rest of this challenge, an integer refers to a Gaussian integer, i.e. a complex number whose ... | stackexchange_codegolf |
There has been a question about yes in the past, but this one is slightly different. You see, despite yes having a rather long size, it is incredibly fast. Running the following command:
timeout 1s yes > out
yields a file that is 1.9 GB. Compared to this program:
int puts();main(){while(1){puts("y");}}
which yields a... | stackexchange_codegolf |
SVG is an XML vector graphics markup language embeddable in web content.
Your tips should be at least somewhat specific to SVG.
Please post one tip per answer.
| stackexchange_codegolf |
Challenge
In this challenge, you are to code in any language a program or function that will take a string and replace certain characters within it with different characters.
Input
The input is the same for both functions and full programs:
[string] [char1] [char2]
string will be an indefinite line of characters surr... | stackexchange_codegolf |
In 2015 the Portland International Airport began the replacement of their iconic carpet. I want you to write a program to draw their old carpet in as few bytes as possible.
The carpet:
Specifications
Here is a link to a scalable pdf image of one tile. Your output should match the relative dimensions and placement o... | stackexchange_codegolf |
Let's consider a list \$L\$ (initially empty) and a pointer \$p\$ into this list (initialized to \$0\$).
Given a pair of integers \$(m,n)\$, with \$m\ge 0\$ and \$n>0\$:
We set all uninitialized values in \$L\$ up to \$p+m+n\$ (excluded) to \$0\$.
We advance the pointer by adding \$m\$ to \$p\$.
We create a vector \$[... | stackexchange_codegolf |
Rosetta Stone Code Challenges are challenges where you must complete the task in as many languages as possible.
The Challenge
You will be given two numbers, n and s, in a list as input. The n will be a number you have to count up to. n will be any number from 2 to 10000. s will be the number you skip by when counting u... | stackexchange_codegolf |
Given a string \$X\$ we will say two strings, \$a\$ and \$b\$, are building blocks of \$X\$ if \$X\$ can be made by concatenating some \$n\$ \$a\$s with \$m\$ \$b\$s in any order. For example the string tomato has building blocks to and ma:
to ++ ma ++ to
We will say that the fineness of a set of building blocks is th... | stackexchange_codegolf |
Introduction:
In my recent Strikethrough the Word Search List challenge I mentioned the following:
When I do the word-search puzzles, I (almost) always go over the words in order, and strike them through one by one.
In some cases I do them in reversed order as a change of pace, although that doesn't matter too much r... | stackexchange_codegolf |
Interpret DOGO
DOGO is a lesser known programming language. While the original DOGO (a joke language from a Usenet post) has never been implemented, a language resembling it has been created. The commands for the language are:
+===========+================================================================+
| Command | ... | stackexchange_codegolf |
Your task is to turn a square root like this:
√12
into a form like this:
2√3
For our purpose, we only need to output the left number here:
2
Test cases
4 -> 2
9 -> 3
12 -> 2
13 -> 1
108-> 6
Specifications
You may assume for the input that \$n>0\$. \$n\$ has to be as large as possible.
If the number is already a ... | stackexchange_codegolf |
Everyone knows what run-length encoding is. It has been the subject of many code-golf challenges already. We'll be looking at a certain variation.
Example
Normal: 11222222222222222222233333111111111112333322
Run-length: 112(19)3(5)1(11)2333322
The number in parentheses specifies the number of times the previous symbol... | stackexchange_codegolf |
This is the robbers' thread, the cops' thread is here
A polyglot is a program, that without modification, can run in multiple languages.
Robbers' Challenge
First, find a vulnerable cop's answer, then try to find languages that the submission works in, if you found any that weren't listed by the cop, then you just cra... | stackexchange_codegolf |
Notation and definitions
Let \$[n] = \{1, 2, ..., n\}\$ denote the set of the first \$n\$ positive integers.
A polygonal chain is a collection of connected line segments.
The corner set of a polygonal chain is a collection of points which are the endpoints of one or more of the line segments of the chain.
Challenge
T... | stackexchange_codegolf |
Challenge
The main objective of the challenge is pretty simple, this is an answer chaining contest, where you have to serially print numbers from 1. That means User 1's answer will print 1, then User 2's answer will print 2 and so on. But there are some rules to make the contest tougher.
Rules
You can't use the charac... | stackexchange_codegolf |
Intro
Cookie Clicker is a popular browser game in which the player has to click a cookie to gain... Cookies!
The player can buy upgrades which will automatically farm cookies for you. Sometimes a golden cookie will enter the screen, which will provide a bonus upon clicking it.
Challenge
This challenge will not be about... | stackexchange_codegolf |
Intoroduction
If you've ever been to Epcot at Disney World, you've probably been to the world showcase: a lake surrounded by various country-themed locations. One thing that's always bothered me about it is that the countries don't appear in the order you would run into them around the world. There are officially eleve... | stackexchange_codegolf |
Background
The number 1729 is the Hardy-Ramanujan number. An amazing property of it was discovered by S. Ramanujan (who is widely regarded as the greatest Indian mathematician1), when G.H. Hardy paid a visit to him in a hospital. In Hardy's own words:
I remember once going to see him when he was ill at Putney. I had r... | stackexchange_codegolf |
Typescript is a typed superset of Javascript. For this challenge, we'll consider the following classic basic types:
string
number
boolean
undefined
null
And two "meta" types:
any
never
The type any annotates that any type is valid:
const a: any = "foo";
const b: any = 42;
const c: any = true;
const d: any = undefin... | stackexchange_codegolf |
Introduction:
Unfortunately an Accordion Solitaire Solver challenge already exists (Solve a game of Accordion), so instead this easier related challenge.
Let's start by explaining how Accordion Solitaire works:
You start with all 52 cards (or 53 if you add a Joker) in one big row.
You pile up cards from right to left ... | stackexchange_codegolf |
In one of our projects at work, we recently discovered a particularly large method for generating a 6 character string from a 15 character alphabet. A few of us claimed "I bet we can get that in one line" which started a little internal game of code golf.
Your task is to beat us, which I have no doubt won't take long!
... | stackexchange_codegolf |
RPS 25 is a version of Rock Paper Scissors which has 25 hand symbols instead of just 3. Each symbol defeats 12 symbols, and is defeated by 12 others.
Here's a link to a chart showing which symbols defeat which.
The challenge here is simple: your program should take in two strings representing the symbols thrown by each... | stackexchange_codegolf |
Background
"Fly straight, dammit" (OEIS A133058) is a sequence of integers, which has these rules:
\$a_0 = a_1 = 1\$
\$a_n = a_{n-1}+n+1\$ if \$gcd(a_{n-1}, n) = 1\$
Otherwise, \$a_n = \frac{a_{n-1}}{gcd(a_{n-1}, n)}\$
In pseudocode:
a[0] = a[1] = 1
if gcd(a[n-1], n) == 1 then
a[n] = a[n-1] + n + 1
else
a[... | stackexchange_codegolf |
Given \$A = (a_1,\dots,a_k)\ k\ge2 \$ a sequence of positive integers, in which all elements are different.
Starting from \$i=2\$, while \$a_i\in A:\$ (until the last element)
If \$d=|a_i-a_{i-1}|\$ is not already in \$A\$, append \$d\$ to \$A\$
Increase \$i\$
Output the completed sequence.
This is code-golf
Example
... | stackexchange_codegolf |
Based on How high can you count? let us give an advantage to the polyglot people.
Challenge:
Your task is to write as many programs / functions / snippets as you can, where each one outputs / prints / returns an integer. The first program must output the integer 1, the second one 2 and so on.
You can not reuse any char... | stackexchange_codegolf |
Tomorrow, November 23rd, is Thanksgiving Day in the United States. To prepare, you need to cook up some ASCII turkeys. However, since you're late in planning, you need a program (or function) to help you with how many birds you need to prepare.
.---. _
.' './ )
/ _ _/ /\
=(_____) (__/_/==
======... | stackexchange_codegolf |
Background
Recognizing primality seems like a poor fit for (artificial) neural networks. However, the universal approximation theorem states that neural networks can approximate any continuous function, so in particular it should be possible to represent any finitely-supported function one desires. So let's try to re... | stackexchange_codegolf |
In a fictional document management system, input documents are structured with weighted headings. Lowest weighted headings are the most important.
This is a sample document:
H1 All About Birds
H2 Kinds of Birds
H3 The Finch
H3 The Swan
H2 Habitats
H3 Wetlands
From this document we would like to produce an outline usin... | stackexchange_codegolf |
Overview
Given a 3 line string, figure out if the structure falls to the left, balances, or falls to the right.
Input structure
You can imagine the structure as metal rod with stuff on top, all being balanced on top of a vertical rod.
1 7 4 a
===============
|
The first line is the items. Each item's w... | stackexchange_codegolf |
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)... | stackexchange_codegolf |
Write a function that accepts a rectangular grid of ids in any reasonable format, for example a multi-line string:
IIILOO
ILLLOO
and a string or list of box drawing charcters such as:
' ═║╔╗╚╝╠╣╦╩╬'
or
[0x20, 0x2550, 0x2551, 0x2554, 0x2557, 0x255a, 0x255d, 0x2560, 0x2563, 0x2566, 0x2569, 0x256c']
(see below for more... | stackexchange_codegolf |
Background
A backronym is an acronym that was formed from an existing word. For example, spam is actually named after the canned meat product as used in the Monty Python sketch, but can be interpreted as "stupid pointless annoying mail".
Challenge
Given a string a, and a word t, capitalise the correct letters of the w... | stackexchange_codegolf |
A Shift matrix is a binary matrix with one superdiagonal or subdiagonal formed by only ones, everything else is a zero.
A superdiagonal/subdiagonal is a diagonal parallel to the main diagonal, which is not the main diagonal, i.e. all entries \$a_{ij}\$ where \$i=j+k\$ and \$k \neq 0\$.
The main diagonal is defined to b... | stackexchange_codegolf |
Introduction
This challenge requires you to set the trailing zeros of an integers binary representation to 010101…, this is best explained with an example:
Given the integer 400, the first step is to convert it to binary:
110010000
As we can see the fifth bit is the least significant 1 bit, so starting from there we r... | stackexchange_codegolf |
The game of xiangqi, also known as Chinese chess, is a chess-like game popular in China, Vietnam, Taiwan, and other East Asian countries. The colours of the two sides in xiangqi are red and black. There are 16 black pieces in xiangqi: the 1 general (G), 2 advisor (A), 2 elephant (E), 2 horse (H), 2 chariot (R), 2 canno... | stackexchange_codegolf |
This question is inspired by Kevin Cruijssen's question.
Now that the carpet is laid out, we want to roll it. Your task is to write a program that takes a string and returns a spiral made from this string (representing a rolled carpet viewed from the side).
The procedure for one step of rolling the carpet is the follow... | stackexchange_codegolf |
Today's problem is easy. You're given two strings A and B of equal length consisting of only the characters ( and ). Check whether after any number of operations you can make both strings balanced or not. The only operation allowed is swapping A[i] and B[i], where i is an arbitrary index.
Here is the definition of a ba... | stackexchange_codegolf |
The well known cat command simply copies its stdin directly to stdout unchanged. But there are plenty of other commandline tools that exist...
What other commands can be used to duplicate the functionality of the venerable cat?
Rules
You are not allowed to use any shell features, including pipes, file redirection, var... | stackexchange_codegolf |
Given the name of a cation and anion, output "S" (soluble) or "I" (insoluble). The table we will be using is from wikipedia: https://en.wikipedia.org/wiki/Solubility_chart. It is copied at the end of the question for future reference.
Input: The cation, followed by the anion, separated by a space. The cation will be on... | stackexchange_codegolf |
Summer Klerance, a senior in college, is what her teachers refer to as GBL*. Students in her probability class have been assigned individual problems to work on and turn in as part of their final grade. Summer, as usual, procrastinated much too long, and, having finally looked at her problem, realizes it is considerabl... | stackexchange_codegolf |
Randomness is fun. Challenges with no point are fun.
Write a function that, given integer input n, will output a set (unordered, unique) of exactly n random integers between 1 and n^2 (inclusive) such that the sum of all integers is equal to n^2.
Randomness does not have to be uniform, provided each valid set has a non... | stackexchange_codegolf |
Write a program or function (hereafter "function") that returns or prints the source code of four new functions: Increment, decrement, undo, and peek.
The initial function contains an internal integer value of 0. Each of the returned functions contains a value based on that value, and each behaves differently:
Increme... | stackexchange_codegolf |
The string tut-tutut-tut-tuttut-tut can be constructed with overlapping or concatenated instances of the word tut-tut:
tut-tutut-tut-tuttut-tut
tut-tut
tut-tut
tut-tut
tut-tut
The string tut-tututut-tutut-tut cannot:
tut-tututut-tutut-tut
tut-tut^
|tut-tut
| tut-tut
... | stackexchange_codegolf |
Looking at the following hackerrank problem:
https://www.hackerrank.com/challenges/flatland-space-stations
You are given a number n where cities can be at indices 0 to n-1 and also given an unsorted list of indices of cities where there are stations. The goal is to find the maximum distance from a city to a station. Fo... | stackexchange_codegolf |
Lets play golf while we golf.
Problem:
Distance to the hole initially is 700m
Each hit to the ball will make it advance to the hole 250-350m, this should be random.
Each hit has a 5% probabilities of going into water, this will make the quantity of hits increase by 1 as a penalty.
When ball is under 250m it will adva... | stackexchange_codegolf |
Write a program/method that:
Becomes a quine when the input matches the source code;
Doesn't halt otherwise.
This is code-golf, so shortest solution wins. Avoid any standard loopholes.
| stackexchange_codegolf |
The problem
You just got a new job, hurray! You expect to be given various interesting tasks, and be able to learn a lot in the next few months.
Good news, your boss gave you your first work this morning. You are now in charge of... Writting adresses on envelopes. Yay.
Fortunatelly, you are not required to write everyt... | stackexchange_codegolf |
This is a variant of Play the word chain and Building a long chain of words .
The input is a non-empty list of unique words at least 2 chars long made of characters in [a-z]. You need to output the length of the longest possible chain, where each subsequent word starts with the last letter of the previous word. You ca... | stackexchange_codegolf |
this challenge was based on a sandboxed post by @dmckee
Old fashioned cell phones were and are used heavily as texting platforms, unfortunately the keyboard has only 12 + a few buttons, and is therefor ill-suited to naive text entry.
Common solutions make use of the traditional telephone coding (generally with a modest... | stackexchange_codegolf |
Let us take a break from the brain-wrecking questions and answer some of the simpler ones
You have recently read something extremely funny, and want to express your laughter to the world! But how can you?
Task
You have to display the string:
Lololololololololololololololololololololololololololololololololololololololo... | stackexchange_codegolf |
Input
Two non-negative floating point numbers \$x < y\$. You can assume they are close enough to each other that there is no integer between \$x\$ and \$y\$.
Output
A fraction with the smallest possible denomination that lies strictly between \$x\$ and \$y\$.
Examples
Input: 1 and 2
Output: 3/2
Input: 0 and 0.33
Output... | stackexchange_codegolf |
The rule is:
a, b, c, d, e is an integer from 0 to 1000, no relation between a, b, c, d, e so a can equal to b or c, ...
can not use more than 3 loops (it can be 3 nested loops or 3 normal loops, or 2 nested loops + 1 normal loop, ...)
you need to find all the answers for (a, b, c, d, e) that is:
a + b + c + d + e = ... | stackexchange_codegolf |
This challenge like some of my previous challenges will have you counting free polyforms, which are generalizations of Tetris pieces.
This code-golf challenge will have you count polyomino-like polyforms on hypercubes. In particular, this challenge is to write a program that takes in three parameters:
n, which represe... | stackexchange_codegolf |
Your task is simple: output the letter x a random number of times. Every possible length of xs must have a non-zero probability of being output.
Of course, there must be some lengths whose probabilities tend to \$ 0 \$, in order for the total probabilities to sum to \$ 1 \$, but all must still be theoretically possible... | stackexchange_codegolf |
Given an array of integers, find "the next to the middle".
The next to the middle is the smallest integer greater than the smallest among mean, median and mode of the given numbers, that is neither the mean, median or mode and is also contained in the array.
For example, in the following array
[ 7, 5, 2, 8, 0, 2, 9, ... | stackexchange_codegolf |
Gobar primes (A347476) are numbers which give a prime number when 0's and 1's are interchanged in their binary representation.
For example, \$10 = 1010_2\$, and if we flip the bits, we get \$0101_2 = 5\$ which is prime. Therefore, 10 is a Gobar prime
As simple as that: print the series with any delimiter. Shortest code... | stackexchange_codegolf |
Your challenge is to write a program that is a quine, meaning it prints out its own source code.
For at least one individual character, when it is removed from the program's source, a single different character is removed from the output.
By different, I mean that the character removed from the code is distinct from th... | stackexchange_codegolf |
Background
Joe is working on his new Brainfuck answer on Codegolf. The algorithm he's using to solve the challenge is a bit complicated, so Joe came up with idea of simplifying his Brainfuck notation to make programming easier and faster.
The challenge
Let's look at snippet written by Joe a moment ago:
0+++++1+++++0[3+... | stackexchange_codegolf |
Given a letter of the English alphabet, your task is to build a semi-diagonal alphabet to the input.
How to build a Semi-Diagonal alphabet?
Brief Description:
First, you take the position of the letter in the alphabet, P (P is 1-indexed here). Then, you print each letter until the input (inclusive) on a line, precede... | stackexchange_codegolf |
What general tips do you have for golfing in Prolog? I am looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Prolog (e.g. one letter variables is not specific to Prolog to reduce the size of programs).
Please indicate in your tips if it is specific to an imple... | stackexchange_codegolf |
The height of a binary tree is the distance from the root node to the node child that is farthest from the root.
Below is an example:
2 <-- root: Height 1
/ \
7 5 <-- Height 2
/ \ \
2 6 9 <-- Height 3
/ \ /
5 11 4 <-- Height 4
Height of binary ... | stackexchange_codegolf |
Challenge
You must output the current time continuously (until cancelled by an interrupt), once every second, by any of the following means:
It must be in 24-hour or AM/PM format.
If it is the former, it must be spaced out with colons (i.e. 15:47:36).
If it is the latter, it must be spaced out with colons and have t... | stackexchange_codegolf |
A little while back, data was frequently stored on punched card. A typical card would have 80 columns of 12 possible 'punch' positions. A plethora of encodings was used, each for their own specific purpose.
These days we like to think of a byte as 8 bits. In this challenge, you're tasked to convert an 8-bit byte to a 1... | stackexchange_codegolf |
Introduction
One day, you were just relaxing in your office in the CIA, when suddenly you see an alert on your computer. Your programs have just intercepted hundreds of coded messages! A quick examination reveals the rule for encoding, but you need a program in order to decode fast.
Challenge
You will be given a list... | stackexchange_codegolf |
In the PPCG chatroom the Nineteenth Byte, using carets ^ (or carrots) is a way of indicating that you agree with one of the previously made comments just above yours.
A caret message consists solely of N ^ characters (where N is a positive integer) and it means agreement with the Nth previous message. So a single ^ mea... | stackexchange_codegolf |
Problem
Draw a hexagon chain x long, each with side of y length
Input
x - the length of the chain <= 50
y - the length of each side <= 50
Examples
x=1,y=1
_
/ \
\_/
x=4,y=1
_ _
/ \_/ \_
\_/ \_/ \
\_/ \_/
x=3,y=2
__ __
/ \ / \
/ \__/ \
\ / \ /
\__/ \__/
\ /
\__/
Rules
... | stackexchange_codegolf |
NOTICE: This challenge is now closed: I will no longer be updating the leaderboard and will not change the accepted answer. However, you are free to run the controller and update the leaderboard yourself, if you wish.
Join the chat!
Introduction
Good evening, traders! You are all traders for the golfing company PPCG.... | stackexchange_codegolf |
Imagine you have an array of integers, whose non-negative values are pointers to other positions in the same array, only that those values represent tunnels, so if the value in position A is positive and points to position B, then the value in position B must be also positive and point to position A to represent both e... | stackexchange_codegolf |
Given a non-negative integer or a list of digits, determine in how many ways can the number be formed by concatenating square numbers, which may have leading zeroes.
Examples
input -> output # explanation
164 -> 2 # [16, 4], [1, 64]
101 -> 2 # [1, 01], [1, 0, 1]
100 -> 3 # [100], [1, 00], [1, 0, 0]
1 -> 1 # [1]
0 -> 1 ... | stackexchange_codegolf |
It frustrates me that when you say "base 16", the 16 is in base 10. We need a base neutral way of writing down numbers when favoring a specific base would be inappropriate.
How it works
We define <n> to be the nth prime. So <1>=2, <2>=3, <3>=5. Note that every positive integer can be uniquely represented by the product... | stackexchange_codegolf |
Your regex will receive a string of the form
!XX!
#<extra>
where X is any hexadecimal digit (0-9 and A-F capital letters only), and <extra> is a character sequence to your choosing. (perhaps something like 0123456789ABCDEF0 could be useful?)
You may use any regex flavour.
Scoring will be calculated as: find regex len... | stackexchange_codegolf |
Introduction
Arrays are usually used with for-loops or iterators. One different task might be the use as a cheap way to rotate through a set of items, so after reaching the last index, the next item would be the first item of the array. This is useful for cases like menus and physical controls.
Challenge
Given the size... | stackexchange_codegolf |
The Animal-Alphabetical Sequence is an infinite string of letters built accordingly to the following procedure:
Start with the letter A;
Replace each letter with the name of the animal starting with such letter in the table below;
Go back to step 2.
For instance, the first four steps of the procedure give:
A
ADD... | stackexchange_codegolf |
It's time... to count the votes!
Today there are local elections in my entire country. Here, the number of seats for each party is decided using the D'Hondt method. Your goal is to implement a program or function that will decide how many seats each party gets, in the shortest amount of bytes.
For this method there are... | stackexchange_codegolf |
Here’s the picture of the first published picture of the Mandelbrot set.
Use the fewest bytes possible to write a program or function that outputs the following.
A trailing new line is permitted. Character * cannot be replaced by any other character.
Useful information: Center is \$(-0.75, 0)\$, \$\Delta x = 0.035\$, ... | stackexchange_codegolf |
Description
You have a list of integers and start counting from the first term to the next and continue from that to the next and so on..
How many times have you counted?
For example given [ 2, 5, 3, 8 ]
you start at 2 and count to 5 -> 3 4 5 (3 times)
then from 5.. 4 3 (2 times)
and finally 4 5 6 7 8 (5 times)
You co... | stackexchange_codegolf |
sandbox (deleted)
Lets define a matrix of 9s as:
$$ N = \begin{bmatrix} 9&9&9\\9&9&9\\9&9&9 \end{bmatrix} $$
Lets define an exploding number as a number at position \$(x,y)\$ that can be decomposed into equal integers between all its adjacent neighbors (including itself) and the absolute value of each portion is great... | stackexchange_codegolf |
Introduction
In this challenge, I asked you to implement swap encoding.
Swap encoding is an encoding method where you iterate through the string, reversing substrings between identical characters. The basic algorithm is:
For each character in the string:
Check: Does the string contain the character again, after the ins... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.