instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Background
From Wikipedia: An Egyptian fraction is the sum of distinct unit fractions. That is, each fraction in the expression has a numerator equal to 1 and a denominator that is a positive integer, and all the denominators differ from each other. The value of an expression of this type is a positive rational number ... | stackexchange_codegolf |
Given a binary number, your task is to create a 'branch' of that number, with a depth of 2.
For example, given 0 as input, you should output exactly this:
/000
/00
/ \001
0
\ /010
\01
\011
This should be fairly self explanatory of how the branches should be created. Depth 2 means we calculate branc... | stackexchange_codegolf |
Given two integer matrices a and b, your challenge is to replace any occurences of b in a with a matrix of the same size filled with 0s. For example:
Given:
a: [ [1, 2, 3],
[4, 3, 2],
[3, 5, 4] ]
b: [ [3],
[2] ]
b occurs once in a:
[ [1, 2, 3],
[4, 3, 2],
[3, 5, 4] ]
Fill that area with zeroes:
[ [1,... | stackexchange_codegolf |
People, it's a popularity contest, you have to do somthing cool here.
Think about cool ways of breaking the code in most languages, not about validating for everyting!
Initially this challenge is NOT for esoteric languages. But I didn't disabled them as I expect voters to be fair enough to downvote answers based... | stackexchange_codegolf |
Introduction
Help! I accidentally dropped my TI-84 calculator out my window (don't ask how) and it broke. I have a math test tomorrow and the only calculator I can find is one with these buttons:
7 8 9 +
4 5 6 -
1 2 3 *
0 = /
My math test is a review test on evaluating expressions. I need a program to take an expres... | stackexchange_codegolf |
A manufacturing company wants to print a design on mats of varying dimensions, and they hired you to program a robot to make these mats. The design consists of alternating rings of any 2 symbols on a mat. Below are some sample looks:
Column 9 by Row 7
Symbol 1: @
Symbol 2: -
Input: 9 7 @ -
@@@@@@@@@
@-------@
@-@@@@@-@... | stackexchange_codegolf |
Write a program that reads a \$n\times n \times n\$ array of binary values which represent an \$n\times n \times n\$ cube, that consists of \$n^3\$ smaller cubes. Each value says whether there is a voxel (small cube) present in the given position or not. The program must output the given array as an ASCII graphic (that... | stackexchange_codegolf |
This programming puzzle is inspired by another question which has been asked here yesterday but which was deleted by the author...
The challenge:
Create an executable binary (Windows .EXE or Linux binary) using Visual C# (or your favorite C# IDE) which prints the following text to the standard output:
Main() is the mai... | stackexchange_codegolf |
When I was a kid, there was a "really cool" shortcut to count to 100:
1, 2, miss a few, 99, 100
Output the exact string above, in the fewest characters possible, without using these characters: 0, 1, 2, 9
| stackexchange_codegolf |
Thunno 2 is a stack-based golfing language with around 400 commands (achieved through overloads) created by me, The Thonnu.
It seems like a good idea to share some tips for golfing in Thunno 2.
Please, one tip per answer, and no tips like “remove comments and whitespace”.
Links:
Tutorial
List of commands
Attempt This... | stackexchange_codegolf |
Given an integer N from 1-9, you must print an NxN grid of NxN boxes that print alternating 1s and Ns, with each box having an alternating starting integer.
Examples
Input: 1
Output:
1
Input: 2
Output:
12 21
21 12
21 12
12 21
Input: 3
Output:
131 313 131
313 131 313
131 313 131
313 131 313
131 313... | stackexchange_codegolf |
A Bayer matrix is a threshold map used for ordered dithering that gives the illusion of having more shades of color than actually present by using a crosshatch-like pattern.
Bayer matrices are square with a side length that is a power of 2. Here are some examples:
\$
\displaystyle\frac{1}{4}
\times
\begin{bmatrix}
0 & ... | stackexchange_codegolf |
How many of you that still use your own knuckle to determine whether a month is having a full 31 days or less?
You job is to write a program to count how many months, in a month range, are having a full 31 days and how many are having less than 31 days by "counting the knuckles".
Courtesy: amsi.org.au
Input
A pair of... | stackexchange_codegolf |
So, this is a task from one very popular educational site in Russia:
https://acmp.ru/index.asp?main=task&id_task=786&ins=1
Mathematically, you need to find the power of two not exceeding the given number, read from the standard input stream, and output their difference in the standard output stream.
My python3 solution... | stackexchange_codegolf |
The Bible is one of the most influential books ever written, and commonly cited as the best selling book of all time. It was written by approximately 40 different authors over hundreds of years before being compiled into it's current form. But what's interesting about The Bible is the way it's divided up. It is split u... | 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 |
Introduction
The challenge itself was something I came across and had to try and figure out for a personal of project of mine. I ended up branching out and asking family members if they could provide an equation to meet the requirements.
Note: I have (with the help of others) found a solution for this but now I'm just ... | 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 |
This is Fortnightly Challenge #3. Theme: Genetic Algorithms
This challenge is a bit of an experiment. We wanted to see what we could do, challenge-wise, with genetic algorithms. Not everything may be optimal, but we tried our best to make it accessible. If this works out, who knows what we might see in the future. Mayb... | stackexchange_codegolf |
This! is an RGB colour grid...
Basically it's a 2-dimensional matrix in which:
The first row, and the first column, are red.
The second row, and the second column, are green.
The third row, and the third column, are blue.
Here are the colours described graphically, using the letters R, G, and B.
Here's how we calcu... | stackexchange_codegolf |
Given a text input such as:
THE QUICK
BROWN FOX
JUMPS OVER
THE LAZY
DOG
render the following output:
/\
\ \
/ \
/ /\/
/ / /\
/ / / /
... | stackexchange_codegolf |
The Fabius function is an example of a function that is infinitely differentiable everywhere, yet nowhere analytic.
One way to define the function is in terms of an infinite number of random variables. Specifically, given a sequence of independent random variables \$\{U_n\}\$, where each \$U_n\$ is uniform on the inter... | stackexchange_codegolf |
Write a program or function that takes in a string and outputs a count of each modern English alphabet letter in the string, case-insensitive.
Input: A string consisting of printable ASCII characters (code points 32-126).
Output: A list of pairs, where each pair consists of a letter and its count in the string. The lis... | stackexchange_codegolf |
Write a program that displays on the screen the sum of the divisors of a number (1 ≤ N ≤ 100) entered by the user in the range of 1 to N.
This is OEIS A000203.
Examples:
Input: 7
7 / 1 = 7
7 / 7 = 1
7 + 1 = 8
Output: 8
Input: 15
15 / 1 = 15
15 / 3 = 5
15 / 5 = 3
15 / 15 = 1
15 + 5 + 3 + 1 = 24
Output: 24
Input: ... | stackexchange_codegolf |
Oh, No!
the sentences are out of balance.
Quick! balance them.
A word is defined as follows:
A sequence of letters [A-Za-z] separated by any non-letter character ([0-9] ~+- etc.)
A word is BaLanCeD if its capitalization is the same forwards as it is backwards.
Given a sentence with words, balance each word by capita... | stackexchange_codegolf |
Did you know that Heronian Tetrahedra Are Lattice Tetrahedra? A Heronian tetrahedron is a tetrahedron where
the length of each edge is an integer,
the area of each face is an integer, and
the volume of the tetrahedron is an integer.
It's always possible to place such a tetrahedron in space such that all of the vertic... | stackexchange_codegolf |
I am exploring a unique approach to the classic problem of Reverse Polish Notation on code.golf. Unlike the conventional solutions, my focus lies on leveraging the eval function in GolfScript. This twist was inspired by a comment in a related thread, where the absence of eval was deemed a limitation.
"It's a shame no ... | stackexchange_codegolf |
Leaderboard - JIT Compiled (Lower is better)
es1024 - 81.2 points (including a working compiler!)
Kieth Randall - 116 points
Ell - 121 points
Leaderboard - Interpreted (Lower is better)
Martin Büttner - 706654 points (somewhere around 2 hours).
criptych - 30379 points (97 seconds)
Your mission, should you choos... | stackexchange_codegolf |
As programmers, we all know the saying: "You can have it fast and good, but it won't be cheap, you can have it cheap and good, but it won't be fast, or you can have it fast and cheap, but it won't be good."
For this challenge, you are implementing an imaginary configuration tool for your custom programming services. Yo... | stackexchange_codegolf |
In calculus, the derivative of a mathematical function defines the rate at which it changes. The derivative of a function f(x) can be marked as f'(x), and these can sometimes be abbreviated to f and f'.
The derivative of the product of two functions fg is f'g + g'f. The derivative of three fgh is f'gh + fg'h + fgh'. In... | stackexchange_codegolf |
Background
The number 1729 is the Hardy-Ramanujan number. An amazing property of it was discovered by S. Ramanujan (who is widely regarded as the greatest Indian mathematician1), when G.H. Hardy paid a visit to him in a hospital. In Hardy's own words:
I remember once going to see him when he was ill at Putney. I had r... | stackexchange_codegolf |
Given a random coordinate (x,y), determine in which square (squares are referenced by their sidelength) it is (or the borders of which squares).
The squares are drawn in a counter clockwise direction, that is, the first square is drawn in the first quadrant, the one after is to the right, the one after that above, th... | stackexchange_codegolf |
The Venetian election system was... complicated.
The Great Council came together and put in an urn the ballots of all the councilors who were older than 30. The youngest councilor went to St Mark's Square and chose the first boy he met who drew from the urn a ballot for each councillor and only those 30 who got the wo... | stackexchange_codegolf |
Basic rules (different from mine)
Story
It is the year 4579, humans now have 2 hands with 1001 fingers each. Chopsticks has become based off of points. And @Dennis has more rep then @Martin... Hand drawn red circles are now downvoted... Jon Skeet has hit 2 trillion rep on every SE site... Yeah scary I know
Chopsticks i... | stackexchange_codegolf |
You should a program in language X, which will only output its source code (i.e function as a quine) when it is not a monday. On monday it should output some string with a levehnstein distance of 4 from the source code. i.e if the code is aaaa on sunday it should output aaaa and on monday it could output ....aaaa or bb... | stackexchange_codegolf |
Befunge Chess is an esolang mini-game I invented that is centered around the Befunge esolang. The general gist of the game is to make the instruction pointer land on a specific target cell while avoiding the opponent's target cell.
Today's challenge isn't to play the game, but to simply execute arbitrary boards.
The Ru... | 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 |
Each element on the periodic table of the elements has an atomic weight. For example, boron (element 5) has an atomic weight of 10.81. Your challenge is to write a program which takes as input the atomic number of an element and outputs its atomic weight.
Your program only needs to support elements up to and including ... | stackexchange_codegolf |
Objective
Given a positive integer, spell it out in the conlang I made.
Specification
Let \$n\$ be the inputted integer. \$n\$ shall be spelled out in the following specification. The entire spelling is case sensitive.
With the decimal expansion of \$n\$, let d be the least significant nonzero digit of \$n\$.
First, d ... | stackexchange_codegolf |
The Task:
Given a .txt file with frames of ASCII art each separated by a \n (see this example if you are unclear) output a motion picture with frame with 1 frame per second.
Note that there is a trailing \n on the final frame.
Each frames dimensions will be:
X<80
Y<20
The Rules
The Previous frame must be cleared bef... | stackexchange_codegolf |
Problem
Recreate the UI from a torrent program
Given no input, output the following:
+----------+----------+----------+
|a.exe |##########|seeding |
+----------+----------+----------+
|b.exe 10% |# |leeching |
+----------+----------+----------+
|c.exe |##########|seeding |
+----------+----------+--... | stackexchange_codegolf |
(related: one, two, three)
An acrostic is a style of poem/writing where the beginning character of each line, when read vertically, also produces a word or message. For example,
Together
Everyone
Achieves
More
also spells out the word TEAM when the first column is read vertically.
Acrostics are a subset of mesostics, ... | stackexchange_codegolf |
Consider the following triangle.
1
23
456
7891
01112
131415
1617181
92021222
324252627
2829303132
33343536373
839404142434
4454647484950
51525354555657
585960616263646
5666768697071727
37475767778798081
As you probably noticed, the first row is of length 1, and each row thereafter is 1 digit longer than to the previo... | stackexchange_codegolf |
Many digital clocks display the time using simplified digits comprised of only seven different lights that are either on or off:
When mirrored horizontally, the digits 018 don't change because they are symmetrical. Also, the digits 2 and 5 get swapped, 2 becoming 5 and vice versa. All the other digits become invalid w... | stackexchange_codegolf |
Rules
You will receive as input a list that contains integers and strings. Your task is to move all of the strings to the end of the list and all of the integers to the beginning of the list.
This is code-golf so the answer with the least number of bytes wins.
| stackexchange_codegolf |
Here in California, we're in a drought so we need to know how much water we have left so we can conserve as much water as possible.
Because water is limited supply, your code will need to be as short as possible.
Examples
| |
| |
|~~~|
|___|
Output: 0.5
|~~~~~|
| |
| |
|_____|
Output: 1
| |
|__|
Outpu... | stackexchange_codegolf |
There is a job which can be decomposed into x equally-sized smaller tasks. You have a team of size y <= x, where every member works equally fast on any task. The goal for this challenge is to divide the work as evenly as possible such that every member of your team has at least 1 task to perform. As evenly as possible ... | stackexchange_codegolf |
I saw a cool gif of the twin dragon curve made from a square, and wondered what would happen if we started from another base image. So I wrote a program to do this.
It's so cool that I thought it would be fun to do it as a challenge.
Task
You will take in a square image with an ... | stackexchange_codegolf |
First, a mathematical interlude, short, and worth your while:
If 0 < a < 4, the logistic function f(x) = ax(1-x) maps the interval [0,1] inside itself. This means that one can play the iteration game; for instance, if a=2, the initial value 0.3 becomes 0.42, then 0.4872, etc.
As the parameter a increases, the quadratic... | stackexchange_codegolf |
Alternating Arrays
An alternating array is a list of any length in which two (not necessarily different) values are alternating. That is to say, all even-indexed items are equal, and all odd-indexed items are equal.
Your task is to write a program or function which, when given a list of positive integers, outputs/retur... | stackexchange_codegolf |
The Home Prime of an integer \$n\$ is the value obtained by repeatedly factoring and concatenating \$n\$'s prime factors (in ascending order, including repeats) until reaching a fixed point (a prime). For example, the Home Prime (\$\text{HP}(n)\$) of \$10\$ is \$773\$ as:
$$\begin{align}
10 & = 2 \times 5 \to 25 \\
25 ... | stackexchange_codegolf |
A triangular number is a number that can be expressed as the sum of consecutive positive integers, starting at 1. They can also be expressed with the formula n(n + 1) / 2, where n is some positive integer.
A number's digitangular counterpart is calculated in the following way:
Split a number into an array of its digit... | stackexchange_codegolf |
Intro
Cookie Clicker is a popular browser game in which the player has to click a cookie to gain... Cookies!
The player can buy upgrades which will automatically farm cookies for you. Sometimes a golden cookie will enter the screen, which will provide a bonus upon clicking it.
Challenge
This challenge will not be about... | stackexchange_codegolf |
Let's assume that
$$
f(x) = \frac{Ax+B}{Cx+D}
$$
Where, \$x\$ is a variable and \$A\$,\$B\$,\$C\$,\$D\$ are constants.
Now we have to find out the inverse function of \$f(x)\$, mathematically \$f^{-1}(x)\$, To do this first we assume,
$$
y = f(x)
\\\rightarrow y=\frac{Ax+B}{Cx+D}
\\\rightarrow Cxy+Dy=Ax+B
\\\rightarrow... | stackexchange_codegolf |
Description :
Given an array of strings representing a grid of cells
With the key :
0 = 'dead cell'
1 = 'live cell'
write a function that returns the next iteration following the rules of Conway's Game of Life .
Rules
Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
Any live ... | stackexchange_codegolf |
For a while now, I've been running into a problem when counting on my fingers, specifically, that I can only count to ten. My solution to that problem has been to count in binary on my fingers, putting up my thumb for one, my forefinger for two, both thumb and forefinger for three, etc. However, we run into a bit of ... | stackexchange_codegolf |
Introduction
Consider two arrays of the same length, say A = [0,1,0,2] and B = [-1,1,2,2].
Suppose we know that their contents are equivalent in some sense, item by item:
0 is equivalent to -1,
1 is equivalent to 1,
0 is equivalent to 2, and
2 is equivalent to 2.
Equivalence is transitive: -1 and 0 are equivalent, an... | stackexchange_codegolf |
In this challenge we'll compute an infinite minimal admissible sequence.
The sequence for this challenge starts with a(1) = 1.
We continue this sequence by finding a(n) as the smallest possible number such that a(n) > a(n-1) and for every prime p, the set {a(i) mod p : 1 ≤ i ≤ n} has at most p-1 elements.
Write a progr... | stackexchange_codegolf |
iBug recently got a long bar made of composite, yet valuable materials. The bar is so long that iBug can't easily sell it for credits, so he wants to cut it. The bar is made of such fragile and magic materials that, if a part is broken, all parts of the bar made of the same material will break, too, making it hard to c... | stackexchange_codegolf |
I'm surprised that this challenge isn't already here, as it's so obvious. (Or I'm surprised I couldn't find it and anybody will mark it as a duplicate.)
Task
Given a non-negative integer \$n\$, calculate the sum of the first \$n\$ primes and output it.
Example #1
For \$n = 5\$, the first five primes are:
2
3
5
7
11
... | stackexchange_codegolf |
(Inspired by ASCII's 95 Characters...95 Movie Quotes)
The Challenge
Given input n, output the nth Fibonacci number. You can use either 0 or 1 indexing, please state which in your submission. Simple, yeah? The catch is you must take the character set of the immediate previous answer, remove two characters from it, and a... | stackexchange_codegolf |
Choose a language and write a program in the language that:
Take a valid program of the language as input,
Output a string(bytearray, etc.). It needn't be a valid program.
Only finite valid inputs result in longer/same-length(in bytes) output.
Different valid input, even if behave same, lead to different output.
Let ... | stackexchange_codegolf |
Input
The board: A 2D container (matrix, list of lists, etc.) of letters like:
["B", "C", "C", "C", "C", "B", "B", "C", "A", "A"],
["B", "A", "C", "B", "B", "A", "B", "B", "A", "A"],
["B", "C", "B", "C", "A", "A", "A", "B", "C", "B"],
["B", "B", "B", "A", "C", "B", "A", "C", "B", "A"],
["A", "A", "A", "C", "A... | stackexchange_codegolf |
This is a code golf challenge I thought of with a mathematical bent. The challenge is to write the shortest code possible such that it is an open question whether or not the code terminates. An example of what I mean could be the following piece of python code, adapted from an anwser to this cs stackexchange question.
... | stackexchange_codegolf |
You work in a kitchen which has a peculiar rule. When you mix something into a pot you must always add at least one new ingredient.
So you can add pasta, oil, salt then pesto, but not pasta, pesto, salt and oil since pesto already contains salt and oil. You only have one pot per dish, so you can't mix ingredients in on... | stackexchange_codegolf |
Write an interpreter for 2B
I like David Catt's esoteric language 2B, having memory stored in a tape where each cell is a seperate tape of bytes (the 'subtape'). Write an interpreter for it!
Language Specification
Official specification can be found here. In this specification, " means a number in the range 0-9 (0 is i... | stackexchange_codegolf |
Consider this nested array
[[1,2,4],[1,2,3],[2,3]]
In each subarray in which 1 appears, a 2 appears. You might say that 1's presence is dependent on 2's presence.
The converse is not true, as 2 appears in a subarray without 1.
Additionally, 3 is dependent on 2, and 4 is dependent on 1 and 2.
Task
Given a list of lists ... | stackexchange_codegolf |
Two lists A and B are congruent if they have the same length, and elements that compare equal in A compare equal in B.
In other words, given any two valid indices x and y:
If A[x] = A[y], then B[x] = B[y].
If A[x] != A[y], then B[x] != B[y].
For example, the lists [1, 2, 1, 4, 5] and [0, 1, 0, 2, 3] are congruent.
Th... | stackexchange_codegolf |
You should write a program or function which receives no input and outputs a stream of digits.
The stream should contain at least once every positive integer number which does not contain the digit sequence 42. E.g. The string 1231 contains the integers 1 12 123 1231 2 23 231 3 31 (and 1 again)
The stream should not c... | stackexchange_codegolf |
Make a Windows style Loading bar by the following instructions.
(notice that this is different than Loading... Forever)
Your output should start by [.... ].
Every tick, you should wait 100 ms, then move each dots by one character right. if the dot is on the tenth character, move it to the first. Notice that you s... | stackexchange_codegolf |
Challenge :
\$\pi\$ is supposed to be infinite. That means every number is contained inside the decimal part of \$\pi\$.
Your task will be to take a positive integer on input and return the position of this number in \$\pi\$ digits on output.
For example, if the input is 59, we'll return 4
Here is why : we will look fo... | stackexchange_codegolf |
My doubles pickleball group often has five people. Four are playing and one is awaiting the next game. We can represent the state of the game with a string of five characters like abCde. This indicates that a and b are playing against c and d with c serving. We want to write a routine that gives the possible positions ... | stackexchange_codegolf |
This challenge is based on a video in which Andrew Huang discusses unusual time signatures...
https://www.youtube.com/watch?v=JQk-1IXRfew
In it, he advises that you can understand time signatures by dividing them into 3's and 2's. So you count to a small number a few times, instead of counting to a large number.
Here's... | stackexchange_codegolf |
Generate the contents of an SVG file containing 6 bingo cards. Winner is the one that uses the shortest code. A qualifying answer has an output that can be directly pasted in a blank to get the required image. Rules are as follows.
The generated SVG code should comply with SVG version 1.1 described here.
The size of t... | stackexchange_codegolf |
Your task, at the moment that you choose to accept it, is to write a program that, when given a string and a PCRE-regex, calculates the minimum Levenshtein distance to another string that matches the regex (fully). All strings, as well as the regexes, should be in the Latin-1 character set.
This is code-golf, so the sh... | stackexchange_codegolf |
Bertrand's postulate states that there is always at least 1 prime number between n and 2n for all n greater than 1.
Challenge
Your task is to take a positive integer n greater than 1 and find all of the primes between n and 2n (exclusive).
Any default I/O method can be used. Whoever writes the shortest code (in bytes)... | stackexchange_codegolf |
Challenge
Display Inky the ghost from Pac-Man using only ANSI escape codes.
Here's a text representation of the image
B B B B B C C C C B B B B B
B B B C C C C C C C C B B B
B B C C C C C C C C C C B B
B C W W C C C C W W C C C B
B W W W W C C W W W W C C B
B E E W W C C E E W W C C B
C E E W W C C E E W W C C C
C C W... | stackexchange_codegolf |
(via chat)
The OEIS entry A123321 lists the sequence of numbers that are the product of seven distinct primes. For brevity, we'll call this a 7DP number. The first few numbers and their corresponding divisors are below:
510510 = 2 * 3 * 5 * 7 * 11 * 13 * 17
570570 = 2 * 3 * 5 * 7 * 11 * 13 * 19
690690 = 2 * 3 * 5 * 7 *... | stackexchange_codegolf |
GolfScript automatically coerces values, according to the following ‘priority’ sequence:
integer → array → string → block
(listed from lowest to highest.)
This means that "1"7+ leaves the string "17" on the stack (and not 8), because strings have a higher priority than integers.
[To those GolfScript veterans – apolog... | stackexchange_codegolf |
I think we've all done this as a kid: some websites require a minimum age of 18, so we just subtract a few years from the year of birth and voilà, we 'are' 18+.
In addition, for most rides at amusement parks the minimum height to enter is 1.40 meters (here in The Netherlands it as at least). Of course this can be cheat... | stackexchange_codegolf |
Introduction
This is the evolution of this previous challenge which was about checking satisfieability of normal formulae in conjunctive normal form (CNF). However, this problem is NP-complete and watching algorithms finish is just boring, so we're gonna simplify the problem!
Specification
Input
You may tune the follow... | stackexchange_codegolf |
The prime cluster of an integer N higher than 2 is defined as the pair formed by the highest prime strictly lower than N and the lowest prime strictly higher than N.
Note that following the definition above, if the integer is a prime itself, then its prime cluster is the pair of the primes preceding and succeeding it.
... | stackexchange_codegolf |
This challenge is essentially identical to this one with just one difference: it is now allowed to shuffle letters anywhere in the string.
Scenario
John has an important number, and he doesn't want others to see it.
He decided to encrypt the number, using the following steps:
His number is always a non-decreasing seque... | stackexchange_codegolf |
A binary convolution is described by a number M, and is applied to a number N. For each bit in the binary representation of M, if the bit is set (1), the corresponding bit in the output is given by XORing the two bits adjacent to the corresponding bit in N (wrapping around when necessary). If the bit is not set (0), th... | stackexchange_codegolf |
We've all been told at some point in our lives that dividing by 0 is impossible. And for the most part, that statement is true. But what if there was a way to perform the forbidden operation? Welcome to my newest creation: b-numbers.
b-numbers are a little bit like imaginary numbers: the main pronumeral involved repre... | stackexchange_codegolf |
Motivation
In this challenge your task was to multiply two strings, this naturally introduces a way to take the square root of a string.
How does it work?
Given a string (for example pub) the first thing you need to do, is to determine the ASCII code for each character:
"pub" -> [112, 117, 98]
Next you map these codes... | stackexchange_codegolf |
One day, when I was bored in maths class, I learned of a neat trick for solving the real cube root of a number!
Let's use the number \$79,507\$ as an example.
First, take digit in the one's place and compare it to this table:
\begin{array} {|r|r|}
\hline
\text{Extracted Digit} &\text{Resulting Digit} \\
\hline
\text{1}... | stackexchange_codegolf |
In this challenge, you are passed two things:
A string length, N
A list of strings, L, each with an assigned point value. Any string that is not passed in has a point value of 0
You need to construct a string of length N such that the sum of all substring points is as large as possible.
For example:
5 [("ABC", 3), (... | stackexchange_codegolf |
There are two objects:
Object1, Object2
You can easily swap them by:
Object3 = Object1
Object1 = Object2
Object2 = Object3
However, you must solve this problem by using no temporary object and Object1 should be changed to Object 2. (and vice versa)
| stackexchange_codegolf |
Your task is to create a plain hunt (a bell ringing pattern) with n bells. An example with 6 bells:
123456
214365
241635
426153
462513
645231
654321
563412
536142
351624
315264
132546
123456
Each number "bounces" off the side of the grid. From Wikipedia:
Each bell moves one position at each succeeding change, unless ... | stackexchange_codegolf |
The Challenge
A simple "spy versus spy" challenge.
Write a program with the following specifications:
The program may be written in any language but must not exceed 512 characters (as represented in a code block on this site).
The program must accept 5 signed 32-bit integers as inputs. It can take the form of a functi... | stackexchange_codegolf |
Create program or function that takes file name as an argument or reads it from standard input, and completes the following task:
Read image from a png file (name given as argument).
Reverse colors in that image, so that for example dark green (0, 75, 30) would become (255, 180, 225) (because 255-0=255, 255-75=180 and... | stackexchange_codegolf |
Introduction
The Boids Algorithm is a relatively simple demonstration of emergent behavior in a group. It has three main rules, as described by its creator, Craig Reynolds:
The basic flocking model consists of three simple steering behaviors which describe how an individual boid maneuvers based on the positions and ve... | stackexchange_codegolf |
OEIS A000009 counts the number of strict partitions of the integers. A strict partition of a nonnegative integer n is a set of positive integers (so no repetition is allowed, and order does not matter) that sum to n.
For example, 5 has three strict partitions: 5, 4,1, and 3,2.
10 has ten partitions:
10
9,1
8,2
7,3
6,4
... | stackexchange_codegolf |
The problem #6 of IMO 2009 reads:
Let a 1, a 2, a 3, ..., a n, be distinct positive integers and let T be a set of n-1positive integers not containing a 1+a 2+a 3+...+a n, A grasshopper is to jump along the real axis, starting at the point 0 and making n jumps to the right with lengths a 1, a 2, a 3, ..., a n in so... | stackexchange_codegolf |
Anyone remember Boaty?
You could totally make any old word, right?
Write a function to turn a string into Somethingy McSomethingface.
It should accept one string as input. Ignore the case of the input.
If the word ends in 'y', your function should not add an additional 'y' to the first instance, but should remove it i... | 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 |
Wheat Wizard has once tried to come up with a parsing problem unsuitable for regex, but it failed due to Anders Kaseorg's Perl regex answer. This is the second attempt. Now that we know that Perl regex is far more powerful than we've imagined, this challenge aims to be un-golfy for it instead.
Introduction
A lambda ter... | stackexchange_codegolf |
Warning: Wouldn't you rather answer a challenge about ponies?1
If you have read The Hostile Hospital, you would know that the Baudelaire orphans, from one of the scraps of paper recovered from the Quagmire's notebooks, they discover a name, "Ana Gram". Later on, they realize that means the word "anagram", not a name.... | stackexchange_codegolf |
Let us say that we have a particular set of functions on strings. These functions are kind of like fill in the blanks or madlibs, except that they only take one input and use that to fill in all of their blanks. For example we might have a function that looks like
I went to the ____ store and bought ____ today.
If w... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.