instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Challenge:
The challenge is to determine whether or not a color, given it's name, is one of the colors in the rainbow.
When supplied with a color, your program should output a truthy value if it is a color in the rainbow, and a falsy one otherwise.
Rules:
The possible input options are exhaustive, and defined in the t... | stackexchange_codegolf |
Basically the tron light-cycle game as a king of the hill competition!
Leaderboard
Updated as of 2022-04-05
#1) Player Avoid by Agent Biscutt
#2) Dodge West by Imanton1
#3) Space Finder by Spitemaster
#4) Blind Bot by TheSilican
Judge/Leaderboard Website
The Game
Players will write bots that compete in a light-cyc... | stackexchange_codegolf |
Background
This challenge is about the Game of Go. Here are some rules and terminology relevant to this challenge:
Game of Go is a two-player game, played over a square board of size 19x19.
One of the players plays Black, and the other plays White. The game is turn-based, and each player makes a single move each turn... | stackexchange_codegolf |
This is the cops' thread of a cops-and-robbers challenge. The robbers' thread can be found here
In this challenge as a cop you will choose two programming languages A and B, as well as a non-empty string S. You are then going to write 4 programs:
A program which outputs exactly S when run in both A and B.
A program w... | stackexchange_codegolf |
As it turns out, Python allows for 1j for to be compressed to 1jfor. However, jfor sounds like xnor. Since all similar-phonic phrases have something in common, there must be some property shared between jfor and xnor.
If we look at the ASCII representation of the first two characters of jfor in binary, we see:
j: 110... | stackexchange_codegolf |
Inspired by this listing from the Commodore 64 User's Guide:
10 PRINT "{CLR/HOME}"
20 POKE 53280,7 : POKE 53281,13
30 X = 1 : Y = 1
40 DX = 1 : DY = 1
50 POKE 1024 + X + 40 * Y, 81
60 FOR T = 1 TO 10 : NEXT
70 POKE 1024 + X + 40 * Y, 32
80 X = X + DX
90 IF X <= 0 OR X >= 39 THEN DX = -DX
100 Y = Y + DY
110 IF Y <= 0 OR... | stackexchange_codegolf |
Not a duplicate of the valid move challenge because that asks for specific pieces.
Backstory
The other night I was doing a little trolling with ChatGPT and chess. I was trying to get it to call me out for making illegal moves, as a lot of the time, you can feed it whatever nonsense you want. While doing so, I wondered ... | stackexchange_codegolf |
Very recently, I changed my SE username because I made this account some years ago and wanted to get back into asking questions. However, I’m still planning to post questions and potentially earn votes. We can imagine a site that has some issues dealing with name changes. The problem: given a list of names, reputation ... | 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 |
Oof! You've been coding the whole day and you even had no time for Stack Exchange!
Now, you just want to rest and answer some questions. You have T minutes of free time. You enter the site and see N new questions. To write an answer for each you'll need ti minutes. Of course, as a dedicated reputation gatherer, you wa... | 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 |
Challenge
Given a 2D array, find the length and direction of all the longest consecutive characters.
If there are ties, output every possible winning combination in any order, (winners can overlap with other winners)
Zero "0" is a special padding character which cannot be a winner.
Code golf rules apply, shortest code... | stackexchange_codegolf |
Given a non-negative integer Excel-style date code, return the corresponding "date" in any reasonable form that clearly shows year, month, and "day".
Trivial, you may think. Did you notice the "scare quotes"? I used those because Excel has some quirks. Excel counts days with number 1 for January 1st, 1900, but as if 19... | stackexchange_codegolf |
Background
Stick Bomber is a two-player game I just made up. Initially, some sticks are placed in one or more groups, and the sticks in each group are laid out in a straight line. So a configuration with three groups of 3, 5, and 8 sticks each may look like the following. For conciseness, we can call it a (3,5,8) confi... | stackexchange_codegolf |
First 15 numbers of the A046173:
1, 99, 9701, 950599, 93149001, 9127651499, 894416697901, 87643708742799, 8588189040096401, 841554882220704499, 82463790268588944501, 8080609891439495856599, 791817305570802005002201, 77590015336047156994359099, 7603029685627050583442189501
Your task is simple, output the first 20 numbe... | 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 |
During work on some project I needed to draw pixels on screen. I found some put-pixel function in JS, but code was quite big and clumsy - so I wonder, how small put-pixel function can be...
Challenge
Create the smallest put-pixel function.
We count size of whole program: initialization code (if needed), function and co... | stackexchange_codegolf |
Description
You are given the results of a range function where every element has been rounded down to the nearest whole number. Your goal is to recover the original list.
For example, the following function (in Python3) will produce an input for your program:
from numpy import arange, floor
def floored_range(A, B, C):... | stackexchange_codegolf |
Problem
A fact you may have noticed about factorials is that as \$n\$ gets larger \$n!\$ will have an increasing number of \$0\$s at the end of it's base \$10\$ representation. In fact this is true for any base.
In this challenge you will be given a base \$b > 1\$ and an integer \$n > 0\$ and you will determine the sm... | stackexchange_codegolf |
In Talos Principle, from time to time player has to solve a puzzle that looks like this:
Source: http://uk.ign.com/wikis/the-talos-principle/File%3A20141108_134749.jpg
This puzzle is already solved - the blue slots on the right are the list of the possible blocks the user could use. They were placed in the grid so tha... | stackexchange_codegolf |
Create a program that does the same thing forwards and backwards, in different languages. “Different languages” does not include different versions of the same language.
Challenge
This program can take any input and write anything to stdout and stderr.
However, the program must output exactly the same things for the sa... | stackexchange_codegolf |
Please note the special scoring for this challenge.
Given a non-empty string made of a-z, output the string immediately before it in the shortlex order.
Shortlex order
We enumerate strings in shortlex order by first listing the strings of length 0, then those of length 1, then length 2, and so on, putting them in alph... | stackexchange_codegolf |
There is a 1x1x1 cube placed on a infinite grid of 1x1 squares. The cube is painted on every side, so it leaves a mark on the grid when it moves.
The sides of the cube are colored 6 distinct colors, re-presentable with any 6 distinct values. A 7th value represents a blank space.
The cube can roll around the grid. Ever... | 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 |
Dialogue by a 3Der.
I was hired by Sr. 4Der to learn the 4D universe and I was willing to get to know more about it. But since I am a 3Der, I wouldn't see him, nor would I know how the real shapes look like. All I can do is illustrate.
Sr. 4Der is pretty much invisible to us. We can't see him, but we can hear his voi... | stackexchange_codegolf |
Write a program which prompts a user to input two integers A and B, the program should determine whether A is greater than or lesser than B without the use of greater than [>] or less than [<] operators (and similar operators or methods like .compare) and should output :
Integer A is greater than B.
Rules : No Bra... | stackexchange_codegolf |
(inspired by a question over on Code Review)
Suppose two people are playing Hangman, but you've only overheard the game and want to draw the current status.
Given two words as input, where the words each match [A-Z]+ or [a-z]+ (your choice), output the current state of the hangman game as ASCII art, following the below... | stackexchange_codegolf |
Given a ragged list of positive integers, where the maximum depth is \$d_\text{max}\$, return the same list, except for every element \$e\$, its depth is \$d_\text{max}+1-d_e\$ (where \$d_e\$ is the depth of that element).
Your output should contain the minimal number of brackets, and you can assume the same from your ... | stackexchange_codegolf |
Recently, I've found a rant from 2004 about Internet Explorer's color parsing. Turns out, MS made sure that just about anything will be parsed as a color somehow and I think it makes for a neat challenge.
Well, how does IE parse colors?
Let's give it an input with a length of...
...less than 4 chars:
Replace chars no... | stackexchange_codegolf |
Given a ASCII string containing control characters, compute what it should look like when printed to a terminal. Imagining the behaviour of a cursor, this is how to treat each character in the input:
0x08 backspace (\b): go left one (if already at the start of a line, do not go up)
0x09 horizontal tab (\t): go right o... | stackexchange_codegolf |
Migrated from chat
Given two non-empty non-negative integer matrices A and B, answer the number of times A occurs as a contiguous, possibly overlapping, submatrix in B.
Examples/Rules
0. There may not be any submatrices
A:
[[3,1],
[1,4]]
B:
[[1,4],
[3,1]]
Answer:
0
1. Submatrices must be contiguous
A:
[[1,4],
[3,1]]... | stackexchange_codegolf |
This is different from Print the Greek alphabet! because it is in words.
This is different from "Hello, World!" because the output is different and much longer, leading to different techniques.
This is different from We're no strangers to code golf, you know the rules, and so do I because the output is different and mu... | stackexchange_codegolf |
Challenge: Add two numbers. In O(n^m) time, where n and m are the two numbers given. Sleeping, or your language equivalent, is not allowed.
Input: Two integers, separated by a space.
Output: The sum of the two integers.
Additional notes: The exact timing doesn't matter, as long as the input 1000 2 takes roughly 1/1000t... | stackexchange_codegolf |
Robber's thread
Your task as cops is to select three things:
A programming language
An OEIS sequence
A byte set
You are then to secretly write a program in that language that computes the nth term sequence using only the bytes in the set. You will reveal the three pieces of information so that robbers can try to f... | stackexchange_codegolf |
Your task is to write a program that outputs its own source code in reverse. However, when the reversed code is run, it should output the source code, facing the correct direction.
Example
Say your program is abc. When run, it should output cba. cba, when run, should output abc.
Rules
Your program should follow all the... | 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 goal is to print (to the standard output) the largest number possible, using just ten characters of code.
You may use any features of your language, except built-in exponentiation functions.
Similarly, you may not use scientific notation to enter a number. (Thus, no 9e+99.)
The program must print the number wit... | stackexchange_codegolf |
What is the shortest regular expression equivilant to the following?
ENERO|GENER|GENNAIO|IANUARI|IANUARII|IONAWR|JAANUARIL|JANAIRU|JANAR|JANNEWARIS|JANUAR|JANUARI|JANUARIE|JANUARO|JANUARY|JANUWALE|JANVIER|JANVYE|JENUWARI
The shortest regex, in bytes, wins.
If you are worried about what flavor of regex we are using, th... | stackexchange_codegolf |
A Latin Square is a square of size n × n containing numbers 1 to n inclusive. Each number occurs once in each row and column.
An example of a 3 × 3 Latin Square is:
[[1, 2, 3],
[3, 1, 2],
[2, 3, 1]]
Another is:
[[3, 1, 2],
[2, 3, 1],
[1, 2, 3]]
Given an integer input n where n > 0, determine how many Latin Square... | stackexchange_codegolf |
Introduction
I would like to drawn a nice spinner by using eight braille patterns on two lines, drawing a square of 8x8 pixel, for showing a kind of snake growing and reducing:
declare -a shapes=([0]=$'\E[A⠁⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [1]=$'\E[A⠈⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [2]=$'\E[A⠀⠁⠀⠀\E[B\E[4D⠀⠀⠀⠀' [3]=$'\E[A⠀⠈⠀⠀\E[B\E[4D⠀⠀⠀⠀' [4]=$'\E... | stackexchange_codegolf |
Can the Tune be Played?
Explanation
A broken musical keyboard has keys labelled with positive integers. It is broken in two ways:
It takes a long time to process key presses: after pressing the key labelled with the number \$n\$, there is a gap of \$n\$ seconds before the \$n\$th note is heard.
So, for example, the \$... | stackexchange_codegolf |
Background
This is loosely based on the now closed Kaomoji question asked a few hours ago.
Kaomojis are sequences of characters designed to express a given emotion. In this code-challenge, you'll be writing a program that takes a Kaomoji as input, and must output the emotion expressed by the Kaomoji.
Input
A Kaomoji. I... | stackexchange_codegolf |
\$723 = 3 \times 241\$ is a semi-prime (the product of two primes) whose prime factors include all digits from \$1\$ to \$n\$, where \$n\$ is the total number of digits between them. Another way to look at this is that the (sorted) digits in the factorisation of \$723\$ are all consecutive. The first 10 such semi-prime... | stackexchange_codegolf |
Goal:
The goal of this challenge is to take a simple 6 row by 6 column XML file (without the standard XML header) and parse it out so that the program can return the value of a cell given it's coordinates.
The entry with the shortest overall length by language and overall will be declared the winner.
Additional informa... | stackexchange_codegolf |
All credits to Adnan for coming up with this challenge.
My last challenge, before I go on break.
Task
Given positive integer n, if n is odd, repeat / that many times; if n is even, repeat \ that many times.
(Seriously, the testcases would be much clearer than this description, so just look at the testcases.)
Specs
Any... | stackexchange_codegolf |
Have you been shooting gallery? We are recently.
In our shooting gallery cans and aluminum cans from under various drinks hang and stand. More precisely, they hung and stood.
From our shots, banks dangled from side to side on a rope, were torn off, rang, crumpled. This is not for you to shoot from your fingers.
Each ... | stackexchange_codegolf |
I'm posting my code for a LeetCode problem copied here. If you have time and would like to golf for a short solution, please do so.
Requirement
It has to only pass the LeetCode's Online Judge, if the language would be available.
If the language is not available, simply we should possibly keep the class Solution as we... | stackexchange_codegolf |
Drunk Uncle (sorry M.E. and AUS for region lock) is a fictional character from Saturday Night Live. He often confuses words for others that sound like them. For this challenge you need to convert normal speech into drunkspeak.
Algorithm
Translating to drunkspeak requires swapping the order of words in the text. Swappin... | stackexchange_codegolf |
Sometimes, while golfing, one needs to represent large number(s) in their code. Writing them as is can significantly increase the byte-count.
What general1 tips do you have for representing long numbers concisely in code?
Please post one tip per answer.
1With general, I mean tips that can be applied to more than a sin... | stackexchange_codegolf |
This question is a sequel to this one, working in the opposite direction.
For a reminder of terminology, the letters L, R, U, and D represent one-unit movement of a robot on the coordinate plane in the directions left, right, up, and down respectively. Given a positive even integer n, generate and print all sequences ... | stackexchange_codegolf |
Atomic chess is a (very fun)
variant of chess in which every capture causes an "explosion," destroying the
captured piece, the piece doing the capturing, and all non-pawns in a 1-square
radius. The goal of this challenge is not to play an entire game of atomic
chess, but simply to simulate what happens when a certain m... | stackexchange_codegolf |
The challenge is relatively simple, but will hopefully lead to some wonderfully creative answers. The task is to take a string as an input (via command line, function parameter etc.) and output/return a stringsploded version of it.
A stringsploded version of a string is its first letter followed by its first 2 letters,... | stackexchange_codegolf |
The goal of this challenge is to complete a list of consecutive nested header numbers when given a start and an end. When given 1.1.1 and 1.1.5 you should generate 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5
Specific Rules
Your entry must take in a start, end, and multiple optional range parameters. Parameters can be taken fo... | stackexchange_codegolf |
The task here is to read from a Golly .rle or plaintext file (your choice) whose filename is provided (on STDIN or as a command line argument) and identify and count the common patterns in the grid encoded therein.
Alternatively, you may choose to have the contents of the file provided directly over STDIN instead.
Your... | stackexchange_codegolf |
This is a challenge I thought of recently which I think is not hard but allows for a wide range of possible solutions. Seems like a perfect fit for the creativity of PPCG users :)
Your Task
Define two functions which together form a lossless round-trip String × String → String → String × String.
More specifically, defi... | stackexchange_codegolf |
Someone gave my wife a decorative calendar consisting of four cubes. Here it is showing today's date (as of the posting of this challenge) on the front:
When I first saw it, I looked at it from the wrong angle (from directly above) and couldn't figure out why it gave this information:
[["February", "January"], [3], [7... | stackexchange_codegolf |
Camel Up Cup 2k18
In this challenge, we will be playing the semi-popular board game Camel Up.
Camel Up! is a board game that has players betting on camels to win rounds, win the game or lose the game, set traps to influence movement or move a camel. Each of these decisions rewards you with the chance of getting some mo... | stackexchange_codegolf |
The Rockstar programming language has "poetic number literals", allowing you to assign nonnegative, finite (at least one Rockstar interpreter supports infinity) numbers to variables without typing a single digit: just type words with length equal to each digit, modulo 10. For example,
This is a challenge
sets the vari... | stackexchange_codegolf |
A fixed-point combinator is a higher order function \$\mathrm{fix}\$ that returns the fixed point of its argument function. If the function \$f\$ has one or more fixed points, then $$\mathrm{fix} f=f(\mathrm{fix} f).$$
The combinator \$Y\$ has such properties. Encoded in lambda calculus: $$Y=\lambda f.(\lambda x.f(x x)... | stackexchange_codegolf |
While at work I spotted a nice and simple challenge.
The job was to stock products in cargo units with a certain capability.
Since an order can have various batches, coming in sequence from the production, we usually make a list of the pieces of those batches distributed in each cargo to make sure nothing is lost durin... | stackexchange_codegolf |
Cyclically self-describing lists
A list \$L\$ of positive integers is cyclically self-describing, if the following conditions hold.
\$L\$ is nonempty.
The first and last elements of \$L\$ are different.
If you split \$L\$ into runs of equal elements, the element of each run equals the length of the next run, and the e... | stackexchange_codegolf |
There has been a question about yes in the past, but this one is slightly different. You see, despite yes having a rather long size, it is incredibly fast. Running the following command:
timeout 1s yes > out
yields a file that is 1.9 GB. Compared to this program:
int puts();main(){while(1){puts("y");}}
which yields a... | stackexchange_codegolf |
Introduction
Formula One is a complex sport and as with complex sports, strategy is very important.Some teams will manage better strategy than others and those teams will often win the races.
After last weekends' amazing German GP, which saw last years Champion Lewis Hamilton pit 6 times (in comparison, some races just... | stackexchange_codegolf |
Write the shortest program that prints the sound my alarm clock makes, and stops after an inputted number of beeps.
For reference, here is the sound my alarm makes:
beep beep beep beep beep beepbeep beepbeep beepbeep beepbeep beepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeep beepbeepbeepbeep bee... | stackexchange_codegolf |
Requirement: Write a program (in any language) that counts the number of lines of code in files matching *.sh in the directory tree starting from the directory that the program is executed in, excluding lines that are empty, only contain whitespace, or are just single-line comments (a line which the first character tha... | stackexchange_codegolf |
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 |
She said s(he) be(lie)ve(d), he said sbeve.
Input
A non-empty string, s. It's guaranteed that s will have only printable ASCII characters and at least one word (defined as [A-Za-z0-9]+) in parentheses, and all parentheses will be closed respectively.
Output
A string containing all non-whitespace characters (whitespa... | stackexchange_codegolf |
So simple: Provide some code that outputs foo and with the reversed source outputs bar. But before you come up with something like this boring python 2:
print "foo"#"rab" tnirp
you should know the score: You multiply the number of bytes with (1 + dead bytes), where dead bytes are bytes that can be changed to most othe... | stackexchange_codegolf |
You have been chosen to make a program that creates some pretty ASCII bar charts. Here is the input format:
[List of words (they can have spaces)] [an integer >= 0]
Bar 3
This is so cool 4
IDK-Why 6
The input will have multiple lines in this format, each one representing one bar in the graph. The output format of a gr... | stackexchange_codegolf |
Generate the nth Narayana-Zidek-Capell number given an input n. Fewest bytes win.
f(1)=1, f(n) is the sum of the previous floor(n/2) Narayana-Zidek-Capell terms.
Test Cases:
f(1)=1
f(9)=42
f(14)=1308
f(15)=2605
f(23)=664299
| stackexchange_codegolf |
As of 13/03/2018 16:45 UTC, the winner is answer #345, by Khuldraeseth na'Barya. This means the contest is officially over, but feel free to continue posting answers, just so long as they follow the rules.
As well, just a quick shout out to the top three answerers in terms of numbers of answers:
1. NieDzejkob - 41 ans... | stackexchange_codegolf |
Write a formula using only the digits 0-9, +, *, -, /, % and ^ to output a 1000 distinct primes when given input (which can be used as a variable n in the formula) of numbers 1 to 1000. (Note that / will give the quotient as all arithmetic is integer arithmetic.) Solutions can use ( and ) freely and they will not be co... | stackexchange_codegolf |
Rules (not too restrictive; flexible):
1.Must be able to draw shapes on command (e.g., I type in "square" and a square is drawn).
Minimum completed shapes that can be drawn on command: Square, Circle, Triangle, Pentagon.
2.Must also be able to also draw shapes vertex-by-vertex, specified by a command function that give... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
You successfully route the laser into the sensor, but nothing happens.
"What?" Frustrated, you flip the note from Santa. There's some more text:
Calculate the number of ways to complete the laser puzzle, and enter it into the number p... | stackexchange_codegolf |
You have to take a base-10 number (e.g. 735) and another number for the base to convert to, and convert the base-10 number into the equivalent number in the other base.
Rules:
You aren't allowed to use any conversion functions built into your language
This is code-golf, the shortest answer in bytes wins!
| stackexchange_codegolf |
A celebration of the many faces of APL
Given a string among those in column 1 or column 2 of the below table, return the string's neighbor to its right. In other words, if given a string in column 1 then return column 2's string on that row, and if given a string in column 2 then return column 3's string on that row.
T... | stackexchange_codegolf |
Introduction
You are sitting with your coworker, having lunch, and bragging to him/her about the latest and supposedly greatest project you've been working on. Getting sick and tired of your constant showcase of egoism, he/she gives you a challenge just so you'll shut up. Being the egoistic and happy-go-lucky person yo... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Oh no, Santa spilled wine all over his great book. Now most of the letters are illegible. How will Santa now know who is groovy and who is unspeakable?
Challenge
There was once a sequence of words, like this:
groovy groovy groovy unspe... | stackexchange_codegolf |
The MU puzzle is a puzzle in which you find out whether you can turn MI into MU given the following operations:
If your string ends in I, you may add a U to the end. (e.g. MI -> MIU)
If your string begins with M, you may append a copy of the part after M to the string.
(e.g. MII -> MIIII)
If your string contains three... | stackexchange_codegolf |
The WannaCrypt ransomware has struck and it is attacking networks right, left and center. A network is defined by an m*n binary matrix (a), which has a a[i][j] = 1 if a computer is infected and a[i][j] = 0 if it is not. At the end of each hour, all computers that are a neighbour (which shares a side or a corner with) ... | stackexchange_codegolf |
Your task is to write a program, function, or snippet that will output one value if run forward, and another if run backward. The program must run without errors.
The output can be any two distinct values, of the same data type. For example, 1 and 3, true and false, or 't' and 'f'. In languages without a concept of dat... | stackexchange_codegolf |
The Dutch system for naming one's ancestors is a lot more interesting than the English version. For English, the sequence goes "parent", "grandparent", "great-grandparent", "great-great-grandparent", "great-great-great-grandparent"; and in Dutch those terms are "ouder", "grootouder", "overgrootouder", "betovergrootoude... | stackexchange_codegolf |
Given a list of N lists, each containing M positive integers, and a separate list of M positive integers (target values), return a list of N scalars (integers with a value of 0 or more) that correspond to each list in the lists of lists, such that when each value in a list is multiplied by it's scalar, and the values a... | stackexchange_codegolf |
You will create a program that generates the stereographic projection of polyhedra.
In particular, to keep things simple, we'll only focus on n-chamfered dodecahedron.
Given a natural number n as input, and also a natural number d your program will output an d pixels by d pixels image which is the stereographic project... | stackexchange_codegolf |
Uptime is a very important metric, as we all know, so we'd like to measure the uptime since our service was first launched. The SLA specifies an uptime of a certain number of nines, such as 3 nines for at least 99.9% uptime, or 1 nine for at least 90% uptime, and you're wondering if you've actually met the SLA or not. ... | stackexchange_codegolf |
Given a positive integer \$n\$ output the integers \$a\$ and \$b\$ (forming reduced fraction \$a/b\$) such that:
$$\frac a b = \prod ^n _{k=1} \frac {p^2_k - 1} {p^2_k + 1}$$
Where \$p_k\$ is the \$k\$ th prime number (with \$p_1 = 2\$).
Examples:
1 -> 3, 5
2 -> 12, 25
3 -> 144, 325
4 -> 3456, 8125
5 -> 41472... | stackexchange_codegolf |
Your goal is to map a piece of text to a sine curve of the form:
a sin ( mx - b )
Where a and m are non-zero rational numbers, b is a rational number, and the calculations are in radians.
It doesn't really matter where the origin of your graph is, as long as you fit all the letters in your output. Also, it must be ASCI... | stackexchange_codegolf |
Most tip calculator apps simply take a flat percentage of the meal price. So, for example, if your meal is $23.45, you can leave a 15% tip = $3.52, or a more generous 20% tip = $4.69.
Convenient enough for credit card users. But not so if you prefer to leave cash tips, in which case these oddball cent amounts get in ... | stackexchange_codegolf |
If we take a positive integer \$n\$ and write out its factors. Someone can determine \$n\$ just from this list alone. In fact it is trivial to do this since the number is its own largest factor.
However if we take \$n\$ and write only the first half of its factors (factors that are smaller than or equal to \$\sqrt{n}... | stackexchange_codegolf |
The cardinality of the set \$\mathbb Q\$ of rational numbers is known to be exactly the same as that of the set \$\mathbb Z\$ of integers. This means that it is possible to construct a bijection between these sets—a mapping such that each integer corresponds to exactly one rational number, and vice versa.
Provide such ... | stackexchange_codegolf |
Remember the kids game, 'Duck, Duck, Goose'? No? Me neither.
The challenge
Print the word 'duck' on individual lines an indeterminate amount of times.
Print the word 'goose'.
Your program ends.
The rules
Attempt to play the game in the fewest bytes.
There must be at least one duck.
There must be exactly one goose, a... | stackexchange_codegolf |
Given an \$n\times m\$ matrix \$A\$ and two integers \$w,h\$, output a matrix of \$w\times h\$ called \$B\$, such that $$B_{i,j} = \int_{i-1}^i\mathbb dx\int_{j-1}^j A_{\left\lceil \frac xw\cdot n\right\rceil,\left\lceil \frac yh\cdot m\right\rceil}\mathbb dy\text{ (1-index),}$$ $$B_{i,j} = \int_i^{i+1}\mathbb dx\int_j... | stackexchange_codegolf |
Befunge is a 2-dimensional programming language, with an instruction pointer (IP).
In Befunge-98, the ; character tells the IP to skip characters up until the next ; (Let us call it skipping mode when the IP is skipping characters). Here is an example:
"This part is read into the stack" ; this part is not ; @
I would ... | stackexchange_codegolf |
Write a program or function that prints or returns a string of the alphanumeric characters plus underscore, in any order. To be precise, the following characters need to be output, and no more:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_
When printing to stdout, an optional trailing newline after y... | stackexchange_codegolf |
Inspired by the fact that a few related challenges to this could be answered by Vyxal in 0 Bytes using a special flag combination.
Given only one input integer \$n\$, calculate \$f(n,n)\$ where
$$ f(x,y)=
\begin{cases}
x & \text{if } y=0 \\
f(\left(\sum_{k=1}^xk\right),\text{ }y-1) & \text{otherwise}
\end{cases}
$$
If ... | stackexchange_codegolf |
Input: A single word as a string (matches [a-zA-Z]+). If the input doesn't follow these guidelines, print "Error" (but no error should be thrown)
Output: The NATO pronunciation of the word. Print out a space separated list of the NATO word that matches each letter of the input word. Trailing white space is accepta... | stackexchange_codegolf |
Generate the nth Narayana-Zidek-Capell number given an input n. Fewest bytes win.
f(1)=1, f(n) is the sum of the previous floor(n/2) Narayana-Zidek-Capell terms.
Test Cases:
f(1)=1
f(9)=42
f(14)=1308
f(15)=2605
f(23)=664299
| stackexchange_codegolf |
⢣⠃⢎⠆⣇⡇⡯⡂⠈⡏⢰⢵⢐⡭⢸⠪⡀⢸⢐⡭⠀⢹⠁⢎⠆⢸⣱⢸⡃⢎⠰⡱⢸⣱⢸⡃⠈⡏⢸⡃⡱⡁⢹⠁⢸⡀⡇⡗⢅⢸⡃⠈⡏⢸⢼⢸⢐⡭⠀
⣇⢸⡃⢹⠁⢹⠁⣟⢸⢕⢐⡭⠀⡮⡆⡯⡂⣟⠀⡯⠰⡱⢸⣸⢸⢕⠀⣏⡆⢎⠆⢹⠁⣪⠅⢸⢼⢸⠰⣩⢸⢼⠀⡮⡆⡗⢼⢸⣱⠀⢎⠆⡯⠀⢇⠇⡮⡆⡯⡂⡇⡮⡆⣟⡆⣇⢸⡃⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀
⢎⠆⡗⢼⢸⡃⢸⡃⡗⠔⡇⡯⠂⢹⠁⢣⠃⠸⡸⢸⡃⡯⡂⢹⠁⡇⢎⢰⢵⢸⡀⢸⡀⡇⡗⢼⢸⡃⢐⡭⢸⡃⡯⠂⡮⡆⡯⡂⡮⡆⢹⠁⣟⢐⡭⠀⢎⢸⢼⢰⢵⢸⢕⢰⢵⠰⡁⢹⠁⣟⢸⢕⢐⡭⠀
⡮⡆⢐⡭⢸⠕⢰⢵⠰⡁⣟⠀⡇⣪⠅⢈⣝⢸⡃⡯⡂⢎⠆⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀
⣪⠅⢎⠆⢸⠈⡏⠀⣇⠰⡱⠰⡱⢸⠪⡀⣪⠅⢸⡀⡇⡗⢅⢸⡃⠸⡰⡸⠰⡱⢸⢕⢸⣱⢐⡭⠀⡮⡆⡯⡂⣟⠀⣪⠅⣟⢸⠕⢰⢵⢸⢕⢰⢵⠈⡏⢸⡃⣏⡆⢸⣳⠘⡜⠀... | stackexchange_codegolf |
This is a tips question for golfing in Python, which is on topic for main.
I'm looking for the shortest way to get all of the most common elements of a list in Python, in the shortest way possible. Here's what I've tried, assuming the list is in a variable called l:
from statistics import*
mode(l)
This throws an error... | stackexchange_codegolf |
I remember this was exam question long long long time ago.
There is a file say MyFile.txt, it can be any size and contains aphanumeric only
your task is to revese the words
example : "Go beyond the traditional laptop with Surface Laptop. It's backed by the best of Microsoft, including Windows and Office"
It should be "... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.