instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Background
It's well known in mathematics that integers can be put into a one-to-one correspondence with pairs of integers.
There are many possible ways of doing this, and in this challenge, you'll implement one of them and its inverse operation.
The task
Your input is a positive integer n > 0.
It is known that there e... | stackexchange_codegolf |
NOTE: This question is currently in the SANDBOX. Please bear this in mind before adding new answers.
I have a large collection of fine art. My toddler is learning to use scissors and glue; lately she has started playing with my art collection. Fortunately she is really quite good with the scissors and cuts things u... | stackexchange_codegolf |
I have recently thought of a wonderful relatively old mobile game, called Tower Bloxx. Alhough I'm not really old myself, but it reminded me of childhood and school :)
So this my challenge is a kind of a reference to that good game!
I have (hopefully) looked into any tower question on PPCG and this won't be a dupe.
... | stackexchange_codegolf |
Goal
Create a program/function that takes an input N, check if N random pairs of integers are relatively prime, and returns sqrt(6 * N / #coprime).
TL;DR
These challenges are simulations of algorithms that only require nature and your brain (and maybe some re-usable resources) to approximate Pi. If you really need Pi d... | stackexchange_codegolf |
\$\left\{ n \atop k \right\}\$ or \$S(n, k)\$ is a way of referring to the Stirling numbers of the second kind, the number of ways to partition a set of \$n\$ items into \$k\$ non-empty subsets. For example, to partition \$\{1,2,3,4\}\$ into \$2\$ non-empty subsets, we have
$$\begin{matrix}
\{\{1\},\{2,3,4\}\} & \{\{2\... | stackexchange_codegolf |
Chaim Goodman-Strauss, Craig Kaplan, Joseph Myers and David Smith found the following simple (both objectively and subjectively) polygon that tiles the plane, but only aperiodically:
Indeed they found a one-parameter family of such aperiodic monotiles or "einsteins". The edges of all tiles in this family meet at 90° o... | stackexchange_codegolf |
Your function must accept two strings and return new string where are UTF-16 code of all symbols is the sum of UTF-16 codes of inputs symbols
If the resulting sum is greater than 65535 (maximum UTF-16 codepoint), take the sum modulo 65536
If there are more symbols in one string then sum with zero, codes of symbols wh... | stackexchange_codegolf |
Your task is to make a histogram given a sample of arbitrary size.
Input
A float array or any other reasonable form of input with an arbitrary number of elements.
Output
The histogram; more to follow.
How to make a histogram
We'll use the sample: [1.1, 3, 5, 13, 15.5, 21, 29.7, 63, 16, 5, 5.1, 5.01, 51, 61, 13]
To ma... | stackexchange_codegolf |
Provided a digit between 0 and 9 (inclusive), your function/subroutine should print all numbers between -100 and 100 (inclusive) that contain the given digit.
For example:
Input: 9
Output: -99 -98 -97 -96 -95 -94 -93 -92 -91 -90 -89 -79 -69 -59 -49 -39 -29 -19 -9 9 19 29 39 49 59 69 79 89 90 91 92 93 94 95 96 97 98 99
... | stackexchange_codegolf |
You are given an array/list/vector of pairs of integers representing cartesian coordinates \$(x, y)\$ of points on a 2D Euclidean plane; all coordinates are between \$−10^4\$ and \$10^4\$, duplicates are allowed. Find the area of the convex hull of those points, rounded to the nearest integer; an exact midpoint should ... | stackexchange_codegolf |
Write a program which will eventually, given enough time, print all possible permutations of ASCII characters (both printable and non-printable) less than or equal to its length, except itself. The text of the program must not appear anywhere in its output.
For example, if your program is abc, then part of your output ... | stackexchange_codegolf |
Python string parsing has quite a few edge cases. This is a string:
"a"
Putting 2 strings immediately after each other implicitly concatenates them, so this is also a string:
"a""a"
However, if you put 3 quotes in a row, it will create a "triple quoted string" which can only be ended by another 3 quotes in a row. A t... | stackexchange_codegolf |
All those busy beavers made quite a mess. They wrote all over the tape. At this rate, our neighbour will stop lending us unbounded tapes.
We need a new way to play the busy beaver game, one that doesn't ruin every tape we use.
The Rules
Brainfuck only. Memory tape is unbounded both ways. Input instruction will always r... | stackexchange_codegolf |
Design a function or program that, when run normally, outputs the triangular numbers. However, when any single character is deleted, the program/function should not function in the original programming language, but instead produce the triangular numbers in one other programming language.
Scoring
Your score will be the... | stackexchange_codegolf |
Given two numbers in tape location #0 and tape location #1 in Brainfuck, compute their product into another tape location (specify with answer). Optimize for the least amount of time-units used, where the interpretation of any command uses one time-unit. As example, here is a quick C++ program to determine the number o... | stackexchange_codegolf |
Introduction:
A typical cartoonish cactus usually looks like this:
One big stem in the middle, with some L-shaped branches sticking out.
We'll use this general shape for this challenge.
Challenge:
Given a pair of words, create an ASCII-art cactus with two upside down alphabets as stem. The first word is the left branc... | stackexchange_codegolf |
In this challenge you will remove one of my least favorite features, operator precedence from traditional math notation, to acheive the syntax of one of my favorite languages, APL. The APL subset we will be working with includes only a few functions and single digit numbers. (No arrays!)
Here is the grammar of the inpu... | stackexchange_codegolf |
A skyline is an array of positive integers where each integer represents how tall a building is. For example, if we had the array [1,3,4,2,5,3,3] this would be the skyline in ascii art:
#
# #
## ###
######
#######
A maximal rectangle is a rectangle that cannot be extended in any direction while being contained... | stackexchange_codegolf |
Power Grid Resource Costs
Introduction
In the board game Power Grid, an integral part of the game is the act of buying resources to fuel your power stations. There are four types of resource used in the game (five, if you include renewable energy, but obviously you can't buy resources for that). These are Coal, Oil, Ga... | stackexchange_codegolf |
In the Pokemon video games, the player is sent out into the world to force wild animals into tiny balls and train them to fight. Of course, everyone knows that no one plays Pokemon for the battling. The real draw the series has is the pokemon catching itself! Your job is to simulate the pokeball during a capture attemp... | stackexchange_codegolf |
The Golden Ratio Bureau is obsessed with this new thing they call base-phi. You see it and decide to code-golf, as is your natural instinct.
To be specific, base-phi is a number system like base 10, except it uses the number phi, or the golden ratio, as its base. A ones digit would be x*10^y, but in base phi 10 is repl... | stackexchange_codegolf |
A simplistic version of English numeral calculator
Task
Write a program that takes a string as input and outputs the result of the expression.
Rules
The input string will be worded and not numeral.
There will be no parentheses.
Order of calculation will be divide,multiply,subtract then add.
For same operations, the cal... | stackexchange_codegolf |
Given two sets of strings, \$ D \$ and \$ R \$, find the shortest string which contains every string in \$ D \$, but contains none of the strings in \$ R \$.
There are almost always multiple possible outputs; you should output at least one of them, but you can output more.
You can assume this is possible with the input... | stackexchange_codegolf |
Task
Given a non-negative number, check if it's odd or even. In case it's even, output that number. Otherwise, throw any exception/error that your language supports, and stop the program.
Example with Python
Input: 1
Output:
Traceback (most recent call last):
File ".code.tio", line 1, in <module>
IfYouWantThenThr... | stackexchange_codegolf |
Your task is to create the shortest program (A) that outputs another program (B) with the most unique bytes, which in turn outputs the original program (A). Essentially, you are golfing one half of a pair of ouroboros programs (a.k.a. periodic iterating quine) and bowling the other half. A and B may be in different lan... | stackexchange_codegolf |
Let's say you have a positive integer N. First, build a regular polygon, that has N vertices, with the distance between neighbouring vertices being 1. Then connect lines from every vertex, to every other vertex. Lastly, calculate the length of all lines summed up together.
Example
Given the input N = 6, build a hexagon... | stackexchange_codegolf |
For the given string s, generate generate a table like below.
Input:abcd
Output:
abcd
bbcd
cccd
dddd
Input:Hello, world!
Output:
Hello, world!
eello, world!
llllo, world!
llllo, world!
ooooo, world!
,,,,,, world!
world!
wwwwwwwworld!
ooooooooorld!
rrrrrrrrrrld!
llllllllllld!
dddddddddddd!
!!!!!!!!!!!!!
Trailin... | stackexchange_codegolf |
The Challenge
Given a list of words and a grid of letters, your job is to determine which of the given words can be found on the grid in all 8 directions (forward, backward, up, down, and the 4 diagonal directions), much like a word search. The grid is toroidal, so the grid wraps around on the edges. Letters can be reu... | stackexchange_codegolf |
Consider a grammar over the alphabet {0, 1, ?, :} defined by the production rule
s → 0 ┃ 1 ┃ 0 ? s : s ┃ 1 ? s : s
Given a string generated from s, parse it as an expression where ?: is right-associative (for example, a?B?X:Y:c?d:e?f:g means a?(B?X:Y):(c?d:(e?f:g))) and evaluate it with the following semantics:
eval(... | stackexchange_codegolf |
Task
Implement a kind of "some users are typing" system, which can be found in Discord and some other chat clients.
If 1 user (say, Bubbler) is typing, output Bubbler is typing...
If 2 users (say, Bubbler and user) are typing, output Bubbler and user are typing...
If 3 or more users are typing (say, Bubbler, randomuse... | stackexchange_codegolf |
Your goal is to write a program that takes no input and outputs the following text:
ca e na ŋa va o sa;
þa ša ra la ła.
ma a pa fa ga ta ča;
în ja i da ða.
ar ħo ên ôn ân uħo;
carþ taŋ neŋ es nem.
elo cenvos.
But there's a catch: for each letter (any character whose general category in Unicode starts with L) in your s... | stackexchange_codegolf |
I know you've always thought about the trials and tribulations of experiencing the joys of life as a web proxy. Honestly, who hasn't? Today you're tasked with realizing this goal (at least a part of it). Website X gets a lot of traffic on the daily and is looking for a PaaS (clearly this refers to Proxy as a Service) b... | stackexchange_codegolf |
A few days ago I made a puzzle about moving people on an airplane. Now I am interested in the general version of this puzzle and the shortest code golf for it.
I will briefly summarise the puzzle here. A small airplane went through some heavy turbulence and all its N passengers ended up sitting in reverse order, ie., p... | stackexchange_codegolf |
This challenge is inspired by a series of young children's books by Fiona Watt and Rachel Wells, which I've recently been enjoying with my daughter.
In each book a mouse (illustrated, but not part of the text) complains that a succession of 5 things of the same type are not its thing. It then backs this up by declarin... | stackexchange_codegolf |
You have to write a program or a function in any language that outputs this pattern:
~|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||~
|~|||||||||||||||||||||||||||||||||||||||||||||||||||||||||~|
||~|||||||||||||||||||||||||||||||||||||||||||||||||||||||~||
|||~|||||||||||||||||||||||||||||||||||||||||||||... | stackexchange_codegolf |
I recently tried to produce the shortest C code possible to display all its command line arguments (which are stored in argv).
I ended with a relatively small piece of code, and I was wondering if there was some trick I'm not aware of.
Here's my try (I compile with C17, but any standard before C23 is very likely to com... | stackexchange_codegolf |
I recently stumbled across this image on wikimedia commons. It's a little bit of an information overload at first, but after examining it a bit it shows an interesting number system for writing nibbles.
Image created by user Watchduck.
First off a "nibble" is a 4 bit number which is really a number ranging from 0 to ... | stackexchange_codegolf |
On a toroidal square grid (you can wrap around) where each cell indicates one direction (^ > v <) if we pick a cell and start to walk following these directions, we will eventually get stuck in a loop.
We may end up in a different loop, depending on our starting cell.
Not all the cells we encounter constitute our term... | stackexchange_codegolf |
Write a program or function that draws a tree of trees, thus constructing a forest.
The trees are drawn like stacking a pyramid. The first (top) row contains 1 tree, the next row down contains 2 (for a total of 3), the next contains 3 (for a total of 6), and so on. If there aren't enough trees to complete a full row, f... | stackexchange_codegolf |
Key Links
Dwarf question
Chat room
Game
Controller Interface
Troll league table
<script src="https://ajfaraday.github.io/Thud/dist/data/tables.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table> <thead> <tr> <th>Client</th> <th>Wins</th><th>Loses</th> <th>Sc... | stackexchange_codegolf |
A well known song by the Irish rock band U2 starts with the singer Bono saying "1, 2, 3, 14" in Spanish ("uno, dos, tres, catorce").
There are various theories as to the significance of those numbers. Apparently the official explanation is "we drank too much that night". But there's a more interesting hypothesis: Bono ... | stackexchange_codegolf |
You are given a string \$s\$ of characters from a to z. Your task is to count how many unique strings of length \$n\$ you can make by concatenating multiple prefixes of the string \$s\$ together.
Since the result can be superlative you can either choose to output the whole result, the result mod \$2^{32}\$ or the resul... | stackexchange_codegolf |
Write a program that determines whether its input is valid JSON.
Input: ASCII text: [\x00-\x7F]*
Note: if ASCII is problematic, feel free to use another encoding, but indicate it in your post.
Output: Valid or Invalid. Trailing newline may be omitted.
Example:
$ echo '{"key": "value"}' | ./json-validate
Valid
$ ... | stackexchange_codegolf |
Background
The fixed-point combinator \$\textsf{fix}\$ is a higher-order function that computes the fixed point of the given function.
$$\textsf{fix}\ f = f\ (\textsf{fix}\ f)$$
In terms of programming, it is used to implement recursion in lambda calculus, where the function body does not normally have access to its ow... | stackexchange_codegolf |
This is the first in a series, the second is Two roads diverged in a yellow wood (part 2)
This challenge is inspired by Robert Frost's famous poem, "The Road Not Taken":
Two roads diverged in a yellow wood,
And sorry I could not travel both
And be one traveler, long I stood
And looked down one as far as I could
... | stackexchange_codegolf |
Here is a simple challenge for you: You must produce this ASCII representation of a chess board. White is represented by uppercase characters, and black is represented by lowercase. Empty tiles are represented by a .. Here is the full board:
rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR
Since... | stackexchange_codegolf |
Implement a function or program which raises x to the power of y. Inputs are 16-bit signed integers. That is, both are in the range [-32768, 32767]. The output should be in the same range. I chose this range because it should make it possible to do exhaustive testing to ensure all edge-cases are covered.
If the output ... | stackexchange_codegolf |
Given a string of parentheses ( and ), find the length of the longest substring that forms a valid pair of parentheses.
Valid pairs of parentheses are defined as the following:
An empty string is a valid pair of parentheses.
If s is a valid pair of parentheses, then (s) is also a valid pair of parentheses.
If s and t a... | stackexchange_codegolf |
SVG is an XML vector graphics markup language embeddable in web content.
Your tips should be at least somewhat specific to SVG.
Please post one tip per answer.
| stackexchange_codegolf |
Amazingly, this is the easier of the three card tricks I know off the top of my head...
The aim of this is to have your compiler perform a specific card trick. There's no slight of hand, and the compiler won't be memorizing the choice and saying "Voila, this is your card!" The code will basically manipulate a stack of ... | stackexchange_codegolf |
Your task is to automatically complete URLs like the address bar in most browsers is doing. We will use the following (simplified) rules:
If the input string starts with http://, ftp:// or https://, return the string unchanged.
Otherwise, if the input string contains a dot ., e.g. in.put then the HTTP is assumed and ... | stackexchange_codegolf |
My boss now wants me to implement a mechanism that lets him search for an item in an array, and gives him the index/indices where that value occurs.
Your Task:
Write a program or function that receives an array and a value (String, Integer, Float, or Boolean), and returns the indices of the array at which the value o... | stackexchange_codegolf |
You are given a \$3\times3\$ square matrix where each cell is any digit between \$0\$ and \$9\$ except \$7\$. Your task is to figure out the minimum number of digits that must be replaced with \$7\$'s so that the sums of the digits in each row and each column are the same.
NB: There is no constraint whatsoever on the d... | stackexchange_codegolf |
This is essentially the inverse of Generate a US License Plate
Challenge: Given a string that matches one of the below license plate formats, output all possible states that match that formatting. In the below table 0 stands for a single digit 0 through 9 inclusive, and A stands for a single letter A through Z inclusiv... | stackexchange_codegolf |
Introduction
Windows 95 used a very simple algorithm for verifying license keys. The scheme of an OEM license key always looked like this:
xxxyy-OEM-NNNNNNN-zzzzz
The day can be anything within 001-366, and the year cannot be lower than 95 or above 03.
xxx represents the day of the year the key was printed on (for exa... | stackexchange_codegolf |
This challenge is pretty simple: Your task is to draw a schematic of a (simplified) memory array. You will be given two (positive) integers n,m and the task is to draw the n:2^n decoder connected to the memory array with d data lines.
The addressing will be in the order of gray codes, to check if the sequence is correc... | stackexchange_codegolf |
The Triforce is a fictional artifact in The Legend of Zelda, made of three identical-looking equilateral triangles representing power, wisdom and courage. Several games in the saga include an animation when the three parts finally join together.
The purpose of this challenge is to draw a single 2D frame of such a simpl... | stackexchange_codegolf |
Let's play some code golf!
Given a tic-tac-toe board state (Example:)
|x|x|o|
|x|o|x|
|o|o|x|
Determine whether a game is a win a lose or cat. Your code should output any of these options given a state. The above game should output lose
Just to be clear: a win is defined as any 3 xs in a row (diagonal, horizontal, ver... | stackexchange_codegolf |
Use any programming language to display numbers divisible by 1000000 that are greater than 1 and less than 10000000. Each number should be displayed in new line. Your program should display exactly:
1000000
2000000
3000000
4000000
5000000
6000000
7000000
8000000
9000000
| stackexchange_codegolf |
This is a two-player card game which resembles a vastly simplified game of Texas Hold'em,
combined with RPS (rock-paper-scissors) and the most basic mechanic of commercial turn-based card games.
The deck
A single full deck consists of 30 unique cards, where each card has one symbol out of RPS and one number between 0 a... | stackexchange_codegolf |
You must use one language to write programs that perform the following nine tasks, in any order you want.
Convert an inputted number from base 10 to base 36.
Sample input: 1000
Sample output: RS (output must be upper case)
Convert each character in a string to its base 10 decimal ASCII codes and print the codes con... | stackexchange_codegolf |
Robber Thread here
The Challenge
Choose any numeric* formula, algorithm, or code challenge. Implement it in such a way that the math is correct, but at least one answer is wildly** wrong due to some defect in how computers/programs operate, e.g. floating point errors, uninitialized/corrupted memory, environment bugs, c... | stackexchange_codegolf |
The goal is simple, print out each day of the twelve days of Christmas, the text should match this exactly
On the first day of Christmas my true love gave to me
A partridge in a pear tree
On the second day of Christmas my true love gave to me
Two turtle doves, and
A partridge in a pear tree
On the third day of Christ... | stackexchange_codegolf |
Brain-Flak is a stack-based esoteric language with eight commands:
() Evaluates to 1
<> Switch active stack; evaluates to 0
[] Evaluates to height of current stack
{} Pop current stack; evaluates to the popped number
(...) Execute block and push the result; evaluates as result
<...> Execute block; eva... | stackexchange_codegolf |
A guess the word game
The agreed dictionary. All words are 6 letters long with all letters distinct
Rules: This is a game of two players and the task will be to implement Player 2.
Player 1 chooses a word from the agreed dictionary
Player 2 repeatedly guesses a word from the agreed dictionary.
At each turn, Player 1 ... | stackexchange_codegolf |
In this challenge you'll be building a program that grows as it traverses through the ages… Until it's 2017.
Challenge
Whenever this challenge description says “program”, you can also read “function”.
Your submission, when executed, will output a program that is THE LENGTH OF YOUR SUBMISSION + 1 bytes long.
When that p... | stackexchange_codegolf |
For the purposes of this challenge a substring \$B\$ of some string \$A\$ is string such that it can be obtained by removing some number of characters (possibly zero) from the front and back of \$A\$. For example \$face\$ is a substring of \$defaced\$
\$
de\color{red}{face}d
\$
This is also called a contiguous substri... | stackexchange_codegolf |
This seems almost trivial, but since after some effort I was not able to beat the literal solution in J, I thought it might make a decent challenge (though, to be clear, this is not a J-specific challenge).
Title says it all. You simply need to write a program, or function (taking no arguments) that returns or prints:... | stackexchange_codegolf |
A CSS selector is made up of five elements:
The element type (tag name)
The id of the element
The classes of the element
The attributes of the element
Operators to chain these element selectors
This challenge will only involve the first four--also taking into account operators would make more than one element be gen... | stackexchange_codegolf |
Introduction
The sign of a number is either a +, or a - for every non-zero integer. Zero itself is signless (+0 is the same as -0). In the following sequence, we are going to alternate between the positive sign, the zero and the negative sign. The sequence starts with 1, so we write 1 with a positive sign, with zero (t... | stackexchange_codegolf |
Magic the gathering has many unique names for colour combinations in decks, as an example when Blue and White appear together in a deck, the deck maye sometimes be named after the Ravnican Guild that features those colours, namely 'Azorius'. There are some exceptions, and oddities though.
Below is a list of colour lett... | stackexchange_codegolf |
An Automorphic number is a number which is a suffix of its square in base 10. This is sequence A003226 in the OEIS.
Your Task:
Write a program or function to determine whether an input is an Automorphic number.
Input:
An integer between 0 and 10^12 (inclusive), that may or may not be an Automorphic number.
Outpu... | stackexchange_codegolf |
Let \$p(x)\$ be a polynomial. We say \$a\$ is a root of multiplicity \$k\$ of \$p(x)\$, if there is another polynomial \$s(x)\$ such that \$p(x)=s(x)(x-a)^k\$ and \$s(a)\ne0\$.
For example, the polynomial \$p(x)=x^3+2x^2-7x+4=(x+4)(x-1)^2\$ has \$1\$ and \$-4\$ as roots. \$1\$ is a root of multiplicity \$2\$. \$-4\$ is... | stackexchange_codegolf |
My preferred way to approximate a derivative is the central difference, its more accurate than forward difference or backward difference, and I'm too lazy to go higher-order. But the central difference requires a data point on either side of point you are evaluating. Normally this means you end up not having a derivati... | stackexchange_codegolf |
There's a minigame in Super Mario 3D World known as the Lucky House. It consists of a slot machine with 4 blocks.
Each block may be one of 5 different icons (Flower, Leaf, Bell, Cherry or Boomerang) and the goal of the player is to get as many identical icons as possible (see a video).
The player is rewarded with coin... | stackexchange_codegolf |
Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that.
This is the robbers thread of a cops-and-robbers challenge. For the cops thread, see here.
Cops will provide a program/function and a flag. Robbers will guess a password. When the password is given to t... | stackexchange_codegolf |
Consider a word/string of length \$n\$, only including the letters A-Z, a-z. A word/string is a double prime word if and only if n is prime and the sum of the letters, s, is also prime, using their numeric position in the alphabet (a=1, B=2, c=3, etc.).
Input can be any combination of upper or lower case alphabetic cha... | stackexchange_codegolf |
You are the captain of a world-famous wrestling team. An Olympic-grade match is coming up, and you are determined not to let your team down. You also happen to be a competent programmer, so you are going to write a program to help your team win!
You have access to the strength ratings for each of your own team wrestler... | stackexchange_codegolf |
Elixir is a programming language with a feature called the pipe operator, |>, similar to the pipe in Bash and other languages. It passes the result of an expression on the left as the first parameter of a given function on the right.
To clarify, here are some examples.
2 |> myFunction()
is equivalent to
myFunction(2)
... | stackexchange_codegolf |
The challenge today is very simple. The task is to determine the TI calculator for which the submitted datafile was made.
The datafiles always start with a string **TI, the version (described below), and other data you can ignore.
Now, the versions you need to recognize are:
95* => TI-95
92P => TI-92+
92* => TI-92
89* ... | stackexchange_codegolf |
Your task is to output a square sandbox of size n+2 with / characters in the corners and | for the sides, and - for the top, with n**2 layers of sand (.) overflowing out of the sandbox of width n+2
Testcases
1
->
/-/
|.|
/./
...
2
->
/--/
|..|
|..|
/../
....
....
....
....
3
->
/---/
|...|
|...|
|...|
/.../
.....
...... | stackexchange_codegolf |
This challenge is about gradually shifting hues in an image to make pretty pictures like this:
(original)
Challenge
Write a program or function that takes in two non-negative integers and an image in any common image file format of your choosing (you can take a path to the image or the raw image data).
We'll call the ... | stackexchange_codegolf |
Given a number n, generate the first n columns of this pattern:
#
# #
# # # #
# # # # # # # #
# # # # # # # # # # # # # # # #
################################ ...
The height of the column at (1-indexed) n is the numb... | stackexchange_codegolf |
Given a positive integer \$n\$ and another positive integer \$b\$ (\$1 < b < 36\$), return the number of digits/length of \$n\$ in base \$b\$
1597 16 -> 3
1709 9 -> 4
190 29 -> 2
873 24 -> 3
1061 27 -> 3
289 26 -> 2
1575 34 -> 3
1135 15 -> 3
1161 22 -> 3
585 23 -> 3
1412 23 -> 3
1268 14 -> 3
714 12 -> 3
700 29 -> 2
100... | stackexchange_codegolf |
Consider:
c=(a,b)=>(+a||0)+(+b||0)
Yes, it is not good to solve it like that. But I want to shorten it even more. If a is a string and b is a string, then return 0. If one is a number, return it (floats and intergers). And if both inputs are numbers, then return the sum (if either string can be cast to a number, treat... | stackexchange_codegolf |
What general tips do you have for golfing in V? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to V (e.g. "remove comments" is not an answer).
Since V is heavily based on vim, most of the tips for golfing vim would apply too. But there are some features in... | stackexchange_codegolf |
Here the first 100 numbers of an easy sequence:
0,1,0,2,1,4,3,7,6,11,10,16,15,22,21,29,28,37,36,46,45,56,55,67,66,79,78,92,91,106,105,121,120,137,136,154,153,172,171,191,190,211,210,232,231,254,253,277,276,301,300,326,325,352,351,379,378,407,406,436,435,466,465,497,496,529,528,562,561,596,595,631,630,667,666,704,703,74... | stackexchange_codegolf |
For this challenge, a word is defined as a string of letters, separated by spaces.
Given a string of words, and an integer i representing an index into that string, output the whole word which contains the character at index i.
For example (using 0-based indexing), with the string code golf, and the index 6, the 7th ch... | stackexchange_codegolf |
The setting
"Well I actually wrote the sql library they, the maintainers actually.."
"Right, but do you have any experience working with django?"
" ...no I don't use frameworks"
After the phone interview is over, you feel like you really need a coffee. While the brew is heating, you check your messages on BusinessBook.... | stackexchange_codegolf |
Introduction
I don't particularly know where the fizz buzz trend came from. It might just be a meme or something, but it is somewhat popular.
Challenge
Your job today is to convert Fizz Buzz into binary (0, 1) respectively, and convert that binary to text. Pretty standard stuff.
How does that work?
FizzBuzzBuzzFizzBuzz... | stackexchange_codegolf |
The famous game of Qwirkle has simple but intricate rules (See part 2 of this question for a summary of the rules!)
The Challenge
You are somehow (text input, function parameter, whatever) given a board of a Qwirkle game, like a snapshot from any current timeframe within a game. This board can be anything from complet... | stackexchange_codegolf |
Given a sorted list of unique positive floats (none of which are integers) such as:
[0.1, 0.2, 1.4, 2.3, 2.4, 2.5, 3.2]
Evenly spread out the values that fall between two consecutive integers. So in this case you would get:
[0.333, 0.666, 1.5, 2.25, 2.5, 2.75, 3.5]
(I have truncated the values 1/3 and 2/3 for ease of... | stackexchange_codegolf |
Given two strings of digits, determine which string, if any, has the earliest digit which is lower than the other string's digit at the same index.
Do note that this differs from alphabetization, as shown in the following examples:
Examples
Given inputs 12345000 and 1233999999, the second string would have the earliest... | stackexchange_codegolf |
from Wikipedia, a number is called B-powersmooth if all prime powers \$p^v\$ that divide the number satisfy \$p^v \leq B\$. B-powersmoothness is important, for example, for Pollard's p-1 factorization algorithm.
Task
your task is to get two numbers, \$n\$ and \$B\$, and output if \$n\$ is \$B\$-powersmooth.
Rules
You ... | stackexchange_codegolf |
While similar to the other water-carrying puzzle, the unique aspects of this challenge make it entirely different.
Beth is located at an oasis in the middle of a desert. There is plenty of water in the lake, but unfortunately there are only X buckets, each of which has a capacity of Y liters of water.
Beth can carry 2... | stackexchange_codegolf |
It's a normal truth machine but instead of taking input, it uses the first character of the program. Thus, internal.
The 0 and 1 are plain characters, i.e. ASCII code 0x30 and 0x31 respectively.
Example: 0abcd prints 0 and halts, and 1abcd prints 1 infinitely. Then your submission is abcd, whose score is 4 bytes. The 0... | stackexchange_codegolf |
Input:
Integer n which is >=0 or >=1 (f(0) is optional)
Output:
The n'th number in the sequence below, OR the sequence up to and including the n'th number.
Sequence:
(0),1,-1,-3,0,5,-1,-7,0,9,-1,-11,0,13,-1,-15,0,17,-1,-19,0,21,-1,-23,0,25,-1,-27,0,29,-1,-31,0,33,-1,-35,0,37,-1,-39,0,41,-1,-43,0,45,-1,-47,0,49,-1,-51,0... | stackexchange_codegolf |
Print this text:
_________
| |
| |
| |
|_________|
Shortest code wins. Notice the space at the start of the first line.
| stackexchange_codegolf |
You should write a program or function that given a list of positive integers multiplies each element with the smallest positive integer possible to create a strictly increasing list.
For example if the input is
5 4 12 1 3
the multiplications will be
5*1=5 4*2=8 12*1=12 1*13=13 3*5=15
and the output will be the incre... | stackexchange_codegolf |
Find the max number of Xs you can fit onto a rectangular tic-tac-toe board of length l and height h without ever having 3 consecutive Xs in a row diagonally, horizontally, or vertically.
This is a code-golf challenge so shortest code wins!
Input
A single line containing values l and h, representing the length and heigh... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.