instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Your task is to write the shortest algorithm in a language of your choosing that accomplishes the following:
Given two matrices it must return the euclidean distance matrix. The euclidean distance between two points in the same coordinate system can be described by the following equation:
\$D = \sqrt{ (x_2-x_1)^2 + (y_... | stackexchange_codegolf |
Strobogrammatic Numbers
Definition
A number which is rotationally symmetrical, i.e., it'll appear the same when rotated by 180 deg in the plane of your screen. The following figure illustrates it better,
(source: w3resource.com)
Task
Given a number as the input, determine if it's strobogrammatic or not.
Examples
Tr... | stackexchange_codegolf |
Inspired by this building (United States Air Force Academy Cadet Chapel, Colorado)
Your task is simple, given a positive integer n, output the spiked building to size n
Testcases
1
->
^
/|\
/.|.\
/..|..\
_______
2
->
^ ^
/|\/|\
/.|..|.\
/..|..|..\
__________
7
->
^ ^ ^ ^ ^ ^ ^
/|\/|\/|\/|\/... | stackexchange_codegolf |
Introduction
I've seen throughout the code-golf challenges several simple tasks involving JSON, such as interpreting JSON strings with RegExs, and almost every other manipulation I could think of.
In a binding for AppleScript that I was using for a Node project, I noticed that objects would be returned in a strange wa... | stackexchange_codegolf |
It's simple, simply write the shortest code to raise a TypeError.
In Python you can do:
raise TypeError
However it should be shorter with a code that gives a TypeError without raising it.
| stackexchange_codegolf |
After seeing some impossibly short solutions in this SE, I began to wonder what code someone could come up with to build a pseudo-random number generator. Now given that I am new to programming, I have absolutely no idea what such generator should look like, or what language to write them in. But that did not stop me f... | stackexchange_codegolf |
Task
Write some code that can be rearranged into n different programs in n different languages each outputting a distinct number from 1 to n.
No two languages should be the same however different versions of "the same language" will be considered distinct languages, as long as they have different major version numbers.... | stackexchange_codegolf |
Ken Iverson, 1920–2020
Let's implement his favourite expression:
Given a row of Pascal's triangle, compute the next row.
This can for example be computed by taking the input padded with a zero on the left, and the input padded with a zero on the right, and then adding the two element-by-element.
Test cases... | stackexchange_codegolf |
Introduction
This problem is a challenge that has to do with DOM manipulation at scale and overcoming some issues that may be inherent in dealing with the DOM.
This challenge is interesting because limitations push us to think through things differently and lean on the strengths of languages different than what we usu... | stackexchange_codegolf |
Intro
The challenge is to create a program/function that prints the intersection of its own source code and a given string input. This is code golf and to be more precise:
Let I be the input set
{"a","b","c"}
Let S be the source code set
{"b","f"}
Then the intersection is what they share
I ∩ S = {"b"}
Inpu... | stackexchange_codegolf |
It's a funny accident that this world happens to have just 1 time dimension, but it doesn't have to be like that. It's easy to imagine worlds with 2 or more time dimensions, and in those worlds you could build computers and run software on them, just like in this one.
The System
Here is a system for running Brainf*ck p... | stackexchange_codegolf |
(Essentially the inverse of Find the needle in the haystack)
Given two tuples, (w, h) and (x, y), generate a haystack composed of a single random printable ASCII character of w width and h height with a needle made of a different random printable ASCII character at (x, y) when measured from the upper-left.
For example,... | stackexchange_codegolf |
Description
"Imtiaz Germain primes" is not a technical name in Mathematics, but my weird creation, in the memoir of the famous mathematician Sophie Germain. These primes can be generated by the following process:
1. Take a Safe prime
2. Apply 2p + 1 on it to obtain a composite number
3. Apply 2p + 1 once more to obtain... | stackexchange_codegolf |
Aww, man, this expiry date doesn't write the months with letters! I can't tell if it's expiring on March 10th or October 3rd... Wait, no, never mind, the year says 2012. (alley-oops half-used brick of cheese into the trash can like a pro)
So let's suppose for a moment that you're too busy to try to reason out when this... | stackexchange_codegolf |
This expression actually has an omitted pair of parentheses.
1 + 2 * 3
To make things clear, it should be,
1 + (2 * 3)
Even this has its parentheses missing.
1 + 2 + 3
It actually means,
(1 + 2) + 3
People often assume left-to-right evaluation to such an arithmetic expression, but I want to make everything very cle... | stackexchange_codegolf |
Given an arbitrary sequence consisting of 1 and A
split this sequence up so that A is at the beginning of each sub sequence.
Sequences without a leading A and Sequences without 1 before the next A will be self contained.
Example
Input
111A11A1111111A1A1AA
should result in
111
A11
A1111111
A1
A1
A
A
Above already cont... | stackexchange_codegolf |
There is a job which can be decomposed into x equally-sized smaller tasks. You have a team of size y <= x, where every member works equally fast on any task. The goal for this challenge is to divide the work as evenly as possible such that every member of your team has at least 1 task to perform. As evenly as possible ... | stackexchange_codegolf |
Rock-and-roll founding father Chuck Berry sadly passed away today.
Consider the chorus of his famous song "Johnny B. Goode":
Go, go
Go Johnny go, go
Go Johnny go, go
Go Johnny go, go
Go Johnny go, go
Johnny B. Goode
(There are other ways it has been punctuated but the above will serve for the purposes of the challenge... | stackexchange_codegolf |
A screen consists of some LED segments like such:
The screen can be split into several(maybe one) component. Each component is a segment like above, with varying lengths. These components can be used to display any amount, including 0, of digits, as long as the component is large enough.
Every digit except 1 needs two... | stackexchange_codegolf |
If we assign each letter a respective integer, starting from 1, then a is 1, b is 2, c is 3, and so on. After z, the letters loop back around, but with a in front (aa, ab, ac). It then goes to ba, bb, bc... After this is completed, as you may have figured, another letter is added (aaa, aab, aac). "Prime letters" would... | stackexchange_codegolf |
Given two non-zero 16-bit integers a and b, decide the smallest number of shift operations needed to turn a into b. A shift is one of the following (big-endian) operations:
shl (shift left): move all bits to the left, adding a 0x0 bit to the right.
shr (shift right): move all bytes to the right, adding a 0x0 bit to th... | stackexchange_codegolf |
Related.
Given a number \$n\$, Euler's totient function, \$\varphi(n)\$ is the number of integers up to \$n\$ which are coprime to \$n\$. That is, no number bigger than \$1\$ divides both of them.
For example, \$\varphi(6) = 2\$, because the only relevant numbers are \$1, 5\$. This is OEIS A000010.
We can now define th... | stackexchange_codegolf |
Challenge
Factory workers are usually very hard-working. However, their work is now being commonly replaced with machines.
You have to write a program that takes a number as input. It will print out a factory of 10 workers 10 times. Every time, each worker has a 1/input chance of being 'fired' and replaced by a machine... | stackexchange_codegolf |
A reflexicon is a self-descriptive word list that describes its own letter counts. Take for example the one found by Ed Miller in 1985 in English:
Sixteen e’s, six f’s, one g, three h’s, nine i’s, nine n’s, five o’s, five r’s, sixteen s’s, five t’s, three u’s, four v’s, one w, four x’s
This reflexicon contains exactl... | stackexchange_codegolf |
Or Fix American Kennel Club's database
As covered by the recent video by Matt Parker, the American Kennel Club permits thirty-seven (37) dogs of each breed to be assigned the same name (source), because of a database restriction for Roman numeral length.
Given an integer, your task is to output the length of its Roman ... | stackexchange_codegolf |
Part of the Code Golf Advent Calendar 2022 event. See the linked meta post for details.
As a Christmas gift, you were given a toy solar system. In this toy, all the orbits are circular and happen in the same plane. Each planet starts at a fixed location, has a fixed circumference orbit, and moves at a fixed speed (all... | stackexchange_codegolf |
This challenge was posted as part of the April 2018 LotM challenge
Brain-Flak is a turing-tarpit language which has gained quite a lot of fame here on PPCG. The memory of the language is composed by two stacks, but a "hidden" third stack was discovered by Wheat Wizard, leading to some interesting new ways of thinking ... | stackexchange_codegolf |
Challenge
Given three numbers \$a\$, \$b\$, and \$n\$, you must expand \$(a + bx)^n\$ in ascending powers of \$x\$ up to \$x^3\$.
Binomial Expansion
Note that this method is an approximation
The binomial expansion works like so:
(a + bx)^n = a^n(1 + bx/a)^n
= a^n(1 + n(bx/a) + n(n -1)(bx/a)^2/2! + n(n-1)(n-1... | stackexchange_codegolf |
The idea for this code golf puzzle is from link: The Bridge and Torch Problem
The inspiration for this code golf puzzle is the Bridge and Torch
problem, in which d people at the start of a bridge must all cross it
in the least amount of time.
The catch is that at most two people can cross at once, otherwise the
... | stackexchange_codegolf |
At the time of writing this puzzle, there are soon to be 269 puzzles related to primes. To celebrate/mourn this event (269 is prime), this challenge will be about exploding primes. In preparation for this task, I've obtained a permit (legal, I assure you) for dynamite charges of military grade, along with enormous dyna... | stackexchange_codegolf |
This is Fortnightly Challenge #3. Theme: Genetic Algorithms
This challenge is a bit of an experiment. We wanted to see what we could do, challenge-wise, with genetic algorithms. Not everything may be optimal, but we tried our best to make it accessible. If this works out, who knows what we might see in the future. Mayb... | stackexchange_codegolf |
Challenge
In this challenge, all numbers are in \$\mathbb{N}_0\$.
Create a function or program that, when given a number \$N\$ and a tuple of \$k\$ numbers \$(n_i)\$ (all ≤ \$N\$), returns the number of ways \$N\$ can be written as a sum of \$k\$ integers (\$x_1 + x_2 + ... + x_k\$) such that \$n_i \le x_i \le N\$.
The... | stackexchange_codegolf |
Some numbers, such as \$14241\$, are palindromes in base 10: if you write the digits in reverse order, you get the same number.
Some numbers are the sum of 2 palindromes; for example, \$110=88+22\$, or \$2380=939+1441\$.
For other numbers, 2 palindromes are not enough; for example, 21 cannot be written as the sum of 2 ... | stackexchange_codegolf |
May be you know the game of Set (a wonderful game for kids btw) a card game with 81 cards, where each card has a figure on it with 4 different attributes (form , number, colour and fill). Each attribute has 3 different values:
form: wave, oval, diamond
colour: red, purple, and green
number: 1, 2, 3
fill: none, dashed, ... | stackexchange_codegolf |
The following problem is taken from the real world — but indubitably code-golf!
In this puzzle, the programming language is fixed, and your job is to write the most efficient program in this fixed language. The language has no loops; a program is a straight-line sequence of instructions. Each instruction consists of ex... | stackexchange_codegolf |
UBASIC is a freeware basic interpreter written by Yuji Kida at Rikkyo University in Japan, specialized for mathematical computing. It is considered to be a "ready-to-run" language that and is capable of running on DOS and Windows.
What general tips do you have for golfing in uBasic? Any ideas that can be applied to cod... | stackexchange_codegolf |
Given a list of paths, output the correct path.
Example of path:
/\
----+/
|
- and | are horizontal and vertical paths.
/ and \ are 90° turns.
+ is treated as a - or a | depending of the current direction.
Paths may go in any direction and a character may be used in multiple paths.
Input will be like this:
... | stackexchange_codegolf |
Inspired by this question by @CᴏɴᴏʀO'Bʀɪᴇɴ.
Taken from the question:
Your task is simple: given two integers a and b, output ∏[a,b]; that
is, the product of the range between a and b. You may take a and b in
any reasonable format, whether that be arguments to a function, a list
input, STDIN, et cetera. You may ... | stackexchange_codegolf |
In this challenge, you will play the noisy iterated prisoner's dilemma.
The Prisoner's dilemma is a scenario in game theory where there are two players, each with two options: cooperate, or defect. Each player does better for themself if they defect than if they cooperate, but both players would prefer the outcome wher... | stackexchange_codegolf |
Write the shortest program possible that traps the mouse cursor inside an upward pointing equilateral triangle with a side length of 274 pixels and a centroid at the exact middle of the screen.
(Triangle because of cheese wedges.)
While your program is running, the tip of the cursor should never be able to move outside... | stackexchange_codegolf |
In this challenge posed by xnor, we were asked to implement XOR multiplication. In this challenge the goal is to find the first n XOR primes. XOR primes are very similar to regular primes as you can see by the following definitions:
Definition of Prime Number: A positive number greater than 1 which cannot be formed thr... | stackexchange_codegolf |
You are to write a program which outputs a single positive integer \$n\$. The integer may have leading zeros and whitespace, and/or trailing whitespace.
Then, choose a positive integer \$m > 1\$. When the program is repeated exactly \$m\$ times, it should output \$m \times n\$ (and only \$m\times n\$). When repeated an... | stackexchange_codegolf |
Background
A polyhex of size \$n\$ is a contiguous shape made from joining \$n\$ unit regular hexagons side-by-side. As an example, the following image (from Wikipedia) contains all 7 distinct tetrahexes (polyhexes of size 4):
A dihex is a polyhex of size 2.
Now, let's define a sticky polyhex as follows:
A single dih... | stackexchange_codegolf |
I recently saw this language in a challenge and it's awesome. Does anyone have some tips for code-golfing in it?
Your tips should be at least somewhat specific to MarioLANG.
Please post one tip per answer.
| stackexchange_codegolf |
I am trying to golf down some C++. Is it possible to make this condition shorter?
X > 3 & X - Y > 1
(Apart from removing whitespace, of course.)
So, X is at least 4 but X >= Y + 2.
X and Y are integers in the [0,5] interval.
I have tried to find some bitwise formula but failed.
| stackexchange_codegolf |
This challenge is based on this Stackoverflow question.
With a positive number as input, output it as the sum of each digit multiplied by its power-of-10 representation.
Input
A number, as an integer, a string or a list of digits/characters.
The number will be strictly positive.
If you accept the number as a string or... | stackexchange_codegolf |
In the game 2048, you have a grid, and you can move the elements in four directions. They all move in that direction as far as they can. For this challenge, you will be given a padded, square 2D string (either with newlines, or a list of strings), like so:
ab cd e
f ghij
kl
mno p
q r st
u v
w x y
... | stackexchange_codegolf |
My mom really wants me to eat broccoli, but I hate it and never want to eat it. Mom wants to trick me so she cuts it into small pieces, puts it in a salad and mixes it. Help me find out if the salad contains broccoli!
Input:
Array of mixed letters of all the ingredients. For a single broccoli ingredient it could be:
[c... | stackexchange_codegolf |
Objective
Given a permutation of 4 distinct items, classify the permutation by the normal subgroup(s) it belongs.
Input/Output Format
You gotta choose the followings as the hyperparameters for your submission:
The 4 distinct items.
The permutation serving as the identity permutation.
The input format is to accept a... | stackexchange_codegolf |
Your task: generate a Koch snowflake to the nth depth. You do not need to make a complete Koch snowflake, just one side of the starting triangle. Wikipedia on Koch flakes: https://en.wikipedia.org/wiki/Koch_snowflake.
Rules:
The program must generate one side of the Koch snowflake to the nth depth.
Output must be ASCI... | stackexchange_codegolf |
Note
This is the decryption challenge. The encryption challenge can be found here.
Challenge
The challenge is to decrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. If you want to know how the input string has been encrypted, refer t... | stackexchange_codegolf |
The task is simple: given a 32 bit integer, convert it to its floating point value as defined by the IEEE 754 (32-bit) standard.
To put it another way, interpret the integer as the bit-pattern of an IEEE binary32 single-precision float and output the numeric value it represents.
IEEE 754 single precision
Here is a conv... | stackexchange_codegolf |
You have to write a program, if its source code is reversed, then it will error.
For example, if your source is ABC, then reversing it and writing CBA should crash/throw an error. And ABC itself should be a vaild program (I mean your primary source should be a valid program). Output of the main source code can be empty... | stackexchange_codegolf |
Problem
You are given a binary string A of length N.
You can perform the following type of operation on the string A:
Choose two different indices \$i\$ and \$j\$ (\$1 \le i\$, \$j \le N\$)
Change \$A_i\$ and \$A_j\$ to \$Ai \oplus Aj\$. Here \$\oplus\$ represents the bitwise XOR operation.
Input
A binary string con... | stackexchange_codegolf |
Given a positive integer as input, output the smallest positive integer such that appending its digits (in base 10) to the end of the input number will form a prime number.
Examples
1 --> 1
2 --> 3
8 --> 3
9 --> 7
11 --> 3
20 --> 11
43 --> 1
134 --> 11
3492 --> 11
3493 --> ... | stackexchange_codegolf |
It is common to need to make a page selection interface. It typically looks like this:
prev 1 ... 3 4 [5] 6 7 ... 173 next
Which means there are totally 173 pages, and you are on the 5th page currently.
This challenge requires you take the total number of pages and the current page number as input, and output a string... | stackexchange_codegolf |
Your task is to take an input n and output element n of the Rummy Sequence, a sequence which I made (looking on OEIS will not help you).
Definition
Each element of the Rummy Sequence is a set of truthy or falsey values. Ex.: [true, false].
The steps to producing a member of the Rummy Sequence are quite simple:
Start o... | stackexchange_codegolf |
Print the phrase And she said, 'But that's his.' using only the following characters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ No punctuation or non-alphabetic characters whatsoever. You can use whatever programming language you want. Whitespace is completely allowed. Shortest program wins.
| stackexchange_codegolf |
The Challenge
Convert a phrase of two words to reverse style: candy bar -> bar le candy.
Specifications
There will be one word (only a-zA-Z0-9 + -), a space (), and then another word.
For equal length, score is used to determine winner.
Test cases:
candy bar -> bar le candy
code golf -> golf le code
programming puz... | stackexchange_codegolf |
Japanese kana characters correspond to a single sound in the Japanese language. With the exception of ん (n), every other kana consists of a consonant part and a vowel part. There is a natural ordering to Japanese kana, a sort of "alphabetical order", which is typically arranged in a 10 by 5 table:
| a i u ... | stackexchange_codegolf |
Introduction
I began studying the Collatz Conjecture
And noticed these patterns;
0,1,2,2,3,3...A055086, and 0,1,2,0,3,1...A082375,
in the numbers that go to 1 in one odd step,
5,10,20,21,40,42...A062052
Related like so;
A062052()(n) = ( 16*2^A055086(n) - 2^A082375(n) ) /3
The formula for A055086 is $$\lfloor\sqrt{4... | stackexchange_codegolf |
In Applied Cryptography by Bruce Schneier (which I have been reading quite a lot recently), a protocol for splitting secrets is discussed. Here is a brief description:
Trent generates a random byte string, R, the same length as the message, M.
Trent XORS M with R to make S.
He gives R to Alice and S to Bob.
Your ... | stackexchange_codegolf |
There are an abundance of questions involving drawing shapes using asterisks - so I thought, with so many asterisks out there, we should draw one, using the ASCII table.
Challenge
Your task is to write a program or function which takes no input, and outputs this exact text:
!
"#
$%
... | stackexchange_codegolf |
The Len(language,encoding) family of languages is a variety of Lenguage derivatives. To encode a program into a Len language, you replace every character with its representation in a certain encoding, then turn that into a giant integer.
Your challenge is to write a function or program that encodes your language into a... | stackexchange_codegolf |
Introduction
Everyone knows the game tic-tac-toe, but in this challenge, we are going to introduce a little twist. We are only going to use crosses. The first person who places three crosses in a row loses. An interesting fact is that the maximum amount of crosses before someone loses, is equal to 6:
X X -
X - X
- X X
... | stackexchange_codegolf |
The title says it all; Given a number in the binary (base-2) number system, output the same number expressed in unary (base-1).
You should take the binary number as a string (optionally with a separator), list, or equivalent structure of digits, using any number or digit you like for the digits. The unary output can us... | stackexchange_codegolf |
Background
A matryoshka doll (or Russian nesting doll) is a set of dolls that fit inside of each other. I've accidentally mixed up my collection of matryoshka dolls and I don't remember which one goes inside which.
Objective
Given a list of unique strings, sort them into nested matryoshka dolls. Each string is an indiv... | stackexchange_codegolf |
Create a program that can be run in 4 different languages such that:
One language prints "Hello World!"
One language outputs its own source code
One language outputs 99 bottles of beer on the wall, that is:
99 bottles of beer on the wall
99 bottles of beer
Take one down, pass it around
98 bottles of beer on the wall
... | stackexchange_codegolf |
Output the infinite list of pairs of integers (a, b), where both \$ a > 1 \$ and \$ b > 1 \$, ordered by the value of \$ a^b \$. When there are multiple pairs where \$ a^b \$ is equal, they should be ordered lexicographically.
For example, \$ 2^4 = 4^2 = 16 \$, but (2, 4) should come before (4, 2), because it is lexico... | stackexchange_codegolf |
While there are only a few users of the Vitsy programming language right now, I wish to create a place for tips for golfing in Vitsy.
What general tips do you have for golfing in Vitsy? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Vitsy (e.g. "remove ... | stackexchange_codegolf |
Connecting Dots
We define a type of question on the test, connecting the dots
Question parameters
There are two parameters. Suppose they are 5 and 4. The second one must be less than or equal to the first one.
Thus, the question will look like this:
*
*
*
*
*
*
*
*
*
Possible answer... | stackexchange_codegolf |
Here is the code which I want to shorten.
n=input()
while n:
s=raw_input()
x,r,g,b=(int(x) for x in s.split())
a=x/r%2
c=x/g%2
d=x/b%2
r=((a*10+c)*10)+d
if r==0:e="black"
elif r==100:e="red"
elif r==1:e="blue"
elif r==10:e="green"
elif r==101:e="magenta"
elif r==11:e="cyan"
elif r==110:e="yellow"
else:e="... | stackexchange_codegolf |
Challenge:
Here we have the first 100 items of a sequence:
6,5,4,3,2,1,66,65,64,63,62,61,56,55,54,53,52,51,46,45,44,43,42,41,36,35,34,33,32,31,26,25,24,23,22,21,16,15,14,13,12,11,666,665,664,663,662,661,656,655,654,653,652,651,646,645,644,643,642,641,636,635,634,633,632,631,626,625,624,623,622,621,616,615,614,613,612,6... | stackexchange_codegolf |
Challenge
Consider the rainbow as seven colours, represented by strings as Red Orange Yellow Green Blue Indigo Violet.
Your task is to create a program that receives one of these colours as input and outputs next in order rainbow colour. This includes overlapping Violet -> Red
Input
A string containing one of rainbow c... | stackexchange_codegolf |
The program must print the alphabet four times: first in the normal alphabetical order, second in the order of a qwerty keyboard, third in the order of a dvorak keyboard, and lastly in reverse alphabetical order. The output should resemble this:
abcdefghijklmnopqrstuvwxyz
qwertyuiopasdfghjklzxcvbnm
pyfgcrlaoeuidhtnsqjk... | stackexchange_codegolf |
Given two integer matrices a and b, your challenge is to replace any occurences of b in a with a matrix of the same size filled with 0s. For example:
Given:
a: [ [1, 2, 3],
[4, 3, 2],
[3, 5, 4] ]
b: [ [3],
[2] ]
b occurs once in a:
[ [1, 2, 3],
[4, 3, 2],
[3, 5, 4] ]
Fill that area with zeroes:
[ [1,... | stackexchange_codegolf |
(There exists some challenges that require to use the best strategy, but here we don't. Even if you are able to win, you are allowed to make a tie)
Challenge
Write a program which plays the game tic-tac-toe. It must not lose (therefore, it should end the game either with a tie or by winning).
Allowed I/O methods
Input... | stackexchange_codegolf |
In the original Shantae game, there are transformation dances that you have to input in time using the D-Pad, A, and B. If you complete a predefined sequence while dancing, you will transform into the corresponding form (or teleport or heal). Your task is to output the corresponding effect when given an input. The catc... | stackexchange_codegolf |
Your task is to create the given target string. Starting with an string that is empty, you will have to add characters to it, until your string is the same as the one we want. You can either add a character to the end of you string with cost x, or you can clone you string with cost y. What we want is the cheapest way t... | stackexchange_codegolf |
Let's just see how this goes
If you've ever listened to the radio program "I'm sorry, I haven't a clue", then you've probably heard of the game called "Mornington Crescent". For those who haven't, it's a game where players name random stations on the London Underground network. The first person to name "Mornington Cres... | stackexchange_codegolf |
From a challenge in a programming book long ago, PNZ is a game where the user must guess three unique digits in the correct order.
Rules:
A random 3 digit number with no repeating digits is generated. (This is what the user is trying to guess)
The user inputs a guess of 3 digits, which is to be evaluated by the progra... | stackexchange_codegolf |
Introduction
As you all know, German has umlauts. They're these things: ¨
However, most keyboards don't have an umlaut key. That's fine, though, because you can write ö, ä, and ü as oe, ae, and ue.
Challenge
Your job is to to replace ö, ä, and ü with oe, ae, and ue (and likewise for their capital versions).
You have t... | stackexchange_codegolf |
As everyone knows, adding inator-3000 to the end of any noun makes it way cooler. But what else can make a word cooler?
Given an ASCII string as input, output the coolness of the word.
Calculating the coolness
There are 4 elements to calculating the coolness of a word.
The word itself. The base score is the number of ... | stackexchange_codegolf |
Introduction
In many programming languages, within syntax exceptions, it is often pointed out to the programmer exactly which character or line is the culprit. This challenge will be a bit of a modification of that - specifically, using an arrow to point out any specific character of an input string.
The challenge
Your... | stackexchange_codegolf |
In North America, most electrical outlets/receptacles follow standards set by NEMA. For this challenge, you'll be given a few properties of a device you need to plug in, and your program (or function) should return all of the outlets that would be compatible.
For this challenge, an outlet has three properties: voltage,... | stackexchange_codegolf |
Given an array where each number represent a color. After iterating each item in the array (for each item in the iteration the pointer can also point to the second-item-to-the-right), and the two colors in the iteration is the same, do the following checking:
If there is a different color between the pointed colors, th... | stackexchange_codegolf |
In an attempt to “liberate” their fellow birds, a group of highly intelligent hens are
attempting to compromise the zoo’s security system. To get access to the zoo’s mainframe,
the hens first need to guess the administrative password. The hens know that the password
is a string built from up to 62 possible characters: ... | stackexchange_codegolf |
I recently saw this language in a challenge and it's awesome. Does anyone have some tips for code-golfing in it?
Your tips should be at least somewhat specific to MarioLANG.
Please post one tip per answer.
| stackexchange_codegolf |
In a round of the prisoner's dilemma exercise, two players each decide whether to cooperate or defect for that round. The scoring for a round is:
Player A and Player B both cooperate: 1 point for both
Player A and Player B both defect: 2 points for both
Player A cooperates and Player B defects: 3 points for cooperatin... | stackexchange_codegolf |
Background
You may be aware that periods in between letters in gmail addresses are ignored. Email sent to example@gmail.com, exam.ple@gmail.com, and e.x.a.m.p.l.e@gmail.com all end up in the same place!
This is a great way to have multiple different emails addresses for things like signing up for free trails, or filter... | 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 |
SF(n) is a function which computes the smallest prime factor for a given number n.
We'll call T(N) the sum of every SF(n) with 2 <= n <= N.
T(1) = 0 (the sum is over 0 summands)
T(2) = 2 (2 is the first prime)
T(3) = 5 = 2 + 3
T(4) = 7 = 2 + 3 + 2
T(5) = 12 = 2 + 3 + 2 + 5
...
T(10000) = 5786451
The winner will be the ... | stackexchange_codegolf |
The task is the following:
Program the shortest fully functional program that checks, if an 8-bit value contains a consecutive sequence of 2 or more ones in its binary form.
If it does contain such a sequence, the output shall be 0. If not: 1.
Examples:
Input: 1
Output: 1
Input: 3
Output: 0
Input: 72
Output: 1
Input: 7... | stackexchange_codegolf |
Reading the text of the millitext font
There is a font here that fits each character into a single, 1x5 pixel block. It does this (assuming you're using an LCD screen) by using the RGB channels of each pixel to expand the one pixel into three subcolumns, one for each channel. Your task is to take in a string of text en... | stackexchange_codegolf |
Given an input of a Spanish verb in its infinitive form, output the verb
conjugated in all 6 forms of the indicative imperfect.
To conjugate an infinitive in the imperfect, remove the infinitive ending (-ar,
-er, -ir, and sometimes -ír) and add the imperfect endings listed below. There
are three irregular verbs in the ... | stackexchange_codegolf |
Intro
Given a whole number \$< 100,\$ extend/shorten the english representation of the number to have as many characters as it's value.
Sandbox
Rules
Take the number \$n\$, and get it in words from this dictionary. You may take this dictionary in any way you prefer. (a list, read from link, command line arg, STDIN, va... | stackexchange_codegolf |
Introduction
Many old chess books use descriptive notation to notate squares on a chessboard, naming the file (column) of the square based on the starting piece positions of White or Black, depending on whose move it is. The ranks (rows) are numbered 1 through 8, with 1 being closest to the player. For example, from Wh... | stackexchange_codegolf |
Description
The Caesar cipher is a cipher, where every letter in the alphabet will be rotated by a secret number.
If the rotation is \$7\$, then a -> h, g -> n, v -> c and z -> g.
Today, we're playing Caesar's Cipher with ASCII chars, (0-127 inclusive).
So, with rotation \$7\$, b -> i, Z -> a, x -> DEL (127),
But, even... | stackexchange_codegolf |
Although related challenges have been asked, this one is different to warrant its own question.
Challenge
Given a positive integer, return the longest sequence of consecutive positive odd integers whose sum is the given integer. If no such sequence exists, you may report an error in whatever way makes sense for your l... | stackexchange_codegolf |
You will be given a point (x,y) relative to the center of the Ulam spiral (the center being the point which represents one), and length z. The task is to check whether there exists a path from (0,0) to (x,y) of length z, assuming prime numbers are obstacles and each turn in path has an angle of 90 degrees. Path may not... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.