instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Given a positive integer N, output this doubling pattern of slash squares/rectangles.
For N=1, the base is:
/\
\/
The next square is added in the bottom right direction for N=2:
/\
\/\
\/
After that, a 2x1 rectangle is added in the bottom left direction for N=3:
/\
/\/\
\ \/
\/
Then a 2x2 square is added in the t... | stackexchange_codegolf |
This is similar to this question.
However, I have a different goal in mind:
Reduce the wordlist to words that could appear.
The easy part is to delete hyphens and similar.
The hard part, however: Remove words containing more than seven letters.
So, the problem:
Given a set of words containing only lowercase (or upperca... | stackexchange_codegolf |
In music theory, an interval is the difference between two pitches. Each pitch is defined by the number of half-steps (The difference between C and C#) or whole steps (The difference between C and D). One whole step is the same as two half-steps. Here is a list of all the default intervals and the number of half-steps... | stackexchange_codegolf |
Consider an eight bit number in which an even position bit will never be 1 if one of its neighbors is 0 (considering MSB and LSB as neighbors). There are fewer than 64 such numbers, so there is at least some reversible mapping of them to 6 bit numbers.
Your task is to write a pair of functions (or code blocks or your l... | stackexchange_codegolf |
This question is heavily based off this question, but should pose a number of additional difficulties.
Your Task
You must write a program or function that, when receiving a string, prints out all possible anagrams of it. For the purpose of this question, an anagram is a string that contains the same character as the o... | stackexchange_codegolf |
Lambda calculus is a system of computation based on single-argument functions; everything in it is such a function. Due to this functional nature, juxtaposition is commonly used to denote function application, grouped from left to right. For example, \$(f g) h=f g h\$ denotes what would conventionally be written \$(f(g... | stackexchange_codegolf |
This is the inverse of Let's do some "deciph4r4ng"
In this challenge, your task is to encipher a string. Luckily, the algorithm is pretty simple: reading from left to right, each typical writing character (ASCII range 32-126) must be replaced by a number N (0-9) to indicate that it is the same as the character N+1 pos... | stackexchange_codegolf |
Given a word list, find all sets of five words of five letters each, such that the words of each set have 25 distinct letters in total.
This challenge was inspired by this video by Matt Parker.
Testcases
Use this file if you want to test your code against the English vocabulary. Sample output sets:
["fjord", "vibex", ... | stackexchange_codegolf |
Caves and Cliffs edition
Part 1, Very related
You're given a piece of ASCII art representing a piece of land, like so:
/‾\ _ __
__/ _/ \‾
_/ __/‾\ |
/ / ‾\ |
\_/‾ \_/
But unlike in the previous challenge, the terrain is mountainous, with caves and cliffs, and can turn b... | stackexchange_codegolf |
Introduction
Fischer random chess, also known as Chess960 for the 960 valid starting boards, is a variant of chess where each player's pieces are randomly shuffled at the start. As a reminder, each player gets 8 pawns, two rooks, two knights, two bishops, one queen, and one king. For this challenge, you don't need to k... | stackexchange_codegolf |
Background
Inspired by Octave's (and, by extension, MATL's) very convenient interpretation of truthy/falsy matrices, Jelly got the Ȧ (Octave-style all) atom.
Ȧ takes an array as input and returns 1 if the array is non-empty and does not contain the number 0 (integer, float, or complex) anywhere in the tree structure; o... | stackexchange_codegolf |
zipwith is a functional construct that takes three arguments: one binary function and two lists of the same length, and returns a single list where each element is constructed by applying the binary function to each pair of elements from the two lists:
zipwith (a+b) [1,2,3] [4,5,6] = [5,7,9]
You are to take a black-bo... | stackexchange_codegolf |
The Tangram is a dissection puzzle made from seven shapes: Five differently sized triangles, a parallelogram and a square. Given a shape, the goal is recreating the shape using all the pieces and without overlapping. There are obviously infinitely many ways to arrange this set of pieces in the plane. An interesting sub... | stackexchange_codegolf |
Challenge
You must write an encoder (and a separate decoder) which takes a string as input and outputs the string encoded in the style of a strand of DNA.
DNA
DNA is made up of four types of nucleotide:
Adenine (A)
Thymine (T)
Cytosine (C)
Guanine (G)
Adenine and thymine pair up together to make AT or TA. Similarly, ... | stackexchange_codegolf |
Background and Rules
There is a variant of chess called atomic chess, which follows essentially the same rules as normal chess, except that pieces explodes other pieces around them when captured. In addition to checkmate, you can also win the game by blowing up the king.
When a piece captures another piece, all adjace... | stackexchange_codegolf |
You need to build a pyramid from cubes. Cubes can be viewed from 2 angles:
_____ _____
/\ \ / /\
/ \____\ /____/ \
\ / / \ \ /
\/____/ \____\/
This is an example for 2-size cubes from the 2 possible angles.
The height of the cubes is $size slashes (or back-slashes), and the w... | stackexchange_codegolf |
In this question I will talk about programs as strings, this is strings of bytes, not characters. How your resultant program is rendered or displayed is not important to this challenge, only how it appears in memory matters.
A pristine program is a program \$S\$ that when run does not error, however it will error when... | stackexchange_codegolf |
A favorite puzzle of mine. Not massively difficult but a tad interesting.
The Objective
Using a low level language (C/C++/similar level) - create a doubly linked list of elements that only stores a single pointer instead of storing both a previous and next element pointer as you normally would.
You must be able to find... | stackexchange_codegolf |
Given a boolean function with inputs, check if it's possible to only use IMPLY gate to express it.
There's no extra limitation on how you use this gate, and you can use each input for any amount of times. See examples below:
\$\begin{matrix}
\text{Expression}&&&&&\text{Solution}&\text{Your output}\\
a&0&0&1&1&a&\text{t... | stackexchange_codegolf |
Your task is to make a script with the shortest byte count, that reverses a word then replaces each letter with the next letter next in the alphabet.
Examples:
input: hi
output: ji
input: hello
output: pmmfi
input: test
output: utfu
A few notes:
Should the letter's value be 27 (z+1), assume it is an a.
Symbols, num... | stackexchange_codegolf |
Have you ever wanted to ask the compiler "Why?" Most of us have been frustrated when the code isn't working as it should. Mathworks has therefore implemented a nice little function, why, that answers the question. To give a few examples from MATLAB:
why
The programmer suggested it.
why
To fool the tall good and smart ... | stackexchange_codegolf |
Background
In France, and probably in the rest of the European Union, any food available for sale must list the ingredients that compose it on its packaging, in weight percentage descending order. However, the exact percentage doesn't have to be indicated, unless the ingredient is highlighted by the text or an image on... | stackexchange_codegolf |
Challenge
Given a whole number divisible by 9 and one missing digit, find the missing digit.
The missing digit may be represented by any character other than the digits 0-9 as long as it is consistent.
If the missing digit could be 0 or 9, output something to signify so.
Assume the user is intelligent enough to put onl... | stackexchange_codegolf |
It is fairly simple to, given a number n, create a range from 0 to n-1. In fact, many languages provide this operation as a builtin.
The following CJam program reads an integer, and then prints out such a range (Try it online!):
ri,
Notice that it prints out numbers without a separator.
The Challenge
Your task is to r... | 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 |
“Cut” a matrix of integers on the line where the sum of the absolute differences of “severed” neighbors is the least.
Example
Consider this matrix:
1 2 -4
5 -1 3
2 -2 0
It can be cut in 4 places, here shown by lines lettered A–D:
A B
╷ ╷
1 ╎ 2 ╎ -4
C ---╎----╎----
5 ╎ -1 ╎ 3
D ---╎----╎--... | stackexchange_codegolf |
Arturo is a bytecode-compiled/interpreted, garbage-collected general-purpose language filling a role similar to JavaScript, Python and Ruby. It is centered around the concept of blocks, which hold code just as easily as data. It uses fixed-arity prefix syntax and emphasizes the procedural and functional paradigms.
What... | stackexchange_codegolf |
Given a string as an input (which can be any acceptable/convenient format in your language), implement pendulum encoding. The test cases are split into individual items (which aren't quoted) for a visually appealing explanation.
How do I do that?
The current iteration index starts at 0.
If the iteration index is even,... | stackexchange_codegolf |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
As soon as the Elves get bored with the last week's game, Bin comes up with a new game. The rules are similar, except the Elves are supposed to say the numbers that have its "left side" equal to its "right side" when written in binary.... | stackexchange_codegolf |
Today we're going to build a pyramid out of letters! Here's an example letter pyramid for the first 5 letters:
Write the first 5 letters with a space between, first ascending and then descending.
A B C D E D C B A
Do the same thing for the first four letters on the line above, but with two extra leading spaces:
A B... | stackexchange_codegolf |
The input will be two five letter words. They don't actually have to be dictionary words, just any five letters each, all lowercase or all uppercase, your choice. Only A-Z will appear in the input words and they will always be 5 characters in length.
Your program is to score them both as though they were poker hands an... | stackexchange_codegolf |
This challenge is related to some of the MATL language's features, as part of the May 2018 Language of the Month event. Associated challenge: Function clipboard: copy.
Introduction
MATL's function clipboard stores ("copies") the inputs to the four most recent calls to normal, input-taking functions. Normal functions a... | 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 |
As we saw in this question complex logical statements can be expressed in terms of the simple connectives of generalized Minesweeper. However Generalized minesweeper still has redundancies.
In order to avoid these redundancies we define a new game called "Generalized-1 Minesweeper".
Generalized-1 Minesweeper is a vers... | stackexchange_codegolf |
Your task is simple, write a single code snippet that when executed in one language outputs only the string 'abc' and when executed in another language outputs only the string 'cba'. The program should take no input.
This is a code-golf challenge.
| stackexchange_codegolf |
Problem: given any input string that does not contain null bytes, determine whether or not the input string matches glob as defined below:
null is disallowed in both string in glob
* matches zero or more characters
** is disallowed in glob
? matches exactly 1 character
[ch] matches a character class o... | stackexchange_codegolf |
The Challenge
Given an integer, calculate its score as described below.
The score is calculated by raising each digit of the input Integer to the power n, where n denotes the index of the digit in Input (beginning with 1) when counted from left to right (the index of leftmost digit should be 1), and then summing them a... | stackexchange_codegolf |
Related: Interquine
Program A outputs program B's code when run, and B outputs C's source, and C outputs A's source.
This time you can't exchange two characters and exchange again :)
Requirements:
Only one language across all programs
Standard loopholes restrictions apply
All programs are different. One program th... | stackexchange_codegolf |
I've always liked screens full of randomly colored pixels. They're interesting to look at and the programs that draw them are fun to watch.
The challenge
Fill your screen, or a graphical window, with colored pixels.
The rules
Your program must have an even chance of picking all colors (i.e in the range #000000 to #FFF... | stackexchange_codegolf |
Curling is a sport where two teams aim to place stones as close to the centre of a target as possible. The winner of a curling end is the team whose stone is closest to the centre – they score as many points as the number of their stones closer to the centre than any of their opponents.
Task
Given two lists of pairs of... | stackexchange_codegolf |
Rolling a 1x1x2 block
This challenge is inspired by the game Bloxorz. Like that game, there is a 1x1x2 block, which may be moved on a square grid in any of the four cardinal directions. It moves by rotating 90 degrees about one of its edges which is touching the ground. Initially, the block is standing upright on a sin... | stackexchange_codegolf |
This challenge is inspired by Fortran's idiosyncratic implicit typing rules. Your task will be to determine the data type of the object GOD according to the implicit typing rules explained below.
Background
Fortran 77 has six data types: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL. Any object not e... | stackexchange_codegolf |
Dedicated to Martin Gardner, taken from his book
Background
In the old days, the Slavs had a divination method for finding out whether a girl would get married. The girl would clutch six straws in her hand so that the ends would poke out the top and bottom of her fist. Then her friend would join together the ends of pa... | stackexchange_codegolf |
You work for a social media platform, and are told to create a program in a language of your choice that will automatically flag certain post titles as "spam".
Your program must take the title as a string as input and output a truthy value if the title is spam, and a falsey value if not.
To qualify as non-spam, a title... | stackexchange_codegolf |
Introduction
Suppose you have a list of lists of integers (or any objects really, but let's stick to integers for simplicity).
The lists may be of different lengths, and some of them may be empty.
Let's write the lists in a tabular format:
[[ 1, 2, 3, 4, 5],
[ 6, 7],
[ 8, 9, 10, 11],
[],
[12, 13, 14... | stackexchange_codegolf |
Based on the "Pretty Ugly" poem.
Input consists of a number of stanzas (positive integer), and four arrays/lists of strings, called the "negatives", "negations", "positives", and "filler" sentences.
You must output a "pretty ugly" poem with the specified number of stanzas. A stanza consists of a negative, negation, pos... | stackexchange_codegolf |
Introduction:
Pete likes doing word search puzzles. Despite that, he has trouble searching for words vertically, (anti-)diagonally, or reversed. Because of that, he'll always search for the words left-to-right, and rotates the entire puzzle in increments of 45 degrees clockwise.
In addition to that, he'll also always s... | stackexchange_codegolf |
As the majority of nations using the Euro have the , as the decimal separator, you must use it also.
The task is to output all the values of the Euro coins and notes in ascending order. You must also put the trailing ,00 on the integer values.
0,01 0,02 0,05 0,10 0,20 0,50 1,00 2,00 5,00 10,00 20,00 50,00 100,00 200,0... | stackexchange_codegolf |
Daylight saving time (DST), is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. The typical implementation of DST is to set clocks forward by one hour in the spring ("spring forward") and set clocks back by one hour in autumn ("fall back") to re... | stackexchange_codegolf |
Many of you already know JSF**k. For those who don't, it's a script that basically turns any JavaScript code into something written using only []()!+.
Your task is to build, using any language of your choice, a program which converts JSF**k into unobfuscated JavaScript.
Input: A string with valid JSF**k code.
Output: ... | stackexchange_codegolf |
Given a list of positive integers as input you are to determine if there is a way to pair up the elements such that:
All but one element is in a pair
No element is in more than one pair
Every pair is of equal elements
No two pairs have elements separated by the same distance in the original list
For example if the in... | stackexchange_codegolf |
A store is having a big sale.
If your price reaches $199 or more, you can reduce it by $100.
You can buy each product only once.
Here's an example list of products: (in order to simplify, the names of the products are represented by letters)
+------+-------+
| name | price |
+------+-------+
| A | 26.9 |
| B | 2... | stackexchange_codegolf |
The Discordian calendar is an alternative calendar used by Discordians.
The discordian year has 5 seasons, each lasting 73 days: Chaos, Discord, Confusion, Bureaucracy, and The Aftermath.
The discordian week has 5 days: Sweetmorn, Boomtime, Pungenday, Prickle-Prickle, and Setting Orange. Every year begins with Sweetmo... | 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 |
Innovation is a card game where players battle through the ages, from prehistory to modern times, in an attempt to earn achievements faster than their opponents.
Each card in Innovation is unique, and provides a player with a number of icons. If we treat each card as a 2x3 grid, then three of the four slots on the left... | stackexchange_codegolf |
I'm not sure if this kind of golf is allowed, but here it is.
Your objective is to create an image containing one pixel of every possible RGB color. The image with the smallest file size wins.
Rules:
The image must be a PNG.
The image must contain exactly one of every possible RGB color.
Acceptable image dimensions ar... | stackexchange_codegolf |
Normally, we decompose a number into binary digits by assigning it with powers of 2, with a coefficient of 0 or 1 for each term:
25 = 1*16 + 1*8 + 0*4 + 0*2 + 1*1
The choice of 0 and 1 is... not very binary. We shall perform the true binary expansion by expanding with powers of 2, but with a coefficient of 1 or -1 ins... | stackexchange_codegolf |
Given the signal level L in the range 0-4. Your program should draw the following ASCII art.
When L=0:
....
....
.... ....
.... ....
.... .... ....
.... .... ....
.... .... .... ....
.... .... .... ....
.... .... .... ....
When L=1:
....
... | stackexchange_codegolf |
Write a program for a specific language that in different orientations performs different tasks.
Your code should have at least two non-empty lines and at least two non-empty columns and should complete at least one challenge from each category of challenges below when oriented in different ways.
Orientations
Your code... | stackexchange_codegolf |
Your task is to format an address given in all lowercase to a friendlier format. Here's the catch, no regexes.
Addresses will be given in the following format:
123 serpentine pl ne shoreline wa 98199
The expected output is the following: (notice the period and commas)
123 Serpentine Pl. NE, Shoreline WA, 98199
Formatt... | stackexchange_codegolf |
Introduction
In this challenge you will be solving diagonal Burrows-Wheeler transforms. Here is a general overview of what a diagonal Burrows-Wheeler transform is. To encode a message, you first must guarantee that it is odd in length (i.e. 5, 7, 9, etc.). Then you make a grid, n by n, where n is the length of the mess... | stackexchange_codegolf |
Your challenge is to output the number of twisted corners given a 2x2 Rubik's Cube scramble.
For the purpose of this challenge, twisted corners are defined as corners where the colour of the top/bottom face before (usually white or yellow) is not facing the top/bottom after the scramble.
Eg. if the cube were to be orie... | stackexchange_codegolf |
Context
As a conlanger, I am interested in creating a uniform, naturalistic language. One of the tricks is to create vocabulary according to certain structures of words. An example from English: In English, we have the word “tap” structured consonant-vowel-consonant. Usually, this means that there are many other words ... | stackexchange_codegolf |
Happy New Year 2024!
2024 is a tetrahedral number. A tetrahedral number is a number that can be represented in the form \$n(n+1)(n+2)/6\$ for some positive integer \$n\$. Or, equivalently, they are the sum of the first \$n\$ triangular numbers. They are also the number of objects in a triangular pyramid which has \$n\$... | stackexchange_codegolf |
Sometimes I make bad jokes... And a bad joke I like to make involves interpreting exclamation marks in sentences as the factorial sign.
Task
Your task is to write a program that receives a sentence and applies the factorial joke to the sentence.
The "factorial joke" consists of looking for exclamation marks "!" and doi... | stackexchange_codegolf |
Challenge
Given a polynomial \$p\$ with real coefficients of order \$1\$ and degree \$n\$, find another polynomial \$q\$ of degree at most \$n\$ such that \$(p∘q)(X) = p(q(X)) \equiv X \mod X^{n+1}\$, or in other words such that \$p(q(X)) = X + h(X)\$ where \$h\$ is an arbitrary polynomial with \$ord(h) \geqslant n+1\... | stackexchange_codegolf |
Background
Three years ago, this guy Tom Murphy got it into his head to extend the idea of a portmanteau to all words in a language and called this a portmantout (portmanteau plus tout [French for all]). Defining English as a list of 108,709 words, he managed to find a sequence of 611,820 letters with the following two... | stackexchange_codegolf |
Background
Scrabble is a word game in which players collaboratively build a board consisting of letter tiles that spell words. Each word must be connected to another word, and players gain points based on the letters they use and where they are placed. Words can be spelled either from left-to-right or top-to-bottom, an... | 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 |
Left in sandbox for at least 3 days.
I want to verify if this inequality is true:
for \$n\geq4\$, if \$a_1,a_2,a_3,\dots,a_n\in R_+\cup\{0\}\$ and \$\sum_{i=1}^na_i=1\$, then \$a_1a_2+a_2a_3+a_3a_4+\dots+a_{n-1}a_n+a_na_1\leq\frac{1}{4}\$.
Challenge
Write a piece of program which takes an integer n as input. It does th... | stackexchange_codegolf |
Disclaimer: ModTen is a fictional card game which was created for the sole purpose of this challenge.
The rules of ModTen
ModTen is played with a standard 52-card deck. Because the full rules are yet to be invented, we're going to focus on the hand ranking exclusively.
A winning hand in ModTen. Graphics from Wikipedia... | stackexchange_codegolf |
Update: It seems that the original question at math.SE was solved, there should be no 23 pieces solution.
The original problem is stated here over at math.SE
The task is writing a program that fits 22 copies (or perhaps 23) of the following pentacube into a 5x5x5 cube (back and front view).
The pentacube must be place... | stackexchange_codegolf |
Optimize the following function for number of tokens:
int length(int x)
{
switch (x)
{
case 1: return 1;
case 3: return 2;
case 7: return 3;
case 15: return 4;
case 31: return 5;
case 63: return 6;
case 127: return 7;
case 255: return 8;
case 511: return 9;
case 1023: ret... | stackexchange_codegolf |
Left in sandbox for at least 3 days.
I want to verify if this inequality is true:
for \$n\geq4\$, if \$a_1,a_2,a_3,\dots,a_n\in R_+\cup\{0\}\$ and \$\sum_{i=1}^na_i=1\$, then \$a_1a_2+a_2a_3+a_3a_4+\dots+a_{n-1}a_n+a_na_1\leq\frac{1}{4}\$.
Challenge
Write a piece of program which takes an integer n as input. It does th... | stackexchange_codegolf |
Pip is an imperative golfing language with infix operators. It also borrows some features from functional and array programming.
What general tips do you have for golfing in Pip? I'm looking for approaches and tricks that are commonly useful for code golf and are specific to Pip (e.g. "remove comments" is not an answer... | stackexchange_codegolf |
Given two strings \$A\$ and \$B\$ with edit (Levenshtein) distance \$x\$, find a third string with edit distance \$a\$ to \$A\$ and edit distance \$b\$ to \$B\$ so that \$a+b=x\$ and \$a=int(x/2)\$ (that is half of \$x\$ rounded down to the nearest integer).
The input is the two strings \$A\$ and \$B\$ and their edit d... | stackexchange_codegolf |
In my language Pyramid Scheme, there is a slightly funny construct: the empty triangle:
^
-
When given no arguments, it returns 0. To generate 1 using this construct, we could use this:
^
/!\
^---
-
This simply passes 0 to the negation function. We can continue negating this result:
^
/!\
---^
/!\
^---
-
... | stackexchange_codegolf |
The challenge is to make any Roman numerals valid code in your chosen language.
They should not appear inside of strings or anything similar, but work just like any other tokens, literals such as (Arabic) numbers, characters or strings; or variable/method/function identifiers, etc.
For instance, in Java, the following... | stackexchange_codegolf |
Super simple challenge today, or is it?
I feel like we've heard a fair bit about double speak recently, well let's define it in a codable way...
Double speak is when each and every character in a string of text is immediately repeated. For example:
"DDoouubbllee ssppeeaakk!!"
The Rules
Write code which accepts one ... | stackexchange_codegolf |
Now that I'm thoroughly addicted to Code Golf, it's probably about time that I try to pick up a few golfing languages.
Given that I play almost exclusively in JavaScript, Japt seems like the logical language to start with. I'll be diving into the documentation at the next opportunity I get but, in the meantime, please ... | stackexchange_codegolf |
A simple way to scramble a 2x2x2 Rubik's cube is to make a sequence random moves. This is not how official scrambles are done, but can get pretty close to a uniform distribution of all possible scramble states. Due to the way a 2x2 only has two layers, doing one turn on one face is equivalent (without considering the p... | stackexchange_codegolf |
The narcissist is a program which, given its own source as input, prints a truthy value and, given anything other than that, prints a falsey value. Today, we're reversing this.
Create a program that, given the name of whatever your language's truthy value is (True, true, 1), prints its own source. Given the name of wha... | stackexchange_codegolf |
Given:
a 12 hour time t in hours and minutes,
a rotation r in degrees,
return the time shown when an analog clock that is displaying the time t is rotated r degrees clockwise.
After rotation, the hour hand will not line up with the new position of the minute hand. To correct for this, the new hour can be derived fro... | stackexchange_codegolf |
The generalised harmonic number of order \$m\$ of \$n\$ is
$$H_{n,m} = \sum^n_{k=1} \frac 1 {k^m}$$
In this challenge, we'll be considering the generalised harmonic numbers of order \$2\$:
$$H_{n,2} = \sum^n_{k=1} \frac 1 {k^2}$$
This sequence begins \$1, \frac 5 4, \frac {49} {36}, \frac {205} {144}, \dots\$ and conve... | stackexchange_codegolf |
Introduction
Here at code colf SE, we appear to love meta-problems. Here, I've tried to compose a meta-problem that's an interesting, not-straightforward challenge.
Challenge
The answer code is allowed to read its own source code, but not allowed to use external resources.
All characters should be 5-lines tall. Charact... | stackexchange_codegolf |
Imagine you are given an array/string containing \$5\$ letters of the English alphabet, with each letter having any value from A to Z (inclusive).
Every day, each letter will perform a job, which can affect itself or other letters in the array. The letter's job is determined by the letter itself.
Most letters are, due ... | stackexchange_codegolf |
It's a well-known fact that Fermat's Last Theorem is true. More specifically, that for any integer \$n \gt 2\$, there are no three integers \$a, b, c\$ such that
$$a^n + b^n = c^n$$
However, there are a number of near misses. For example,
$$6^3 + 8^3 = 9^3 - 1$$
We'll call a triple of integers \$(a, b, c)\$ a "Fermat n... | stackexchange_codegolf |
It's a well-known fact that Fermat's Last Theorem is true. More specifically, that for any integer \$n \gt 2\$, there are no three integers \$a, b, c\$ such that
$$a^n + b^n = c^n$$
However, there are a number of near misses. For example,
$$6^3 + 8^3 = 9^3 - 1$$
We'll call a triple of integers \$(a, b, c)\$ a "Fermat n... | stackexchange_codegolf |
Wanna be an Alchemist
I've been watching Full Metal Alchemist these past days and I've been wondering, It is really possible to trans-mutate matter? In the real world, I don't know if it is possible, but in the machine world, we think we "can".
Problem
Your task is, Given an input of N chemical elements (K, Mg, C, O, ... | stackexchange_codegolf |
Your task is to create a program that adds random numbers to previous sums in the ultimate number racing showdown.
Each racer (column) starts at 0 and adds either 1 or 0 to the previous sum at each step of the race until all of the racers reach the score required to win. The 1 or 0 should be chosen at random (the stand... | stackexchange_codegolf |
When I was posting answers for the Husk Language of The Month thread, I realized it took more time to enter them in the thread than it took to actually write the answers. So, why not automate it?
Write a program/function which inputs a language name, and displays all answers in that language during the current month so... | stackexchange_codegolf |
You're with your best bud, Jim, at the amusement park and as your favorite ride comes into view, you and Jim exchange glances. Naturally you race to get in line. Unfortunately he wins because you're a golfer and he plays a real sport (sorry friends). In fact, you're so far behind that you and Jim are separated by x peo... | stackexchange_codegolf |
Given a non-negative integer input, write a program that converts the number to hexadecimal and returns a truthy value if the hexadecimal form of the number contains only the characters A through F and a falsey value otherwise.
Test cases
10
==> True (A in hexadecimal)
100
==> False (64 in hexadecimal)
161
==> False... | stackexchange_codegolf |
This challenge is a sequel to Letter Boxed Validator.
The New York Times has a daily online game called Letter Boxed (the link is behind a paywall; the game is also described here), presented on a square as follows:
You are given 4 groups of 3 letters (each group corresponds to one side on the picture); no letter appe... | stackexchange_codegolf |
Your challenge is to write a polyglot that works in different versions of your language. When run, it will always output the language version.
Rules
Your program should work in at least two versions of your language.
Your program's output should only be the version number. No extraneous data.
Your program may use what... | stackexchange_codegolf |
Background
A rooted tree is an acyclic graph such that there is exactly one path from one node, called the root, to each other node. A node v is called the parent of another node u if and only if the path from the root to u goes through v and there is an edge connecting u and v. If node v is the parent of node u, node ... | stackexchange_codegolf |
I don't like numbers, but I do like the Fibonacci sequence. I'm sure we could work something out.
Please read one integer n from STDIN and output the nth Fibonacci number in base 26 (abcdefghijklmnopqrstuvwxyz instead of 0123456789) to STDOUT.
The first Fibonacci number is 0. The second one is 1. The nth fibonacci num... | stackexchange_codegolf |
Given some raw HTML, sanitize it by formatting the spaces, as defined below.
Output rules:
Like many challenges, this one is inspired by XKCD.
First, "untag" all tags with nothing but spaces in them. (<i>te<b> </b>xt</i> becomes <i>te xt</i>). If a tag has nothing in it (like <b></b>, simply delete it and move o... | stackexchange_codegolf |
The sequence discussed in this challenge is a variant of the Descending Dungeons sequence family. Specifically, the sequence generation rules:
(A_b = A's base 10 representation read as a base b number, A = A_10)
A(0) = 10
A(n) = 10_(11_(12_(...(n+9)_(n+10))))
Your goal is to make a program which accepts a nonnegative ... | stackexchange_codegolf |
Your task is, to count how many pluses I have.
What Pluses?
The no plus: 0 Points
-
The naïve Plus: 1 Point
+
The double Plus: 2 Points
+
+++
+
The mega double plus: 3 Points
+
+++
+
+ + +
+++++++++
+ + +
+
+++
+
Pluses of higher order than 3 must be ignored.
Rules
Input will ... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.