instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
This code-golf challenge will give you an integer n, and ask you to count the number of positive integer sequences \$S = (a_1, a_2, \dots, a_t)\$ such that
\$a_1 + a_2 + \cdots + a_t = n\$, and
\$\displaystyle
\sqrt{a_1+\sqrt{a_2 + \cdots + \stackrel{\vdots}{\sqrt{a_t}}}}
\$ is an integer.
Example
If n = 14, then the... | stackexchange_codegolf |
The paint on the walls in my room has a random, almost fractal-like, 3-dimensional texture:
In this challenge you will write a program that generates random images that look like they could be part of my walls.
Below I've collected 10 images of different spots on my walls. All have roughly the same lighting and all we... | stackexchange_codegolf |
Task
Given an input, evaluate it as a mathematical equation following the order of operations.
But, instead of the using PEMDAS, we drop the parentheses and exponentiation and introduce spaces - SMDAS - spaces, then multiplication & division, then addition & subtraction.
How does that work?
Every operator with more spa... | stackexchange_codegolf |
Summary
We already have a challenge for the minimal number of characters for Turing completeness. But what about the minimal maximum byte?
Challenge
For a language of your choice, find a subset of characters that allows your language to be Turing complete with the minimal maximum byte value.
Example
If your language is... | stackexchange_codegolf |
Natural numbers ≡ \$\mathbb{N}≡\{0,1,2,...\}\$
The submission can be either a program or a function, both cases will henceforth be referred to as "function".
The task is to golf the shortest function \$\mathbb{N}^n→\mathbb{N}\$, i.e. a function that maps \$n\$ natural numbers (with \$n>0\$ being a number of your choosi... | stackexchange_codegolf |
Write a program that takes in a string containing only spaces, newlines, and angle brackets: <, > (chevrons). Output a string of spaces, newlines, and slashes: /, \ (soliduses) whose shapes correspond to the input, but rotated a quarter turn clockwise, with a column of spaces inserted between each row of the original i... | stackexchange_codegolf |
The "prime frog" is a strange animal that jumps between integers, until it arrives on 3 or 19...
Your program should accept an integer n as input and output the result of the below algorithm (3 or 19).
For a given integer n >= 2:
Let f be the position of the frog. It is initially set to n
if f = 3 or f = 19 : the fro... | stackexchange_codegolf |
Your task is pretty simple, calculate the n-th element of A190810.
Elements of A190810 are calculated according to these rules:
The first element is 1
The sequence is increasing
If x occurs in the sequence, then 2x+1 and 3x-1 also do
You can use 1-based or 0-based indexing, but if you use 0-based indexing, please say... | stackexchange_codegolf |
Introduction
You are a biologist studying the movement patterns of bacteria.
Your research team has a bunch of them in a petri dish, and you are recording their activity.
Unfortunately, you are seriously underfunded, and can't afford a video camera, so you just take a picture of the dish at regular intervals.
Your task... | stackexchange_codegolf |
A set of n positive numbers has 2^n subsets. We'll call a set "nice" if none of those subsets have the same sum. {2, 4, 5, 8} is one such nice set. Since none of the subsets has the same sum, we can sort the subsets by sum:
[{}, {2}, {4}, {5}, {2, 4}, {2, 5}, {8}, {4, 5}, {2, 8}, {2, 4, 5}, {4, 8}, {5, 8}, {2, 4, 8}, {... | stackexchange_codegolf |
An Izhikevich neuron is a simple yet quite effective model of a biological neuron, designed for use in a discrete time-stepping simulation. In this golfing challenge, you will be implementing this model.
Parameters
This model involves only 7 variables organized into 2 differential equations, compared to the dozens of p... | stackexchange_codegolf |
The robber's thread is here
The cops task is to write a function or program that, when given an input of itself, outputs a finite deterministic string. If the program is given a different input, it should return a different output.
Rules:
Submissions consist of
Language name
If any flags are used, they should be r... | stackexchange_codegolf |
Given a number n, calculates BB(n) (the maximum number of 1s finally on the tape, among all halting 2-symbol n-state Turing machines with tape of zeros).
To solve the problem, you are given an extra (black-box) function H as input, which takes a function in your language (f) and returns a truthy/falsy value indicates w... | stackexchange_codegolf |
The challenge is simple: Print the last, middle, and first character of your program's source code, in that order.
The middle character is defined as follows, assuming a source length of n characters, and 1-indexing:
If n is even, print the n/2-th and n/2 + 1-th character. (abcdef == cd)
If n is odd, print (n-1)/2 + 1... | stackexchange_codegolf |
I'm posting my code for a LeetCode problem copied here. If you have time and would like to golf for a short solution, please do so.
Requirement
It has to only pass the LeetCode's Online Judge, if the language would be available.
If the language is not available, simply we should possibly keep the class Solution as we... | stackexchange_codegolf |
In computer science, a suffix automaton is the smallest partial deterministic finite automaton that recognizes the set of suffixes of a given string. (Wikipedia)
Given a string \$S\$ consisting of lowercase letters (a-z), construct the suffix automaton for it.
A suffix automaton is an array of states, 0-indexed or 1-... | stackexchange_codegolf |
This is the Robber post. The Cop post is here.
Your task is to take an integer input N and output the Nth digit in the sequence OEIS A002942.
The sequence consists of the square numbers written backwards:
1, 4, 9, 61, 52, 63, 94, 46, 18, 1, 121, 441, ...
Note that leading zeros are trimmed away (100 becomes 1, not 00... | stackexchange_codegolf |
Let's say I've got some ASCII art:
___
,"---".
: ;
`-.-'
| |
| |
| |
_.-\_/-._
_ / | | \ _
/ / `---' \ \
/ `-----------' \
/,-""-. ,-""-.\
( i-..-i i-..-i )
|`| |-------| |'|
\ `-..-' ,=. `-..-'/
`------... | stackexchange_codegolf |
From Codidact with permission.
Description
APL trains are a series of functions, that get applied to an argument in this way:
(f g) x = f g x here f and g are prefix functions
(f g h) x = (f x) g (h x) here f and h are prefix functions, while g is an infix function
(a b c d e f) x = (a (b c (d e f))) x = a (b x) c (d x... | stackexchange_codegolf |
Inspired by the fact that a few related challenges to this could be answered by Vyxal in 0 Bytes using a special flag combination.
Given only one input integer \$n\$, calculate \$f(n,n)\$ where
$$ f(x,y)=
\begin{cases}
x & \text{if } y=0 \\
f(\left(\sum_{k=1}^xk\right),\text{ }y-1) & \text{otherwise}
\end{cases}
$$
If ... | stackexchange_codegolf |
Introduction
This challenge appeared in the 2020 Estonian Open Informatics Olympiad and was created Sandra Schumann. I thought it was interesting because it involves symmetry and is quite hard even to brute force by hand.
The problem author said that it's ok for me to post it here:
Challenge
You may use a modified vers... | stackexchange_codegolf |
Your task is to write a RegEx that matches everything inside strings.
A string is defined as everything surrounded by (but not including) two unescaped ".
A " can be escaped by \, which can also be escaped again.
Testcases
string: ab\c"defg\\\"hi"jkl"mn\\\\"opqrst""
matches: ^^^^^^^^^^ ^^^^^^ ^ (the em... | stackexchange_codegolf |
Background
Perfect shuffle algorithms like Fisher-Yates shuffle don't produce great results when it comes to music playlist shuffling, because it often produces clusters of songs from the same album. In an attempt to solve this problem, Spotify introduced an interesting shuffle algorithm in 2014. At the end of the arti... | stackexchange_codegolf |
An orthogonal matrix is a square matrix with real entries whose columns and rows are orthogonal unit vectors (i.e., orthonormal vectors).
This means that M^T M = I, where I is the identity matrix and ^T signifies matrix transposition.
Note that this is orthogonal not "special orthogonal" so the determinant of M can be... | stackexchange_codegolf |
Simple question!
Given a string that contains a date in ISO8601 format, print the first of the next month in ISO8601 format.
Example inputs:
2018-05-06
2019-12-20
Their respective outputs:
2018-06-01
2020-01-01
The rules:
Imports are free and don't count towards your score.
The date will be stored in a string called s... | stackexchange_codegolf |
Introduction
All these snakes everywhere! I've had enough, and have decided that I much prefer camels. Therefore, I want you to convert my snakes to camels for me.
Challenge
Turn any snake_case string into a camelCase string.
Capitals should be returned to lowercase before the conversion occurs.
Test Cases
In: camel_c... | stackexchange_codegolf |
Given a sequences of events with probabilities between 0.0 and 1.0, generate and derive the probability of each combination occurring. You may presume that a sequence of numbers is provided in whatever construct your chosen language provides.
Here's an example; you may presume that the length of the sequence's combinat... | stackexchange_codegolf |
Given an ASCII art with simple closed paths using | and - (pipes and dashes), output a random point inside the boundary.
Eg. given:
---- ----
| |- --- => |12|- ---
| | | | |345| |6|
----- --- ----- ---
Any point 1-6 should have an equal probability of being printed.
Specs
T... | stackexchange_codegolf |
Background
Fibonacci trees \$T_n\$ are a sequence of rooted binary trees of height \$n-1\$. They are defined as follows:
\$T_0\$ has no nodes.
\$T_1\$ has a single node (the root).
The root node of \$T_{n+2}\$ has \$T_{n+1}\$ as its left subtree and \$T_n\$ as its right subtree.
T0 T1 T2 T3 T4
O ... | stackexchange_codegolf |
Your job is to create the longest period iterating quine, where the length of each program in the sequence is bounded by 500 bytes.
That is, if you repeat the following steps:
Start with your initial program
Run the current program
Go back to step 2
You will eventually get back to your original program. The number of... | stackexchange_codegolf |
A permutation of a set \$S = \{s_1, s_2, \dotsc, s_n\}\$ is a bijective function \$\pi: S \to S\$. For example, if \$S = \{1,2,3,4\}\$ then the function \$\pi: x \mapsto 1 + (x + 1 \mod 4)\$ is a permutation:
$$
\pi(1) = 3,\quad
\pi(2) = 4,\quad
\pi(3) = 1,\quad
\pi(4) = 2
$$
We can also have permutations on infinite s... | stackexchange_codegolf |
Introduction
In this challenge you should split an integer into two pieces. Since nobody likes getting the smaller piece of cake, your goal is to be as fair as possible. For example if you wanted to split the integer 7129 into two pieces, there are 3 possible ways of doing so.
7,129, 71,29 and 712,9 are all possibiliti... | stackexchange_codegolf |
A permutation of a set \$S = \{s_1, s_2, \dotsc, s_n\}\$ is a bijective function \$\pi: S \to S\$. For example, if \$S = \{1,2,3,4\}\$ then the function \$\pi: x \mapsto 1 + (x + 1 \mod 4)\$ is a permutation:
$$
\pi(1) = 3,\quad
\pi(2) = 4,\quad
\pi(3) = 1,\quad
\pi(4) = 2
$$
We can also have permutations on infinite s... | stackexchange_codegolf |
An arithmetico-geometric sequence is the elementwise product of an arithmetic sequence and a geometric sequence. For example, 1 -4 12 -32 is the product of the arithmetic sequence 1 2 3 4 and the geometric sequence 1 -2 4 -8. The nth term of an integer arithmetico-geometric sequence can be expressed as
$$a_n = r^n \cdo... | stackexchange_codegolf |
Main task
Your task is to print out integers in descending order, starting from 1, and increasing as you keep hitting 1 again, up until the given input is reached, then, print out the rest until you hit 1 again. Example with input 6:
1
21
321
4321
54321
654321
Without newlines (valid output):
121321432154321654321
Sid... | stackexchange_codegolf |
can we print 1 to 100 without using any if conditions and loops in c&c++?
Conditon:
main point is you must not use recursion...and doesnt hardcode code in it
for e.g
print(1 2 3..etc);
| stackexchange_codegolf |
Symja is a "computer algebra language & Java symbolic math library for Android NCalc calculator". It's a fun little language, so I'm wondering if y'all have any tips for golfing in Symja.
As per usual, "remove comments", etc, isn't really an answer. It turns out that there is no comment system in Symja, so "remove com... | stackexchange_codegolf |
We don't have a challenge for conversion between Cartesian and polar coordinates, so ...
The challenge
Write two programs (or functions) in the same language:
one that converts from polar to Cartesian coordinates, and
the other from Cartesian to polar coodrinates.
The score is the sum of the two program lengths in by... | stackexchange_codegolf |
Assume that there is a number a. In every conversion of that number, the number can either convert itself to its value plus the value of one of its digits, or convert itself to its value minus the value of one of its digits.
In this situation, find the minimum number of conversions one has to make in order to get to th... | stackexchange_codegolf |
Given a ragged list of positive integers return a full cycle of recursive rotations starting with the unchanged input and ending with the state immediately before revisiting the initial state.
Examples:
[[2,3],4,5,5] -> [[2,3],4,5,5] , [4,5,5,[3,2]] , [5,5,[2,3],4] , [5,[3,2],4,5]
[1,10,[2,2,4],6,[[5,6],7],1] -> [1,10... | stackexchange_codegolf |
Problem: We have a two dimensional matrix of positive integer cells. On each turn any non-zero cell with a neighbor (top/bottom/left/right) of zero decreases by 1. We want count to the number of non-zero cells present and add them up across all turns.
Is there a faster solution than to use a priority queue?
Is there a... | stackexchange_codegolf |
A Latin square is a square that has no repeated symbols in either the X or Y columns. For example:
ABCD
DABC
CDAB
BCDA
is one such square. Notice how every column and row contains a permutation of the same 4 letters.
However, our Latin square has a problem: If I were to rotate the second row (DABC) 1 to the lef... | stackexchange_codegolf |
Imagine we get a slice of some mountainous region, this would result in a shape similar to this:
4 _
3 _ _ __/ \
2 / \__/ \ _/ \_ /
1 / \ / \_/
0 \/
12322223210012233343221112
As we can see, we can represent this (to a certain degree) with a sequence o... | stackexchange_codegolf |
Introduction
Logic gates! Everyone knows them, everyone loves them (unless you're starting to learn them). Take two booleans, compare them, get a single boolean in return. AND, NAND, OR, NOR, XOR, XNOR. Fun! But, what if you only had the inputs and output, but not the operator?
Challenge
Given a three digit number, xy... | stackexchange_codegolf |
This is the reverse of Music: what's in this chord?, which is to print the notes in a given chord. This time the input is a list of notes in a chord, and your task is to output which chord it is.
Your program should support the following triadic chords. Examples are given with root C. Chords with other roots are the sa... | stackexchange_codegolf |
Challenge
Given a positive-length string \$S\$, a divisor of \$S\$ is another (not necessarily distinct) string for which there exists a number \$a\$ such that when we repeat the divisor \$a\$ times, we get the string \$S\$.
For example, the string abcd is a divisor of the string abcdabcd with \$a=2\$.
Your challenge i... | stackexchange_codegolf |
It's time for another Mesoamerican calendar! The Xiuhnelpilli was used by the Aztecs (more properly, the Mexica) to name their years. Each year has a number and a sign. Here's part of the cycle:
Input; Output
1089; 13 Calli
1090; 1 Tochtli
1091; 2 Acatl
1092; 3 Tecpatl
1093; 4 Calli
1094; 5 Tochtli
1095; 6 Acatl
... | stackexchange_codegolf |
You are given a bunch of ASCII test-tubes, your task is to reduce number of test-tubes used.
Each test tube looks like this:
| |
| |
| |
|~~|
| |
| |
| |
| |
|__|
Obviously, ~~ is the water level. Test-tube can be also empty, in which case there are no ~~ characters inside. Single tube can contain up to 8 water... | stackexchange_codegolf |
The bots are looking for love. Can you help them?
The rules
The goal of this game is find the bot you have the highest compatibility with. However, robots, who are inexperienced at dating are unable to tell how well a date went.
In the game, bots take turns "speed dating" some other bot. After each date, each bot choos... | stackexchange_codegolf |
Challenge
Create a program that, when run, changes the contents of the source file. This means that you can delete/add/change characters in the source file, but you can't delete the (source) file itself (deletion is when the source file does not exist after the program is run).
In the case of pre-compiled languages suc... | stackexchange_codegolf |
Challenge
Build the Wheat Wizard's stove using 2-input NAND gates. The solution with the fewest NAND gates wins.
Externally, it works in the following way: (the first line is added from the original spec for physical output)
It has 10 levels, from 0 to 9. The display has 9 lights, and if the current level is L, exactl... | stackexchange_codegolf |
Part 1 of the task is here
Flags Mashup Bot is a small Twitter bot that generates a new country name based on two random country names and tweets the result every couple of minutes.
Task
Your task is to replicate what the bot does by writing a script or a function based on the following criteria:
The input is two cou... | stackexchange_codegolf |
Your job is to implement bitwise addition.
To ensure that this is done, you will compute and print the result of addition without carry (or bitwise XOR). Then, you will compute the carry of the addition (bitwise AND) and multiply it by two (bitwise left shift). If the carry is nonzero, then you add the carry and the pr... | stackexchange_codegolf |
This is the cops' challenge. To post a robber, go here.
In this challenge, cops will invent a (likely simple) programming language, and write an interpreter, transpiler, or compiler that allows you to run it. Robbers will write a program in this language that manages to inject arbitrary code into the interpreter, trans... | stackexchange_codegolf |
A palindrome is a word which is spelled the same backwards and forwards. For example, "racecar" is a palindrome as is "redder". A double palindrome is a palindrome whose halves are also palindromes. For example, "abbabba" is a double palindrome, as the half "abba" is also a palindrome. Similarily, "abaababaaba" is a tr... | stackexchange_codegolf |
Pretty simple challenge here. Who can make the fastest algorithm (lowest time complexity) to determine whether or not the circle is "boxed in" given the following setup?
Input: Your program receives a pair of numbers (a,b) that denotes the position of a circle on a grid like this with arbitrary dimensions:
Where a-1 i... | stackexchange_codegolf |
Shortest program wins, of course.
| stackexchange_codegolf |
UTF-9 was an April Fool's Day RFC joke specifications for encoding Unicode suitable for 9-bit nonet platforms.
Challenge
Your task is to implement a program or a function or a subroutine that takes one integer, who represents the codepoint of a character, to return a sequence of integers that represents its correspondi... | stackexchange_codegolf |
Introduction
OEIS sequence A127421 is the sequence of numbers whose decimal expansion is a concatenation of 2 consecutive increasing non-negative numbers. Put simply, every number in the sequence is formed by putting together n with n+1 for some non-negative, integer value of n. The first several terms are:
1, 12, 23,... | stackexchange_codegolf |
Church Subtraction
Lambda calculus has always been a fascination of mine and the emergent behaviors of passing functions into each other is delightfully complex. Church numerals are representations of natural numbers contructed from the repeated application of a function (normally the unary addition of a constant). For... | stackexchange_codegolf |
Challenge
The goal of this challenge is to take a radical and convert it to a reduced and entire radical, and a real number. You do not have to convert it to all 3, however, you will get bonus points for converting it to 2 or 3 of them. You will also get bonus points if your code works not just with square roots. How t... | stackexchange_codegolf |
Consider a zero-sum game with 2 contestants. Each round, each contestant chooses, independently of each other, one of \$n \ge 2\$ different choices. Depending on the two chosen choices, one player is awarded an amount from the other player's pot. For example, the following table shows the gains (positive integers) and ... | stackexchange_codegolf |
You are given an array \$A\$, which may contain duplicate elements. In each swap, you may swap the value of any two indices \$i, j\$ (i.e. switch the values of \$A_i\$ and \$A_j\$). What is the least amount of swaps needed to sort the array, and what are the corresponding swapped indices?
Scoring
This is code-golf, so ... | stackexchange_codegolf |
Inspiration
Conway's Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are:
Any live cell with 2 or 3 living neighbours (the 8 cells immediately aroun... | stackexchange_codegolf |
Challenge
Create a quine, that instead of outputting it's source, output's it's source QWERTY-sorted.
What is QWERTY sorting?
QWERTY sorting is sorting code by the QWERTY keyboard. Anything higher or more left is greater (q > Q, \ > /) with presedence on higher. To check, find the locations of the two characters to com... | stackexchange_codegolf |
Print the phrase And she said, 'But that's his.' using only the following characters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ No punctuation or non-alphabetic characters whatsoever. You can use whatever programming language you want. Whitespace is completely allowed. Shortest program wins.
| stackexchange_codegolf |
Given an \$m \times n\$ matrix of integers A, there exist a \$m \times m\$ matrix P, an \$m \times n\$ matrix D, and an \$n \times n\$ matrix Q such that:
\$A = P D Q\$.
P and Q are unimodular matrices (i.e. matrices which are invertible and whose inverses are also integer matrices);
D is diagonal;
each diagonal entry... | stackexchange_codegolf |
A bit-counting comparator (BCC) is a logic circuit that takes some number of counting inputs A1, A2, A3, ..., An as well as inputs B1, B2, B4, B8, ... representing a number. It then returns 1 if the total number of A inputs that are on is greater than the number represented in binary by the B inputs (e.g. B1, B2, and B... | stackexchange_codegolf |
Risky is a new language of mine, which features an interesting form of tacit programming. In this challenge, you'll take a Risky program as input, and visualize the parsing.
No knowledge of Risky is needed for this challenge, but it's a pretty interesting language so I'd recommend trying it :p.
Task
Risky's parsing is ... | stackexchange_codegolf |
There are 5 different "special characters": % & # $ !
These special characters are in a string with numbers. Like so: "5 ! 60%2$5.3" (valid). You must determine the validity of the string and there are certain rules in order to determine validity of the string.
Rules:
These special characters can exist in a string... | stackexchange_codegolf |
Challenge
You find yourself in a bash terminal, and want to do some simple tests
on sqlite3.
So you issue the following command:
echo "CREATE TABLE T (id INT NON NULL PRIMARY KEY)" | sqlite3 test.db
Now you want to insert the first N integers (starting from 0, excluding N) into the table T.
For convenience, you execut... | stackexchange_codegolf |
INTRODUCTION
I like Karma Fields : he's a music producer that creates original music tracks. His artwork also matches up really well his style.
He has a logo witch I find really interessing :
GOAL
Your goal will be to reproduce that logo, graphically or in ASCII.
Edit
@NahuelFouilleul managed to provide a readable asc... | stackexchange_codegolf |
Intro
We have had histograms and counting, but not listing all of them.
Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. This is a language agnostic code-golf edition of this year's sixth problem.
I have explicit permission to post this challenge here from the original... | stackexchange_codegolf |
Assuming StackExchange doesn't decide to restore my account after deleting it due to age restrictions (even though I'm 14 already and almost 15 ಠ_ಠ), a lot of people on this site just lost reputation from my upvotes being deleted. This happened at around 5:30 PM on June 20th, 2017, UTC.
So, your challenge is to show ho... | stackexchange_codegolf |
A palindrome is a word that is its own reverse. I will define the left palindromic root of a word as the shortest prefix of the word for which the shortest possible palindrome that begins with that prefix is the original word. So the left palindromic root of racecar is race and the left palindromic root of ABBA is ABB.... | stackexchange_codegolf |
Given a sequence of three integers, determine if the sequence is arithmetic (of the form [a, a+d, a+2*d]) or geometric (of the form [a, a*r, a*r^2]) by outputting a fourth term that completes it (a+3*d for arithmetic, a*r^3 for geometric).
Examples:
[1, 2, 3] -> 4 (This is an arithmetic sequence with a difference of 1)... | stackexchange_codegolf |
Challenge
Write a full program/function to Demolish a given building at the rate 1 floor per second.
INPUT
Input is a building through STDIN(or whatever is called in your language) or through an ARGUMENT of a function.
t=0 s
|
|#|
{#}
|# #|
|# # #|
|# # #|
|# # #|
TTTTTTT
input consists of :
| marks sta... | stackexchange_codegolf |
Disclaimer: This does not do any justice on the rich topic of elliptic curves. It is simplified a lot. As elliptic curves recently got a lot of media attention in the context of encryption, I wanted to provide some small insight how "calculating" on an elliptic curve actually works.
Introduction
Elliptic curves are set... | stackexchange_codegolf |
Spreadsheet Columns
In most spreadsheet programs, columns go A, B, C, ... X, Y, Z. After this comes AA, AB, AC ... AX, AY, AZ, BA and so on.
Your task is to convert one of these strings in to a column number. You must support inputs up to the maximum length of your language, to a minimum of 3.
Test Cases:
A => 1
B ... | stackexchange_codegolf |
Many old Game Boy games often required string input from the user. However, there was no keyboard. This was handled by presenting the user with a "keyboard screen" like so:
The 'character pointer' would begin on letter A. The user would navigate to each desired character with the D-Pad's four buttons (UP, DOWN, LEFT a... | stackexchange_codegolf |
In your grandparents' day, dialing a phone number was done with a rotary dial like this:
To dial each digit, put your finger in the corresponding hole, pull it over to the finger stop, and release it. A mechanism will cause the dial to spin back to its resting position, and the phone will disconnect and reconnect a c... | stackexchange_codegolf |
Imagine you have a grid where some squares are walls, some are empty, and some are lights that shine for arbitrary distances in the four cardinal directions until they meet walls:
####.####
##..L....
####.##.#
####.##L.
##......L
In the above grid, the lights cover all the tiles. But in some cases, they may not be:
##... | stackexchange_codegolf |
It is ancient knowledge that every non-negative integer can be rewritten as the sum of four squared integers. For example the number 1 can be expressed as \$0^2+0^2+0^2+1^2\$. Or, in general, for any non-negative integer \$n\$, there exist integers \$a,b,c,d\$ such that
$$n = a^2+b^2+c^2+d^2$$
Joseph-Louis Lagrange pro... | stackexchange_codegolf |
Given a permutation of the alphabet and an input string, encrypt the input string by replacing all characters with the one's you've been given.
The capitalization should be kept the same and non-letters are not to be changed.
[hnvwyajzpuetroifqkxmblgcsd], "Hello, World!" -> "Zytti, Giktw!"
As [abcdefghijklmnopqrstuvwx... | stackexchange_codegolf |
Challenge
Create the shortest program that meets the requirements
Requirements
The code must generate a 5x5 grid of 0s, like so:
00000
00000
00000
00000
00000
The code must accept an input (column, row, character). The grid must change accordingly:
Start:
00000
00000
00000
00000
00000
Input:
(2,5,*)
Output:
0*000
0... | stackexchange_codegolf |
The Cabbage, Wolf, Goat riddle with a twist!
Backstory:
There’s an intergalactic river than needs to be crossed! Being a space-ferryman you’ve offered some aliens on your small space ferry that can only carry two entities: you and a passenger. However, you know that because politics, some of these aliens will instantly... | stackexchange_codegolf |
Background
You have again been given the task of calculating the number of landmines in a field. However, we have now travelled into the flatlands.
You must calculate the landmine score given a list/string of numbers (which will be 2D) and the landmine number.
The landmine number tells you where landmines are.
For each... | stackexchange_codegolf |
Stuttering is a problem which many of us might have experienced or at least seen it. Although most of famous speech recognition softwares have serious issues with stuttered speaking, let's imagine a software which understands stuttering, but cannot fix them and only writes them as is.
An example written text by such a ... | stackexchange_codegolf |
Part of the Code Golf Advent Calendar 2022 event. See the linked meta post for details.
As a Christmas gift, you were given a toy solar system. In this toy, all the orbits are circular and happen in the same plane. Each planet starts at a fixed location, has a fixed circumference orbit, and moves at a fixed speed (all... | stackexchange_codegolf |
Consider an \$n \times n\$ grid of integers which is part of an infinite grid. The top left coordinate of the \$n \times n\$ grid of integers is \$(0, 0)\$.
The task is to find a circle which when overlaid on the grid gives the largest sum of values inside it. The constraints are:
The circle has its centre at \$(x, x... | stackexchange_codegolf |
Consider a date formatted in YYYY-MM-DD.
You can use the joker * at the end of the date string. E.g. 2016-07-2* describes all the dates from 2016-07-20 to 2016-07-29.
Now, consider a period represented by a start date and an end date.
The algorithm must find the smallest possible list of dates representing the period.... | stackexchange_codegolf |
Dialogue by a 3Der.
I was hired by Sr. 4Der to learn the 4D universe and I was willing to get to know more about it. But since I am a 3Der, I wouldn't see him, nor would I know how the real shapes look like. All I can do is illustrate.
Sr. 4Der is pretty much invisible to us. We can't see him, but we can hear his voi... | stackexchange_codegolf |
Inspiration. Posted with permission.
Print one of the possible XKCD calendar "facts":
You can get the raw text and structure from my APL reference implementation or from Explain XKCD's transcript (including the title text just under the illustration).
Rules
At every decision node, there must be an equal (pseudo-)rando... | stackexchange_codegolf |
A Fermi-Dirac Prime is a prime power of the form \$p^{2^k}\$, where \$p\$ is prime and \$k \geq 0\$, or in other words, a prime to the power of an integer power of two. They are listed as integer sequence A050376. While a normal prime factorization generally does not contain a set of distinct primes (for example \$24=2... | stackexchange_codegolf |
For this challenge you are going to make a function (your function may be a complete program) that takes a list as input and returns a permutation of that list. Your function must obey the following requirements.
It must be deterministic.
Composing your function with itself a variable number of times should be capabl... | stackexchange_codegolf |
Write a function or program that, when given a list of names, outputs or returns a list where duplicates of given names have a unique shortened version of their surname.
Input:
A list of names, where a name is defined by a given name and a last name separated by a space. Names are non-empty strings containing only upp... | stackexchange_codegolf |
I have written a few challenges related to matrices, and common for all are that I use a format like the one below when representing the matrices, both in examples and in test cases:
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
This is likely a cumbersome format in many languages.
Challenge... | stackexchange_codegolf |
Imagine that there are \$n\$ different types of objects \$O_1,O_2,O_3,\ldots,O_n\$ and they each have a conversion factor \$k_1,k_2,k_3,\ldots,k_n\$. You can, for any \$1\le i\le n\$, convert \$k_i\$ amount of \$O_i\$ into \$1\$ of any other type of object.
Task
Your objective is to output all the possible ending confi... | stackexchange_codegolf |
This challenge is not about the game Snake.
Imagine a 2d snake formed by drawing a horizontal line of length n. At integer points along its body, this snake can rotate its body by 90 degree. If we define the front of the snake to be on the far left to start with, the rotation will move the back part of the snake and t... | stackexchange_codegolf |
For any ragged list its dimensions will be a list of non-negative integers defined as follows:
Elements that are not a list will have dimensions \$\textbf{[}\,\,\textbf{]}\$.
An empty list has dimensions \$[0]\$.
An \$n\$ dimensional list \$L\$ of length \$x\$ has dimensions \$x : k\$ where \$k\$ is the element wise m... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.