instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
This challenge takes place on the snub square tiling.
Start by choosing any triangle, and color it \$c_1\$.
Next, find all tiles which touch this triangle at any vertex, and color them \$c_2\$. Next, find all tiles which share a vertex with any \$c_2\$-colored tile, and color these \$c_3\$.
Continue this process ad inf... | stackexchange_codegolf |
Challenge
Let's have a list L of n elements. The task is to swap every two elements in this list.
Constrains
the list L has at least two elements
size of the list L is a multiple of two (i.e. number of elements is even)
Example
input: [1,2,3,4,5,6]
output: [2,1,4,3,6,5]
input: [0,1,0,1]
output: [1,0,1,0]
Rules
... | stackexchange_codegolf |
For Gregorian calendars, the date format varies from a country to another. There are three main formats recognized:
YY-MM-DD (big-endian)
DD-MM-YY (little-endian)
MM-DD-YY (middle-endian)
Your task is to write a program which, given an input string representing a date, output all the possible date formats by which th... | stackexchange_codegolf |
You are a historian studying a long forgotten language. You have just discovered a clay tablet which seems to list all known words in the language, in alphabetical order. Your task is to find this alphabet's order, if it exists.
The Task
Given an ordered list of words, try to output an ordered list of characters such t... | stackexchange_codegolf |
Introduction
Tensor contraction is an operation that can be performed on a tensor. It is a generalization of the idea of the trace of a matrix. For example, if we have a rank-2 tensor (a matrix) and we contract along both of its axes, we take the sum of each entry in which the indices of these axes are equal. In this c... | stackexchange_codegolf |
You will be given a list of radii, you must output the area of the smallest rectangle which they will all fit in.
For example, given the list [5,3,1.5] you would output 157.460.
This is the image:
The width is 15.7460 and the height is 10, so the area is 157.460
Rules:
You get the list via stdin or function argument,... | stackexchange_codegolf |
The challenge is simple: Read 3 letters from a system input¹ and convert them to numbers (A-1, B-2, C-3...Z-26)². Print each of those numbers in the order the letters were inputted in, each on a new line and then the sum of all 3 numbers, on its own line as well.
NOTE: There will be no extra input characters, only 3 le... | stackexchange_codegolf |
Traditionally presents are kept secret in boxes wrapped in paper. Since the ice caps are melting Santa Claus has begun to investigate some ways they might make the whole gift wrapping operation a little more eco-friendly. The first thing they've decided to do is to put all presents in perfectly cubic boxes. This makes... | stackexchange_codegolf |
Background
In the game stick ranger, there is an item which grants the character the ability to get critical hits.
Each time a projectile hits an enemy, it has some probability to be a critical hit (crit). For most weapons this is calculated independently each time, but for one class (the angel) things work differently... | stackexchange_codegolf |
Typescript is a typed superset of Javascript. For this challenge, we'll consider the following classic basic types:
string
number
boolean
undefined
null
And two "meta" types:
any
never
The type any annotates that any type is valid:
const a: any = "foo";
const b: any = 42;
const c: any = true;
const d: any = undefin... | stackexchange_codegolf |
Notice: This question originally had people write comments with a shorter program, rather than new answers. This has been changed so that people with shorter programs can get reputation too. Hopefully this doesn't become unmanageable...
There have been a couple of OEIS-related questions recently, so here's another:
Pic... | stackexchange_codegolf |
The purpose of the challenge is to approximately plot the attractor of the logistic map as a function of its parameter r (also called bifurcation diagram), or a subregion of it. The appearance of the graph can be seen in the following image from Wikipedia:
Background
The logistic map is a mathematical function that ta... | stackexchange_codegolf |
(related/inspired by: Draw a bowling formation)
A fun pastime in the winter months here is to perform snowman bowling, using a large ball (like a basketball) and tiny snowman figures. Let's recreate this in ASCII.
Each snowman consists of the following:
(.,.)
( : )
Here is the alignment of the ten snowman "pins"
(.,.)... | stackexchange_codegolf |
In this challenge, You have to bring ASCII art (which are usually 2D) to 3D!
How?
like this,
X X DD
X D D
X X DD
to...
X X DD
X X DD D
X X DDDD
X XDDD
X X DD
Then How do we do that?
Given the ascii art and N, repeat this N times.
for every character (we will call this A):
let B be the character which is ex... | stackexchange_codegolf |
Related to this question.
A room is defined to be a (not necessarily convex) non-intersecting polygon, expressed as an ordered list of 2-dimensional coordinates. A sufficiently bright lightbulb is placed at a specific point inside the room, and emits light in every direction. Your task is to find the total illuminated ... | stackexchange_codegolf |
Introduction:
Although it seems challenges scored by least unique characters have been attempted, there are few which were well-received. I think it's a potentially interesting scoring criterion, as long as different languages aren't competing with each other (as with code golf).
Challenge:
Create a basic FizzBuzz prog... | stackexchange_codegolf |
Challenge
Robin likes having his variables declaration in the shape of an arrow. Here's how he does it:
Input any number of strings
Order them by ascending length
Output them ordered by the middle to roughly form a negative arrowhead, like this (whichever order golfs the best):
5 or 4
3 2
1 1
2 3
4 ... | stackexchange_codegolf |
The problem:
Given a non-empty set of points in the Cartesian plane, find the smallest circle that encloses them all (Wikipedia link).
This problem is trivial if the number of points is three or less (if there's one point, the circle has a radius of zero; if there are two points, the line segment that joins the points ... | stackexchange_codegolf |
Given two points \$(x_1, y_1)\$ and \$(x_2, y_2)\$ with integer coordinates, calculate the number of integer points (excluding the given points) that lie on the straight line segment joining these two points. Use any maths formula you like, such as
$$gcd(|x_2 - x_1|, |y_2 - y_1|) - 1$$
Input
Four integer coordinates of... | stackexchange_codegolf |
This is a problem on Luogu OJ. I decided to post it here because on Luogu OJ, many people, including me and my friend, are interested about how to solve this problem within the fewest characters.
Your task is to output the following ASCII-art:
************
####....#.
#..###..... | stackexchange_codegolf |
Given a non-empty matrix of non-negative integers, answer which unique rows contribute most to the sum total of elements in the matrix.
Answer by any reasonable indication, for example a mask of the unique rows order of appearance (or sort order), or indices (zero- or one- based) of those, or a submatrix consisting of ... | stackexchange_codegolf |
I have a coding problem that goes like this:
Given a positive integer \$N\$, return a list of all possible pairs of positive integers \$(x,y)\$ such that $$\frac1x+\frac1y=\frac1N$$
I already solved the problem using Python, but I was wondering how I can code golf it. The following is my attempt at golfing (I try to ... | stackexchange_codegolf |
Challenge
You are supposed to output the series I recently designed which goes as follows which are pen stroke counts of ascending prime numbers:
2, 3, 2, 4, 3, 5, 6, 5, 7, 7, 7, 10, 4, 6, 7, 4, 4, 4, 7, 6, 8...
Example
This is an illustration of how this series is formed, first, it takes a prime number from in sequen... | stackexchange_codegolf |
It is December 2014, and 2015 has almost started. However, it appears not everyone has realized this.
But the people of PPCG come to the rescue!
Input
Your program is given a grid like the one one the wall, where days that are in the month December look different from those in November and January. Each week starts wi... | stackexchange_codegolf |
Challenge:
Take a string of upper or lower case letters as input (optional), and calculate the score that string would get in a game of Scrabble in English.
Rules:
The score of each letter is as follows (use this even if there are other versions of the game):
1 point: E, A, I, O, N, R, T, L, S, U
2 points: D, G
3 point... | stackexchange_codegolf |
Don't you hate it when you're trying to roughly sort a list based on user data, but you have to poll the user for thousands of comparisons?
Hate no more, because the answers to this challenge are (going to be) here!
Method
The sorted-ness of a list is defined by how many possible comparisons it has which are correct.
L... | stackexchange_codegolf |
2fuck is a simple 2D variation on brainfuck. Like traditional brainfuck, there is an 1D memory tape that extends 30000 bytes to the right from its beginning, consisting of values between 0 and 255.
Arithmetic should wrap around, adding 1 to 255 sets the cell to 0, and moving right from memory cell 29999 should move the... | stackexchange_codegolf |
Semordnilaps (also known as heteropalindromes, semi-palindromes, half-palindromes, reversgrams, mynoretehs, reversible anagrams, word reversals, or anadromes) are words which are also words when spelled backwards. A few examples are:
Ward <=> Draw
Mined <=> Denim
Parts <=> Strap
Given a positive integer N (via functi... | stackexchange_codegolf |
Inspired by wezl.
Your challenge is to take words (sequences of [a-zA-Z]) and truncate them to length 3. For example, never gonna give you up would become nev gon giv you up.
Words will not necessarly be delimited by spaces - for example, youtube.com/watch?v=dQw4w9WgXcQ will become you.com/wat?v=dQw4w9WgX. Input will b... | stackexchange_codegolf |
Introduction
The Sierpinski Arrowhead Curve is a curve that's limit is Sierpinski's Triangle.
It first starts like this:
_
/ \
Then, each line is replaced with a rotated version of the first one:
_
/ \
\ /
_/ \_
Next:
_
/ \
\ /
_/ \_
/ \
\_ _/
_ \ / _
/ \_/ \_/ \
Your task
Given a ... | stackexchange_codegolf |
Introduction
This is how a chessboard looks like.
You can see that a1 is a dark square. However, b1 is a light square.
The Task
The challenge is, given dark, light or both, output all the dark, light or all squares with a separator (like a whitespace or a newline). The order of all the squares does not matter.
Test ca... | stackexchange_codegolf |
A square-free word is a word consisting of arbitrary symbols where the pattern \$XX\$ (for an arbitrary non-empty word \$X\$) does not appear. This pattern is termed a "square". For example, squarefree is not square-free (using the lowercase letters as the alphabet), as the square ee appears; but word is square-free. A... | stackexchange_codegolf |
Background
The summary of a non-negative integer \$n\$ is the concatenation of all digits that appear in \$n\$ in increasing order, with each digit being preceded by the number of times it appears in \$n\$.
Some Examples:
n -> summary(n)
1221 -> 2122 (2 ones, 2 twos)
1212 -> 2122 (2 ones, 2 t... | stackexchange_codegolf |
You are given a nonnegative integer n and an integer p >= 2. You need to add some p-th powers (p=2 means squares, p=3 means cubes) together to get n. This is always for any nonnegative n, but you don't know many p-th powers (of any positive integer) you'll need.
This is your task: find the minimum number of p-th powers... | stackexchange_codegolf |
Your input is an array of integers in the range [-1,4]. An array element of -1 means that there might be a bomb in that position. A non-negative element means that there is not a bomb in that position and also the numeric value tells how many bombs there are within distance 2.
For example, if we have the following arra... | stackexchange_codegolf |
The pyramid begins with the row 1 1. We'll call this row 1. For each subsequent row, start with the previous row and insert the current row number between every adjacent pair of numbers that sums to the current row number.
$$
1\quad1\\
1\quad\color{red}{2}\quad1\\
1\quad\color{red}{3}\quad2\quad\color{red}{3}\quad1\\
1... | stackexchange_codegolf |
Let \$ A \$ represent the alphabet, such that \$ A_1 = \$ a and \$ A_{26} = \$ z.
Let's define that a word \$ W = w_1 w_2 ... w_n \$ (where \$ w_c \in A\$) is in standard order if and only if:
\$ w_1 = A_1 \$, and
for \$ 2 \le i \le n \$, if \$ w_i = A_x \$ then \$ w_j = A_{x-1} \$ for some \$ j < i \$ and some \$x\$.... | stackexchange_codegolf |
As you may know, the typical binary floating point numbers in a computer language are quite different than the typical integer numbers in a computer language. Floating point numbers can represent a much larger range, and can represent fractional amounts, however there is a trade-off that is frequently elided.
The dista... | stackexchange_codegolf |
Your program should take an array as input.
The array:
Will always be 1 dimensional
Will only contain integers
Can be empty
The program should reverse the array, and then add up the elements to the original for example:
Input: [1, 2, 3]
Original: [1, 2, 3]
Reversed: [3, 2, 1]
[1, 2, 3]
+ + +
[3, 2, 1]
[1+3, 2+2,... | stackexchange_codegolf |
Inspired by this question and refined by Luis Mendo.
Challenge
Given a 2D matrix of integers, each row has a maximum value. One or more elements of each row will be equal to the maximum value of their respective row. Your goal is to determine which column(s) contain the most entries which are equal to their respective ... | stackexchange_codegolf |
Write a program fragment so that, when repeated N times it prints the Nth Fibonacci number. For example, if your program is print(x) then:
print(x) should print 1
print(x)print(x) should print 1
print(x)print(x)print(x) should print 2
print(x)print(x)print(x)print(x) should print 3
print(x)print(x)print(x)print(x)prin... | stackexchange_codegolf |
A balanced string is a string of parentheses () so that every parenthesis is can be matched with another one. More rigorously they are the strings spanned by this grammar:
S → (S)S | ε
We can turn a string "inside out" by:
Switching all occurrences of ( and ) with each other
Moving characters from the front of the s... | stackexchange_codegolf |
Given three integers >= 2, create an ASCII cube in an orthogonal (cabinet) projection.
The three integers represent height, width and depth (measured in visible characters) including the corners. The corners should be 'o's or '+', free choice.
w: 10, h: 5, d: 4
Thus gives:
o--------o
/ /|
/ / |
o... | stackexchange_codegolf |
Instructions
Barry is a not so good backend developer in charge of a small API that should give you information about purchases made in a client's shop. However, he hasn't done a great job and your boss tells you to fix it client-side instead. Ideally you should receive comma-separated values such as 927,2,45,90 which ... | stackexchange_codegolf |
This challenge is pretty simple: you need to alert / print / show to the user the text "beep boop bop" (or "beep\nboop\nbop", with newlines), but it needs to be obfuscated. (where you couldn't see anything saying "beep", "boop", or "bop"). Points are calculated where your point value is in characters (not bytes)
| stackexchange_codegolf |
Related
Now you have some dice which you may roll several times. You need a uniform random integer between 1 and \$n\$, inclusive. Show a method that rolls the fewest times and behaves as an \$n\$-sided dice.
Alternative question: Given a set \$S\$ and \$n\$, pick the fewest elements from \$S\$(each element can be pick... | stackexchange_codegolf |
Let's make a little stupid program that simulates the meme "Mr. incredible becoming uncanny", but in this case, our little ASCII friend is going to react to our code length.
Objective:
Create a program that takes anything (preferably a program) as input and outputs this:
Pov:
<face> you score X on codegolf
Where X ... | stackexchange_codegolf |
Objective
Write a program or function (or equivalent) that sorts out and returns the odd letter in the matrix of random size.
Details
You will be passed a matrix (as a string) as input of random dimensions such as this.
bbbbbbbbbb
bbbbbdbbbb
bbbbbbbbbb
bbbbbbbbbb
bbbbbbbbbb
Your job is to find the letter that doesn't... | stackexchange_codegolf |
Consider the following probability puzzle.
We start with a string of bits all set to 0. At each step we choose a bit uniformly and independently at random and flip it. The value your code has to compute is the probability of getting to the all 1s bit string before you get back to the all 0s bit string.
Let \$n\$ be the... | stackexchange_codegolf |
I haven't been on PP&CG for a while, so I thought I would post something!
Your task is to find how "smooth" a natural number is. Your method is to:
1: Convert the number to binary
2: Find the number of changes / switches
3: Find the length of the string (in binary)
4: Divide length by changes
So, an example. 5.
Sta... | 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 |
Adapted from this FiveThirtyEight riddle.
Background
Examine the following infinite sequence:
3 3 3 2 3 3 3 2 3 3 3 2 3 3 2 3 3 3 2 ...
Let's say the sequence is 1-indexed. The ith number in the sequence determines how many 3s there are before the ith 2 and following any previous 2s. So since the sequence starts with ... | stackexchange_codegolf |
Your challenge is to draw/plot one of the hearts below. The size must be at least 50x50 pixels (vector graphics is OK). You may choose which of the hearts you want to draw/plot. Axes, grid lines etc. are accepted. There must be at least 100 distinct coordinates/points on the graph. The heart can be filled with color if... | stackexchange_codegolf |
Your task is, to count how many pluses I have.
What Pluses?
The no plus: 0 Points
-
The naïve Plus: 1 Point
+
The double Plus: 2 Points
+
+++
+
The mega double plus: 3 Points
+
+++
+
+ + +
+++++++++
+ + +
+
+++
+
Pluses of higher order than 3 must be ignored.
Rules
Input will ... | stackexchange_codegolf |
A man from the stars has come to Earth! Luckily the president of the United States, Donald Trump, has an infinity-sided die. Using this die, he can conjure up a number which you, the mayor of Podunk, must use to determine who should be sent to stop the invader! But be careful, you can only send a limited amount of byte... | stackexchange_codegolf |
From Wikipedia, Gabriel's Horn is a particular geometric figure that has infinite surface area but finite volume. I discovered this definition in this Vsauce's video (starting at 0:22) where I took the inspiration for this problem.
You begin with a cake (a cuboid) of dimension \$x \times y \times z\$. In your first sli... | stackexchange_codegolf |
Given an integer n ≥ 0 , output it in a non-positional base-3 notation, using digits 139ABCDE… and a 1-character separator. Every digit is a consecutive power of 3 and the digits on the left side of the separator are negated, e.g. A931|B → 81−(1+3+9+27) → 41. A digit may appear only once.
Rigorously, let ... | stackexchange_codegolf |
Given as input a list of positive integers, your task is to determine if every integer present has exactly two neighbors in the list. The neighbors of a integer \$x\$ are the distinct integers that appear next to an \$x\$ anywhere in the list. For example in the list:
[1,3,4,4,3,2,1]
The number 3 has 3 neighbors 1, 4... | stackexchange_codegolf |
If you have ever had any exposure to Japanese or East Asian culture you will have surely encountered the Amidakuji game:
As Wikipedia explains, it is a type of lottery drawn on paper and used to randomly select a permutation of N items.
For example, it may be used to randomly assign a starting sequence to N people, o... | stackexchange_codegolf |
Background
The Collatz Conjecture is quite well-known. Take any natural number. Triple and increment if odd; cut in half if even. Repeat, and it will reach 1 eventually. This famous conjecture, however, is only that, for it is yet unproven.
Little-known to the world, that was not Lothar Collatz's first attempt at fame.... | stackexchange_codegolf |
Here is Minkowski's question mark function:
It is a strictly increasing and continuous function from the reals to themselves that, among other unusual properties, maps rational numbers to dyadic rationals (those with a power-of-two denominator). Specifically, suppose the continued fraction representation of a rational... | stackexchange_codegolf |
OCTOBER 22 IS INTERNATIONAL CAPS LOCK DAY! UNFORTUNATELY, SOME DO NOT RECOGNIZE THE GLORY OF THE ALMIGHTY CAPS LOCK. THEY SAY IT SEEMS "OBNOXIOUS" OR "LIKE SHOUTING" OR SOME NONSENSE. IN ORDER TO CONFORM TO THESE OBVIOUSLY ILLOGICAL AND INANE COMPLAINTS, PLEASE WRITE ME A PROGRAM THAT TURNS NORMAL TEXT INTO "SENSIBLE" ... | stackexchange_codegolf |
Let's define a pristine program as a program that does not have any errors itself but will error if you modify it by removing any contiguous substring of \$N\$ characters, where \$1 \le N < \text{program length}\$.
For example, the three character Python 2 program
`8`
is a pristine program (thanks, Sp) because all the... | stackexchange_codegolf |
Disclaimer: This challenge is extremely scientifically inaccurate.
;)
Given an input of a list of molecules, output what the result would be if they
were to all combine via dehydration synthesis, if possible.
For the purposes of this challenge, although this description is inaccurate, a
dehydration reaction
between two... | stackexchange_codegolf |
Challenge
Write code that, given an English word, outputs the number of syllables it has. Scoring will be determined by a combination of code length and accuracy.
Rules
The accuracy of the solution should be measured against this CSV file (which countains syllable counts for all the 52,439 entries in the CMU Pronounc... | stackexchange_codegolf |
An alternating permutation is a permutation of the first \$ n \$ integers \$ \{ 1 ... n \} \$, such that adjacent pairs of values in the permutation alternate between increasing and decreasing (or vice versa).
Equivalently, it is a permutation where there are no "runs" of continuously increasing or decreasing values wi... | stackexchange_codegolf |
There are one hundred members of the United States Senate. Assuming that nobody filibusters and that the Vice President isn't cooperating, at least fifty-one members are necessary to pass a bill. But some members work together better than others, entropy-wise.
Your task: Output the last names of at least 51 of the US s... | stackexchange_codegolf |
So the golf question was like this:
You are given a number T and then a total of T number of 17-character strings. For each of the strings, output yes if it contains four consecutive identical characters or contains the substring DX, else output no.
The following constraints are promised for each of the 17-character ... | stackexchange_codegolf |
Given a date written in any (must handle all in the same program) of the following formats, parse it into a valid yyyy/mm/dd date.
17th May 2012
March 14th, 2016
20 February 2014
September 14, 2017
Sunday, June 8, 2015
Rules
Dates will sometimes be invalid, ie. incorrect day for the month or number of months in a yea... | stackexchange_codegolf |
Write a non-empty program or function that when called outputs a single value, 1 or 0, and when called
multiple times, the output numbers produce the binary representation of your program's source code
(in the same code page from which your code is compiled/interpreted).
For instance, if your source code was abc (in AS... | stackexchange_codegolf |
Given two strings: a string s and an alphabet a, implement string projection in the shortest code possible.
String projection returns a string o that contains the characters in s that are in a. The order of the characters in o must match the order of characters in s. So if s = "abcd" and a = "12da34", o = "ad", since o... | stackexchange_codegolf |
Tonight, 31 January 2020, Brexit will happen and the United Kingdom will leave the European Union, the first time that the number of EU member states will decrease.
Your job is to take a date and output the number of EU1 members on that date, according to the following table:
| Start | End | Number of memb... | stackexchange_codegolf |
In the misty years of yore, when fanfold terminals walked the earth, there lived a strange creature. Oddly crippled and yet oddly powerful, the line editor teemed across the programming landscape in untold numbers; covering the earth as far as the eye could see.
Now it is fallen on hard times. That vast population hunt... | stackexchange_codegolf |
Every so often I have a function of type a -> b and a function of type b -> b -> c and I would like a function of type a -> a -> c. For example if I wanted to check the second element of each two tuples were equal
snd :: (a , b) -> b
(==) :: Eq a => a -> a -> Bool
And I want something of type
Eq b => (a, b) -> (c, b)... | stackexchange_codegolf |
Given two strings a and b, count how many times b occurs as a substring in a, but only when it overlaps with another instance of b.
(This means that 1 will never be a valid output, because in order for the substring to be strictly overlapping, there must be at least one other instance for it to overlap with.)
Test case... | stackexchange_codegolf |
You work at a virtual, old-fashioned printing press. To help you arrange your monospace letters faster, you decide to make the shortest program possible to help you. Given a string of text and a page size, generate and output each page of the text.
Examples
For example, with a page width of 14, height 7, and some text,... | stackexchange_codegolf |
Input: A string
Output: The rarity of the string, as described below.
To find the rarity of a string, follow the steps below.
Start with 0.
Subtract 3 for each E, A, T, or O in the string.
Subtract 2 for each I, N, S, or H in the string.
Subtract 1 for each R, D, L, or C in the string.
Add 1 for each W, F, G, or Y in ... | stackexchange_codegolf |
Take a matrix A consisting positive integers, and a single positive integer N as input, and determine if there are at least N consecutive occurrences of the same number in any row or column in the matrix.
You need only test horizontally and vertically.
Test cases
N = 1
A =
1
Result: True
----------------
N = 3
A =
1 ... | stackexchange_codegolf |
Definition
A number is positive if it is greater than zero.
A number (A) is the divisor of another number (B) if A can divide B with no remainder.
For example, 2 is a divisor of 6 because 2 can divide 6 with no remainder.
Goal
Your task is to write a program/function that takes a positive number and then find all of it... | stackexchange_codegolf |
Create a function in your chosen language that prints out the following:
Old MacDonald had a farm, E-I-E-I-O,
And on that farm he had a cow, E-I-E-I-O,
With a moo moo here and a moo moo there,
Here a moo, there a moo, everywhere a moo moo,
Old MacDonald had a farm, E-I-E-I-O!
Where cow and moo are strings in the funct... | stackexchange_codegolf |
Goal
Given a deal result from Duplicate Contract Bridge, calculate the deal score.
Basically the same as iBug's question, which was deleted. I figured out this scoring system while trying to answer that question.
Input
Input is a deal result, and whether or not the declaring side is vulnerable.
The deal result is a str... | stackexchange_codegolf |
Recamán's sequence (A005132) is a mathematical sequence, defined as such:
A(0) = 0
A(n) = A(n-1) - n if A(n-1) - n > 0 and is new, else
A(n) = A(n-1) + n
A pretty LaTex version of the above (might be more readable):
$$A(n) = \begin{cases}0 & \textrm{if } n = 0 \\
A(n-1) - n & \textrm{if } A(n-1) - n \textrm{ is positi... | stackexchange_codegolf |
Inspired by this question.
Create a program that prompts the user to store some data, and when the program is quitting, spit out the program itself, except the session data changed.
The user then open the newly generated program, and can recall the data from the previous program.
Commands
KEY VALUE: sets session varia... | stackexchange_codegolf |
You are given a very special gun with a full magazine.
Let n be the initial number of bullets in the magazine and i the number of bullets left.
That gun is really unreliable, hence each time you shoot, you have a i/n chance to successfully shoot. The fewer bullets you have left, the more tries it requires to shoot.
The... | stackexchange_codegolf |
Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.
How does this work?
Convert each number to its binary representation.
Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
Create a wall where the 1s are brick... | stackexchange_codegolf |
A positive integer \$k\$ is a Loeschian number if
\$k\$ can be expressed as \$i^2 + j^2 + i\times j\$ for \$i\$, \$j\$ integers.
For example, the first positive Loeschian numbers are: \$1\$ (\$i=1, j=0\$); \$3\$ (\$i=j=1\$); \$4\$ (\$i=2, j=0\$); \$7\$ (\$i=2, j=1\$); \$9\$ (\$i=-3, j=3\$); ... Note that \$i, j\$ for... | stackexchange_codegolf |
I thought of a new way to generate my passwords, and even though it's probably not very clever in the long run, it could still make for a fun code-golf.
Taking a string of words, the password is generated thus:
Pick the nth character in the nth word
If n is larger than the word, continue counting backwards
Example:
T... | stackexchange_codegolf |
Introduction
You must create a function to convert Greek numerals into Arabic numerals. The input will be a Greek numeral less than 1000 and more than 0. This is the reverse of my previous challenge.
Algorithm
Split input into letters (e.g. ΡΚΓ -> Ρ, Κ, Γ)
Take each letter, and change to character found in table below... | stackexchange_codegolf |
CHALLENGE
This is a fastest-code challenge.
Count how many n-dimensional hypercubes with n=1,2,3,4 exist, with vertices labeled with either 1 or 0, such that there does not exist any rectangle formed by 4 vertices such that one diagonal is 1-1 and the other diagonal is 0-0. To be more clear, the forbidden rectangles ha... | stackexchange_codegolf |
I thought it'd be interesting to turn AoC day 3 puzzle into a Golfing Challenge, so here it is.
Task
Find the number of # you'd encounter in an 11x11 grid (consisting of # and .) that repeats itself (to the right side), starting at the top left corner, which is always a .. You will need to check the position that is \$... | stackexchange_codegolf |
Key Links
Dwarf question
Chat room
Game
Controller Interface
Troll league table
<script src="https://ajfaraday.github.io/Thud/dist/data/tables.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table> <thead> <tr> <th>Client</th> <th>Wins</th><th>Loses</th> <th>Sc... | stackexchange_codegolf |
We've had challenges for SIGSEGV and SIGILL so why not...
Write the shortest code that results in a Bus Error (SIGBUS) in any programming language.
Your program can't call raise() or kill(getpid(),sig) or pthread_kill(pthread_self(),sig), or any other equivalent.
| stackexchange_codegolf |
For the purpose of this challenge, a smaller-base palindrome (SBP) is a number which is palindromic in a base between 1 and itself (exclusive), and is not a repdigit in the same base. For example, 5 is a SBP because it is a palindrome in base 2 (101). The first few SBPs are 5,9,10,16,17,20,21,23,25,26,27,28,29,33...
... | stackexchange_codegolf |
Background
Combinatory logic is a system where a term is written using a finite set of combinators and function application between terms, and reduction rules are defined for each combinator. The well-known S and K combinators have the following reduction rules:
$$
\begin{aligned}
S\;x\;y\;z & \overset{S}{\implies} x\;... | stackexchange_codegolf |
Display numbers from one to one-hundred (in increasing order), but number 2 shouldn’t appear anywhere in the sequence. So, for example, the numbers two (2) or twenty-three (23) shouldn't be in the sequence.
Here is an example output, with newlines separating the numbers:
1
3
4
5
6
7
8
9
10
11
13
14
15
16
17
18
19
30
31... | stackexchange_codegolf |
Dotcomma is a simple esolang I made a while ago that only uses four operators: [.,]. In this challenge, you'll determine if a dotcomma program consisting only of [.] halts. Without ,, there is no input, output, or queue, making this challenge possible.
Blocks:
Any code wrapped in [] is a block. All blocks and operators... | stackexchange_codegolf |
Given a string or list, calculate the effects of gravity on that string/list.
The string will be made of 5 characters:
N has a weight of 2
L has a weight of 1
S has a weight of -2
D has a weight of -1
(the 5th character is whatever you want, it means empty space. I use (space) in my examples)
Items with negative we... | stackexchange_codegolf |
This challenge is simple: Take a path to an png image file as input and overwrite that file with a copy of itself rotated 90 degrees clockwise. You may assume that the file has dimensions of 128x128 pixels. You may not use image metadata modifications (like Exif) to rotate the image; the pixels themselves must be trans... | stackexchange_codegolf |
Your task, at the moment that you choose to accept it, is to write a program that, when given a string and a PCRE-regex, calculates the minimum Levenshtein distance to another string that matches the regex (fully). All strings, as well as the regexes, should be in the Latin-1 character set.
This is code-golf, so the sh... | stackexchange_codegolf |
Define a prepend-append sequence of length n to be a permutation of the numbers 1, 2, ..., n that can be generated by the following procedure:
Start with the number 1.
For each number from 2 to n, place this number to the beginning or end of the sequence (either prepend or append it, hence the name of the sequence).
... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.