instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Introduction
Cacti come in various different sizes, shapes and colors. However, the most iconic cactus and must-have in every Western has to be the saguaro. Important features are its size and arms, which have defined the stereotypical cactus appearance.
Your task is to bring the saguaro in the ASCII world. However, ... | stackexchange_codegolf |
Now that I'm thoroughly addicted to Code Golf, it's probably about time that I try to pick up a few golfing languages.
Given that I play almost exclusively in JavaScript, Japt seems like the logical language to start with. I'll be diving into the documentation at the next opportunity I get but, in the meantime, please ... | stackexchange_codegolf |
This is a cross-post of a problem I posted to anarchy golf: http://golf.shinh.org/p.rb?tails
Given two integers \$ n \$ and \$ k \$ \$ (0 \le k \le n) \$, count the number of combinations of \$ n \$ coin tosses with at least \$ k \$ tails in a row.
For example, if \$ n = 3 \$ and \$ k = 2 \$, the answer is \$ 3 \$:
HHH... | stackexchange_codegolf |
Challenge
You will be making a program/function that takes a string input of length n, and:
Puts the kth char at the center of the space, where k = (n+1)/2. This will be the location of your ground zero.
Puts the rest of the non-whitespace chars randomly arranged around ground zero. The Pythagorean distance from the c... | stackexchange_codegolf |
Background
The Sidi polynomial of degree \$n\$ – or the \$(n + 1)\$th Sidi polynomial – is defined as follows.
$$S_n(x) = \sum^n_{k=0}s_{n;k}x^n \text{ where } s_{n;k} = (-1)^k\binom n k (k+1)^n$$
The Sidi polynomials have several interesting properties, but so do their coefficients. The latter form OEIS sequence A0755... | stackexchange_codegolf |
According to this XKCD comic, there is a formula to determine whether or not the age gap in a relationship is "creepy". This formula is defined as:
(Age/2) + 7
being the minimum age of people you can date.
Therefore a relationship is creepy if either of the people in said relationship are younger than the minimum age ... | stackexchange_codegolf |
Simpler version of this
Task
You must create a program that outputs a triangle of a given size N.
A triangle is made of 3 identical triangles
A triangle of size N should be made of N lines
A triangle's line starts from 1 star, and increases by 2 stars each line
Test Cases:
1 ->
*
* *
3 ->
*
***
*****
... | stackexchange_codegolf |
I'm golfing a program to sum two numbers in C++.
Example:
10 3
13
I found out that this problem can be solved in 54 symbols (without spaces and so on) using C++.
My code (63 symbols):
#include <iostream>
main() {
int a, b;
std::cin >> a >> b;
std::cout << a + b;
}
I have no idea how to make my program sho... | stackexchange_codegolf |
I have a follow-up question here from my previous question on Math SE. I am lazy enough to explain the content again, so I have used a paraphraser to explain it below:
I was considering arbitrary series, springing up as a top priority, when I considered one potential series in my mind. It is as per the following:
The ... | stackexchange_codegolf |
Your challenge: Write a function that takes a string s, a character c, and finds the length of the longest run of c in s. The length of the run will be l.
Rules:
If s is of length 0 or c is empty, l should be 0.
If there are no instances of c in s, l should be 0.
Standard loopholes and Standard I/O Rules apply.
No mat... | stackexchange_codegolf |
This is an answer chaining puzzle, where each answer must add on to the last.
The \$n\$th submission must output its own source code in the \$n\$th language and the \$n−1\$ languages before it.
A language can be either a dialect or a major version of a language, so Python version 2.121 is only counted as version 2 and ... | stackexchange_codegolf |
In this code golf, you will have to determine the direction of the shortest shot that hits exactly n cushions before falling into a pocket.
The billiard table is a 6 pocket pool table with the following characteristics:
Dimensions are variable (a x b)
No friction : the ball will roll forever until it falls into a pock... | stackexchange_codegolf |
I forgot towel day
Sandbox link
PHP script for both examples (error, formatting the string)
Corrected php script, the input is self explanatory
PHP script with more input comment/uncomment $argv to see different results
As you may know, May 25 is well known as Towel Day, because of the many uses a towel can have.
A si... | stackexchange_codegolf |
Let us say that we have a particular set of functions on strings. These functions are kind of like fill in the blanks or madlibs, except that they only take one input and use that to fill in all of their blanks. For example we might have a function that looks like
I went to the ____ store and bought ____ today.
If w... | stackexchange_codegolf |
Concept
In what ways can you scramble the English alphabet so that it can still be sung to the tune Twinkle Twinkle Little Star without ruining the tune?
Rules
Swapping
Let's just assume the letters contained in each of the following sets can be swapped freely by default without ruining the tune:
{ A, J, K }
{ B, C, ... | stackexchange_codegolf |
Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different.
For example, \$1\$ and \$0\$ have binary forms 00000001 and 00000000, which are one bit apart. Similarly, \$152\$ and \$24\$ are 010011000 and 000... | 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 |
Take as input two strings \$A\$ and \$B\$. Output a string \$C\$ that is \$A\$ but with two characters swapped such that the Levenshtein distance \$d(C,B)\$ is as small as possible. You must swap two characters and you cannot swap a character with itself, although you may swap two identical characters in different po... | stackexchange_codegolf |
The Task
In this challenge, your task is to write a program, which takes in no input, with as many anagrams that are quine of themselves as possible.
Your score will be the number of anagrams of your program's source code that are valid quines divided by the total number of anagrams possible, i.e. the percentage of the... | stackexchange_codegolf |
Task
Your task is to write a program that will take input, and then output the lyrics to We Are Number One, changing specific words. The input will contain both the words to be changed, and the replacement word.
Input
The input will be in the following format:
one, two\n
net, villain\n
(\n is a newline, it's not actua... | stackexchange_codegolf |
For the purpose of this challenge, we'll define whitespace as only linefeeds (0x0A) and spaces (0x20). Note that most languages and regex flavours consider many other characters as whitespace as well, both inside and outside the ASCII range so you might not be able to make use of the corresponding built-ins.
The Cops' ... | stackexchange_codegolf |
With all the gyms closed down with the COVID-19 situation, we have to exercise with the weight we have lying around at home. The problem is, we have a small selection of plates at varying weights, and can't immediately determine if we can create a setup at the desired weight.
Given an unsorted array of weighted plates... | stackexchange_codegolf |
This is an answer-chaining challenge relating to the OEIS.
Oh, the justification for this is because a company needs one program to print out their OEIS sequences real bad and they have every language.
The answer-chaining format works in the following way:
Someone posts the first answer, from which all further solution... | stackexchange_codegolf |
Task
Given a representation of a line, output the number of quadrants that that line passes through.
Valid Representations of a Line
You can represent a line as
Three signed integers A, B, and C which share no common factor and where A and B are not both zero, representing the line Ax + By = C,
Four signed integers X1... | stackexchange_codegolf |
Given a matrix, output a representation of the matrix where the top left element is on top, the anti-diagonal is the central row and the bottom right element is at the bottom.
For example, consider the following matrix:
1 2 3
4 5 6
7 8 9
The diamond version of this matrix is:
1
4 2
7 5 3
8 6
9
Inputs and output... | stackexchange_codegolf |
I only very recently discovered code golf and just found this part of the Stackexchange network, and naturally after looking at so many clever answers, I feel inferior. Inner me knows I'll get better over time, but inner me is also vain and needs validation.
At the same time, I don't take kindly to pandering, so you'd ... | stackexchange_codegolf |
Challenge
There are many numbers which can be expressed as the difference of two squares, or as the difference of two cubes, or maybe even higher powers. Talking about squares, there are various ways of writing a number, say 75, as the difference of 2 squares. You can write:
75 = (10)^2 - (5)^2
= (14)^2 - (11)^2
... | stackexchange_codegolf |
\$\left\{ n \atop k \right\}\$ or \$S(n, k)\$ is a way of referring to the Stirling numbers of the second kind, the number of ways to partition a set of \$n\$ items into \$k\$ non-empty subsets. For example, to partition \$\{1,2,3,4\}\$ into \$2\$ non-empty subsets, we have
$$\begin{matrix}
\{\{1\},\{2,3,4\}\} & \{\{2\... | stackexchange_codegolf |
The task is to write code to identify which key is pressed on the keyboard. You can assume that only one key is pressed at a time and that there is a standard US keyboard layout. That is the layout with the @ over the 2.
Your code should output a unique identifier for any key pressed. This includes PrtScn, Scroll Lock,... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
An Elf is hopping on a chessboard which extends infinitely in all four directions. They move like a generalized chess Knight: on each step, they move X units horizontally and Y units vertically, or Y units horizontally and X units vert... | stackexchange_codegolf |
It's 22022 and the Unicode consortium is having a problem. After the writing system of the ⮧⣝Ⅲⴄ⟢⧩⋓⣠ civilization was assigned the last Unicode block, the consortium members have been scrambling to find a new encoding to replace UTF-8. Finally UTF-∞, a proposal by Bob Rike, was adopted. UTF-∞ is backwards compatible wit... | 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 |
We often get restricted-source questions here on PPCG that favour submitting solutions using only a subset of characters (sufficiently so that there's a tag printable-ascii that identifies a particular subset of those challenges). Wouldn't it be nice if we could automatically cut languages down to a subset of their nor... | 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 |
Introduction
A function that adds months to a date (without overflowing ends of months) is implemented in many languages/packages. In Teradata SQL it's ADD_MONTHS, here are some examples:
ADD_MONTHS('2021-01-31', 1) => 2021-02-28
ADD_MONTHS('2021-01-30', 1) => 2021-02-28
ADD_MONTHS('2021-02-28', 1) => 2021-03-28
... | stackexchange_codegolf |
The goal of this challenge is to take a positive integer n and output (in lexicographic order) all sequences \$S = [a_1, a_2, ..., a_t]\$ of distinct positive integers such that \$\max(S) = n\$.
For example, for an input n = 3 your program should output the following eleven sequences in the following order:
[
[1, 2, ... | stackexchange_codegolf |
You have been given the charge to calculate the current balance as of the day that you perform the calculation for 330,000 individuals who worked for an average of 30 years spanning 300 years where the initial principal was 1 with an addition of 1 per day and interest rate set at 3%.
You initially tried to use online ... | 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 |
You are tasked with displaying the string "ABCDEFGHIJKLMNOPQRSTUVWXYZ" and only that, except for trailing newlines if they're unavoidable.
You must not output any homoglyphic characters like Cyrillic A. You can use non-Unicode encodings, but just to be sure, only output the Latin letters.
Regardless of the encoding you... | stackexchange_codegolf |
In Wordle, you try to guess a secret word, and some letters in your guess are highlighted to give you hints.
If you guess a letter which matches the letter in the same position in the secret word, the letter will be highlighted green. For example, if the secret word is LEMON and you guess BEACH, then the E will be high... | stackexchange_codegolf |
For today's challenge you have to take an input, and if your source code is reversed, then the input should be printed doubled.
Let's say your source code is ABC and its input is xyz. If I write CBA instead and run it, the output must be any of be xyzxyz or xyz xyz or
xyz
xyz
For any numerical input you should not mu... | stackexchange_codegolf |
makina is a cell-based esolang composed of automata which move around a grid. These automata follow paths of instructions that direct their movement. Your task is to, given a makina program using only the below instructions (so a subset of normal makina) as input, output two distinct values depending on whether or not ... | stackexchange_codegolf |
As the June 2021 Language of the Month is Red, what are some general tips for golfing in Red language?
Please suggest tips that are at least somewhat specific to Red (e.g. "remove comments" isn't a valid tip here).
Please one tip per answer!
| stackexchange_codegolf |
Task:
Take a string as input and if it meets the requirements, accept the password.
Input: a string, e.g. someString, asjk23t89h, 123456789abcdef.
Output: two distinct values representing "secure" and "insecure", e.g. 0/1, true/false, secure/insecure.
Password requirements:
In order for a password to be determined as s... | stackexchange_codegolf |
Challenge:
The concept is simple enough: write a full program to output its own code golf score!
Output should only be the byte count of your program and a trailing bytes.
BUT WAIT..... there is one restriction:
Your source code can not include any of the digits from your byte count
So if your score is 186 bytes, you... | stackexchange_codegolf |
Stack Cats is a reversible, stack-based language. Its reversible nature makes for somewhat weird loops. This challenge is about the conditional loop (...). When these loops are nested in certain ways, it's possible to transform the code to reduce the nesting depth. Here are the rules (where A and B stand for an arbitra... | stackexchange_codegolf |
A musical string is any string that can be played on a piano keyboard.
For those of us who weren't forced to learn the piano as kids, here is what the keyboard looks like.
So the string feed a dead cabbage is a musical string because every single letter corresponds to one of these nots.
Your challenge is to write a pr... | stackexchange_codegolf |
I like Tetris a lot, but I'm not very good at it. Just once I'd like to see that spaceship take off in front of my own eyes! And since computers are oh-so great at everything, the only possible solution is to make a program to play it for me... except you're going to do that bit for me!
Given a tetromino (shape made of... | stackexchange_codegolf |
Since jq is the Language Of The Month for September 2021, what general tips do you have for golfing in jq? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to jq (e.g. "remove comments" is not an answer).
Please post one tip per answer.
| stackexchange_codegolf |
Given a non-empty string (or an integer, or a list/array if you prefer) composed exclusively of digits in the range [1-9], your task is to write a function (or a whole program) that applies a "Match-3 type of rule" from left to right and outputs the resulting string, like this :
[parameter] "12223" -> [returned value] ... | stackexchange_codegolf |
Imagine a simple SKI calculus expression - for example, (((S α) β) γ). As you can see, each node of the rooted tree has exactly two children. Sometimes though, the parentheses are omitted and the tree is unrooted (just to make the notation clear, I believe). The challenge is to put the parentheses back, so that the tre... | stackexchange_codegolf |
This is the Cops' thread. Robbers' thread is here.
Background
Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) A... | stackexchange_codegolf |
Introduction:
Ever used Dropbox with some other people and you both modified the same file? Ever had a multi-user application with a relational database, and two people were modifying (or worse, one was deleting and the other modifying) the same object? Well, let's simulate that with this challenge (sort-of).
For the s... | stackexchange_codegolf |
It is wartime, and rationing is taking place in certain regions of your country. Your cities' region is one such region. The city chooses to give everyone the same amount, but in reality, larger people need more food. Chances are, a 200lb man is going to be eating more than that 7lb baby over there. The city, realizing... | stackexchange_codegolf |
Background
Often, when storing a number in binary with some maximum, we simply round the maximum to the next power of two then allocate the number of bits nececairy to store the whole range. Lets call the result of this method \$S(x, m)\$ where x is the number and m is the maximum.
While not bad, the naive has a few bi... | stackexchange_codegolf |
The Bernoulli numbers (specifically, the second Bernoulli numbers) are defined by the following recursive definition:
Where denotes a combination.
Given a nonnegative integer m as input, output the decimal representation OR a reduced fraction for the mth second Bernoulli number. If you output a decimal representation... | stackexchange_codegolf |
Don't tell anyone, but I've nicked my uncle's time travel machine! My uncle is obsessed with prime numbers, though, and that shows in the machine — he has programmed it so that it can only go to dates that sum up to a prime number.
So it can't go to 1947-08-15 because 1947+8+15 = 1970, which is not a prime number. It ... | stackexchange_codegolf |
This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:
"Isn't the baby cute?", "Eh, baby shmaby"
"Come buy from my store, we ... | stackexchange_codegolf |
In this task you will take as input a non-negative integer \$n\$, and output the number of pairs of non-negative integers \$a,b\$ such that both are palindromes*, \$a \leq b\$, and \$a+b = n\$. For example if \$n\$ is \$22\$ then the valid pairs are
\$
\begin{array}{c|c}
a & b \\
\hline
0 & 22 \\
11 & 11 \\
\end{arra... | stackexchange_codegolf |
A well known song by the Irish rock band U2 starts with the singer Bono saying "1, 2, 3, 14" in Spanish ("uno, dos, tres, catorce").
There are various theories as to the significance of those numbers. Apparently the official explanation is "we drank too much that night". But there's a more interesting hypothesis: Bono ... | stackexchange_codegolf |
Your goal is to write a perfect player for the game of Wythoff's Nim.
Rules of Wythoff's Nim
Wythoff's Nim is a deterministic two-player game played with two piles of identical counters. Players alternate turns, in which they do one of these:
Remove one or more counters from the first pile
Remove one or more counters ... | stackexchange_codegolf |
Write a program or function that takes two inputs:
A text message
The dictionary of English language, as it appears in this Github file (containing about 60000 words)
and outputs the number of spelling errors in the message (see below for definition and test cases).
You can receive the dictionary as a parameter to yo... | stackexchange_codegolf |
Joe is your average BF developer. He is about to check in his code changes to their repository when he gets a call from his boss. "Joe! The new client's machine is broken! The brainfuck interpreter sets all the cells to random values before program execution. No time to fix it, your code will have to deal with it." Joe... | stackexchange_codegolf |
Write a quine that consists of real English words separated by single spaces. A "word" is defined as a string containing only lowercase and uppercase letters (/[a-zA-Z]+/ in regex). To be "real" your word must be recognized by the official Scrabble dictionary.
I'm using the Scrabble dictionary since it gives a definiti... | stackexchange_codegolf |
Description
Write a function f(m, G) that accepts as its arguments a mapping m, and a set/list of distinct, non-negative integers G.
m should map pairs of integers in G to new integers in G. (G, m) is guaranteed to form a finite abelian group, but any element of G may be the identity.
There is an important theorem that... | stackexchange_codegolf |
The goal of this challenge is to determine if a move is a legal English Checkers move.
This challenge will use an 8x8 board. A moved piece should be treated as a man (not a king) that can only move diagonally forward. The board will have 0 or more black pieces and 1 or more white piece. One white piece will be current... | 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 |
The challenge is simple: write a program or function that, when given a finite non-negative integer, outputs a nested array.
The rules
Your code must produce a unique valid nested array for every integer 0 ≤ n < 231.
Every possible nested array with up to 16 open brackets must be outputted within this range. (This d... | stackexchange_codegolf |
Write code to generate a PDF file containing 6 bingo cards. Winner is the one that uses the shortest code and needs no actions except for installing a library and running the code. (No Save As PDF). Rules are as follows.
The generated PDF file should display accurately in Adobe's PDF reader, Google Chrome and Moxilla ... | stackexchange_codegolf |
In one of this question's bonuses I asked you to design a permutation on the natural numbers such that the probability of a random term being odd was \$1\$. Now let's kick it up a notch. I want you to design and implement a permutation, \$f\$, on the natural numbers such that, for every integer \$n\$ greater than 0,... | stackexchange_codegolf |
Subleq is a Turing-complete esolang with only one instruction, SUBLEQ. This instruction takes in three parameters, A, B, and C, all of which are memory addresses. The instruction subtracts the value in memory address A from that in memory address B, storing it in address B. If the value at B is now less than or equal t... | stackexchange_codegolf |
CONGRATULATIONS to @kuroineko for the best entry and winning the 200 bounty from @TheBestOne (excellent sportsmanship!).
Write a program to colour as much of an image as possible before opposition programs do.
Rules in brief
Your program will be given an image, your colour, and integer N.
Each turn you are sent pixel... | stackexchange_codegolf |
We define the function g as g(n) = n XOR (n * 2) for any integer n > 0.
Given x > 0, find the smallest integer y > 0 such that gk(y) = x for some k > 0.
Example
x = 549
549 = 483 XOR (483 * 2) (as binary: 1000100101 = 111100011 XOR 1111000110)
483 = 161 XOR (161 * 2) (as binary: 111100011 = 10100001 XOR 101... | stackexchange_codegolf |
You are given an array A of length N and an array B of length N-1.
You need to output array where items alternates:
A[0], B[0], A[1], B[1], ..., B[N-2], A[N-1]
Restrictions:
N>0
Type of items is not specified, but code should work at least for unsigned integers.
Sample input:
A = [1,2,3,4]
B = [7,8,9]
Sample output:... | stackexchange_codegolf |
You're driving a car in an infinite city whose blocks are pentagons arranged in the order-4 pentagonal tiling. At each step, you proceed to the next intersection and choose whether to continue left, right, or straight. A sequence of choices that returns you to your initial state (street segment and direction) is called... | stackexchange_codegolf |
Create the shortest program that given an input string it outputs the opposite-cased string. For example if I pass the string "HeLlO" the program should output "hElLo".
Of course, neither aggregate functions can be used, nor framework functions like toupper() or tolower(). Any language is welcome.
| stackexchange_codegolf |
Keep Talking and Nobody Explodes is a local multiplayer game where one player has control over a virtual "bomb", and has to be guided by another player, the "expert", who has access to a bomb defusal manual. One of the modules to be disarmed in the game is the keypad module, which is what we'll be dealing with in this ... | stackexchange_codegolf |
Task
You will be given a string in the input consisting only of the characters from a to z, i.e. the input will match the regex /^[a-z]*$/.
Your output should be a complete program in the same language, whose source code contains the input, and is a proper quine.
Example
Your program would receive the input abc and out... | stackexchange_codegolf |
Amazingly, this simple task doesn't seem to exist already, so...
Your task is to write a program that takes as input a 12 hour time, and converts it into "military time", or 24-hour time format.
Input will be in the form:
HH:MM am/pm
Although slight variations are allowed:
The space separating the am/pm from the res... | stackexchange_codegolf |
The following puzzle was asked in puzzling SE. This puzzle is quite hard to solve by hand because every answer depends on another answer. So, for example, a solution with all answers being A does not work because then the question 7 would contradict question 8, for example.
One of the answers there at puzzling SE sugge... | stackexchange_codegolf |
Your task is, given a family tree, to calculate the Coefficient of Inbreeding for a given person in it.
Definition
The Coefficient of Inbreeding is equal to the Coefficient of Relationship of the parents. The Coefficient of Relationship between two people is defined as weighed sum over all common ancestry as follows:
E... | stackexchange_codegolf |
I just got a job as a postman and I need your help to keep it.
I have to order a lot of mails before I go out to deliver them.
Streets are numbered strictly sequentially, starting with 1 at the start of the street, and continuing in order skipping no numbers until the end, with odd numbers on the left side and evens on... | stackexchange_codegolf |
In 1988, the International Mathematical Olympiad (IMO) featured this as its final question, Question Six:
Let \$a\$ and \$b\$ be positive integers such that \$ab + 1\$ divides \$a^2 + b^2\$. Show that \$\frac{a^2 + b^2}{ab + 1}\$ is the square of an integer.
(IMO problems)
This can be proven using a technique called ... | stackexchange_codegolf |
Challenge
Create a program that outputs a square grid showing visible and non-visible points \$(x, y)\$ from the origin based on their greatest common divisor (GCD).
A point \$(x, y)\$ is considered visible from the origin \$(0, 0)\$ if the \$\gcd(x, y) = 1\$. Otherwise, it's non-visible.
Input
An integer \$n\$, repre... | stackexchange_codegolf |
This challenge is about printing a series of growing ASCII-art arrows. I'll describe the pattern in words, but it might be easier to look at what the start of this series looks like:
>
<
->
<-
-->
<--
--->
<---
---->
<----
----->
<-----
------>
<------
...
An arrow with length n contains an arrowhead (< or >) and n-1 ... | stackexchange_codegolf |
During the 49 days between Passover and Pentecost, Jewish liturgy provides four numerical problems that I've here phrased as code golf problems.
Input/Arguments
These four, in any order, and by any means:
A text \$L\$ consisting of exactly 7 sentences.
The first and last sentences have 7 words each, the middle one ha... | stackexchange_codegolf |
Consider the following alphabetically sorted list of words:
balderdash
ballet
balloonfish
balloonist
ballot
brooding
broom
All of the words start with b, and the first 5 start with bal. If we just look at the first 2 words:
balderdash
ballet
we could write instead:
balderdash
+let
where the ' ' is used where a wor... | 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 |
Inspired by a tweet by Nathan W. Pyle
There is, now, a standard method of converting your boring, normal human name into a mysterious, ethereal Ghost Name™️. Ably described by Mr Pyle...
Use your first name:
a - add “t” after it
e - add “boo” after it
h - becomes “s”
n - add “oo” after it
r - add “eee” after it... | stackexchange_codegolf |
Given a description of the base state of a recursive ASCII pattern, output an expanded state somewhere along the recursion steps.
More specifically: Let the following be an example:
##..
##..
..__
..__
Where # is filled, . is empty, and _ is recursive.
This describes a pattern wherein the top left quarter is filled, t... | stackexchange_codegolf |
In this challenge you will receive a list of positive integers \$W\$ called a word, and a square symmetric matrix \$M\$. Your task is to determine if the word can be turned into the empty list by applying a series of valid moves.
The valid moves are:
If two consecutive values in the list are equal you may remove them ... | stackexchange_codegolf |
I have a serious problem. I have some text files where I keep my very important numbers -- all of the important ones! And twos, and threes..
These numbers were so important that I couldn't entrust them to those newfangled decimal or binary number systems. I kept each number encoded in unary, as so:
+--+
... | stackexchange_codegolf |
Challenge
Implement the 1-indexed sequence A054049, which starts like this:
1, 2, 3, 6, 13, 5, 9, 377, 21, 11,
89, 14, 8, 233, 16, 987, 18, 2584, 20, 6765,
55, 23, 28657, 25, 75025, 27, 196418, 29, 514229, 31,
1346269, 33, 3524578, ...
This sequence is the lexicographically smallest sequence of positive integers, so t... | stackexchange_codegolf |
In this challenge, you'll need to edit a grid of characters to make a program that does a task, while ensuring that you leave a lasting mark on the grid.
Task
The task to perform is determined by when you answer. Specifically, for the nth answer, divide n by 5, and if the remainder is...
0. Read a positive integer fro... | stackexchange_codegolf |
A superabundant number is an integer n that sets a new upper bound for its ratio with the divisor sum function σ. In other words, n is superabundant if and only if, for all positive integers x that are less than n:
$$\frac{\sigma(n)}n>\frac{\sigma(x)}x$$
For a few of the values:
n σ(n) σ(n)/n superabundant
1 1 ... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2017 Day 3, Part 2.
You come across an experimental new kind of memory stored on an infinite two-dimensional grid.
Each square on the grid is allocated in a spiral pattern starting at a location marked 1 and then counting up wh... | stackexchange_codegolf |
Your challenge is to turn a Japanese word and a dictionary pitch accent number into a new string where the rises and falls in pitch are marked: e.g. (2, ウシロ) → ウ/シ\ロ.
To help you out with this, I'll explain a little about Japanese phonology.
Background: on moras
For the purpose of this challenge, we will write Japane... | stackexchange_codegolf |
Related: Read a crossword
Task
Given a completed Crossword puzzle, extract the words in it with their respective clue numbers, with "across" (horizontal) and "down" (vertical) words grouped and ordered like a real crossword puzzle.
The words are numbered in the row-major order of their first letters. If an "across" wor... | stackexchange_codegolf |
You probably know the game mastermind:
The player tries to guess a code of 4 slots, with 8 possible colors - no duplicates this time.
Let's call those colors A through H, so possible solutions could be ABCD or BCHD.
Each time you place a guess, the game master will respond with two information: how many slots you got r... | stackexchange_codegolf |
The divisors of a natural number form a poset under the relation of "a divides b?", \$a | b\$. This challenge is to produce the number, \$C\$, of non-empty chains of such posets for natural numbers, \$N\$.
This is A253249 in the Online Encyclopedia of Integer Sequences.
That may sound complicated, but it's not really, ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.