instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
In the misty years of yore, when fanfold terminals walked the earth, there lived a strange creature. Oddly crippled and yet oddly powerful, the line editor teemed across the programming landscape in untold numbers; covering the earth as far as the eye could see.
Now it is fallen on hard times. That vast population hunt... | stackexchange_codegolf |
Given an integer \$n > 1\$, output a balanced binary tree with \$n\$ leaf nodes.
The tree should be constructed out of (space), \ and / (slashes). Each slash represents a branch.
A node is represented by adjacent slashes: /\. There must be a root node at the top of the tree (i.e. the first row of the output).
To con... | stackexchange_codegolf |
What general tips do you have for golfing in MathGolf? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to MathGolf (for tips which can be applied to loads of programming languages, look at the general tips).
| stackexchange_codegolf |
Everyone knows, that you can leave out the multiplication symbol (\$\times\$, or *) in
a*b
23*a
(2+3)*a
a^(b*c)
(a+b)*(c+d)
but not in
2*3 => you don't want it to be 23
a*23 => most mathematicians just don't do it
a^2*b => now it's (a^2)*b, if you remove the *, it's a^(2b)
a/2*b => now it's (a/2)*b, if you remove th... | stackexchange_codegolf |
In the MMORPG Final Fantasy XIV, the Ninja class has the ability to use combinations of up to three handsigns (Ten, Chi and Jin) to perform a variety of ninjutsu skills.
The skill you cast depends on the last sign used, and using two or more of the same sign makes the ninjutsu skill fail and puts a little bunny on your... | stackexchange_codegolf |
Cubes can be made of six squares as sides. But you could also fold three 2x1 rectangles in half and glue them together to form a cube. Now in this challenge you get a set of pieces which are each made from squares, and you have to determine whether you can choose pieces to form a unit cube. Not all of the pieces have t... | stackexchange_codegolf |
Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't.
An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered speci... | stackexchange_codegolf |
As in, the 5 speed transmission from the original VW Golf GTI.
Print the transmission pattern in as few bytes as possible.
Yes I know this isn't what it actually looks like but the GTI 5 speed shift knob pattern is a lot worse.
1 3 5
| | |
|--|--|
| | |
2 4 R
| stackexchange_codegolf |
So, you're browsing Programming Puzzles & Code Golf, and you see a new challenge. The author (gasp) forgot to say "No standard Loopholes". You decide to take advantage of this situation, and you read the answer from a file/network. However, you need to make sure that your answer is actually shorter than the legitimate ... | stackexchange_codegolf |
Forth is one of the few non-esoteric stack-based languages. For this challenge, we will use a small subset of Forth, which simply executes a sequence of words in a linear fashion — without any definitions or loops.
In good Forth code, each word definition includes a stack effect comment, which explains the layout of th... | stackexchange_codegolf |
Introduction
Book cipher
A Book cipher is a very unique method of a encipher. Here's how's it done:
You have a book / a document or a article (something full of text, the more pages of text the better).
You have a message to convey (a secret, of some sort)
You simply-put read trough the text and the secret message (ma... | stackexchange_codegolf |
Adapted from the UIL - Computer Science Programming free response question "Carla" for 2018 District.
Introduction
In UNIX-like operating systems, each file, directory, or link is "owned" by a "user", who is a member of a "group", and has certain "permissions" represented by a ten-character string such as "drwxrwxrwx".... | stackexchange_codegolf |
J-uby is the Language of the Month for June 2022, so I'm looking for tips for golfing in it. As usual, please post one tip per answer, and avoid general tips such as "remove whitespace" or "avoid comments".
| stackexchange_codegolf |
In this challenge, we render Ascii user interfaces.
+----------------------+
|+-----------++-------+|
||<- Previous||Next ->||
|+-----------++-------+|
|== The title == |
| |
|Lorem ipsum dolor |
|sit amet... |
|+--------------+ |
||Post a comment| |
|+--------------+ ... | stackexchange_codegolf |
My first code golf post, apologies for any mistakes...
Context
In rock climbing (bouldering specifically), the V/Vermin (USA) climbing grades start at 'VB' (the easiest grade), and then go 'V0', 'V0+', 'V1', 'V2', 'V3', 'V4', 'V5' etc. up to 'V17' (the hardest grade).
Task
You will take as input a list/array of climbin... | stackexchange_codegolf |
I was in the bus today, and noticed this sign:
seated standing wheelchairs
max1 37 30 00
max2 36 26 01
max3 34 32 00
The number of seated passengers, standees, and wheelchairs all have to be no larger than some row in the table. (See chat fo... | stackexchange_codegolf |
Let's map some strings to 2d space, fractal style. Your task is to compute a Hilbert curve and lay a string along it.
Task
The task is to take the single-line input string, and lay it out along a Hilbert curve big enough to contain it, but no bigger. Try to make the byte count as low as possible; this is code-golf aft... | stackexchange_codegolf |
J-uby is the Language of the Month for June 2022, so I'm looking for tips for golfing in it. As usual, please post one tip per answer, and avoid general tips such as "remove whitespace" or "avoid comments".
| stackexchange_codegolf |
Suzhou numerals (蘇州碼子; also 花碼) are Chinese decimal numerals:
0 〇
1 〡 一
2 〢 二
3 〣 三
4 〤
5 〥
6 〦
7 〧
8 〨
9 〩
They pretty much work like Arabic numerals, except that when there are consecutive digits belonging to the set {1, 2, 3}, the digits alternate between vertical stroke notation {〡,〢,〣} and horizontal stroke notat... | stackexchange_codegolf |
I have 2 inputs: 1 single number and some numbers separated by whitespace:
1
1 2 3 4 5
I want to loop over the second input, and I don't need the first input. I did this, which works:
input()
for x in input().split():somecode()
But can I go directly to the second input without doing the input() at the beginning or wi... | stackexchange_codegolf |
A number is whole if it is a non-negative integer with no decimal part. So 0 and 8 and 233494.0 are whole, while 1.1 and 0.001 and 233494.999 are not.
Input
A floating-point number in the default base/encoding of your language.
For example, the default integer representation for Binary Lambda Calculus would be Churc... | stackexchange_codegolf |
Challenge
Given a natural number, output it in the ASCII form of Agrippa's number system.
Description
I like odd alphabets and numeral systems. My favorite numeral system is one given by Heinrich Cornelius Agrippa. It gives a succinct way to write numbers in the range [0,9999], where single digits are written as follow... | 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 |
Game
In this challenge you will play a made-up turn-based game.
The game is made up of the following elements:
A 8x8 grid with each spot containing nothing (space), a robot (*), a wall (#), or HP (@)
A public stack
Robots
In this challenge, you will be playing as a robot. Each robot has health (starts at 10HP and ca... | stackexchange_codegolf |
Challenge :
Inspired by Alphabet Position Finder
Given an string and one of two possible mathematical operator (+ or -) as input, your task is to return the operation of each alphabet position from the string.
Example :
Input: "Hello World", "+"
=> "Hello World" = [8, 5, 12, 12, 15, 23, 15, 18, 12, 4] (converted to the... | stackexchange_codegolf |
Let's write the shortest code to perform a simplified variant of the DoD 5220.22-M Wipe Method with only two writing passes.
Any programming language accepted, but the use of disk-wiping-oriented libraries is prohibited.
Here's how we are to implement it in pseudocode:
Set x to 0
[Start]
'Write Pass
For each sector in... | stackexchange_codegolf |
Give credit to whom credit is due.
Objective Given an integer N > 0, out the smallest integers A, B, and C so that:
All of A, B, and C are strictly greater than N;
2 divides A;
3 divides B;
and 4 divides C.
This is a code-golf, so the shortest answer in bytes wins.
Test cases
N => A, B, C
1 => 2, 3, 4
4 => 6, 6, 8
43... | stackexchange_codegolf |
The task is simple, given an integer n of how many lines the next n lines is and, a multi-line input, output the resulting 90 degree tilted grid in a clockwise formation.
E.g.
Input:
2
c d
o e
Output:
o c
e d
I/O format:
Input will have spaces in between them
Input always contains alphabetical characters except the ... | stackexchange_codegolf |
Inspired by Golf me an ASCII Alphabet, of which this challenge is (almost) a direct inverse.
Task:
Take a string of ASCII-art text and output the content of the text as regular ASCII text.
Input:
String of ASCII-art text.
Input will only contain instances of ASCII character #, spaces and 4 or 5 newlines (a trailing n... | stackexchange_codegolf |
Dungeon Master was one of the first ever real-time role-playing games, originally released in 1987 on the Atari ST. Among other exciting things for the time, it offered a rather sophisticated spell system based on runes.
Your task today is to write a program or function that evaluates the number of Mana points required... | stackexchange_codegolf |
Olympic vine-swingers perform their routines in standard trees. In particular, Standard Tree n has vertices for 0 up through n-1 and edges linking each nonzero vertex a to the vertex n % a below it. So, for example, Standard Tree 5 looks like this:
3
|
2 4
\ /
1
|
0
because the remainder when 5 is divided b... | stackexchange_codegolf |
Given a drawing of the letter shoot system, where an existing piece of pipe is marked with a *, and an empty spot is marked with a ., your task is to compile a lexicographically sorted list of index tuples [entry row, entry column, exit row, exit column], where each index is 0-based. Entry and exit points are always on... | stackexchange_codegolf |
(Based on this closed challenge, related)
Given an integer n > 1, draw a grid composed of the characters: "-" "+" and "|". However, since I want the grid to look nice, the horizontal component should be 2 wide.
Trailing spaces for each line are not required.
Examples:
n = 2
|
--+--
|
n = 3
| |
--+--+--
| ... | stackexchange_codegolf |
The Challenge
Given a multiline string, return the longest substring of leading whitespace present in every line, ignoring empty lines or lines composed only of whitespace. If input is empty or whitespace, return nullish or the empty string--up to you.
Update: Per Meta consensus, the input may also be treated as an ar... | 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 |
Imagine you have two lights. These lights blink on and off at a specific rate:
Light 0: Delay 0ms and then blink every 1000ms
Light 1: Delay 500ms and then blink every 1000ms
Let's simulate these lights for the first 2000ms:
0ms: Light 0 on
500ms: Light 1 on
1000ms: Light 0 off
1500ms: Light 1 off
2000ms: Light 0 ... | stackexchange_codegolf |
Suppose denominations of banknotes follow the infinity Hyperinflation sequence: \$ $1, $2, $5, $10, $20, $50, $100, $200, $500, $1000, $2000, $5000, \cdots \$. How many banknotes are required, at minimum, to pay a \$$n\$ bill?
Consider Alice needs to pay \$ $992 \$ to Bob. It is possible for Alice to use 7 banknotes \$... | stackexchange_codegolf |
Your task: given an integer n, output an embedded triangle to the nth depth.
Standard methods of input and output, input in any convenient format, output should be as a string. Examples are 0-indexed, you can use 1-indexed if you want. Standard loopholes apply
The left and right sides of each figure is 2^n, when 0 inde... | stackexchange_codegolf |
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... | stackexchange_codegolf |
Aliens have arrived, and they aren't friendly.
Turns out, they've been in the process of converting all matter in the universe into compute capability so they can have more fun in their VR simulations.
Our solar system is the last bit of space they haven't converted yet, and they're about to remedy this oversight.
Howe... | stackexchange_codegolf |
This challenge is to write a program that prints a great famous speech.
Goals:
Obfuscated text (you should not be able to tell what speech it prints without running it)
Obfuscated code (it is more fun if you cant figure out how it works)
non-wrapping text and code is preferred. (78 chars/line)
Low score wins.
Rules:
... | stackexchange_codegolf |
Introduction
In chess, Knights can move two squares in one direction, and then one square in an orthogonal direction. On an x/y plane, these can be thought of as being a relative change of coordinates, such as (+1, -2).
Challenge
Your task is to output all 8 possible moves as pairs of relative x/y coordinates, in any o... | stackexchange_codegolf |
Landslides
In this challenge, your job is to predict the extent of damage caused by a massive landslide.
We use the following simplified two-dimensional model for it, parameterized by an initial height h >= 0 and a critical coefficient c > 0.
You start with a cliff of height h, and it is assumed that the terrain is com... | stackexchange_codegolf |
Background (feel free to skip)
Ordinals are the abstract representation of well-orders. A well-order of a set is a total order, which basically means that every element in the set can be compared against any other element in the set, and one of them is either smaller or larger. Also there are no cycles.
The crucial dif... | stackexchange_codegolf |
Definition
The maxima and minima of a given function are the largest and smallest values of the function either within a given range or otherwise within the entire domain of the function.
Challenge
The challenge is to find the local maxima and minima of a given polynomial function using any method you may like. Don't w... | stackexchange_codegolf |
Lets define a class of functions. These functions will map from the positive integers to the positive integers and must satisfy the following requirements:
The function must be Bijective, meaning that every value maps to and is mapped to by exactly one value.
You must be able to get from any positive integer to any o... | stackexchange_codegolf |
Challenge: I want to know about the real roots of polynomials. As a pure mathematician, I care about the existence of such roots, rather than their numeric values.
The challenge is to write the shortest program that takes a polynomial, of degree at most 4, and simply returns how many distinct real roots said polynomial... | stackexchange_codegolf |
Every so often I have a function of type a -> b and a function of type b -> b -> c and I would like a function of type a -> a -> c. For example if I wanted to check the second element of each two tuples were equal
snd :: (a , b) -> b
(==) :: Eq a => a -> a -> Bool
And I want something of type
Eq b => (a, b) -> (c, b)... | stackexchange_codegolf |
Given a matrix of size at least 3×3 formed by positive integers, determine if it contains at least one "U" pattern, defined as
+ + + - - - + +
+ + - N - N - +
+ + - N - N - +
+ + - N N N - +
+ + + - - - + +
where
N is the same number, repeated in those seven positions
- (optional) represents any number different than... | stackexchange_codegolf |
Fastest code is a scoring method on this site where the goal is to write code that is as fast as possible.
From the tag wiki:
The winner of a fastest-code challenge is determined by the runtime performance of the submissions. For fairness, all submissions should be benchmarked on the same machine, which usually means ... | stackexchange_codegolf |
Task
Given a non-empty string of lowercase ASCII letters a-z, take its first character, and:
Surround it with a square of copies of the second character,
Surround that with a diamond of copies of the third character,
Surround that with a square of copies of the fourth character…
…alternating between square and diamon... | stackexchange_codegolf |
Let's parse and process Key-Language! Given the input of a sequence of keyboard keypresses and/or special keys, write a program, function, etc. that outputs the product when all the actions are processed based on the following keyboard:
+-------------------------------------------------------+
| ~ | ! | @ | # | $ | % |... | stackexchange_codegolf |
Write a program or function that takes a character as input and outputs a character. Also, choose a list of 13 distinct ASCII printable characters (32-126). When a character from this list is passed into the program or function, it should output the character at the corresponding position in Hello, world!. This way, ru... | stackexchange_codegolf |
We all know that \$(-a) \times (-a) = a \times a\$ (hopefully), but can you prove it?
Your task is to prove this fact using the ring axioms. What are the ring axioms? The ring axioms are a list of rules that two binary operations on a set have to follow. The two operation are addition, \$+\$, and multiplication, \$\... | stackexchange_codegolf |
Output this table:
-2*
-1*
-
0
-
1
2
-1*
0
1
-
2
3
4
1
2
3
-
4
5
6
3
4
-
5
-
6
7
5
6
-
7
-
8
9
6
7
8
-
9
10
11
8
9
10
-
11
12
13
10
11
-
12
-
13
14
You can output one string with two types of split, 1D string array with one type of split, or 2D string array
If your language support mix... | stackexchange_codegolf |
Definition
A dollar word is a word where when each of its letters is given a cent value, from a = 1 to z = 26, and the letters are summed, the result is 100. Here is an example on CodeReview, and here is a list of dollar words I found online.
Input
Input will be alphabetical from a-z, in your one language's text dataty... | stackexchange_codegolf |
Given a number N from 2 to 8, place any nonzero number of queens on a grid of any size so that every queen has exactly N queens (counting itself) in each of its row, column, and each diagonal.
This challenge has a significant restricted-time runtime limit. Your code must finish all N from 2 to 8 (combined) within the 6... | stackexchange_codegolf |
Write a regular expression which matches a given string consisting of three non-negative, space-separated integers if and only if the last integer is the sum of the previous two. Answers may be for integers of any numeral system with radix between 2 and 10.
Test cases
These should fail:
0 1 2
10 20 1000
These should m... | stackexchange_codegolf |
The challenge is to implement a function or program that takes two numbers, \$x\$ and \$y\$ and return the result of \$x^y\$.
The program cannot use any other mathematical operation other than \$+\$ or \$-\$, so no multiplication or division. Functions built into languages are also not allowed.
The code in the least a... | stackexchange_codegolf |
The Binet formula is a closed form expression for the \$n\$'th Fibonacci number:
$$F_n = \frac {\phi^n - (1-\phi)^n} {\sqrt 5}$$
where \$\phi = \frac {1 + \sqrt 5} 2\$ is the golden ratio. This formula works even when \$n\$ is negative or rational, and so can be a basis to calculating "complex Fibonacci numbers".
For e... | stackexchange_codegolf |
Consider 30 by 30 Toeplitz matrices all of whose entries are 0 or 1. This challenge is a simple optimization challenge to find the matrix with the largest determinant possible.
Input None
Output A 30 by 30 Toeplitz matrix all of whose entries are 0 or 1 along with its determinant.
Score The determinant of the matrix y... | stackexchange_codegolf |
Inclusion-Exclusion lets you calculate the sizes of some unions and intersections between sets knowing some of the other values. I won't explain it exactly, but your challenge is to visualize inclusion-exclusion on a Venn Diagram.
Because I'm nice, you'll be using rectangles, not circles.
You will be given a list of re... | stackexchange_codegolf |
Recamán's Sequence is defined as follows:
\$a_n=\begin{cases}0\quad\quad\quad\quad\text{if n = 0}\\a_{n-1}-n\quad\text{if }a_{n-1}-n>0\text{ and is not already in the sequence,}\\a_{n-1}+n\quad\text{otherwise}\end{cases}\$
or in pseudo-code:
a(0) = 0,
if (a(n - 1) - n) > 0 and it is not
already included in the sequ... | stackexchange_codegolf |
Task
Write a program/function that when given 3 positive integers \$a, b\$ and \$m\$ as input outputs a positive integer \$x\$ such that \$a^x\equiv b\ (\text{mod}\ m)\$ or that no such \$x\$ exists.
A reference implementation can be found here.
Constraints
You can expect \$a\$ and \$b\$ to be less than \$m\$.
Scoring
... | stackexchange_codegolf |
The partition function:
In number theory, the partition function p(n) represents the number of possible partitions of a positive integer n into positive integers
For instance, p(4) = 5 because the integer 4 has five possible partitions:
1 + 1 + 1 + 1
1 + 1 + 2
1 + 3
2 + 2
4
Your task:
Accept an input (let's call i... | stackexchange_codegolf |
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)... | stackexchange_codegolf |
A \$k\$-hyperperfect number is a natural number \$n \ge 1\$ such that
$$n = 1 + k(\sigma(n) − n − 1)$$
where \$\sigma(n)\$ is the sum of the divisors of \$n\$. Note that \$\sigma(n) - n\$ is the proper divisor sum of \$n\$. The sequence of \$k\$-hyperperfect numbers begins
$$6, 21, 28, 301, 325, 496, 697, \dots$$
This ... | stackexchange_codegolf |
ed is the standard text editor on Unix systems. Your goal is to write an ed clone.
Task
Write a program that reads an input stream and for every received end of line character, print ? followed by a end of line character.
The communication has to interactive. Means the program needs to output as soon as possible and h... | stackexchange_codegolf |
Background
Consider an \$n\times n\$ grid, where each cell is either empty (denoted by .) or a wall (denoted by #). We say that two cells are adjacent if they share an edge (a corner is not enough). A path is a sequence of distinct empty cells \$s_0,s_1,\ldots,s_k\$ such that cells \$s_i\$ and \$s_{i+1}\$ are adjacent ... | stackexchange_codegolf |
The task
Given any array of integers, e.g.:
[-1,476,578,27,0,1,-1,1,2]
and an index of that array (this example uses 0 based indexing, though you can use 1 based indexing as well.):
index = 5
v
[-1,476,578,27,0,1,-1,1,2]
Then return the nearest number greater than the element at that index. ... | stackexchange_codegolf |
Note this is a question primarily focusing on data-structures
Introduction
Bacefook wants people to be friendlier! As such, they are implementing a new system to suggest friends! Your task is to help Bacefook to implement their new suggesting system.
Specifications:
Your program must be a REPL (read-eval-print loop) su... | stackexchange_codegolf |
Following the great advice (what do you mean it's not advice?!) on Adding unnecessary fluff we can devise the following task:
Take a list of positive integers and a positive integer \$m\$ as input.
Only keep the prime values from the list.
Define \$f(n) = F_{n^2 + 1}\$ (the \$n^2+1\$-th element in the Fibonacci sequen... | stackexchange_codegolf |
As the title says, your task is to print the largest string using the shortest code without taking any input value.
Rules
The program must take no input and print the largest string to STDOUT
The string must contain only ASCII Characters. If you don't know the ASCII Characters, take a look at the table
No Loops are a... | stackexchange_codegolf |
In elementary school, children learn about proper fractions, where the numerator is less than the denominator, and thus the value of the fraction is less than one. Later, they are taught about fractions where the value of the fraction is greater than one, and two different ways to express these fractions: mixed fractio... | stackexchange_codegolf |
Write a program that, given a string of capital letters, output all possible phrases that could have been written originally, using any variant of the Oxford English Dictionary.
Input
There are two inputs:
A string \$s\$ of A-Z capital letters that is a phrase with certain letters removed. Example: THSSANEAMPLE
Anoth... | stackexchange_codegolf |
The goal of a Rosetta Stone Challenge is to write solutions in as many languages as possible. Show off your programming multilingualism!
The Challenge
Your challenge is to implement a program that will input a list of numbers and output a box plot of the data, in as many programming languages as possible. The box plot... | stackexchange_codegolf |
Draw the following in the fewest bytes possible:
-------------------------
| | ABC | DEF |
| 1 | 2 | 3 |
-------------------------
| GHI | JKL | MNO |
| 4 | 5 | 6 |
-------------------------
| PQRS | TUV | WXYZ |
| 7 | 8 | 9 |
-------------------------
| | ... | stackexchange_codegolf |
Non-associative operators (for example the subtraction-operator) often are either left- or right associative, such that one has to write less parentheses. Consider for example the following:
$$
a-b-c
$$
Probably everybody read that as \$(a-b)-c\$, by default (usually) subtraction is left-associative.
Now let us conside... | stackexchange_codegolf |
Given an input n, output the value of the Fransén-Robinson constant with n digits after the decimal place, with rounding.
Rules
You may assume that all inputs are integers between 1 and 60.
You may not store any related values - the constant must be calculated, not recalled.
Rounding must be done with the following cr... | stackexchange_codegolf |
The word BANANA appears exactly once in this word search:
B A N A A N B B
A B A N A B A N
A N A B N N A A
N N B A A A N N
N A A N N N B A
A N N N B A N A
N A A B A N A N
B A N A N B B A
The word search above contains only one occurrence of the word BANANA looking up, down, left, right, or diagonally, but it has lot of... | stackexchange_codegolf |
There are clever ways of determining whether a number is a power of 2. That's no longer an interesting problem, so let's determine whether a given integer is an integer power of -2. For example:
-2 => yes: (-2)¹
-1 => no
0 => no
1 => yes: (-2)⁰
2 => no
3 => no
4 => yes: (-2)²
Rules
You may write a program or a func... | stackexchange_codegolf |
Your task is to write a program or function that checks if a string is a valid phone number.
Given a string (or list of characters/codepoints) input, you will output a truthy value if the input is a valid phone number. If it is not, output a falsey value. An input string is considered a valid phone number for this chal... | stackexchange_codegolf |
Background
This challenge is about Convolutional neural networks, and its two main building blocks, namely Convolutional layer and Pooling layer.
For simplicity, we ignore the "depth" of the images and intermediate tensors, and just look at the width and height.
Convolutional layer
A convolutional layer works like a ke... | stackexchange_codegolf |
Write a code to display "I Love You".
Without using any built-in tools or functions like echo, System.out.println, printf, ...
You are not allowed to directly call any function throughout the program execution, but the system environment or the compiler-generated code might do. This way, you can put your code in a mai... | stackexchange_codegolf |
For those who didn't know, Sigma is a Greek letter which is heavily used in mathematics as the summation sign. Given a string representing an expression depending on \$k\$ that we will denote \$E(k)\$, compute the sum of the results for \$E(k)\$, for each \$k\in\{1,2,3,4,5\}\$. Concisely, you should find \$S\$ such th... | stackexchange_codegolf |
Challenge
Write a program that outputs the lyrics to 99 Bottles of Beer, but instead of "beer", output "fizz" if the number of bottles on the wall is a multiple of 3, "buzz" if it is a multiple of 5, and "fizzbuzz" if it is a multiple of 3 and a multiple of 5. If the number of bottles on the wall is not a multiple of 3... | stackexchange_codegolf |
Brainfuck is an esoteric programming language that is Turing Complete, meaning you can't tell whether a given program will halt without running it. It's cell-based and has an infinite tape of cells, values containing an unsigned integer from 0 to 255, but if you give it arbitrary-size cells, just three is enough to mak... | stackexchange_codegolf |
Introduction:
I have loads of different ciphers stored in a document I once compiled as a kid, I picked a few of the ones I thought were best suitable for challenges (not too trivial, and not too hard) and transformed them into challenges. Most of them are still in the sandbox, and I'm not sure yet whether I'll post al... | stackexchange_codegolf |
The trumpet is a valved aerophone instrument, usually pitched in B♭. The sound is made when the player vibrates their lips to displace air inside the instrument. That vibration is acquired by setting one's mouth in a specific way, called the embouchure. Different embouchures, with tighter or looser lips, produce differ... | stackexchange_codegolf |
Problem source: https://oj.vnoi.info/problem/backtrack_j
We have these two shapes:
#.
##
and
.#
##
Let's call the first shape the L and the second shape the flipped L.
On a 4x4 board, there are 16 cells. Each cell can be either free or occupied. In all the illustrations, # represents an occupied cell and . represents... | stackexchange_codegolf |
Given the number of vertices N of a convex polygon and each of their (x, y) calculate the polygon's area. vertexes are in clockwise order
You must handle all N <= 45 ,-600 <= x,y <= 600, and your answer must be accurate to at least 2 decimal places.
Example:
3
1 6
1 2
-4 2
The area is 10.00.
This is code-golf, fewe... | stackexchange_codegolf |
Task
Haskell's and Scala's standard libraries have an unfold function that builds a list from an initial state s and a function f. This is done with the following steps (explained in an imperative way to be simpler):
Apply f to s.
If the result
is empty, we're done building the list!
Otherwise, the result should cont... | stackexchange_codegolf |
Background
In most reasonable programming languages, it's very easy to rotate the rows or columns of a 2D array.
In this challenge, your task is to rotate the anti-diagonals instead.
Recall that the anti-diagonals of a 2D array are its 1D slices taken in the northeast direction ↗.
Input
A non-empty rectangular 2D array... | stackexchange_codegolf |
Write a regex that works in at least 2 regex flavors (or versions), and match a different string in each flavor (or version) it is running in.
The strings to be matched in this challenge are the first words of the Ubuntu code names, which are listed below. Your regex has to match from the top of the list. That is, if y... | stackexchange_codegolf |
Create A "Hello, World!" program but without any vowels. Winner is the program with the least bytes.
Rules:
No vowels are allowed in the code.
Must print to STDOUT
Must be a full program.
Submissions are measured in Bytes
Any language goes as long as there aren't any vowels
Edit:
Y is only a vowel if there aren't any... | stackexchange_codegolf |
Your task: Print or return a conversion table with every byte from 00 to ff's value as an unsigned integer, to its value as a signed one (using two's complement).
For example:
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
1... | stackexchange_codegolf |
Introduction
Factorials are one of the most frequently used examples to show how a programming language works.
A factorial, denoted \$n!\$, is \$1⋅2⋅3⋅…⋅(n-2)⋅(n-1)⋅n\$.
There is also the superfactorial (there are other definitions of this, but I chose this one because it looks more like the factorial), denoted \$n$\$,... | stackexchange_codegolf |
In this challenge you must write a computer program that creates a stack of a thousand identical \$1 \times 1\$ frictionless homogeneous blocks such that each block is supported and the stack is stable under gravity when placed on the edge of a table which spans from \$x = -\infty\$ to \$0\$ horizontally, with the surf... | stackexchange_codegolf |
Write a program or function that prints an input string around the discrete circle that has the minimum possible radius. For example, for input This is an example, your program should output:
a si
n s
i
e h
x T
a
m
p
le
Circle generation
You shall use the M... | stackexchange_codegolf |
The Recursively Prime Primes is are sequence of primes such that
p(1) = 2
p(n) = the p(n-1)th prime
Here is an example of how one might calculate the 4th Recursively Prime Prime.
p(4) = the p(3)th prime
p(3) = the p(2)th prime
p(2) = the p(1)th prime
p(1) = 2
p(2) = the 2nd prime
p(2) = 3
p(3) = the 3rd prime
p(3) = 5... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.