instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
With the US election going on right now, I noticed that there is one (completely meaningless, but still) thing which Trump can still achieve and which is out of reach for Biden: Having the won states being connected.
Task: Given a list of strings of two-letter abbreviations (see below) for US states, determine whether ... | stackexchange_codegolf |
Your challenge is simple. You need to write a program that prints to either STDOUT or a file the year the language it is written in was released. Because this is such a simple task, the twist is that it must be written in as many different languages as possible.
Your score is the total number of different years that ar... | 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 |
Given a string consisting of ()[]{}, print the paired brackets in the same order as they appear in the string.
Any opening bracket ([{ can be paired with any closing bracket )]}.
For example:
({()[}]]
returns:
(], {], (), [}
Rules
A string consisting of ()[]{} should be received as the input
The bracket-pairs should ... | stackexchange_codegolf |
Given a number n, print the nth prime Fermat number, where the Fermat numbers are of the form 22k+1. This code should theoretically work for any n (i.e. don't hardcode it), although it is not expected to terminate for n > 4. (It should not return 4294967297 for n=5, as 4294967297 is not a prime number.)
Do note that wh... | stackexchange_codegolf |
Inspired by this Puzzling challenge.
Challenge
Given a 2D rectangular grid where each cell is either an empty space or a wall, find the path (or one of the paths) from the top left cell to the bottom right, which satisfies the following:
Only movement to one of four adjacent cells is allowed.
The path breaks (or passe... | stackexchange_codegolf |
Let's map some strings to 2d space, fractal style. Your task is to compute a Hilbert curve and lay a string along it.
Task
The task is to take the single-line input string, and lay it out along a Hilbert curve big enough to contain it, but no bigger. Try to make the byte count as low as possible; this is code-golf aft... | stackexchange_codegolf |
Letter dice are common in word games. It can be fun to try to spell funny words with boggle dice, for instance. If you grab a handful of dice, chances are you won't be able to spell certain words. This challenge is a generalization of that idea.
Challenge
Given a list of dice which each have at least 1 face and a word,... | stackexchange_codegolf |
Preamble
A common pain-point when working with rational numbers and decimals is how infrequently one can represent their rational number as a clean, non-repeating decimal. Let's solve this by writing a program to decimalize (not to be confused with decimate) them for us!
The Challenge
Given a fraction, check if it can ... | stackexchange_codegolf |
Your challenge is to passwordify the string! What is passwordifying, you ask?
Take a string as input. This string will only contain uppercase letters, lowercase letters, digits, and spaces.
You must replace all spaces with underscores and move all numbers to the end of the string in the order that they appear from lef... | stackexchange_codegolf |
Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice couple of words twice in succession.
To make sure make sure other people are not bothered by this, your task is to write a program that resolves this problem!
Task
Given an input string (if it matters f... | stackexchange_codegolf |
There is an asdfmovie video about a pie flavoured pie. Someone also made an edited version with more pies, so I created this challenge.
The input is a positive integer.
The code should first output the following string:
I baked you a pie!
Oh boy, what flavour?
Then, the next line should be PIE (input number of times)... | stackexchange_codegolf |
You need to make a program, that when giving a list and a string, searches on the list for items that contains the string.
Examples:
Input: th [thing, awesome, potato, example]
Output: thing (Because it starts with "th")
Input: ing [thing, potato]
Output: thing (Because it ends with "ing")
Input: tat [thing, potato]
... | stackexchange_codegolf |
The task is simple, post 2 code snippets that perform the same task, where one seems very optimized at first glance, but actually is significantly slower than the other.
Only one rule:
Both snippets must finish with the exact same output (for the same given input, if any).
| stackexchange_codegolf |
This is a problem that the Hacker Cup team made for the 2018 Facebook Hacker Cup, but we ended up not using it (though Ethan struggles through a variety of other challenges). Normally code size isn't a factor in the Hacker Cup, but we thought this would make for an interesting code golf challenge. We look forward to se... | stackexchange_codegolf |
The alternating factorial is an alternating sum of decreasing factorials. For example, we could calculate the alternating factorial of 4 as follows:
First, calculate the factorials from 4 down to 1:
$$
4!\quad3!\quad2!\quad1!\quad = \\
4\cdot3\cdot2\cdot1\qquad3\cdot2\cdot1\qquad2\cdot1\qquad1\quad= \\
24\quad6\quad2... | stackexchange_codegolf |
This task is a classic programming task: Implement a regular expression parser. That is, write a program or function which takes a string describing a regular expression and a candidate string, and test whether the complete candidate string matches the regular expression. You may assume that the regular expression pass... | stackexchange_codegolf |
Given the number of vertices n ≥ 3 and the "step size" 1 ≤ m < n/2 (indicating the distance between two connected vertices), output a graphical representation of the corresponding regular polygram. If the polygram consist of multiple closed loops, each loop must be rendered in a different line colour. (If this sounds ... | stackexchange_codegolf |
The House of Santa Claus
Note: This is the first challenge that I have attempted to set. It has been through the Sandbox however if you find something wrong with it please do not just downvote but leave a comment so that I can improve it.
Background
There is a old childrens puzzle where the challenge is to draw a box w... | stackexchange_codegolf |
Objective
Given an integer \$n\$ interpreted as two's complement binary, output two integers, namely the integer consisting of \$n\$'s bits at places of \$2^0, 2^2, 2^4, \cdots\$, and the integer consisting of \$n\$'s bits at places of \$2^1, 2^3, 2^5, \cdots\$.
Note that the input may be negative. Since \$n\$ is inter... | stackexchange_codegolf |
The challenge
Well, I think it is quite clear, isn't it? You have to make a function or a program that takes a string as an argument and outputs the corrispondent Yoda-speaking.
This is code-golf, so least number of bytes wins.
The input
The input could be any string without linefeed. You can translate a string if it i... | stackexchange_codegolf |
Wow, time really flies! It's already been one year since the debut of the Code Golf Stack Exchange site design. Let's celebrate this milestone with a code golf challenge... to imitate the site logo!
Golf a program that outputs a graphic of a medal enclosed in curly braces {}, along with two lines of text containing COD... | stackexchange_codegolf |
Not to be confused with this question.
You need to draw a times table (also known as Cremona's method for cardioid generation) as shown in this video. The number \$n\$ and \$k\$ will be the inputs.
In the video n and k are 2 and 10 respectively.
How to draw?
Draw a circle, divide its perimeter into equal spaced parts... | stackexchange_codegolf |
What I want:
Quite simply, I want a text based display, that asks for an input, n, then shows that value on the display! But there's a catch. Each of the 'true' 'pixels' (the ones filled in) has to be represented by that number n..
Example :
You are given an input n. You can assume n will be a single digit
Input: 0
O... | stackexchange_codegolf |
In any programming language, make a program that outputs infinite subsequent powers of two, starting at any power of two with finite integer exponent. There does not need to be a seperator between outputs.
Note: it only has to theoretically output infinite subequent powers of two given infinite integer size (so you can... | stackexchange_codegolf |
A ragged list is a (finite depth) list where each element is either a positive integer or a ragged list.
A ragged list is properly tiered if it contains either all positive integers or all properly tiered ragged lists.
For example [1,2,3,6] is properly tiered because it is a list of only positive integers. [[1,2],[[1]... | stackexchange_codegolf |
This function should take four integer inputs (a,b,c,d) and return a binary word based on which values equal the maximum of the four.
The return value will be between 1 and 0xF.
For example:
a = 6, b = 77, c = 1, d = 4
returns 2 (binary 0010; only 2nd-least significant bit is set corresponding to b being sole max value... | stackexchange_codegolf |
Cops' Challenge
Robbers' challenge here.
It has now been four days since the challenge was posted so all new answers should be marked as non-competing in the title. These answers can still be cracked by robbers but will not go towards their total, and cannot win this challenge.
In this cops-and-robbers challenge, you... | stackexchange_codegolf |
Some of you may say that I am wasting my time, but this task does not give me peace for more than 500 days. It is required to write a program in Python 3.x that takes two numbers as input and displays their sum. The numbers are given in the following format:
a b
Some example test cases:
100 500 -> 600
3 4 -> 7
Th... | stackexchange_codegolf |
A marquee is a low-tech board that allows customizable letters. For example, here is a marquee:
SALE ON SNEAKERS
However, someone might come along and vandalize it by removing letters to send a different message:
S N AKE
Given two non-empty string inputs, an original message and a new message, determine whethe... | stackexchange_codegolf |
Given a sequence of three integers, determine if the sequence is arithmetic (of the form [a, a+d, a+2*d]) or geometric (of the form [a, a*r, a*r^2]) by outputting a fourth term that completes it (a+3*d for arithmetic, a*r^3 for geometric).
Examples:
[1, 2, 3] -> 4 (This is an arithmetic sequence with a difference of 1)... | stackexchange_codegolf |
Most computer keyboards feature a small integrated LED light,
indicating the current input mode, as controlled with the CAPS LOCK button.
Your task is to blink it:
Turn it on;
Wait for 0.5 (+/-0.1) seconds;
Turn it off again.
Video footage of the LED blinking is highly appreciated !
Rules
You can blink a different ... | stackexchange_codegolf |
Let's begin with a thought experiment. You have a clock and a timer, in which you start the timer when the clock shows exactly hh:mm.00.
Clock: The clock employs 24-hour time. So the range of hh is 0<=h<23. (Because 23 inputs are unsolvable, you aren't required to handle that)
Timer: It starts exactly on 00.00. The nu... | stackexchange_codegolf |
99 bugs in the code
The adaption of "99 bottles of beer on the wall" for computer science where the bugs increase instead of the bottles decreasing is often re-posted around the internet. Example T-Shirt Here.
I think it'll be interesting to see potential recursion and random number generation across a huge variety of ... | stackexchange_codegolf |
Once upon a time I wanted to order custom tokens for a board game. They say they can do it, and then they present me their price list. I was confused because they charge per inch of head movement, and I have no idea how much will my tokens cost.
INPUT: a 2d grid:
|,-,\,/ are straight cuts. Each has a length of 1.
┌,┐,... | stackexchange_codegolf |
Introduction:
(Source: Wikipedia)
When we look at a rainbow it will always have the colors from top to bottom:
Red; orange; yellow; green; blue; indigo; violet
If we look at these individual rings, the red ring is of course bigger than the violet ring.
In addition, it's also possible to have two or even three rainbow ... | stackexchange_codegolf |
The Challenge
Write a program or function that takes no input and outputs a 3-dimensional vector of length \$1\$ in a theoretically uniform random direction.
This is equivalent to a random point on the sphere described by $$x^2+y^2+z^2=1$$
resulting in a distribution like such
Output
Three floats from a theoretically ... | stackexchange_codegolf |
I recently found out about the Fishing language, and it is now a favorite of mine. However, I'm finding it difficult to do anything cool with it, including code golf. Are there any tips for golfing with Fishing to use the least characters? And any string manipulation tricks would be cool, as I am finding that difficult... | stackexchange_codegolf |
Given an input sentence consisting of one or more words [a-z]+ and zero or more spaces , output an ASCII-art histogram (bar graph) of the letter distribution of the input sentence.
The histogram must be laid out horizontally, i.e. with the letter key along the bottom in alphabetical order from left to right, with a Y-a... | stackexchange_codegolf |
99 bugs in the code
The adaption of "99 bottles of beer on the wall" for computer science where the bugs increase instead of the bottles decreasing is often re-posted around the internet. Example T-Shirt Here.
I think it'll be interesting to see potential recursion and random number generation across a huge variety of ... | stackexchange_codegolf |
Jelly has an "untruth" atom: Ṭ. This takes a non-empty array of positive integers and returns a Boolean array with 1s at the indexes in the input. For example:
[1,3,5,6]Ṭ ⁼ [1,0,1,0,1,1]
[5]Ṭ ⁼ [0,0,0,0,1]
[2,1,1,2]Ṭ ⁼ [1,1]
[5,4,3]Ṭ ⁼ [0,0,1,1,1]
[1]Ṭ ⁼ [1]
Try it online!
Note that Jelly uses 1-indexing... | stackexchange_codegolf |
You are working as an intern for a mathematician who really hates TeX, LaTeX, etc. So much so that he has decided to abandon all typesetting whatsoever and make you do all the formatting in ASCII. You got tired of this after a while and decided to start automating parts of it, starting with square roots.
Here's how a s... | stackexchange_codegolf |
Given two strings as input, return the result of XORing the code-points of one string against the code points of the other.
For each character in the first input string, take the code-point (e.g. for A, this is 65) and XOR the value against the corresponding index in the second string and output the character at the co... | stackexchange_codegolf |
Develop a program which takes two arrays of decimal numbers, and compare the sum of whole numbers only and the decimal part. If the sums of the whole numbers are the same, and the decimal parts of Array a are a subset of the decimal parts of Array b, return True. Otherwise, return False.
Example-1 :-
Array a ={2.5,3.0,... | stackexchange_codegolf |
Your task is to write a program which implements a bijection \$\mathbb{N}^n\to\mathbb{N}\$ for \$n \ge 1\$. Your program should take \$n\$ natural numbers as input, in any acceptable method (including taking them as a single, \$n\$ element list/array) and output a unique natural number for all possible inputs.
In layma... | stackexchange_codegolf |
Miller-Rabin test
Given a base \$b\$ and an odd number \$n\$:
Write \$n\$ as \$2^{s}\times d + 1\$ where \$d\$ is odd
\$n\$ is a strong probable prime if either:
\$b^d\equiv 1 \pmod n\$
\$b^{d\cdot2^r}\equiv -1 \pmod n\$
for any non-negative \$r\$ strictly less than \$s\$.
A strong probable prime which is composite ... | stackexchange_codegolf |
Unless you have a userscript that modifies the site's design (or even if so), you should have noticed that we have our site design!
(It's November now)
So, to celebrate, let's make a program that retroactively applies this design (oversimplified, of course)!
So, the most important changes are:
our new name is now Code... | stackexchange_codegolf |
Gozinta Chains
(Inspired by Project Euler #606)
A gozinta chain for n is a sequence {1,a,b,...,n} where each element properly divides the next.
For example, there are eight distinct gozinta chains for 12:
{1,12}, {1,2,12}, {1,2,4,12}, {1,2,6,12}, {1,3,12}, {1,3,6,12}, {1,4,12} and {1,6,12}.
The Challenge
Write a progr... | stackexchange_codegolf |
Background
Roman numeral is a simple number system with the following properties:
Each symbol in the system maps to a specific value. (e.g. I = 1, V = 5, X = 10, C = 100)
The value of a Roman numeral can be evaluated as follows:
First, find all occurrences of adjacent pairs of symbols where a strictly smaller-valued ... | stackexchange_codegolf |
Challenge
Given a positive integer n, you must calculate the nth digit of \$e\$, where \$e\$ is Euler's number (2.71828...).
The format of the output can be a number or a string (e.g., 3 or '3')
Example
# e = 2.71828...
nthDigit(3) => 8
nthDigit(1) => 7
nthDigit(4) => 2
Shortest code wins.
| stackexchange_codegolf |
The JavaScript compressor RegPack uses a very simple string compression algorithm. Given a piece of code, it will make a list of characters that aren't used in that code and use them to delimit repeated strings that are inserted back into the string.
To show how strings are compressed, it's necessary to show how the de... | stackexchange_codegolf |
Sometimes in chat, if someone says something you agree with, you'll send a message with an ^, which points at the message above:
Radvylf: Cats are far superior to JavaScript
You: ^
Sometimes you'll also add some text:
Radvylf: I sure do like integers
You: I mostly agree with ^ but floats are pretty neat too
You can a... | stackexchange_codegolf |
Requirement: Write a program (in any language) that counts the number of lines of code in files matching *.sh in the directory tree starting from the directory that the program is executed in, excluding lines that are empty, only contain whitespace, or are just single-line comments (a line which the first character tha... | stackexchange_codegolf |
Given two inputs, a distance \$d\$ and a number \$n\$ output a list of \$n\$ random colors which each have distance \$d\$ from the previous.
Background
A random walk is a path which is defined by choosing a random direction and (usually) fixed distance to go at each step. We will be taking a random walk through the RGB... | stackexchange_codegolf |
Input: you are given 2 integers, n and k. n is a positive (>= 1) integer, and k an integer, which is the number of times you are allowed to use n.
Output: output all of the non-negative integers that can be formed using at most k n's using these mathematical operations: +, -, *, /, and parentheses.
Edit: if your lang... | stackexchange_codegolf |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
The story continues from AoC2016 Day 2, Part 2.
You finally figure out the bathroom code (on the weird diamond-shaped keypad) and open the bathroom door. And then you see another door behind it, with yet another keypad design:
For those who... | stackexchange_codegolf |
I like to pretty print multidimensional arrays, like this:
[ [ [1, 2, 3],
[4, 5, 6] ],
[ [7, 8, 9],
[6, 4, 2] ] ]
But it's a pain to do by hand and it'd be nice to have a program that does this for me. Your challenge is to create a program that does this for me, taking a multidimensional array containing onl... | stackexchange_codegolf |
The challenge is simple: Print the last, middle, and first character of your program's source code, in that order.
The middle character is defined as follows, assuming a source length of n characters, and 1-indexing:
If n is even, print the n/2-th and n/2 + 1-th character. (abcdef == cd)
If n is odd, print (n-1)/2 + 1... | stackexchange_codegolf |
Sometimes when you're lying in bed and reading a message, your phone screen will pop into landscape mode right in the middle of a sentence. Only being able to read left to right, you find yourself incapacitated, unable to process the text in front of you.
To ensure that this won't happen again, you decide to make every... | stackexchange_codegolf |
Background
You have just learned what combinatory logic is. Intrigued by the various combinators you spend quite a bit of time learning about them. You finally stumble upon this particular expression:
(S I I (S I I))
You notice that when trying to reduce it to its normal form, it reduces to itself after three steps:
(... | stackexchange_codegolf |
There is a Sioux village. It has a totem:
__
___| |___
\/ \ / \/
/\ ``| |`` /\
/^^\ | | /^^\
/ /\ \ | | / /\ \
''''''''''''''''''''''''''''
The totem lets the Sioux mastering the weather for helping in their different tasks. Help the villagers p... | stackexchange_codegolf |
Given a list of math expressions that all hold true and consist of modulo remainder calculations with two numbers and a result, your task is to yield the first n numbers that hold true for all the statements in the list.
For example:
[m % 3 = 0, m % 4 = 1, m % 5 = 3], where % is the modulo operator.
For n = 3, the fir... | stackexchange_codegolf |
Task is pretty simple. Your program should take a number N from 1 to 20 and draw the following ASCII art.
When N=1:
_____
| | |
| | |
| | |
| | |
| | |
| | |
| | |
|_|_|
\ /
\-/
v
When N=2:
_______
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| ... | stackexchange_codegolf |
I encountered some silly code from a game and I figured this would actually turn into a fun golfing problem, so:
Given any ASCII string in the limited char range specified below.
Append as few characters as possible such that, given:
i = 1
sum = 0
for char in string
sum += char.intval * i++
end for
sum % 1000 == 0
W... | stackexchange_codegolf |
The Matoran Alphabet is the alphabet used by many of the characters in the Bionicle universe.
Your challenge is to create a program or function that takes a string as input and creates an image of the input written in the Matoran alphabet.
The input will only consist of uppercase letters (A-Z), numbers (0-9), and spac... | stackexchange_codegolf |
As a fan of an at most moderately successful footballBE team, towards the end of the season I often wonder whether my favourite team still has any theoretical chance left of becoming champion. Your task in this challenge is to answer that question for me.
Input
You will recieve three inputs: the current table, the lis... | stackexchange_codegolf |
ed is the standard text editor on Unix systems. Your goal is to write an ed clone.
Task
Write a program that reads an input stream and for every received end of line character, print ? followed by a end of line character.
The communication has to interactive. Means the program needs to output as soon as possible and h... | stackexchange_codegolf |
A lipogram is a block of words that omits a particular symbol. Right now, I am avoiding our fifth symbol of 26 that commonly show up. You should know by now what I am omitting. If not, look up "lipogram" and you will know.
Your Task
With a char, a blank, and a following string (blanks may show up in this; with only ASC... | stackexchange_codegolf |
This challenge is a harder version of this one.
A variable number of trits is an array of 0 or more trits (a trit is a ternary digit). So [0, 2, 2, 1] is a variable number of trits, but so is [].
Write a function or program that, given an non-negative integer returns a variable number of trits such that every integer h... | stackexchange_codegolf |
Kakuro Combinations
Because I can't do mental arithmetic, I often struggle with the Kakuro Puzzle, which requires the victim to repeatedly work out which distinct numbers in the range 1 to 9 (inclusive) sum to another number in range 1 to 45 when you know how many numbers there are. For example, if you may want to know... | stackexchange_codegolf |
The goal is to get all combinations of hold'em starting hands (every two card combination) in the shortest amount of code.
A hold'em hand is two distinct cards dealt from a standard deck of 52 cards, with deal-order being irrelevant, as such there are 52*51/2 = 1326, hands.
There is also a commonly used notation for th... | stackexchange_codegolf |
Today I installed MonoGame and ran the test application, which creates a basic colored window. I was surprised to see that the process was using 32.2 MiB of memory, and I thought it could be improved.
Your challenge is to write a program that creates a 640 by 480 window displaying only black pixels. Whatever program u... | stackexchange_codegolf |
Background:
Jack is a pumpkin that enjoys spooking the citizens of the villages near his pumpkin patch every Halloween. However, every year after someone lights the candle inside of him, he has a limited amount of time to spook everyone before the candle burns out, thus being unable to spook any more villagers because... | stackexchange_codegolf |
Introduction
Recently, me and a couple of my friends decided to play some cards, and one of them suggested the game 'Irish Snap', which was the inspiration for this challenge. However, I later learnt that the game has a lot of different rules that you can play with, some of which are listed here. The rules that are in... | stackexchange_codegolf |
Challenge
You will be given an input string, anywhere the word "Lemon" is found it should be converted to "Lemonade" but the a, d, and e must be borrowed from somewhere else in the sentence.
Example
Example Input:
I found a lemon when I was a kid
Example Output:
I foun a lemonade whn I was kid
The Lemonade was c... | stackexchange_codegolf |
Introduction:
Inspired by these two SO questions (no doubt from the same class): print the elements in the subarray of maximum sum without adjacent elements java and Maximum sum of non adjacent elements of an array, to be printed.
Challenge:
Given a list of integers, output a subsequence consisting of non-adjacent elem... | stackexchange_codegolf |
The challenge
Find the smallest feedforward neural network such that, given any 3-dimensional input vector \$(a,b,c)\$ with integer entries in \$[-10,10]\$, the network outputs the largest (i.e., "most positive") root of the polynomial \$x^3+ax^2+bx+c\$ with error strictly smaller than \$0.1\$.
Admissibility
The notion... | stackexchange_codegolf |
The idea for this code-challenge is simple: given a matrix of integers, let's sort it by applying Rubik-style movements. This means that you can select a single row or column and rotate its elements in any direction:
[1, 3, 2, 4] => [3, 2, 4, 1] (rotate left for rows/up for columns)
[1, 3, 2, 4] => [4, 1, 3, 2] (rota... | stackexchange_codegolf |
In this challenge, you need to find a specific pixel within an photograph (taken with a real camera).
You are passed an (R, G, B) tuple and an image, and you need to return a point (x,y) within the image that matches the RGB color given. The image may have multiple points that match the color; you only need to find 1.... | stackexchange_codegolf |
Challenge
Given a positive integer, determine whether that number is currently being used to represent a question on PPCG.
The question must not have been removed, but may be open or closed.
The number is the one being used in the URL of the question, such as:
https://codegolf.stackexchange.com/questions/[input]
Note... | stackexchange_codegolf |
This is a successor to a previous challenge.
Input
An integer \$1 \leq n \leq 5\$.
Task
Your code should produce all strings that satisfy the following properties:
Your string should contain exactly two each of the first \$n\$ letters of the alphabet.
It should not contain the same letter twice in a row
It must start ... | stackexchange_codegolf |
Seven countries lay official claims to parts of Antarctica: Argentina, Australia, Chile, France, New Zealand, Norway, and the United Kingdom. We will focus only on the claims of the main Antarctic landmass south of 60° S, which are:
Chile: between 90° W and 53° W
United Kingdom: between 80° W and 20° W
Argentina: betw... | stackexchange_codegolf |
As an exercise, I've created a simple solution for this challenge, in x86 Assembly Language. I'm running this with FASM on Windows. Here's my source code:
format PE console
entry start
include 'WIN32A.inc'
section '.text' code executable
start:
push char ; Start at 'A'
call [printf] ; ... | stackexchange_codegolf |
In this challenge you will be simulating a frog jumping from lily-pad to lily-pad in a pond. A frog's jump distance is uniquely determined by the size of the lily pad it jumps from. So for example there are lily-pads that let a frog jump 1 unit, lily-pads that let a frog jump 2 units etc. A frog can never jump more ... | stackexchange_codegolf |
Related
Sometimes when I use my microwave, I do a little trolling and enter times such as 2:90 instead of 3:30 because they end up being the same time anyway. The microwave happily accepts this and starts counting down from 2:90, displaying times like 2:86 and 2:69 until it gets back to a stage where it can count down... | stackexchange_codegolf |
A room can be made up of connected rectangles, for instance an L-shaped room. Such a room can be described by a list of dimensions describing the size of each rectangle.
Assume you have two input lists. The first contains the width of rectangles stacked vertically over each other. The second contains the height of the... | stackexchange_codegolf |
Consider a positive integer N written in base b. A sequence is generated from this number by finding the largest digit d in the expansion of N and writing N in base d+1, repeating until the base the number is written in can be decreased no further. For example, the sequence generated by 346 (10) in starting base 16 has... | stackexchange_codegolf |
Challenge
For this challenge, a mountainous string is one that conforms to the grammar rule M: x(Mx)* where at each production, the all x's are the same character. When indented, a mountainous string might look something like this:
A
B
C
D
C
E
F
E
C
B
A
As you can see, it looks a bit like a mounta... | stackexchange_codegolf |
Given a string, if it is even, break the string into 2 even parts, then reverse the parts to get the "reversencoded" string.
Example:
onomatopoeia -> tamonoaieopo
If the string is not of even length, then do not change the position of the middle character, and reverse the letters before and after the middle character.
... | stackexchange_codegolf |
Here’s the picture of the first published picture of the Mandelbrot set.
Use the fewest bytes possible to write a program or function that outputs the following.
A trailing new line is permitted. Character * cannot be replaced by any other character.
Useful information: Center is \$(-0.75, 0)\$, \$\Delta x = 0.035\$, ... | stackexchange_codegolf |
This is a relatively simple question. I'm trying to golf a Snake game I've written, and I'm trying to work out if there's a way to golf the following conditional assignments which control x and y coordinates of the snake ensuring a wrap around of the play area:
if (P<0) {
P = T-1;
}
if (P>T-1) {
P = 0;
}
if (Q<0) {... | stackexchange_codegolf |
Given a double-precision float, find the closest double-precision float whose binary representation is a palindrome.
Input
A floating point number x. You may use any format you like for input, but the format you chose must be able to represent every possible IEEE 754 binary64 value, including denormals, distinct repres... | stackexchange_codegolf |
The pyramid begins with the row 1 1. We'll call this row 1. For each subsequent row, start with the previous row and insert the current row number between every adjacent pair of numbers that sums to the current row number.
$$
1\quad1\\
1\quad\color{red}{2}\quad1\\
1\quad\color{red}{3}\quad2\quad\color{red}{3}\quad1\\
1... | stackexchange_codegolf |
Challenge
Given a positive integer, determine whether it is a triangular number, and accordingly output one of any two constant, distinct values.
Definition
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 \$\fr... | stackexchange_codegolf |
You should code a piece of code that looks like it outputs the language name but actually outputs the name reversed.
E.g. a Python program should look like it outputs Python but should actually output nohtyP.
The winner is the answer with the most upvotes in a week!
| stackexchange_codegolf |
Introduction
In this challenge, we will be dealing with a certain infinite undirected graph, which I call the high divisor graph.
Its nodes are the integers starting from 2.
There is an edge between two nodes a < b if a divides b and a2 ≥ b.
The subgraph formed by the range from 2 to 18 looks like this:
16-8 12 18
\|... | stackexchange_codegolf |
Situation: You are a high school teacher, teaching your computing class how to write C programs. However, since it is just the beginning of the term, you haven't taught them about the importance of indentation and spacing. As you are marking their work, your eyes hurt so much you scream in agony, and realise that this ... | stackexchange_codegolf |
You find yourself on a chessboard, as one does. You can see the exit but it is awfully far away and you would rather not walk all the way. Luckily some locals have offered you a ride. A Knight, a Rook, a Bishop and a King are all willing to take you to your destination, but seeing how this is a chessboard they must e... | stackexchange_codegolf |
We have some new sheriffs moderators in town, Mego and DJMcMayhem. We need a challenge to properly honour them for their new positions, so there we go.
Here's something that has caught my attention when hovering over their profiles – their user IDs are \$31716\$ and \$45941\$. If you perform digit-wise subtraction, y... | stackexchange_codegolf |
Note: This is the radiation-hardening version of my previous challenge Pristine Bit Checking. This should be much more difficult than that one.
Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different.
Fo... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.