instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Introduction
In the strange world of integer numbers, divisors are like assets and
they use to call "rich" the numbers having more divisors than their reversal, while they call "poor" the ones having less divisors than their reversal.
For example, the number \$2401\$ has five divisors : \$1,7,49,343,2401\$, while its r... | stackexchange_codegolf |
Let's have a ragged list containing no values, only more lists. For example:
[[[],[[]],[],[]],[],[[],[],[]],[]]
And the list will be finite, meaning that eventually every path terminates in an empty list [].
It's simple enough to determine if two of these are structurally equal. Check each element in order for equali... | stackexchange_codegolf |
You are to write a program that takes a list of strings as input. For every string in the list you are to determine the smallest N such that no other string in the list begins with the same N characters as the string in question. Now compose a new list with all these strings. Here is an example, on the left we have ... | stackexchange_codegolf |
"Baby Shark" is a children's song about a family of sharks. Having long been popular as a campfire song, it has been popularized since the mid-2000s by social media, online video and radio. - Wikipedia
Write program that takes no input, and writes the following text to the standard output or an arbitrary file:
Baby S... | stackexchange_codegolf |
Write the shortest possible program to remove all partial matched duplicates from a list and only retain the longest lines. Sort order does not matter.
For following inputs, the intent is to search for the string reminder followed by a number and retain the longest unique reminder + number lines.
Some rules
reminder i... | stackexchange_codegolf |
Sometimes I feel like the conversation is going down the wrong path and take it upon myself to steer it in another direction. And this conversation is going wrong real fast, so I need to change the subject in as few characters as possible.1
Task
Given a list of sentences, return the sentences ordered such that each sen... | stackexchange_codegolf |
Given a nonempty list of nonnegative integers, consider rewriting it as an arithmetic problem where:
A plus sign (+) is inserted between pairs of numbers that increase from left to right (a.k.a. from the start of the list to the end).
A minus sign (-) is inserted between pairs of numbers that decrease from left to rig... | stackexchange_codegolf |
The narcissist is a program which, given its own source as input, prints a truthy value and, given anything other than that, prints a falsey value. Today, we're reversing this.
Create a program that, given the name of whatever your language's truthy value is (True, true, 1), prints its own source. Given the name of wha... | stackexchange_codegolf |
Challenge
Design a compression algorithm specialized for compressing ASCII mazes. You will need to create both a compression algorithm and a decompression algorithm. Your score will be based on the size of your compressed mazes.
Mazes
These mazes are made primarily of the characters (floors), +, -, |, and # (walls), a... | stackexchange_codegolf |
Two-dimensional programming languages often have mirror commands like / and \ to redirect the instruction pointer on the grid:
>>>>\
v
v
<<<</
In this challenge, you're given an incoming direction and a mirror and you need to determine the outgoing direction.
Rules
The incoming direction will be given as one o... | stackexchange_codegolf |
Task
Given a UTF-8 string (by any means) answer (by any means) an equivalent list where every element is the number of bytes used to encode the corresponding input character.
Examples
! → 1
Ciao → 1 1 1 1
tʃaʊ → 1 2 1 2
Adám → 1 1 2 1
ĉaŭ → 2 1 2 (single characters)
ĉaŭ → 1 2 1 1 2 (uses combining overlays)
チャオ → 3 3... | stackexchange_codegolf |
Background
Challenge is inspired by this question.
The 1-expression is a formula that in which you add and multiply the number 1 any number of times. Parenthesis is allowed, but concatenating 1's (e.g. 11) is not allowed.
Here is an example to get the 1-expression for \$19\$:
(1+1)*(1+1)*(1+1+1+1)+1+1+1 = 19
Total num... | stackexchange_codegolf |
A lazy physicist has the job to perform the double slit experiment. However, they are lazy and can't be bothered to set up all the equipment themselves and so are going to simulate the effects. They can't program though so are going to need some help. As they are lazy your program should be as short as possible.
Given... | 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 |
You've been hired by a bomb defusing company to perform some "controlled" demolition of un-exploded ordnance. You are given a list of bombs represented by non-negative integers.
[3,2,4,0,3,1,2]
Every step you can set up and explode a bomb. When a bomb \$n\$ explodes, it destroys all bombs within \$n\$ places replacin... | stackexchange_codegolf |
+-= is a language created by Esolangs user Anonymous in 2017.The language consists of only three commands:
+ increases the accumulator by one.
- decreases the accumulator by one.
= outputs the accumulator and a newline.
Rules
This is code-golf, all usual golfing rules apply.
Standard rules apply.
You may assume inpu... | stackexchange_codegolf |
You are providing tech support to the Bruce Dickenson as he produces a Blue Öyster Cult recording session. When he asks for more cowbell, you can give it to him.
Your task
Write a program or function that takes a string (or equivalent in your language) as input, and outputs a related string containing one more cowbell.... | stackexchange_codegolf |
Given the battery level L in the range 0-5, your code should draw the following ASCII art.
When L=0:
############
# ###
# ###
# ###
############
When L=1:
############
### ###
### ###
### ###
############
When L=2:
############
##### ###
##### ###
##### #... | stackexchange_codegolf |
Problem
I've got a GREAT new program that will change the way we think about math in computing, taking in strings of algebraic functions and doing AMAZING things with them! The only problem, is that I am only able to parse specific algebra, otherwise the universe folds into itself, which is bad. Fortunately, I only nee... | stackexchange_codegolf |
To find the digital hardness of an integer, take its binary representation, and count the number of times both a leading and trailing 1 can be removed until it either start or ends with a 0. The total number of bits removed is its digital hardness.
That's quite a wordy explanation - so let's break it down with a wor... | stackexchange_codegolf |
Construct a program or function that takes input in form of
<width>, <height>, <color1>, <color2>
and generates an output such that first row alternates between pixels of color <color1> and <color2> with a period of <height>. For each row that follows, the period shall be <height> - <row number>. Note that <color1> a... | stackexchange_codegolf |
Write a function that accepts a rectangular grid of ids in any reasonable format, for example a multi-line string:
IIILOO
ILLLOO
and a string or list of box drawing charcters such as:
' ═║╔╗╚╝╠╣╦╩╬'
or
[0x20, 0x2550, 0x2551, 0x2554, 0x2557, 0x255a, 0x255d, 0x2560, 0x2563, 0x2566, 0x2569, 0x256c']
(see below for more... | stackexchange_codegolf |
This is an ascii-art challenge where you will draw ascii-art showing a person "jumping" off the top of a building.
The building
Input given will be a group of rectangular buildings. You may assume buildings are not "stacked on top of each other", hence only one row of buildings. This is the standard format of a buildi... | stackexchange_codegolf |
From the infinite triangular array of positive integers, suppose we repeatedly select all numbers at Euclidean distance of \$\sqrt{3}\$, starting from 1:
$$
\underline{1} \\
\;2\; \quad \;3\; \\
\;4\; \quad \;\underline{5}\; \quad \;6\; \\
\;\underline{7}\; \quad \;8\; \quad \;9\; \quad \underline{10} \\
11 \quad 12 \q... | stackexchange_codegolf |
Problem
Starting from n=2 dice:
Roll n dice, with each number 1 to 6 equally likely on each die.
Check if their sum equals the most probable sum for n dice, that is 3.5*n.
If they're equal, terminate.
Otherwise, print n, and repeat from the start with n+2 dice
Your code doesn't have to do this procedure exactly... | stackexchange_codegolf |
In the video game Minecraft, the player can obtain experience points (XP) from various activities. In the game, these are provided as XP "orbs" of various sizes, each of which give the player various amounts of XP. The possible orbs are shown in the image below, along with the smallest and largest amount of XP that orb... | stackexchange_codegolf |
Greeklish, a portmanteau of the words Greek and English, is a way of writing modern Greek using only ASCII characters. This informal way of writing was extensively used in older applications / web forums that did not support Unicode, and were not programmed to show Greek characters. Nowadays, its use is minimized due t... | 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 |
Calculate the area of a polygon.
Inspired by this shoelace algorithm video.
Task
Your job is to create a program or function that calculates the area of a polygon. Program or function is defined according the the default definition in meta.
Input
You will receive the X and Y coordinates of each vertex of the polygon. Y... | stackexchange_codegolf |
Inspired by this, print an ascii diamond pattern built using 0-9.
Rules
Input n should be between 0-9, anything outside that range is undefined
The diamond should be padded with spaces
The middle line should always have no padding and be the only line to contain n, in the center
Print to stdout
As always, this is code... | 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 |
Let's solve the same task as in this challenge but faster!
Input: a non-empty string containing letters a-z
Output: the length of a longest (contiguous) substring in which all letters are different
Time and space complexity: O(n).
The number of letters in the alphabet is 26, or O(1). Make sure you understand how your l... | stackexchange_codegolf |
My father who was a really good APLer and taught me all the basics of APL (and much more), passed away on this day, five years ago. In preparation for 50 Years of APL, I found this patent letter (translated for the convenience of those who do not read Danish) for a handwritten logo. It explains a major reason for APL n... | stackexchange_codegolf |
Let's make an ASCII art clock and calendar that tells us the current month, day of the month, day of the week, hour, minute, and whether it's night or day (but not the year or second).
At any particular time the calendar will look something like this: (it looks better with less line spacing)
__________________________... | stackexchange_codegolf |
Given the spiral of size S and the step N, output the "square" S*S spiral having N asterisks, built from the outer to inner radius clockwise.
Test cases (examples) below.
Input: 4 3
Output:
***
Input: 4 6
Output:
****
*
*
Input: 4 11
Output:
****
*
* *
****
Input: 6 18
Output:
******
*
*
* *
... | stackexchange_codegolf |
As I'm applying for some jobs whose job advert doesn't state the salary, I imagined a particularly evil interviewer that would give the candidate the possibility to decide their own salary ...by "golfing" it!
So it goes simply like that:
Without using numbers, write a code that outputs the annual salary you'd like to ... | stackexchange_codegolf |
For this challenge, the objective is to take a list of integers, and output the sum of every unique integer in that list, i.e. count multiples of the same integer only once.
Your input will be a string in the format "{1,2,3,4}" with any amount of elements. The string will never have whitespace or be in a format that do... | stackexchange_codegolf |
Task
The prepend,append-Sequence is defined recursively, like this
a(1) = 1
a(n) = a(n-1).n , if n is even
a(n) = n.a(n-1) , if n is odd
where the . represents an integer concatenation.
So the first few terms are: 1,12,312,3124,53124,531246,7531246,... This is A053064.
Your task is, given an integer a > 0 to return... | stackexchange_codegolf |
How do I remove all duplicates from list and order it based on count?
s = ["foo", "this", "lem", "foo", "lem"]
s = ["foo", "ebh", "wosv", "wosv", "ebh", "4whcu"]
#should return
>>> ["foo", "lem", "this"]
>>> ["ebh", "wosv", "foo", "4whcu"]
Rules:
Must be shorter than the below code in terms of byte size.
Order must b... | stackexchange_codegolf |
Yesterday, as part of a IQ-style test, I got this interesting question:
The time on a 24-hour clock is 11:43. What is the least number of minutes I should wait before the same digits are on the screen again (in any valid 24-hour time order)?
The answer's 91 minutes, if you were wondering!
This stuck in my mind, and ... | stackexchange_codegolf |
Given a matrix of integers \$M\$ and a list of four integers \$L\$, find the sub-matrix \$N\$ whose corners are given by \$L\$ and return the sum of its elements.
Suppose you're given the list \$L = [-8, -3, 2, 9]\$ and the following matrix \$M\$. The numbers in the list are highlighted in blue to illustrate:
$$
\begi... | stackexchange_codegolf |
Odd prime numbers are either in the form of 4k+1 or 4k+3 where k is a non-negative integer. If we divide the set of odd prime numbers into two such groups like this:
4k+3 | 3 7 11 19 23 31 43 47 59 67 71
|
4k+1 | 5 13 17 29 37 41 ... | stackexchange_codegolf |
In the Bitcoin protocol, 2016 is a very special number. The "difficulty" of finding a hash to create a new block is adjusted every 2,016 blocks to approximate changing once every two weeks.
This number was chosen is because the difficulty adjusts itself so that every block takes about 10 minutes to be found, and in two... | stackexchange_codegolf |
In any programming language, make a program that outputs infinite subsequent powers of two, starting at any power of two with finite integer exponent. There does not need to be a seperator between outputs.
Note: it only has to theoretically output infinite subequent powers of two given infinite integer size (so you can... | stackexchange_codegolf |
Task
Given an integer, n, where 3 <= n < 2^32, calculate the area of a regular n-gon, with an apothem of 1, using the formula A = n * tan(π / n).
The apothem of a regular polygon is a line segment from the center to the midpoint of one of its sides.
Output the area of this regular polygon as a floating point value sh... | stackexchange_codegolf |
Given an input of a note, output an ASCII drawing of the corresponding major
key on the treble clef.
Here are all the major keys (that don't include double-sharps or double-flats)
and their corresponding key signatures:
Circle of fifths deluxe 4 by Wikipedia user Just plain Bill, copyright CC BY-SA 3.0
If the input is... | stackexchange_codegolf |
Given a description of the base state of a recursive ASCII pattern, output an expanded state somewhere along the recursion steps.
More specifically: Let the following be an example:
##..
##..
..__
..__
Where # is filled, . is empty, and _ is recursive.
This describes a pattern wherein the top left quarter is filled, t... | stackexchange_codegolf |
This challenge is from a game, Keep Talking And Nobody Explodes.
It's hard to say how this mechanism works. The engineering is pretty impressive, but there must have been an easier way to manage nine wires. — from the manual
Input
Exactly 9 "wires", each which is labeled 'A', 'B', or 'C', and is colored red, blue, or b... | stackexchange_codegolf |
Your challenge is to read a "password" from the keyboard / standard input.
Challenge:
Read a string s invisibly.
For each of the characters in s, print a character c.
In realtime.
Rules:
You must print c in realtime. As soon as the user enters a character you must display c.
c must be constant, i.e. it must be the s... | stackexchange_codegolf |
This is a problem that the Hacker Cup team made for the 2018 Facebook Hacker Cup, but we ended up not using it (though Ethan struggles through a variety of other challenges). Normally code size isn't a factor in the Hacker Cup, but we thought this would make for an interesting code golf challenge. We look forward to se... | stackexchange_codegolf |
in my country we have a children's song which goes like this:
Priletela muha na zid, muha na zid, muha na zid.
Priletela muha na zid,
muha na zid.
Pralatala maha na zad, maha na zad, maha na zad.
Pralatala maha na zad,
maha na zad.
Preletele mehe ne zed, mehe ne zed, mehe ne zed.
Preletele mehe ne zed,
mehe ne zed.
... | stackexchange_codegolf |
Inspired by Greg Martin's "Shiny cryptarithm" puzzle.
A cryptarithm is a game consisting of a mathematical equation among unknown numbers, whose digits are represented by letters of the alphabet. The goal is to identify the value of each letter. They are usually represented by an addition operation, such as SEND + MORE... | stackexchange_codegolf |
FizzBuzz is so simple, bet you can do it backwards. In this challenge, you will be given the length of the FizzBuzz string and must give the positive integer that produced that string.
Description
To break this down, a FizzBuzz string for n is generated by the following algorithm.
Start with an empty string and, for e... | stackexchange_codegolf |
Inspired by a recent Daily WTF article...
Write a program or function that takes a GUID (string in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX, where each X represents a hexadecimal digit), and outputs the GUID incremented by one.
Examples
>>> increment_guid('7f128bd4-b0ba-4597-8f35-3a2f2756dfbb')
'7f128bd4-b0ba-45... | stackexchange_codegolf |
Definitions
An algebraic number is a number that is a zero of a non-zero polynomial with integer coefficients. For example, the square root of 2 is algebraic, because it is a zero of x^2 - 2.
The corresponding polynomial is called the minimal polynomial of the algebraic number, provided that the polynomial is irreduci... | stackexchange_codegolf |
A snakified string looks like this:
T AnE eOf ifi ing
h s x l A k e r
isI amp Sna dSt
Your Task
Take a string s and a size n, then output the snakified string. The inputs ThisIsAnExampleOfaSnakifiedString and 3 would produce the example above.
Specifications
s will only contain ASCII characters between code points 33... | stackexchange_codegolf |
Find the shortest function/algorithm to translate these numbers to the ones after the dash:
0 - 0
1 - 10
2 - 20
3 - 30
4 - 40
5 - 50
6 - 60
7 - 70
8 - 80
9 - 90
10 - 100
11 - 115
12 - 130
13 - 150
14 - 175
15 - 200
16 - 230
17 - 260
18 - 300
19 - 350
20 - 400
Every integer higher than 20 is calculated by subtracting 1... | stackexchange_codegolf |
This is a short one:
Only once in American history has there been a decade in which four of the years were prime numbers.
Your program has to output the decade after 1776 where four its years were primes. This is code golf so the shortest code wins.
The output must be like so:
1710s
or
1980s
Note: The answer must b... | stackexchange_codegolf |
Challenge:
Given a 2D array (8x8) of characters, is the enemy king in check?
The program should return true if and only if the king is currently in check.
Standard chess rules apply.
Specifications:
The game is provided using a 2D array,
where blank space means there is not a piece on that square.
You may assume that t... | stackexchange_codegolf |
This is a king of the hill challenge for Dots and Boxes (aka Pen the Pig). The game is simple, on your turn just draw a line on an empty fence. Every time you complete a square you get a point. Also, since we are playing by championship rules, if you complete at least one square on your turn you get an extra turn. This... | stackexchange_codegolf |
Task
Make code given on the command line that takes an unpacked hex value as input and evals that in Perl. Like this:
perl -e 'map{eval}pack q/h*/,q/072796e6470222458656275672370202d6f62756020222b302072796e6470222478616e60202f6e6560202771697020247f6020246f602029647e2c5e622/'
But with one additional restriction: Your c... | stackexchange_codegolf |
The Zen of Python must surely be one of the most beautiful Easter eggs in any language. (It is created by writing import this)
So why not create a version for your own language?
For those who don't have access to Python 2 or 3, your code should output the following:
The Zen of [YOUR LANGUAGE]
Beautiful is better than ... | stackexchange_codegolf |
Based on this game.
Description :
Based on Wikipedia's description.
The 24 Game is an arithmetical card game in which the objective is to find a way to manipulate four integers so that the end result is 24.
For example, for the card with the numbers 4, 7, 8, 8, a possible solution is :
\begin{equation}
( 7 − ( 8 ÷ 8 ) ... | stackexchange_codegolf |
Introduction
Yes, it's as simple as that. Download any file from the internet!
Rules
You must use your language's API.
You must output the file you downloaded to STDOUT, the console, a file, etc.
Input should be empty, or the URL you wish to download, but the url must count to byte count..
Good luck!
| stackexchange_codegolf |
Given a list of positive integers as input you are to determine if there is a way to pair up the elements such that:
All but one element is in a pair
No element is in more than one pair
Every pair is of equal elements
No two pairs have elements separated by the same distance in the original list
For example if the in... | stackexchange_codegolf |
Given a set of substrings, such as [ca, ar, car, rd], it's possible to create infinitely many strings by concatting them together. Some examples of this for the given substrings could be:
ca
caar
card
rdca
carrd
rdrd
...
One interesting property of this set of substrings is that any string can only be constructed in o... | stackexchange_codegolf |
Reversible computation refers to computation in which little or no information is deleted. Reversible computation a major component of quantum computation, and reversible computation is potentially many times more energy efficient than conventional computation. I want to know how easy it is to compute the conjugacy of ... | stackexchange_codegolf |
Make a program that takes the word you input, and adds that word to the back of itself minus its first letter, then repeats until all letters are gone. For example, cat would become catatt, and hello would become helloellolloloo.
Input
Any of the 26 letters of the English alphabet. There may be multiple words separat... | stackexchange_codegolf |
The aim of this challenge is to write a program that satisfies the following conditions:
The program is not palindromic, or essentially palindromic (meaning that it is possible to remove characters to make it a palindrome without changing the effects of the program).
The program is not an involution (meaning that it d... | stackexchange_codegolf |
I got the spontaneous idea of making a series of challenges of users that have helped and continue to help the PPCG community be an enjoyable place for everyone, or maybe just specifically for me. :P
If you convert Dennis's name to an array of 1s and 0s where each consonant is 1 and each vowel is 0, the array is [1, 0,... | stackexchange_codegolf |
Why don't you grow up?
In the past week a meme involving the young actor Aaron Bailey became trending in most Brazilian social networks. Entitled "why don't you grow up" it consists in repeating a sentence replacing its vowels with is (it's a bit more complicated than that, I'll explain below). As I want to be a cool g... | stackexchange_codegolf |
While implementing polynomial multiplication in Itr I found the following interesting operation on strings
To compute the convolution of two strings (for instance Hello and World) first combine all pairs of letters with indices that add up to the same number
(ordered by the index of the first element)
0 -> "HW"
1 -> "... | stackexchange_codegolf |
This is the robbers' challenge. To post a cop, go here.
In this challenge, cops will invent a (likely simple) programming language, and write an interpreter, transpiler, or compiler that allows you to run it. Robbers will write a program in this language that manages to inject arbitrary code into the interpreter, trans... | stackexchange_codegolf |
Challenge
Given two positive integers \$1 \le m \le 12\$ and \$1\le d \le 31\$, representing a month and days into the month, output the amount of days that have passed since January 1st, on a non-leap year. You can assume that the number of days passed will always be constrained by the number of days in the month (so ... | stackexchange_codegolf |
I'm surprised this hasn't been done yet, but here we go.
Create a program which prints some number of 1s (ideally as large as possible) before halting.
The rules are simple:
Your program is bounded to 50 bytes in size.
Your output must only be a continuous row of 1s (plus trailing newline if it has to be added), withou... | stackexchange_codegolf |
Description
I guess everyone knows the fairy tale of Rapunzel and the prince. For those who do not: read it here. However, Rapunzel had just had her hair cut, so it might not be long enough to let her prince climb up! She may get very sad..
Challenge
Your task is to write a function that evaluates what Rapunzel will be... | stackexchange_codegolf |
Hex triplets such as #ffffff (white) or #3764ef (blueish) are often used to denote RGB colors. They consist of # followed by six hexadecimal digits (0-f), or sometimes three digits where the real color is obtained by doubling each digit. For example, #fff is #ffffff and #1a8 is #11aa88.
Sadly, that three digit shorthan... | 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 |
Originally sandboxed by @xnor
Left-or-right is a very simple language @xnor made up. Its expressions are made of arrows < (left), > (right), and parentheses. The goal is to evaluate an expression to either < or >.
An expression A<B picks the left item A, while A>B picks the right one B. Think of < and > as arrows point... | stackexchange_codegolf |
Input: a whole positive number greater than 4
Output: A whole positive number that describes the highest possible period an oscillator could have inside a square space of size (input)x(input) in a "life" grid that follows the rules of Conway's Game of Life. The oscillator never leaves this area throughout its cycles. I... | stackexchange_codegolf |
You may be aware of the famous old rhyme, "I before E, except after C". It is a rule taught to aid in the spelling of certain English words.
Quoting Wikipedia:
If one is not sure whether a word is spelled with the digraph ei or ie, the rhyme suggests that the correct order is ie unless the preceding letter is c, in wh... | stackexchange_codegolf |
A Pythagorean triple consists of three positive integers a, b, and c, such that a2 + b2 = c2. Such a triple is commonly written (a, b, c), and a well-known example is (3, 4, 5). If (a, b, c) is a Pythagorean triple, then so is (ka, kb, kc) for any positive integer k. A primitive Pythagorean triple is one in which a, b... | stackexchange_codegolf |
This is the cop's thread of a cops-and-robbers challenge. You can view the robber's thread here
A pretty common beginner style question is to print some string, but there's a catch! You need to do it without using any of the characters in the string itself!
For this challenge, we will find out who is the best at printi... | stackexchange_codegolf |
We don't have a challenge for conversion between Cartesian and polar coordinates, so ...
The challenge
Write two programs (or functions) in the same language:
one that converts from polar to Cartesian coordinates, and
the other from Cartesian to polar coodrinates.
The score is the sum of the two program lengths in by... | stackexchange_codegolf |
You may know the game The Six Degrees of Kevin Bacon, based on the conjecture that every actor in Hollywood can be connected to Kevin Bacon by no more than 6 "co-star" relations, so Kevin Bacon is supposedly the "best-connected" node in that graph. Your task will be to find the Kevin Bacon of a graph.
We will use posit... | stackexchange_codegolf |
Given a positive integer as input, output that integer, but with its bits rotated two times to the right. Also, think of the number as a donut of bits, eg. 21 -> (10101). If all of the bits suddenly decided to move to the right, they would wrap around. eg. rRot(21) -> (11010) = 26. Do what i explained 2 times (at the s... | stackexchange_codegolf |
Telephones in the United States (and perhaps some other places) have letters associated with some of the numbers.
2 = A, B, C
3 = D, E, F
4 = G, H, I
5 = J, K, L
6 = M, N, O
7 = P, Q, R, S
8 = T, U, V
9 = W, X, Y, Z
No letters are associated with the number 0 or 1.
Your challenge: Given any phone number in seven-digit... | stackexchange_codegolf |
Powers
We define an important power as a number that can be represented as \$ x^y \$ where \$ x ≥ 2 \$ and \$ y ≥ 2 \$.
Palindrome
We define an important palindrome as a number that is the same written forwards and backward, and is greater than 10. Thus, the last digit must not be 0.
Palindromic Power
We define a Palin... | stackexchange_codegolf |
Help! My Completely Automated Lights From Darks Separator V3001.01 broke! :(
Guidelines
Task
Write a program that will take an input of an array (or a list in some languages) of any amount of strings that are either the letter L or the letter D (representing lights or darks) and output an array that contains two arra... | stackexchange_codegolf |
Given a large number (in base 10), such as 1234567891011121314151617, find prime "subnumbers" in it.
A prime "subnumber" is a consecutive sequence of digits (taken from the input), which represents a prime number (in base 10).
Input:
A number (either a string, a file, or whatever you like).
Output:
All prime subnumb... | stackexchange_codegolf |
We'll define the ASCII Odd/Even Cipher via the below pseudocode:
Define 'neighbor' as the characters adjacent to the current letter in the string
If the one of the neighbors is out of bounds of the string, treat it as \0 or null
Take an input string
For each letter in the string, do
If the 0-based index of the cur... | stackexchange_codegolf |
Satisfying Rounding
You know when you're in science class, and asked to round to 2 sig figs, but your answer is 5.2501...? You should round to 5.3, but that's just so unsatisfying! By rounding to 5.3, you're off by a whole 0.05, which is a large amount compared to 0.1 (the place value you're rounding to)! So help me ro... | stackexchange_codegolf |
Note: There are some rude words in this question.
There's an implicit puzzle posed in this classic Monty Python sketch (you can also ready the script online).
Various phrases are described as being 'woody' or 'tinny', and one is described as being 'PVC'.
Given a phrase, respond with its type according to the following... | stackexchange_codegolf |
It's 2050, and people have decided to write numbers in a new way. They want less to memorize, and number to be able to be written quicker.
For every place value(ones, tens, hundreds, etc.) the number is written with the number in that place, a hyphen, and the place value name. "zero" and it's place value does not need ... | stackexchange_codegolf |
Given a decimal in the form of <float>, <precision>, you draw the graphical representation of the decimal part (i.e. fraction) of the float. Examples:
Input: 6.75, 4, output:
6||| 7
----
6.75 (first number from the input) is the number to explain, 4 (the second number from the input) is the number of dashes below t... | stackexchange_codegolf |
We're going rootin' tootin' cow-poke shootin!
This is a simple contest, first program to draw their pistol wins.
How it works:
I require 2 things from you, an executable, and a command to be run
from a bash terminal.
The executable needs to do one thing: wait
until it receives 'draw!' from STDIN, and then print 'bang!... | stackexchange_codegolf |
The Challenge
Given an integer input, return the first Fibonacci number that contains the input within itself along with the index of that Fibonacci number (indexes starting at 0 or 1 - up to you, but please mention which in your answer). For example, if given the input of 12, the program would return 26: 121393 as 12 ... | stackexchange_codegolf |
Task:
Given sample index, x, calculate sample value f(x) of triangular wave, with period of 4 samples and amplitude 1. Offset can be negative and sample value could be either {0, 1, -1}.
Test cases:
-5 -> -1
-4 -> 0
-3 -> 1
-2 -> 0
-1 -> -1
0 -> 0
1 -> 1
2 -> 0
3 -> -1
4 -> 0
5 ->... | stackexchange_codegolf |
Klein is a 2D language I have designed that can be embedded on 12 different topological surfaces. A Klein program can be run on different surfaces by changing the command line arguments.
The topology determines where the instruction pointer goes when it goes off the edge of the program. When moving off of the edge th... | stackexchange_codegolf |
Given a non-negative integer skyline height list, answer how many uninterrupted 1-unit-high horizontal brush strokes are needed to cover it.
[1,3,2,1,2,1,5,3,3,4,2], visualised as:
5
5 4
3 5334
32 2 53342
13212153342
needs nine brush strokes:
1
2 3
4 5555
66 7 88888
9999... | stackexchange_codegolf |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 28