instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Your task, if you choose to accept it, is simple.
Objective
You must make a program that, when run, prints some (as many as you want) terms in a sequence that you choose. The sequence must be a valid OEIS sequence. The twist is that when you take the characters from your code that make up your sequence, string them tog... | stackexchange_codegolf |
You want to find the length shortest path between two points, on an 2d ASCII "map". The roads are made up of + characters, and the two endpoints are represented by #s (not counted in the length). This road can be arranged in any way, and any other characters can be ignored. You can assume the endpoints will always conn... | stackexchange_codegolf |
Let's define a self-contained number as a positive integer, whose digits appear in runs of length equal to themselves only. In other words, any decimal digit d (excluding 0) occurs only in runs of length exactly d.
Task
You can choose any of the three methods listed below:
Given an integer n, output the nth (either 0 ... | stackexchange_codegolf |
Tomorrow, November 23rd, is Thanksgiving Day in the United States. To prepare, you need to cook up some ASCII turkeys. However, since you're late in planning, you need a program (or function) to help you with how many birds you need to prepare.
.---. _
.' './ )
/ _ _/ /\
=(_____) (__/_/==
======... | stackexchange_codegolf |
Two points pand q in a topological space can be separated if there are open sets U and V such that:
p is an element of U and q is an element of V
U and V do not have any elements in common
Your task is given a topology (a set of open sets) and two points p and q (p!=q) to output sets U and V satisfying the above cond... | stackexchange_codegolf |
Basically the tron light-cycle game as a king of the hill competition!
Leaderboard
Updated as of 2022-04-05
#1) Player Avoid by Agent Biscutt
#2) Dodge West by Imanton1
#3) Space Finder by Spitemaster
#4) Blind Bot by TheSilican
Judge/Leaderboard Website
The Game
Players will write bots that compete in a light-cyc... | stackexchange_codegolf |
What are some tips on how to shorten this code even further? The code is meant to compute the parallel resistance of an electric circuit.
Using scanf
float r;main(){float a;scanf("%f",&a);r+=1/a;printf("%f",1/r);main();}
Using command-line arguments
#include<stdlib.h>
float r;main(c,v)char**v;{for(int i=1;i<c;)r+=1/at... | 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 |
\$ 1089 \$ is a very special number. To prove why, select any 3-digit number whose first and last digits differ by at least 2. Then, reverse the digits, and take the difference of these two numbers. Reverse the digits once more, and add these two numbers together. You will get \$ 1089 \$. The magic is left as an exerci... | stackexchange_codegolf |
A Bayer matrix is a threshold map used for ordered dithering that gives the illusion of having more shades of color than actually present by using a crosshatch-like pattern.
Bayer matrices are square with a side length that is a power of 2. Here are some examples:
\$
\displaystyle\frac{1}{4}
\times
\begin{bmatrix}
0 & ... | stackexchange_codegolf |
Sometimes, when I'm idly trying to factor whatever number pops up in front of me¹, after a while I realize it's easier than I thought. Take 2156 for example: it eventually occurs to me that both 21 and 56 are multiples of 7, and so certainly 2156 = 21 x 100 + 56 is also a multiple of 7.
Your task is to write some code ... | stackexchange_codegolf |
Background
There are self-extracting .ZIP files. Typically they have the extension .EXE (and by executing the file they will be extracted) but when renaming them to .ZIP, you can open the file with some ZIP extracting software.
(This is possible because .EXE files require a certain header but .ZIP files require a certa... | stackexchange_codegolf |
About the Series
This is a guest entry for the Random Golf of the Day series.
First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information abo... | stackexchange_codegolf |
The task is to convert a string representing a number in decimal (base 10) representation to duodecimal (base 12). The input is thus a string, the output should be printed.
The input number can be positive and negative, can be integer or rational. The decimal and duodecimal representations will have a finite number of ... | 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 |
Your regex will receive a string of the form
!XX!
#<extra>
where X is any hexadecimal digit (0-9 and A-F capital letters only), and <extra> is a character sequence to your choosing. (perhaps something like 0123456789ABCDEF0 could be useful?)
You may use any regex flavour.
Scoring will be calculated as: find regex len... | stackexchange_codegolf |
There are a bunch of different casing conventions, like camelCase, PascalCase, snake_case etc. It's annoying juggling all of these, so instead of choosing one like a sensible person, why not cursedly mix all of them together?
Your challenge is to, given a list of words (only containing lowercase letters), convert them ... | stackexchange_codegolf |
A frog sits on a lily pad wishing it were on the other side of the river. There are some lily pads of varying sizes between the frog and the other side of the river. Larger lily pads allow the frog to jump further than smaller ones and the frog wishes to reach the other side of the river in as few jumps as possible.
... | stackexchange_codegolf |
There's a board with n squares in a horizontal row.
You start in the leftmost square, and roll a 3-faced dice.
3 possible outcomes for a single roll of the die:
Left: you move 1 step to the left, if possible.
None: you stay where you are
Right: you move 1 step to the right, if possible.
You want to roll the dice exac... | stackexchange_codegolf |
Given a multi-line string as input containing characters "|", "_" and " " (space), count the number of cells it contains.
A cell is the following structure of 3 characters by 2 lines:
_
|_|
That is, an underscore on one line (the characters to its right and left don’t matter), and "|_|" right below it.
Two cells can ... | stackexchange_codegolf |
This is the logo for LAPACK, a widely used software library for numerical linear algebra.
Your task is to print the logo (color and matrix brackets not required) as this exact string. Trailing newline is allowed.
L A P A C K
L -A P -A C -K
L A P A -C -K
L -A P -A -C K
L A -P -A C K
L -A -P A C -K
| stackexchange_codegolf |
Given a random coordinate (x,y), determine in which square (squares are referenced by their sidelength) it is (or the borders of which squares).
The squares are drawn in a counter clockwise direction, that is, the first square is drawn in the first quadrant, the one after is to the right, the one after that above, th... | stackexchange_codegolf |
As you may know it, the factorial of a positive integer n is the product of all the positive integers which are equal or smaller to n.
For instance :
6! = 6*5*4*3*2*1 = 720
0! = 1
We will now define a special operation with an irrelevant name like sumFac:
Given a positive integer n, sumFac(n) is the sum of the factori... | stackexchange_codegolf |
Task
Given two positive integers (dividend and divisor), calculate the quotient and the remainder.
Normally it would be calculated as e = o*q+r where q*o<=e and 0<=r<o.
For this challenge it still e = o*q+r but q*o>=e and -o<r<=0.
For example e=20 and o=3, normally it would be 20/3 -> 20=3*6+2, since 18<=20 and 0<=2<3.... | stackexchange_codegolf |
I remember this was exam question long long long time ago.
There is a file say MyFile.txt, it can be any size and contains aphanumeric only
your task is to revese the words
example : "Go beyond the traditional laptop with Surface Laptop. It's backed by the best of Microsoft, including Windows and Office"
It should be "... | stackexchange_codegolf |
An uninteresting number (which I totally didn't make up only for this challenge) is created like this:
Take a positive integer N
Create a new number O by adding the digits of N at the end of N
The final uninteresting number is O*N
For example for N=12:
O = 1212
O*N = 1212 * 12
Final number is 14544
Input
A posi... | stackexchange_codegolf |
Let \$R, C\$ be positive integers and let \$0 < s \leq 1\$. Consider the \$R \times C\$ matrix \$\mathbf M\$ defined as
\begin{equation}
M(i,j) = \frac{\mathrm{mod}\,(j, i^s)}{R^s}, \quad i = 1, \ldots, R, \quad j = 1, \ldots, C
\end{equation}
where \$\,\mathrm{mod}\,\$ denotes the modulo operation: for \$a,b > 0\$ not... | stackexchange_codegolf |
The Chinese Remainder Theorem tells us that we can always find a number that produces any required remainders under different prime moduli. Your goal is to write code to output such a number in polynomial time. Shortest code wins.
For example, say we're given these constraints:
\$n \equiv 2 \mod 7\$
\$n \equiv 4 \mod ... | stackexchange_codegolf |
Inspired by this CR question (please don't kill me for browsing CR)
Spec
The probabilities of misspelling a word are:
1/3 of the time don't change the output
1/3 of the time remove a random character
1/3 of the time duplicate a random character
The chance for removing/duplicating a given character in the input should... | stackexchange_codegolf |
Write an \$n\$-bytes program \$AB\$ such that:
it outputs an integer \$x,\ 0\lt x\lt n\$;
both its \$x\$-byte prefix \$A\$ and \$(n-x)\$-byte suffix \$B\$, when run as programs, output \$AB\$.
\$A, B\$ and \$AB\$ should:
run in the same language
not take any input
use the same output method
This is code-golf, so th... | stackexchange_codegolf |
How many petals around the rose
How many petals around the rose is a dice game you can play with your friends. Similar to "can I join the music box", there is a person that knows how the game works and the others have to discover the rule.
In this game, someone rolls some dice (usually two or more) and then people have... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
The story continues from AoC2017 Day 14.
To recap: The disk is a rectangular grid with \$r\$ rows and \$c\$ columns. Each square in the disk is either free (0) or used (1). So far, you have identified the current status of the disk (a 0-1 ma... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2020 Day 20, Part 1. (This day is a dreaded one for many of you, I know :P)
Obligatory final "but you're not Bubbler" explanation.
As the train carries you to the destination, you've got some spare time. You open the travel boo... | stackexchange_codegolf |
Challenge:
Given an integer \$n\$, guaranteed to be \$\geq2\$ and a power of 2, we are going to draw multiply boards either side-by-side or below one another, where the first has dimensions of \$n\$ by \$n\$; the second \$\frac{n}{2}\$ by \$\frac{n}{2}\$; the third \$\frac{n}{4}\$ by \$\frac{n}{4}\$; etc.; until the fi... | 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 |
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 |
Inspired by How do you write dates in Latin?
Challenge
Given a month-and-day date, output that date in abbreviated Latin, as explained below.
Input
Input is flexible, following conventions from other date and sequence challenges. You may choose to:
Take a date in mm/dd or dd/mm format or two separate month,day argumen... | 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 |
The Venetian election system was... complicated.
The Great Council came together and put in an urn the ballots of all the councilors who were older than 30. The youngest councilor went to St Mark's Square and chose the first boy he met who drew from the urn a ballot for each councillor and only those 30 who got the wo... | stackexchange_codegolf |
Given an input string, determine the number of regions that a page will be split into.
Consider the letter P. It has one enclosed region within the letter. Assume that each letter splits the page by one or more regions (i.e. a box is drawn around the character).
Input
A string of 0 or more characters. You may assume th... | stackexchange_codegolf |
In the card game Magic: the Gathering there are five different colours, which represent loose affiliations of cards, White (W), Blue (U), Black (B), Red (R) and Green (G). These are often arranged in a pentagon as follows:
W
G U
R B
Both in the lore of MtG as well as in many card mechanics, adjacent colours in th... | stackexchange_codegolf |
I define the n-th ternary as a ternary that returns n and has the form:
1 ? 2 ? 3 ? n - 1 ? n : 0 : 0 : 0 # n - 1 zeroes
Write a function or complete program that given an input n will output or return the n-th ternary. Code-Golf.
Testcases
0 #=> undefined behaviour
1 #=> 1
2 #=> 1 ? 2 : 0
3 #=> 1 ? 2 ? 3 : 0 : 0
10 ... | stackexchange_codegolf |
Given positive integer n < 10, create a 2 dimensional matrix where each location is filled with its x and y index (starting from the top left).
For example:
Input: 2
00 10
10 11
Input: 3
00 10 20
01 11 21
02 12 22
Once the grid is created, randomly fill each index. This can be with an 'x' or any other way to denote a... | stackexchange_codegolf |
Given a matrix, the goal is to ensure all the values in each column occur at least once, while at the same time doing so requiring the least possible amount of rows. Fastest solution wins.
Note: a value in one column (e.g. 1) is considered different from the same value in another column.
Expected output: an array/list... | stackexchange_codegolf |
Given a list of points, find the shortest path that visits all points and returns to the starting point.
The Travelling Salesman Problem is well-known in the computer science field, as are many ways to calculate/approximate it. It's been solved for very large groups of points, but some of the largest take many CPU-ye... | stackexchange_codegolf |
Jimmy has had a busy last week with all these platforms and ropes, and poor Jimmy doesn't even have legs or feet to stand on!
Your job is to take a string containing multiple Jimmys and give them legs and shoes!
Get input in the form of a Jimmy String
Jimmy String => /o\ /o\ /o\
containing only /o\ and
give each ... | stackexchange_codegolf |
Daylight saving time (DST), is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. The typical implementation of DST is to set clocks forward by one hour in the spring ("spring forward") and set clocks back by one hour in autumn ("fall back") to re... | stackexchange_codegolf |
Some of you may have heard of the Wargame series of computer based real time strategy game. These games pit teams of players with primarily cold war era units to see how a hot cold war would have played out. The goal of this challenge is to simulate a tank battle in these games.
Input
Two "tanks" (one red and one bl... | stackexchange_codegolf |
I haven't. :P So I decided to define one:
A tralindrome is a string which contains three equal-length sections X, Y, Z such that
all characters in the string are included in at least one of the three sections,
X starts at the first character, Y starts at or right after the last character of X, and Z starts at or right... | stackexchange_codegolf |
Objective
Given a date, spell it out in Romanized Japanese.
I/O Format
The input format is flexible. The output format is <month spelling> <day spelling>; note the space. You can freely mix cases in output. You may output trailing newline.
Mapping
Months
Month
Spelling
January
Ichigatsu
February
Nigatsu
Mar... | stackexchange_codegolf |
You've gotten out of Earth's gravity well - good for you! However, you're feeling a bit uncomfortable in zero-gravity, and you want to replicate 1 \$g\$ of force in a centrifuge. Use the equation for force in a centrifuge:
$$\text{RCF} = \frac{r_\text{m} \, \left(\frac{2 \pi N_\text{RPM}}{60}\right)^2}{g}$$
Where
\$\t... | stackexchange_codegolf |
Given two integers, compute the two numbers that come from the blending the bits of the binary numbers of equal length(same number of digits, a number with less digits has zeros added), one after the other, like such:
2 1
10 01
1 0
1001
0 1
0110
some examples:
Input
Binary
Conversion
Output
... | stackexchange_codegolf |
In this challenge, you will calculate what your reputation would be, if the reputation cap didn't exist on PPCG.
Everyone can access the rawdata for reputation changes on the adress: codegolf.stackexchange.com/reputation.
The raw data follows a setup like this (these are the first few lines of my version of the page.
t... | stackexchange_codegolf |
If \$R\$ runners were to run a race, in how many orders could they finish such that exactly \$T\$ runners tie?
Challenge
Given a positive integer \$R\$ and a non-negative integer \$0\leq T\leq {R}\$ produce the number of possible finishing orders of a race with \$R\$ runners of which \$T\$ tied.
Note, however, that run... | stackexchange_codegolf |
Challenge: Add two numbers. In O(n^m) time, where n and m are the two numbers given. Sleeping, or your language equivalent, is not allowed.
Input: Two integers, separated by a space.
Output: The sum of the two integers.
Additional notes: The exact timing doesn't matter, as long as the input 1000 2 takes roughly 1/1000t... | stackexchange_codegolf |
Input: from STDIN number of vertices in Graph \$2 \leq N \leq 100\$.
Rules: [Code size] = max ([code length without spaces, tabs and newlines], [total code length divided by 4])
Math formulation: In the graph of N vertices, between each pair of vertices can be 3 road states:
there is no road
there is a road from A to ... | stackexchange_codegolf |
You cannot use if,while,for, ?:, ||, && etc., or recursion!
Assume it is Int.32
Shortest answer wins
| stackexchange_codegolf |
The Challenge
Given two vertexes and a point calculate the distance to the line segment defined by those points.
This can be calculated with the following psudocode
def dist(point, v1, v2):
direction := normalize(v2-v1)
distance := length(v2-v1)
difference := point - v1
pointProgress ... | stackexchange_codegolf |
NOTICE: This challenge is now closed: I will no longer be updating the leaderboard and will not change the accepted answer. However, you are free to run the controller and update the leaderboard yourself, if you wish.
Join the chat!
Introduction
Good evening, traders! You are all traders for the golfing company PPCG.... | stackexchange_codegolf |
I spent all of today at a Super Smash Bros. tournament, and I started thinking about some of the terminology we use when describing sets. These are the three kinds of sets that I see played at tournaments:
Best of 3 (Bo3)
Three games are played. The winner of the set is the player who won the majority of the games.
... | stackexchange_codegolf |
Left in sandbox for at least 3 days.
I want to verify if this inequality is true:
for \$n\geq4\$, if \$a_1,a_2,a_3,\dots,a_n\in R_+\cup\{0\}\$ and \$\sum_{i=1}^na_i=1\$, then \$a_1a_2+a_2a_3+a_3a_4+\dots+a_{n-1}a_n+a_na_1\leq\frac{1}{4}\$.
Challenge
Write a piece of program which takes an integer n as input. It does th... | stackexchange_codegolf |
A lawn is defined as a rectangular field with of one character surrounded by two layers of visible whitespace. This means two lines above and twos lines below, and a two space padding on the left (the right has visible whitespace, so you do not need to include it).
|||||
|||||
|||||
A mowed lawn is... | stackexchange_codegolf |
Gobar primes (A347476) are numbers which give a prime number when 0's and 1's are interchanged in their binary representation.
For example, \$10 = 1010_2\$, and if we flip the bits, we get \$0101_2 = 5\$ which is prime. Therefore, 10 is a Gobar prime
As simple as that: print the series with any delimiter. Shortest code... | stackexchange_codegolf |
You are trying to fit a sphere into a 5-sided box, but sometimes it does not fit completely. Write a function to calculate how much of the sphere is outside (above the rim of) the box.
There are 3 possible situations:
The sphere fits completely in the box. The answer will be 0.
The sphere sits on the rim of the box. T... | stackexchange_codegolf |
Given a pattern of squares on a grid, determine if it is possible to create that pattern with non-overlapping dominoes. In case you are not familiar, a domino is a rectangular shape created by joining exactly two squares at their edges.
Examples
For the pattern on the left, O represents an occupied cell on the grid and... | stackexchange_codegolf |
You are playing a famous game called \$1\text{D Array BattleGround}\$. In the game, the player can be stationed in any position from \$0\$ to \$10^5\$.
You are a Paratrooper in the game and have the ability to do two types of operation \$-\$
Advance, which would multiply your position by \$2\$
Fall-back, which would d... | stackexchange_codegolf |
For this challenge, you need to print out the fingerings for various brass instruments.
The notes an instrument can play (as well as their fingerings) are listed below:
Cornet Baritone
Trumpet Bugle French Horn Euphonium Tuba
A#0 0
B0
C1 ... | stackexchange_codegolf |
This is not the same as m-ss-ng-lette-s
Challenge:
Given a string with masked characters, generate all possible words, inclusive of non-meaningfull words.
Rules:
The sequence of the characters in the string does not change.
The masked character (*) will be one of an English alphabets [a-z].
There are no line breaks, s... | stackexchange_codegolf |
The challenge:
Assuming you have \$ X \$ collections, each collection \$ C_i \$ has a name \$ N_i \$ and a capacity \$ N_i \$ of elements - Determine which collection will be overflowed first while counting the occurrences of the names in a cyclic list. Also print how many cycles of the list occurred.
Example:
4 Collec... | stackexchange_codegolf |
Write a quine that
Writes its source code to disk
Recursively executes the written source code
Produces some variation to the code the third time (so not a true Quine)
Stops recursively calling itself the fifth time
Bonus points for leaving nothing on disk after execution.
| stackexchange_codegolf |
Yeah... it's confusing. Let me explain it a little better:
With a string, get the unicode code points of each letter
Let's use "Hello World!".
The code points would be [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
Of each digit of the code points, get their binary format
Get the binary of 7, then 2, the... | 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 |
In this challenge, your task is to decipher a string. Luckily, the algorithm is pretty simple: reading from left to right, each encountered digit N (0 to 9) must be replaced with the character which is N+1 positions before it.
Example
The input string "Prog2am0in6" would be decoded this way:
Hence, the expected output... | stackexchange_codegolf |
If you're not familiar, Diceware is a method for creating passwords using an ordinary die from a pair of dice as a hardware random number generator.
For the sake of fun, let's ignore anything about the security of computer's random number generators.
Write a function or program that prints or returns a single five-cha... | stackexchange_codegolf |
Introduction
The perimeter density matrix is an infinite binary matrix M defined as follows.
Consider a (1-based) index (x, y), and denote by M[x, y] the rectangular sub-matrix spanned by the corner (1, 1) and (x, y).
Suppose that all values of M[x, y] except Mx, y, the value at index (x, y), have already been determin... | 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 |
On Pomax's Primer on Bézier Curves this "fairly funky image" appears:
This is related to the fact that every cubic Bézier curve can be put in a "canonical form" by an affine transformation that maps its first three control points to (0,0), (0,1) and (1,1) respectively. Where the fourth and last control point lies afte... | stackexchange_codegolf |
Background
The special linear group \$ SL_2(\mathbb{Z}) \$ is a multiplicative group of \$ 2 \times 2 \$ matrices whose elements are integers and determinant is 1.
It is known that every member of \$ SL_2(\mathbb{Z}) \$ is a product of some sequence of the following two matrices \$ S \$ and \$ T \$ (reference pdf):
$$
... | stackexchange_codegolf |
Loopy is a puzzle game from the collection of Simon Tatham. The previous link contains a javascript implementation of a Loopy puzzle generator. I suggest everybody who wants to attempt this challenge to solve a couple of puzzles manually to understand how they are supposed to work.
Here are instructions on how to solve... | stackexchange_codegolf |
Write a program that, given a small positive even integer from standard input, calculates the probability that flipping that many coins will result in half as many heads.
For example, given 2 coins the possible outcomes are:
HH HT TH TT
where H and T are heads and tails. There are 2 outcomes (HT and TH) that are half ... | stackexchange_codegolf |
This challenge is inspired by a talk about Schläfli symbols, etc that I gave in a Geometry seminar. While I was putting together this challenge, I saw that Donald Knuth himself was interested in (some subset of) this problem. In October 2016, he commented on a related OEIS sequence:
If [the OEIS author] is wrong about... | stackexchange_codegolf |
Originally from a CMC I proposed for the last BMG event
Challenge
Given a non-negative integer \$n\$, create a 2D array of size \$2^n × 2^n\$ which is generated in the following manner:
Divide the matrix into four quadrants of size \$2^{n-1} × 2^{n-1}\$.
Visiting order of the four quadrants is defined to be the Z-shap... | stackexchange_codegolf |
Being programmers, watching us flex aren't very interesting. Today we change that! In this challenge you will lex and flex hexaflexagons.
About
For a video introduction, watch viharts video(s) on flexagons
A flexagon is a shape that you can flex to reveal faces other than the top and bottom one; we are making a hexahex... | stackexchange_codegolf |
A dual graph is defined such that for every "face" in a graph G, there is a corresponding vertex in the dual graph, and for every edge on the graph G, there is an edge in the dual graph connecting the vertices corresponding to the two faces on either side of the edge of the original graph. Note that the faces on both s... | stackexchange_codegolf |
Conways' 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 around it) lives ... | stackexchange_codegolf |
Draw an "apartment" building according to the specifications below.
Basic Rules
Take, as input, the number of floors of the building.
Return a building with that many floors meeting the following specifications:
The building will be eight characters wide, with eight underscore characters (_) on top and eight dashes (-)... | stackexchange_codegolf |
Let's play a one-player game called jump the array. To play, you only need an array of integers, say a. You start at some position i, and on each turn, you jump to a new position. On turn n,
if n is even, you jump to the absolute position a[i] mod length(a),
if n is odd, you jump to the relative position (i + a[i]) mo... | stackexchange_codegolf |
Sokobunny 1
You love buns!
You love them so much, that you chased one down a bunburrow. The burrows are like mazes, and YOU WANT TO CATCH THE FLUFFBALLS!!!! However, the buns are smart! You can't catch the bun by by chasing after it, as you wait out of politeness for the buns.
Taken from the game Paquerette Down the Bu... | stackexchange_codegolf |
Background
Though this is a bit late for Pi Day, I saw an article about Pilish and thought it would make a great challenge. Pilish is created by using a sequence of words where each word's length corresponds to a digit of pi.
Example from Wikipedia:
The following Pilish poem (written by Joseph Shipley) matches the fir... | stackexchange_codegolf |
Background
The Italian definite article (corresponding to English the) has seven different forms: l', il, lo, gli, i, la, le. Which one to use depends on three variables:
Gender: masculine / feminine.
Number: singular / plural.
Initial letter of the subsequent word: vowel / consonant type A / consonant type B.
Vowel... | stackexchange_codegolf |
Intro
Help! I'm stuck on a snow-covered mountain and I need to get down as fast as possible, preferably without dying. I have a map showing how high each part of the mountain is above the normal ground.
I am a novice skier, which means I like to stick to slopes that aren't too steep. I'm willing to go down just two mod... | stackexchange_codegolf |
Goal: create a self-referencing tuple satisfying x == (x,) in any version of Python. Standard libraries, matplotlib, numpy, pandas only.
Answers meeting this extra condition are prioritised (which may be impossible): this tuple should also be insertable into a dict or set.
If the extra condition is impossible, apart fr... | stackexchange_codegolf |
Thank you for you help fixing my calculator's multiply function, but I've found another critical error all calculators seem to share. None of them understand that 2+2=fish. So now I need code to properly add 2 numbers.
Challenge
Take 2 numbers as input (Type doesn't matter, but only 2 items will be passed. This is add... | stackexchange_codegolf |
The flick input method is a way of inputting Japanese kana on a modern smartphone. It is arranged in a 12-key layout, with the following labels:
あかさ
たなは
まやら
小わ、
When a key is tapped, it produces its respective kana. However, when the key is flicked in one of the four cardinal directions (up, down, left, right) it prod... | stackexchange_codegolf |
Given the width and height of a line in characters, draw it using ascii characters.
Input
Two integers separated by a space, the first one being the width, the second one being the height.
Example: 5 3
Output
An oblique line formed with the characters /\|_, that has the width and height given in the input. The characte... | 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 |
Given an integer N from 1-9, you must print an NxN grid of NxN boxes that print alternating 1s and Ns, with each box having an alternating starting integer.
Examples
Input: 1
Output:
1
Input: 2
Output:
12 21
21 12
21 12
12 21
Input: 3
Output:
131 313 131
313 131 313
131 313 131
313 131 313
131 313... | stackexchange_codegolf |
Task
This one is simple. We want to compress a URL, but don't trust URL shorteners.
Write a program that prints to stdout (or a 0-argument function that returns) the following, working URL:
http://a.b.c.d.e.f.g.h.i.j.k.l.m.n.oo.pp.qqq.rrrr.ssssss.tttttttt.uuuuuuuuuuu.vvvvvvvvvvvvvvv.wwwwwwwwwwwwwwwwwwwwww.xxxxxxxxxxxx... | stackexchange_codegolf |
Make a program that outputs the number of seconds from the beginning of today (00:00:00 of the day you run it) to the second you ran it. However, if this number is divisible by three, print Fizz instead. If it is divisible by five, print Buzz instead. If it is divisible by three and five, print FizzBuzz.
Don't pad the ... | stackexchange_codegolf |
First, study this puzzle to get a feel for what you will be producing.
Your challenge is to write a program or function which will output a circular graphic like the ones from the puzzle, given a (base 10) number between 1 and 100 (inclusive). This is similar to this challenge, except that you will be producing a graph... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.