instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
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 |
Input
4 integers w, x, y, z from the range -999 to 999 inclusive where none of the values is 0.
Output
4 integers a, b, c, d so that aw + bx + cy + dz == 0 where none of the values is 0.
Restrictions
Your output should be the solution with the smallest sum of absolute values possible. That is the smallest value of \$|... | stackexchange_codegolf |
Given a directed graph on the nodes 0, 1, ..n, where each edge has two non-negative integer costs, return the set of all possible Pareto Optimal path costs between node 0 and node n.
These are the costs of paths for which you cannot decrease the first component of the cost without increasing the second component, and c... | stackexchange_codegolf |
The zombie apocalypse has come, and the world is coming to an end. Suddenly, someone discovers a formula that takes the current hour, minute, and day, and spits out the perfect note to play on a piano that instantly kills every zombie that hears it. Unfortunately, there is only one piano player left in the world, and h... | stackexchange_codegolf |
My dog ate my calendar, and now my days are all mixed up. I tried putting it back together, but I keep mixing up the days of the week! I need some help putting my calendar back together, with the days in the correct order.
And since I need my calendar put together as fast as possible, don't waste my time by sending me ... | stackexchange_codegolf |
You will be given two Arrays / Lists / Vectors of non-negative integers A and B. Your task is to output the highest integer N that appears in both A and B, and is also unique in both A and B.
You may assume that there is at least one such number.
Any reasonable Input and Output method / format is allowed.
These Looph... | stackexchange_codegolf |
A digit word is a word where, after possibly removing some letters, you are left with one of the single digits:
ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT or NINE (not ZERO).
For example, BOUNCE and ANNOUNCE are digit words, since they contain the digit one.
ENCODE is not a digit word, even though it contains an O,... | stackexchange_codegolf |
Given an image that has only black and white pixels and an (x,y) location that's a white pixel, color the white pixels based on their minimal Manhattan distance from (x,y) in a path that only involves traversing other white pixels.
The hue of the colored pixels must be proportional to their distance from (x,y), so the ... | stackexchange_codegolf |
The knight is a chess piece that, when placed on the o-marked square, can move to any of the x-marked squares (as long as they are inside the board):
.x.x.
x...x
..o..
x...x
.x.x.
Eight knights, numbered from 1 to 8, have been placed on a 3×3 board, leaving one single square empty ..
They can neither attack each other... | stackexchange_codegolf |
Given a rectangular grid of text, line up the diagonals that go from the upper-left to the bottom-right into columns such that the lowest-rightmost characters of all diagonals are on a level. Use spaces for indentation.
For example, if the input grid of text is
abcd
1234
WXYZ
then you'd line up the diagonals W, 1X, a2... | stackexchange_codegolf |
Background
This challenge is based on a personal project I did, UnitDC. This challenge is a super-miniaturized version of UnitDC.
Challenge
Please write a simple unit-aware calculator that evaluates a sequence of positive integers, units and operators in RPN (postfix) notation, while checking whether the units are comp... | stackexchange_codegolf |
I got the following question at a test:
Write a function f with the following type a -> b -> (a -> b). a and b should not be bound in any sense, the shorter the code, the better.
I came up with f a b = \x -> snd ([a,x],b). Can you find something tinier?
Currently the winner is: f _=(.f).const
| stackexchange_codegolf |
Challenge
Given a number width, number height, hours and minutes print the time using the following format style:
------ - ------ ------ - - ------ ------ ------ ------ ------
| | | | | | | | | | | | | |
| | | ------ ------ ------ ------ ------ | ... | stackexchange_codegolf |
You are playing a famous game called \$1\text{D Array BattleGround}\$. In the game, the player can be stationed in any position from \$0\$ to \$10^5\$.
You are a Paratrooper in the game and have the ability to do two types of operation \$-\$
Advance, which would multiply your position by \$2\$
Fall-back, which would d... | stackexchange_codegolf |
The challenge is to write a deterministic program (any language/OS) which takes no arguments or other input and behaves differently in a debugger from how it behaves when not being debugged.
For example, the program may output something when being debugged but not output anything when not being debugged. Or output some... | stackexchange_codegolf |
I've been developing some programs involving me fetching a vector from a url using Alpha-2 country codes (such as GET /jp.svg for Japan). Except, oh no! All the country data on my computer uses Alpha-3! That just won't do...The task is simple: Take an Alpha-3 country code (e.g. UKR) and return its Alpha-2 equivalent (... | stackexchange_codegolf |
Story
My local pizza delivery introduced new discount. You get 50% discount from every second item on your order.
But being greedy capitalists, they forgot to mention that they will rearrange items the way they need to give you as little as possible.
Example
Imagine you ordered
- Pizza $20
- Pizza $20
- Coke $2
- Coke ... | stackexchange_codegolf |
Remove every pair of newline characters, that means every two newline characters appearing together are elided, whereas unaccompanied newline characters remain present.
Example:
echo -ne 'a\n\nb\nc\n\n\n\nd\n\n\n' | your-command
should output the same as
echo -ne 'ab\ncd\n'
Watch out, some POSIX tools have implementa... | stackexchange_codegolf |
Introduction
Every letter in the English alphabet can be represented as an ASCII code. For example, a is 97, and S is 83. As we all know, the formula for averaging two numbers \$x\$ and \$y\$ is \$\frac{x+y}{2}\$. I'm pretty sure you can see where this is going. Your challenge is to average two letters.
Challenge
Yo... | stackexchange_codegolf |
Your mission is to build an algorithm (program or function) that can optimize packing fruit from a conveyor belt into bags to be sent off to retailers, optimizing for a largest number of bags.
Each bag has to weight at least a certain amount, but any excess is lost profit since that weight could be used to fill another... | stackexchange_codegolf |
Your task is to build a program (using only printable ASCII characters and/or tabs and newlines) that prints out exactly the characters in the printable ASCII space (0x20 to 0x7e) that don't appear in your program's source code (in any order, however many times you want).
The shortest code to do this in any language wi... | stackexchange_codegolf |
The partition function:
In number theory, the partition function p(n) represents the number of possible partitions of a positive integer n into positive integers
For instance, p(4) = 5 because the integer 4 has five possible partitions:
1 + 1 + 1 + 1
1 + 1 + 2
1 + 3
2 + 2
4
Your task:
Accept an input (let's call i... | stackexchange_codegolf |
Inspired by this and this which was inspired by the first question.
I've set my farmers' fields on fire, but unfortunately they saw me do it! If I don't deal with this situation they could report me and then I'd get arrested! So, that shouldn't be too hard. All I have to do is kill them with fire!
The field will be an ... | stackexchange_codegolf |
Introduction
Briscola is one of Italy's most popular card games. It is a trick-taking card game, like Bridge. Briscola is well known for its bizarre point system. In this challenge, given two cards, you will output whether the first one scores more, less, or the same number of points as the second in Briscola's point s... | stackexchange_codegolf |
In crossword terminology, the grid is the region into which the crossword answers are inserted, consisting of white and black squares. The crossword answers, called entries, are inserted into contiguous sequences of white squares in a row or column, separated by black squares.
For straight (American) crosswords, the g... | 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 |
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 |
Challenge
Write the shortest program that, when compiled or executed, produces a fatal error message smaller than the program itself. The error message may not be generated by the program itself, such as Python's raise. A valid answer must include both the code and the error message. Shortest valid answer wins.
No erro... | stackexchange_codegolf |
This problem is an extension of what happens to me on a regular basis: I have to have $1.00 in coins and have to be able to give change to somebody. I discovered rather quickly that the ideal coins to have were 3 quarters, 1 dime, 2 nickels, and 5 pennies. This is the smallest number of coins (11 total) that allows me ... | stackexchange_codegolf |
Given an initial \$n\$-tuple \$t_0=(t_{0,1},...,t_{0,n})\$, we can obtain its corresponding Ducci sequence \$\{t_0, t_1, ...\}\$ by the recurrence \$\displaystyle t_{i+1}=\left(\left|t_{i,1}-t_{i,2}\right|,\left|t_{i,2}-t_{i,3}\right|,...\left|t_{i,n}-t_{i,1}\right|\right)\$.
That is, to obtain the next term of the seq... | stackexchange_codegolf |
Your task is to print this exact text:
z
yz
xyz
wxyz
vwxyz
uvwxyz
tuvwxyz
stuvwxyz
rstuvwxyz
qrstuvwxyz
pqrstuvwxyz
opqrstuvwxyz
nopqrstuvwxyz
mnopqrstuvwxyz
lmnopqrstuvwxyz
klmnopqrst... | stackexchange_codegolf |
The brilliant engineers at <enter company you love to hate> have struck again. This time they've "revolutionised" the generation of random permutations. "Every great invention is simple" they say and their magical new algorithm is as follows:
Start with a list 1,2,3,...,n of numbers to permute.
For each element x in t... | stackexchange_codegolf |
Given an array of integers, find "the next to the middle".
The next to the middle is the smallest integer greater than the smallest among mean, median and mode of the given numbers, that is neither the mean, median or mode and is also contained in the array.
For example, in the following array
[ 7, 5, 2, 8, 0, 2, 9, ... | stackexchange_codegolf |
Inspired by this question over on Math.
Let the prime factorization of a number, n, be represented as: \$P(n) = 2^a\times3^b\times5^c\times\cdots\$. Then the number of divisors of n can be represented as \$D(n) = (a+1)\times(b+1)\times(c+1)\times\cdots\$. Thus, we can easily say that the number of divisors of \$2n\$ is... | stackexchange_codegolf |
The Challenge
Implement the Sundaram sieve for finding prime numbers below n. Take an input integer, n, and output the prime numbers below n. You can assume that n will always be less than or equal to one million.
Sieve
Start with a list of the integers from 1 to n.
Remove all numbers that are in the form i + j + 2ij... | stackexchange_codegolf |
Consider the following probability puzzle.
We start with a string of bits all set to 0. At each step we choose a bit uniformly and independently at random and flip it. The value your code has to compute is the probability of getting to the all 1s bit string before you get back to the all 0s bit string.
Let \$n\$ be the... | stackexchange_codegolf |
The idea for this code golf puzzle is from link: The Bridge and Torch Problem
The inspiration for this code golf puzzle is the Bridge and Torch
problem, in which d people at the start of a bridge must all cross it
in the least amount of time.
The catch is that at most two people can cross at once, otherwise the
... | stackexchange_codegolf |
Challenge
You have been assigned a task to write a program which takes a multigraph as its input and if it contains an Eularian circuit to return one. Otherwise, the program's behavior is undefined, according to the specifications you're handed by your boss.
However, you recently caught your new coworker Steven several... | stackexchange_codegolf |
The turtle wants to move along the grid to get to his food. He wants to know how many moves it will take for him to get there.
As well since he is slow he has teleporters set up around his domain that he will utilize if it shortens his path. Or avoid them if it lengthens his path.
Meet the turtle
The turtle lives on a... | stackexchange_codegolf |
Background
Hamiltonian circuit problem is a decision problem which asks whether a given graph has a Hamiltonian circuit, i.e. a cycle that visits every vertex exactly once. This problem is one of the well-known NP-complete problems.
It is also known that it remains so when restricted to grid graphs. Here, a grid graph ... | stackexchange_codegolf |
Given the size of the chess board and initial position of the knight, calculate the probability that after k moves the knight will be inside the chess board.
Note:
The knight makes its all 8 possible moves with equal probability.
Once the knight is outside the chess board it cannot come back inside.
Input
Inputs ar... | stackexchange_codegolf |
In the future when Time Travel (abbreviated as TT) will be common, coin tossing will become a serious mind-sport. To prepare for the future we create a competition for programs where time traveling will be really happening from the viewpoints of the entries.
The competition is a round-robin style King of the Hill consi... | stackexchange_codegolf |
For this challenge, you need to print out the fingerings for various brass instruments.
The notes an instrument can play (as well as their fingerings) are listed below:
Cornet Baritone
Trumpet Bugle French Horn Euphonium Tuba
A#0 0
B0
C1 ... | stackexchange_codegolf |
I came across this picture, which I initially questioned and thought about posting to Skeptics. Then I thought they'll only tell me if this one case is true, but wouldn't it be great to know how true any "rule" really is? Today you're going program a skeptic-bot
Challenge
Write a program or function which when given a ... | stackexchange_codegolf |
Not to be confused with Password Bishop Goodness!
Given a string, answer (truthy/falsy or two consistent values) if it constitutes a password which is strong against bishops.
A password is strong against bishops if it is a string consisting of alternating letters (in a-h) and digits (in 1-8) such that each pair of char... | stackexchange_codegolf |
Your challenge, should you choose to accept it, is to write a program in a language of your choice that, when given a string (limited to printable ASCII) as input, outputs a new program in the same language that outputs that string without using any characters from that string in the code.
But this task is impossible a... | 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 |
Write a function/program that accepts a string of lower/uppercase letters [A-Za-z] as input, that checks whether the occuring letters are unique and in alphabetical order (ignoring lower and uppercase) or not. The output must be truthy if they are unique and in alphabetical order and falsy if not.
Here some testcases
a... | stackexchange_codegolf |
Using the word “conemon” print each character 2 times more than the last. The first letter, “c”, should be printed 10 times, the second 12 and so on. Each repeated-letter-string should be printed on a new line.
So the end-result becomes:
cccccccccc
oooooooooooo
nnnnnnnnnnnnnn
eeeeeeeeeeeeeeee
mmmmmmmmmmmmmmmmmm
ooooooo... | stackexchange_codegolf |
Task
Write a polyglot in two languages that when run, outputs the name of the language it is run in. Additionally, this program must also output the other language's name if the source code is reversed
Example:
Program ABC in language foo outputs foo. ABC in language bar outputs bar. CBA in language foo outputs bar, an... | stackexchange_codegolf |
I though this would be a good challenge : http://adventofcode.com/2016/day/1
Task description
Given a sequence of rotations and distances following the pattern (L|R)[1-9][0-9]*, give the manhattan distance between the start and the ending points, that is the minimal number of vertical and horizontal moves on a grid.
Ex... | stackexchange_codegolf |
Given an array of positive integers in base 10, where n > 0, output their representation of a binary wall.
How does this work?
Convert each number to its binary representation.
Pad the representation with leading zeroes to the length of the longest one i.e. 1, 2 -> 1, 10 -> 01, 10.
Create a wall where the 1s are brick... | stackexchange_codegolf |
We all know true and false, but what do speakers around the globe say?
+----------------------+------------+------------+
| Language | True | False |
+----------------------+------------+------------+
| Arabic | sahih | zaif |
| Armenian | irakan | kelc ... | stackexchange_codegolf |
Inspired by one of many bugs I ran into while implementing selection sort in trilangle.
Given a non-empty list of non-negative integers, "sort" the list using the following procedure:
Find and output the smallest value in the list.
If the list only has one element, stop.
Recurse on a sublist:
If the last element in t... | stackexchange_codegolf |
Suppose there are 5 positive integers in an array or list as 14, 12, 23, 45, 39.
14 and 12 cannot be taken in the subset as 1 is common in both. Similarly {12, 23}, {23, 39}, {14, 45} cannot be included in the same subset.
So the subset which forms the maximum sum is {12, 45, 39}. The maximum sum such formed is 96.
the... | stackexchange_codegolf |
I was watching the world snooker championship and it got me wondering..
Snooker scoring
In the game of snooker there are certain rules that you must adhere too:
When there are red balls on the table, during your turn you must first pot a red ball
After potting each red ball, you must pot a colored (not red) ball (the ... | stackexchange_codegolf |
The title pretty much describes it all. Given as input a \$n \times m\$ matrix and an integer \$i\$ create a complete function/program that returns the matrix \$i\$ times clockwise rotated by \$90^\circ\$.
Rules:
as matrix you can use any convenient representation you like e.g. a list of lists etc...
matrix values can... | stackexchange_codegolf |
This is a problem on Luogu OJ. I decided to post it here because on Luogu OJ, many people, including me and my friend, are interested about how to solve this problem within the fewest characters.
Your task is to output the following ASCII-art:
************
####....#.
#..###..... | stackexchange_codegolf |
In case you missed Encode Factor Trees, here is the definition of a Factor Tree:
The empty string is 1.
Concatenation represents multiplication.
A number n enclosed in parentheses (or any paired characters) represents the nth prime number, with 2 being the first prime number.
Note that this is done recursively:... | stackexchange_codegolf |
(or: Output the plural demonym.)
When in Rome, do as the Romans do. This is a well-known English phrase meaning that it’s best to follow what others are doing around you — to go with the flow. Today, you're going to rewrite the phrase to fit most (Western) place names.
To get the name of a group that lives within a reg... | stackexchange_codegolf |
Background
Supplementary reading 1, Supplementary reading 2
Linear lambda calculus is a limited form of lambda calculus, where every bound variable must be used exactly once. For example, \a b c d e -> a b (d c) e is a valid term in linear lambda calculus. When embedded as a logic system, this enforces each input to be... | stackexchange_codegolf |
Suzhou numerals (蘇州碼子; also 花碼) are Chinese decimal numerals:
0 〇
1 〡 一
2 〢 二
3 〣 三
4 〤
5 〥
6 〦
7 〧
8 〨
9 〩
They pretty much work like Arabic numerals, except that when there are consecutive digits belonging to the set {1, 2, 3}, the digits alternate between vertical stroke notation {〡,〢,〣} and horizontal stroke notat... | stackexchange_codegolf |
Given some positive integer \$n\$ generate all derangements of \$n\$ objects.
Details
A derangement is a permutation with no fixed point. (This means in every derangement number \$i\$ cannot be in the \$i\$-th entry).
The output should consist of derangements of the numbers \$(1,2,\ldots,n)\$ (or alternatively \$(0,1,... | stackexchange_codegolf |
Create a function (or closest equivalent, or full program) that takes an list of some datatype (your choice) that may be nested and a string (in either order), and generalizes the lisp c[ad]+r functions.
Functions are provided which perform compositions of up to four car and cdr operations. Their names consist of a C,... | stackexchange_codegolf |
I've been developing some programs involving me fetching a vector from a url using Alpha-2 country codes (such as GET /jp.svg for Japan). Except, oh no! All the country data on my computer uses Alpha-3! That just won't do...The task is simple: Take an Alpha-3 country code (e.g. UKR) and return its Alpha-2 equivalent (... | stackexchange_codegolf |
Introduction
I crochet a lot, and lately I've started writing crochet patterns. However, while I work very well from notes such as rnds 2-6 (round number = x, original number of stitches = y): *dc x-2 stitches, 2 dc in next stitch* around (xy stitches), most published patterns spell out each row in more detail. I don't... | 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 |
May this challenge serve as (another) tribute to Stan Lee, who passed away aged 95.
Stan Lee has left us an invaluable legacy and a peculiar catch word: Excelsior. So here's a small challenge based on what he said it was its meaning:
Finally, what does “Excelsior” mean? “Upward and onward to greater glory!” That’s wh... | stackexchange_codegolf |
Note: as this question has been marked as a duplicate, I have accepted an answer. However, I will still check this question if users can find a shorter way of doing it, and accept that answer.
Given two numbers (which are multiples of 0.5) representing heads-percentage and tails-percentage from a series of coin-flippin... | stackexchange_codegolf |
I have previously posted a challenge, smallest number of steps for a knight in chess.
Now I would like to go a step further by adding the possibility to choose your piece.
If you place a piece on any square of a chessboard, what is the smallest number of steps to reach every possible position?
Rules
It is an 8 by 8 bo... | stackexchange_codegolf |
Challenge
Given a size s, print a cube net of that size made of hash symbols (#) and spaces ().
Examples:
1:
#
# # #
#
#
2:
# #
# #
# # # # # #
# # # # # #
# #
# #
# #
# #
3:
# # #
# # #
# # #
# # # # # # # # #
# # # # # # # # #
# # # # # # # # #
# # #
#... | stackexchange_codegolf |
Objective
Given a date, spell it out in Romanized Japanese.
I/O Format
The input format is flexible. The output format is <month spelling> <day spelling>; note the space. You can freely mix cases in output. You may output trailing newline.
Mapping
Months
Month
Spelling
January
Ichigatsu
February
Nigatsu
Mar... | stackexchange_codegolf |
\$BB\$ is the busy beaver function, an uncomputable function.
Write a program which when given an integer \$n\$ as input, will output \$BB(n)\$, with at least \$\frac 2 3\$ probability. You can do whatever (return something wrong, infinite loop, explode, etc.) in other cases.
To help you compute it, you're given a func... | stackexchange_codegolf |
In ValiDate ISO 8601 by RX, the challenge was to use only standard regular expressions to validate standard date formats and values (the former is a common job for RX, the latter was unusual). The winning answer used 778 bytes. This challenge is to beat that using any language of your choosing, but without special date... | stackexchange_codegolf |
Challenge Taken from my university code challenge contest
This is actually Day 0 but yesterdays' challenge was too easy and can be a dupe of another question here.
Tetris is a video game that became popular in the 80s. It consists of placing a series of pieces with different shapes that fall on a board, so that they f... | stackexchange_codegolf |
Write the shortest possible code which converts tabs to spaces in the input. Tab size should be supplied as a parameter or be hardcoded in the code in a single place.
Spaces on output should point to the right column, e.g. (\t represents a tab character):
a\tb
aa\tb
aaa\tb
aaaa\tb
should become (for tab size 4):
a b... | stackexchange_codegolf |
Introduction
A disk is a linear container with blocks indexed 0 through size-1.
A file is a named list of block indexes used by that file.
An example filesystem is expressed like this:
15 ALPHA=3,5 BETA=11,10,7
"The disk has 15 blocks, the first block of file ALPHA is the disk block at index 3..."
The disk map could b... | stackexchange_codegolf |
You are starting up a cryptocurrency exchange website which supports conversion from USD to two currencies, foo-coin and bar-coin. Write a program that takes the exchange rate for each coin to USD as arguments and outputs the maximum value of USD that cannot be completely divided into the two currencies (assuming these... | stackexchange_codegolf |
At time of writing, my reputation is \$16,256\$. As I noted in chat,
Oh cool my rep is the concatenation of two powers of 2: 16,256
Or even the concatenation of a power of 2 and its square, which is much more interesting
which then spawned a CMC about checking if a number has this property.
Given an integer \$n > 0\... | stackexchange_codegolf |
Martin has created a nice snippet that can be used to keep track of the score for answers to challenges. That's great and all, but wouldn't it be better if you could keep track of it yourself?
Create a program that compares the byte counts in itself with the rest of the answers to this question, and returns "I'm answer... | 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 |
Shikaku is a 2D puzzle. The basic rundown of it is that a rectangular grid has some numbers in it, and you want to partition the grid into rectangular components such that each component contains exactly one number which is the number of grid squares in that component.
This challenge involves a 1D simplification of thi... | stackexchange_codegolf |
A math Olympiad will be held, and participants are being registered. The highest number of participants is 100. Each participant is given an ID number. It is given in a sequence like \$100, 97, 94, 91, 88, ...., 1\$, and when the first sequence is over, then \$99, 96, 93, 90, 87, ...., 3\$ sequence and so on.
Let's ass... | stackexchange_codegolf |
A downhill maze is given as a series of rows of space separated digits from 0 to 9 inclusive, plus one "S" and one "X", where the S denotes the start and the X denotes the finish. In a downhill maze, you may only go to a space that is adjacent to you to the north, south, east, or west (no diagonals), and you may only ... | stackexchange_codegolf |
Given a non-negative number n, sort the digits of n by their first occurrence in pi.
Input can be taken via function cli argument, or STDIN and as a string, char[] or integer. You may output via return value, exit status or STDOUT.
| stackexchange_codegolf |
Strassen's algorithm was the first method of matrix multiplication in subcubic time complexity, namely O(n**log2(7)) for a pair of n*n matrices (assuming the numbers therein are large enough that their O(n*log2(n)) exact multiplication has become the constraint on your performance, and any nested structures and functio... | stackexchange_codegolf |
The aim is to trim elements in from the ends of a list, depending on if they are in a second list of "falsey" results.
For example, if the first list is [-1, 1, 2, 0, -1, 3, -1, 4, -1, -1] and the second is [-1], then we would remove all leading and trailing -1s from the first input, but not any -1s in the middle: [1, ... | stackexchange_codegolf |
Symja is a "computer algebra language & Java symbolic math library for Android NCalc calculator". It's a fun little language, so I'm wondering if y'all have any tips for golfing in Symja.
As per usual, "remove comments", etc, isn't really an answer. It turns out that there is no comment system in Symja, so "remove com... | stackexchange_codegolf |
Introduction
There is an Apple tree trunk positioned between -2 to 2 on the x-axis, where some apples fall down around it:
| |
| |
<-------|---|------->
-2 2
Everyday, n apples fall down. Each apple maintains its x coordinate as falls straight to the ground.
But if it lands on top of anoth... | stackexchange_codegolf |
Context
We're at war! You need to transfer an important message to your general to inform them from an imminent assault. The thing is, your enemy knows a lot about cryptography : you will need to be more creative in order to encode your message...
Task
Create a program that accepts an ascii message as input, and output... | stackexchange_codegolf |
Imagine that a list of integers describes the heights of some two-dimensional terrain as seen from the side.
Stamina: [ 4 4 4 4 4 4 3 3 3 3 2 2 2 - ]
O
/|\
/ \
+---+ +---+
| | | |
+---+ ... | stackexchange_codegolf |
Given an array of letters in the range 'a' to 'o', compute how to construct the array by successively inserting the letters in alphabetical order. You will always start the insertion with a base array of all the 'o's that are in the array to be reconstructed.
Examples
Let the input array be:
['o', 'b', 'o', 'b', 'a']
... | stackexchange_codegolf |
Given a ragged list, we can define an element's depth as the number of arrays above it, or the amount that it is nested.
For example, with the list [[1, 2], [3, [4, 5]]] the depth of the 2 is 2, as it is nested within two lists: The base list, and the list [1, 2]. The depth of the 4 is 3 as it is nested within three li... | stackexchange_codegolf |
This is the Robber post. The Cop post is here.
Your task is to take an integer input N and output the Nth digit in the sequence OEIS A002942.
The sequence consists of the square numbers written backwards:
1, 4, 9, 61, 52, 63, 94, 46, 18, 1, 121, 441, ...
Note that leading zeros are trimmed away (100 becomes 1, not 00... | stackexchange_codegolf |
Your task
Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$
Example
Let's say we are given the inputs \$x=4\$ and \$d=2\$.
First, we get the series \$n^4\$:
\$0^4 = 0\$
\$1^4 = 1\$
\$2^4 = 16\$
\$3^4 = 81\$
...
These are the first 10... | stackexchange_codegolf |
Let z be a complex number. z is an nth primitive root of unity if for a certain positive integer n and for any positive integer k < n .
Challenge
Write a full program or function that, given a positive integer n as input, outputs all of the nth primitive roots of unity. You may output them in polar form (e^θi or e^iθ,... | stackexchange_codegolf |
Air balloons need a gas that is lighter than air. However, hydrogen is flammable, while helium is not sustainable, so we need a replacement! You must write code that determines whether any given gas is lighter than air.
Input: a molecular chemical formula of a gas (ASCII)
Output: true if the gas is lighter than air; f... | stackexchange_codegolf |
To shuffle a string \$s\$, Alice applies the following algorithm:
She takes the ASCII code of each character, e.g. "GOLF" → \$[ 71, 79, 76, 70 ]\$
She sorts this list from lowest to highest: \$[ 70, 71, 76, 79 ]\$
She reduces each value modulo the length of the string (4 in this case), leading to the list \$A = [ 2, 3... | stackexchange_codegolf |
The task
Your program will be given the following inputs: a number n, and an array of n positive integers. Your program only has to work when n=1000.
The program must do the following:
If the input array is a permutation of the range [1, 2, …, n], output Huh!?
Otherwise, return a three-element array [i, j, n], where i... | stackexchange_codegolf |
Golf Golf!
This is my first challenge, so please be gentle! The challenge is to write a program that will output the correct score for a layout in the card game "Golf."
The card game Golf has many variations. The house rules I use follow the standard rules for Six-Card Golf given by Pagat, with one slight difference. T... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.