instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
In the 1990s, COBOL computer engineers worked out a way to extend six-digit date fields by converting them to YYYDDD where YYY is the year - 1900 and DDD is the day of the year [001 to 366]. This scheme could extend the maximum date to 2899-12-31.
In the year 2898, the engineers started panicking because their 900 yea... | stackexchange_codegolf |
The following data contains the (approximate) population of each UTC timezone in the world (source):
UTC;Population (in thousands)
-11;57
-10;1853
-9.5;8
-9;639
-8;66121
-7;41542
-6;272974
-5;332101
-4.5;31923
-4;77707
-3.5;499
-3;248013
-2;4855
-1;3285
0;285534
+1;857443
+2;609921
+3;496279
+3.5;81889
+4;129089
+4.5;3... | stackexchange_codegolf |
Challenge
Given a single word as input, determine if the word is odd or even.
Odd and Even words
Assume the general rules:
odd + odd = even
even + odd = odd
odd + even = odd
even + even = even
In the alphabet, the odd letters are:
aeiou
And the even letters are:
bcdfghjklmnpqrstvwxyz
The same applies to capital lett... | stackexchange_codegolf |
String Stairs
Disclaimer: This is the first challenge I propose. Any and all feedback is welcome. If this is a duplicate, please point it out.
Here's a link to the sandbox post.
Goal
The goal of this challenge is to, given a string and an integer, print the string into blocks of that integer's size. If a word has more ... | stackexchange_codegolf |
What am I?
As a plant cell, your program/function/etc. must undergo photosynthesis:
When the input is 6CO2+6H2O+light in any order, output C6H12O6+6O2 in any order. It does not have to be the same for each arrangement of the input.
When the input is just r, replicate (i.e. output your own code). quine rules apply.
Whe... | stackexchange_codegolf |
Church booleans
A Church boolean is a function that returns x for true and y for false where x is the first argument to the function and y is the second argument to the function. Further functions can be composed from these functions which represent the and not or xor and implies logical operations.
Challenge
Construct... | stackexchange_codegolf |
The game is played on a 1x8 board with the following setup:
KNR..rnk
White's pieces are on the left, while black's pieces are on the right.
The king (K) can move 1 space in any direction.
The knight (N) can jump 2 spaces in any direction, regardless of bordering pieces.
The rook (R) can move any number of spaces in an... | stackexchange_codegolf |
Your task is to write a program that will take input like this:
a + b * c + a / 2
and will generate the source code for a program that takes user input and then evaluates the expression.
The expression can contain the operators +,-,*,/; single-letter lowercase variables; and integers between 0 and 32000. Standard a... | stackexchange_codegolf |
Background
The tabs versus spaces war in programming has been going on a long time, basically because spaces are too low-level to have all the properties you'd want for alignment and indentation, but tabs can't be relied upon to work in all contexts (with some programs optimizing the use of tabs for indentation whilst ... | stackexchange_codegolf |
To celebrate the island's next Founder's Day, colored filters (fuchsia, chartreuse, and aquamarine*) have been installed in every lighthouse. All lighthouses begin operation with their fuchsia filter, and they are all on the same color cycle: FCA, FCA, ... Each lighthouse changes its color filter after every ON blink,... | stackexchange_codegolf |
Given \$a\$ and \$b\$, both odd \$n+1\$-bit integers, compute \$a/b\$ to a precision of \$n+1\$ bits in the 2-adic integers. That is, compute \$c\$ such that \$a = bc\, (\mathop{\rm mod} 2^{n+1})\$. \$n\$ should be your language's native integer size, or if native integers are bigints, take it as a parameter. If your l... | stackexchange_codegolf |
Your task is to given two integer numbers, a and b calculate the modular multiplicative inverse of a modulo b, if it exists.
The modular inverse of a modulo b is a number c such that ac ≡ 1 (mod b). This number is unique modulo b for any pair of a and b. It exists only if the greatest common divisor of a and b is 1.
Th... | stackexchange_codegolf |
Challenge
Assume two vectors \$\mathbf{a} = (a_1,a_2,\cdots,a_n)\$ and \$\mathbf{b} = (b_1,b_2,\cdots,b_n)\$ are given in an \$n\$-dimensional space, where at least one of \$b_1,\cdots,b_n\$ is nonzero. Then \$\mathbf{a}\$ can be uniquely decomposed into two vectors, one being a scalar multiple of \$\mathbf{b}\$ and on... | stackexchange_codegolf |
I like to think of a 10-adic number as a number that goes infinitely to the left, or an integer modulo a very very large power of 10.
Things carry infinitely to the left and vanish. To see what I mean, note that ...6667 * 3 = 1 in the 10-adic land, since the "2" that carries to the left goes to infinity.
Addition and m... | stackexchange_codegolf |
Siteswap is a notation for juggling patterns.
The other siteswap puzzle is great and it explains siteswap in greater detail than here. This puzzle is meant to be a bit simpler! Numberphile recently interviewed Colin Wright which helped develop the notation. The part at ~16min will be useful for this challenge. Another ... | stackexchange_codegolf |
In chat, we are often fast-typers and don't really look at the order of letters before posting a message. Since we are lazy, we need a program that automatically swaps the last two letters in our words, but since we don't want to respond too late, the code must be short.
Your task, if you wish to accept it, is to write... | stackexchange_codegolf |
The Setup
Most of us are familiar with crossword numbering, which follows three basic rules:
in a character grid consisting of blacks and whites (see below), any maximal contiguous horizontal or vertical chain of whites with length ≥ 2 is considered a word
any white at the leftmost end of a horizontal word and/or at t... | stackexchange_codegolf |
The goal is simple. Write a program that outputs itself encoded as a QR code.
A QR code is a way to encode data in a black and white image, similar to a 2D image.
An example implementation can be found here.
The QR code is displayed as text, where each pixel is either a "#" for a black pixel, or a space for a white pi... | stackexchange_codegolf |
Pascal's triangle is a triangular diagram where the values of two numbers added together produce the one below them.
This is the start of it:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
You can see that the outside is all 1s, and each number is the sum of the two above it. This continues forever.
Your challenge is to coun... | stackexchange_codegolf |
Write a script that outputs A to stdout infinitely.
There should be no newlines or separators between the characters.
Standard loopholes apply.
This is code-golf. The shortest solution in each language wins.
| stackexchange_codegolf |
Stroustrup has recently posted a series of posts debunking popular myths about C++. The fifth myth is: “C++ is for large, complicated, programs only”. To debunk it, he wrote a simple C++ program downloading a web page and extracting links from it. Here it is:
#include <string>
#include <set>
#include <iostream>
#includ... | stackexchange_codegolf |
So, you're browsing Programming Puzzles & Code Golf, and you see a new challenge. The author (gasp) forgot to say "No standard Loopholes". You decide to take advantage of this situation, and you read the answer from a file/network. However, you need to make sure that your answer is actually shorter than the legitimate ... | stackexchange_codegolf |
The first magic card trick I ever learned as a child was the following:
Have 1 deck of cards where the pattern on the back is not vertically symmetric.
Organize all cards to be facing one direction.
Ask an individual to, "pick a card, any card, memorize it and give it back to you".
Proceed to put it into the deck (in ... | stackexchange_codegolf |
Definition
A dollar word is a word where when each of its letters is given a cent value, from a = 1 to z = 26, and the letters are summed, the result is 100. Here is an example on CodeReview, and here is a list of dollar words I found online.
Input
Input will be alphabetical from a-z, in your one language's text dataty... | stackexchange_codegolf |
Create a program which prints itself, followed by an additional program. This additional program should print the first program, itself, and then a third program. This continues until the nth program, which prints every program in order up to itself, but fails to print a successor.
All programs output by your code shou... | stackexchange_codegolf |
Inspired by Braille graphics and Build an analog clock.
The goal there is to create a tool that use terminal console to draw and animate a clock by using UTF-8 fonts \U2800: ⠀ to \U28FF: ⣿.
00:[⠀] 01:[⠁] 02:[⠂] 03:[⠃] 04:[⠄] 05:[⠅] 06:[⠆] 07:[⠇] 08:[⠈] 09:[⠉] 0A:[⠊]
0B:[⠋] 0C:[⠌] 0D:[⠍] 0E:[⠎] 0F:[⠏] 10:[⠐] 11:[⠑] 12:... | stackexchange_codegolf |
I have recently been on a quest to create really really slow sorting algorithms that make Bogosort seem like it is the best.
The task is simple: Sort an array of integers in as long average time as possible, with the average Bachmann–Landau notation begin as high as possible, while keeping the best case performance fas... | 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 |
Apply an indefinite integral to a given string. The only rules you will be using are defined as such:
∫cx^(n)dx = (c/(n+1))x^(n+1) + C, n ≠ -1
c, C, and n are all constants.
Specifications:
You must be able to integrate polynomials with any of the possible features:
A coefficient, possibly a fraction in the format ... | stackexchange_codegolf |
Given a positive integer n >= 1, output the first n rows of the following structure:
#
# #
###
# #
# # #
## ##
#####
# #
# # #
# # # #
# ### #
## ##
## # ##
### ###
#######
The n-th 1-indexed row is the binary representation of n, mirrored without copying the last character, with # in place of 1 a... | stackexchange_codegolf |
Challenge
Write a program or function that takes a number \$n\$ and returns the smallest \$k\$ such that concatenation \$n'k\$ is a square. This sequence is described by A071176 on the OEIS.
I/O Examples
input --> output
1 --> 6 (4^2)
10 --> 0 (10^2)
35 --> 344 (188^2)
164 --> 836 (406^2)
284 --> 2596 (168... | stackexchange_codegolf |
Find the maximum possible number of disjoint sets of characters, that are Turing complete subsets of your language.
Rules:
You can assume your Turing complete subset is contained in/called from a main-function if that is required by your language
The subsets must not share any characters (in the native encoding of th... | stackexchange_codegolf |
I was wondering if there is any way to assign 2 values (G and H) to say a list of ["egg", "chicken"] in Pyth. In python it would be something along the lines of
G, H = ["egg", "chicken"]
At the moment the shortest way I can think of would be something like
=N["egg""chicken")=G@N0=H@N1
which uses the lookup function t... | stackexchange_codegolf |
A magic word is a word whose Braille spelling contains precisely 26 dots (because the Morse code alphabet can be circularly encoded within). For example:
⠎ ⠝ ⠥ ⠛ ⠛ ⠇ ⠽ snuggly
⠏ ⠕ ⠇ ⠽ ⠛ ⠕ ⠝ polygon
⠝ ⠥ ⠛ ⠛ ⠑ ⠞ ⠽ nuggety
⠽ ⠕ ⠛ ⠓ ⠥ ⠗ ⠞ yoghurt
are all magic words.
Objective:
Craft a program to identify 77 such mag... | stackexchange_codegolf |
Given input n, produce a word grid of size n, in as few bytes as possible.
Details
The number provided will always be odd. The centre square of the grid must always be empty (a space character). The letters that fill the grid must be chosen at random from the English Scrabble letter distribution of letters. That is, ea... | stackexchange_codegolf |
Use any programming language to display numbers between 1 and 99 (including both) in such a way, so that:
the numbers are separated by single space,
if a number is divisible by 3, it should be in parentheses,
if a number is divisible by 4, it should be in square brackets,
if a number is divisible by both 3 and 4, it s... | stackexchange_codegolf |
Challenge
Write a program which, using the XML data from the site here, display the name of the programme which is currently showing on BBC 1.
Information
All times are given at London time (GMT+1 at the time of posting and GMT+0 after the 30th October). Therefore, you should convert your local time to London time.
Eac... | stackexchange_codegolf |
Pseudo-Quantum Bogosort
Quantum Bogosort is as follows:
Quantumly randomise the list, such that there is no way of knowing what order the list is in until it is observed. This will divide the universe into O(n!) universes; however, the division has no cost, as it happens constantly anyway.
If the list is not sorted, ... | stackexchange_codegolf |
Snakes look like this:
>>>v
@ ^ v
^ >>>^ v
^ v
^<<<<<<<<<
The snake can cross over itself as in this case:
@
^
>^>v
^<<
For a crossover to be valid, the characters on either side must be moving the same direction. The case of
@
>^v
^<
can be considered unclear and invalid.
The output is a st... | stackexchange_codegolf |
The Wilson score interval is a confidence interval of the probability of success, based on the proportion of successes in a set of Bernoulli trials (a Bernoulli trial is a trial in which exactly two outcomes are possible: success or failure). The interval is given by the following formula:
The two values given by the ... | stackexchange_codegolf |
Write the shortest program which, when run with no arguments, stdin, or user input, triggers a core dump.
Your code must behave this way when run on some common out-of-the-box Linux distribution. Other than installing support for your target language, you may not reconfigure the system to make it more fragile than it i... | stackexchange_codegolf |
Task
Write a program/function that when given a positive integer \$n\$ and a digit \$d\$ which is not 0 outputs a way to represent \$n\$ using only addition, subtraction, multiplication, exponentiation, division, concatenation, parenthesis and the digit \$d\$.
Examples
n = 6, d = 1 => (1 + 1) * (1 + 1 + 1)
n = 6, d... | stackexchange_codegolf |
You work at a bakery, and every day you make pastries. You make 100 of each of several different types. However customers are less predictable. Some days they order all of one kind of pastry and you run out, some days they order hardly any and you have some left over. So your boss has made up a chart which tells you ho... | stackexchange_codegolf |
Story
So I have a book that I want to separate from my table with nothing but other books. I want to know how many books do I need to achieve this with \$n\$ book lengths.
Here's a visualization that my friend at Wolfram drew for me:
More information about the topic in Wolfram and Wikipedia.
Challenge
Given an integer... | stackexchange_codegolf |
Given a sequence of integers or to be more specific a permutation of 0..N
transform this sequence as following:
output[x] = reverse(input[input[x]])
repeat
For example: [2,1,0] becomes [0,1,2] and reversed is [2,1,0]. [0,2,1] becomes [0,1,2] and reversed [2,1,0].
Example 1
In: 0 1 2
S#1: 2 1 0
S#2: 2 1 0
Output:... | stackexchange_codegolf |
Barbrack
Your task is to write a program or function that takes a non-negative integer (in decimal or any other convenient base for your language), and output a number in the numbering system Barbrack.
What's that?
Barbrack is a numbering system I made up that can represent non-negative integers. Zero is represented wi... | stackexchange_codegolf |
URLs are getting too long. So, you must implement an algorithm to shorten a URL.
i. The Structure of a URL
A URL has 2 main parts: a domain and a path. A domain is the part of the URL before the first slash. You may assume that the URL does not include a protocol. The path is everything else.
ii. The Domain
The domain ... | stackexchange_codegolf |
Related, both rope, nail and falling, but reversed and some other differences
Consider a loop of rope hanging on n nails on a row. Given a table showing whether the rope would fall down when each possible set of nails were removed, please provide a possible roping way. You may assume such a solution exist.
Here, "fall ... | stackexchange_codegolf |
Cops' thread
In this thread, your task is to make a recursion-based program/function to generate any integer series. Robbers will try and find a shorter non-recursive solution over in the Robbers' thread.
Challenge synopsis
In many languages, recursive functions can significantly simplify a programming task. However, ... | stackexchange_codegolf |
The task
Given an ascii string, output a program in my esolang MAWP that outputs the inputted string when run.
Useful functions in MAWP
Numbers from 0-9: Pushes the number to stack
M Takes the top two numbers off stack and pushes the sum to stack
A Takes the top two numbers off stack and... | stackexchange_codegolf |
The task is to write code to identify which key is pressed on the keyboard. You can assume that only one key is pressed at a time and that there is a standard US keyboard layout. That is the layout with the @ over the 2.
Your code should output a unique identifier for any key pressed. This includes PrtScn, Scroll Lock,... | stackexchange_codegolf |
Inputs:
Two single digits (let's call them m and n) and two chars (let's call them a and b) in your input format of choice.
Output:
For the walkthrough, pretend m=2, n=5, a='a', b='b'.
Your output will be a string built from your four inputs. Let's call the string result, with value "". First, concatenate a onto result... | stackexchange_codegolf |
Challenge: Given an expressions made of additions and multiplications, output an expression that is a sum of products. The output must be equivalent to the input modulo the law of distribution. For example, \$1 + ((2 + 5\times 6) \times(3+4))\$ becomes \$1 + 2 \times 3 + 2 \times 4 + 5\times6\times3 + 5 \times 6 \times... | stackexchange_codegolf |
Let's say I have this string:
s = "Code Golf! I love Code Golf. It is the best."
I want to replace all the vowels with repeated "aeiou".
Notes:
Uppercase vowels should be replaced by an uppercase letter, and lowercase vowels should be replaced by a lowercase letter.
Consonants (all alphabet characters except for "ae... | stackexchange_codegolf |
This is the cops' thread. See the robbers' thread here.
In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the robbers will try to come up with their algorithm. The catch is, the 'algorithm' must be a single closed-form mathematical e... | stackexchange_codegolf |
Introduction
In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other catalogue challenges, there is "Hello World!" and "Is this number a prime?".
Challenge
Write a program that prints the decimal ... | stackexchange_codegolf |
Create a program which prints itself, followed by an additional program. This additional program should print the first program, itself, and then a third program. This continues until the nth program, which prints every program in order up to itself, but fails to print a successor.
All programs output by your code shou... | stackexchange_codegolf |
All those busy beavers made quite a mess. They wrote all over the tape. At this rate, our neighbour will stop lending us unbounded tapes.
We need a new way to play the busy beaver game, one that doesn't ruin every tape we use.
The Rules
Brainfuck only. Memory tape is unbounded both ways. Input instruction will always r... | stackexchange_codegolf |
This includes tips for all related derivatives, as coding in these langs often primarily consists of writing the function in the lambda calculus and then compiling it down at the end.
Among others, this includes tips for:
Standard combinator calculi
SKI system
BCKW system
Esolang combinator calculi
Iota/Jot/Zot
La... | stackexchange_codegolf |
Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that.
This is the robbers thread of a cops-and-robbers challenge. For the cops thread, see here.
Cops will provide a program/function and a flag. Robbers will guess a password. When the password is given to t... | stackexchange_codegolf |
Task
Write a program/function that when given 3 positive integers \$a, b\$ and \$m\$ as input outputs a positive integer \$x\$ such that \$a^x\equiv b\ (\text{mod}\ m)\$ or that no such \$x\$ exists.
A reference implementation can be found here.
Constraints
You can expect \$a\$ and \$b\$ to be less than \$m\$.
Scoring
... | stackexchange_codegolf |
Write a proper quine containing at least one newline/linefeed whose every unfurling is either itself a proper quine or outputs the original quine. Your answer can mix and match outputting itself and outputting the original quine.
Unfurlings
Unfurlings consist of:
Appending spaces to make the input a rectangle.
Taking ... | stackexchange_codegolf |
Challenge
Write the shortest snippet of code possible such that, when N copies of it are concatenated together, the number of characters output is N2. N will be a positive integer.
For example if the snippet was soln();, then running soln(); would print exactly 1 character, and running soln();soln(); would print exactl... | stackexchange_codegolf |
Given an ASCII representation of a piece of string, determine its length.
Input
An multi-line ASCII rendering of a piece of string, which runs from top to bottom, with one 'node' (corner) on each line of input. The delimiter may be assumed to be CR, LF, CRLF, or LFCR. Input may be accepted from STDIN, Command Line Argu... | stackexchange_codegolf |
This challenge is simple: Take a path to an png image file as input and overwrite that file with a copy of itself rotated 90 degrees clockwise. You may assume that the file has dimensions of 128x128 pixels. You may not use image metadata modifications (like Exif) to rotate the image; the pixels themselves must be trans... | stackexchange_codegolf |
I am trying to push my limits of making a python code as short as possible.
I left the readability part way behind.
I was attempting the K-Goodness String problem from Round A of Google Kick Start 2021.
The following was my initial solution:
def func(N, K, S):
if not S: return 0
y = 0
for i in range(N//2)... | stackexchange_codegolf |
from Wikipedia, a number is called B-powersmooth if all prime powers \$p^v\$ that divide the number satisfy \$p^v \leq B\$. B-powersmoothness is important, for example, for Pollard's p-1 factorization algorithm.
Task
your task is to get two numbers, \$n\$ and \$B\$, and output if \$n\$ is \$B\$-powersmooth.
Rules
You ... | stackexchange_codegolf |
The Challenge
Given a rational number, determine the smallest number which is a positive integer multiple of it. Eg.
Given: 1.25
x1: 1.25
x2: 2.5
x3: 3.75
x4: 5
Thus: Answer is 5
Clarifications
Inputs will be a rational number in the range of (0,100] of which the Decimal Representation has no more than 4 ... | stackexchange_codegolf |
The problem over here introduces an new type of strings: if you split the string into equal halfs and swap the pairs, it produces the same output as sorting the string. We call that a half-sort.
Given a purely ASCII string, check if the string is in a half-sort.
An example of a half-sort string
The string node is a hal... | stackexchange_codegolf |
The Seidel Triangle is a mathematical construction similar to Pascal's Triangle, and is known for it's connection to the Bernoulli numbers.
The first few rows are:
1
1 1
2 2 1
2 4 5 5
16 16 14 10 5
16 32 46 56 61 61
Each row is generated as follows:
If the row number is even (1-indexed):
Bring... | stackexchange_codegolf |
Convert a string containing digits as words into an integer, ignoring leading zeros.
Examples
"four two" -> 42.
"zero zero zero one" -> 1.
Assumptions
Submissions can assume that:
The input string is comprised of space-separated digit words.
All words are valid (in the range "zero".."nine") and lowercase. Behaviour ... | stackexchange_codegolf |
Input:
A list of integers (which will never contain a zero)
Output:
A list of the same size with counts based on the following:
If the current item is negative: Look at all items before this item, and count how many times the digits occurred in those other numbers
If the current item is positive instead: Look at all i... | stackexchange_codegolf |
Challenge
You have one string of input bytes, output only the last byte in it.
Rules
Your submission may be a program or function outputting the last byte in the input which
is either a string, stdin or command-line arguments, and
is non-empty.
I was trying to solve this with brainfuck, however all languages are allo... | stackexchange_codegolf |
We're back! And this time with an objective scoring criteria!
This is a challenge I thought of recently which I think is not hard but allows for a wide range of possible solutions. Seems like a perfect fit for the creativity of PPCG users :)
Your Task
Define two functions combine and separate with respective types Str... | stackexchange_codegolf |
I'm sure most of us have seen SQL results in a terminal, all neatly formatted into rows and columns. If you haven't, here's an example:
+----------+-----------+----------------+
| column 1 | column 2 | column 3 |
+----------+-----------+----------------+
| data | more data | even more data |
| etc | jus... | stackexchange_codegolf |
Challenge:
Given two integers \$a\$ and \$b\$, with lengths \$A=length(a), B=length(b)\$, output an ASCII-art of the \$a^{th}\$ root of \$b\$, including the answer rounded to \$A\$ amount of decimal places.
The size of the ASCII-art root also depends on \$A\$ and \$B\$.
Example:
\$a=123\$, \$b=1234\$
____
123 /123... | stackexchange_codegolf |
The challenge involves printing the difference between ICMP originate and receive timestamps.
The idea is being able to determine which asymmetric internet path is responsible for packet delay.
One can use hping with --icmp-ts option to gain the raw data on ICMP_TSTAMP. The task is complicated by the fact that hping d... | stackexchange_codegolf |
You will be given two integers \$M\$ and \$N\$. Find the number of pairs \$(x,y)\$ such that \$1 \le x \le M\$, \$1 \le y \le N\$ and \$(x+y)\bmod5 = 0\$.
For example, if \$M = 6\$ and \$N = 12\$, pairs which satisfies such conditions are, \$(1,4), (4,1), (1,9), (2,3), (2,8), (3,2), (3,7), (3,12), (4,6), (6,4), (4,11),... | stackexchange_codegolf |
Unlike many C&R challenges, this does not require a separate robbers post; the goal of the robbers is to crack the previous answer and then post a new one as a cop.
As answerers, you will write a series of polyglots that look like this (each column is a language, and each entry is the output of the answer in that langu... | stackexchange_codegolf |
Introduction
This challenge requires you to set the trailing zeros of an integers binary representation to 010101…, this is best explained with an example:
Given the integer 400, the first step is to convert it to binary:
110010000
As we can see the fifth bit is the least significant 1 bit, so starting from there we r... | stackexchange_codegolf |
Sometimes when I'm bored, I take some text and fill the "holes" in the letters. But isn't filling the holes the most boring thing you can do? I think we should automate it, so we could use our time better.
Standard code-golf rules apply.
Input
A string containing sequence of alphanumeric characters (a-z, A-Z, 0-9) and ... | stackexchange_codegolf |
Most people are familiar with Pascal's triangle.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Pascal's triangle is an automaton where the value of a cell is the sum of the cells to the upper left and upper right. Now we are going to define a similar triangle. Instead of just taking the cells to the upper left and the upp... | stackexchange_codegolf |
Coming from this sandbox post
This is inspired from an 8th graders math test
Intro
We have a cube with following corners
A(0, 0, 0)
B(1, 0, 0)
C(1, 1, 0)
D(0, 1, 0)
E(0, 0, 1)
F(1, 0, 1)
G(1, 1, 1)
H(0, 1, 1)
This cube clearly has 8 corners, 12 edges and 6 faces. If we now cut off corner G, such that our cut plane goe... | stackexchange_codegolf |
Morpion solitaire
This is a game that I remember having learnt from my grandparents in my childhood. Initially I didn't know the name. G B has found it to be Join Five (or less ambiguously - Morpion solitaire) with a slightly different starting position.
NOTE: it seems that it's kinda known and this problem formulation... | stackexchange_codegolf |
GPA Calculator
(GPA = Grade Point Average)
You are a stressed out college student during finals week. Instead of studying for your exams coming up, you decide it is best to determine what GPA you will have at the end of the semester. This way you have data to back up your decision of staying up all night to get that A ... | stackexchange_codegolf |
Al wanted to use my computer to do some simple calculations, so I lent him the use of my R terminal for a bit. He complained though, saying it wasn't set up how he liked it. I said "No problem Al, set it up how you like and I'll just revert it later." This suited Al, and I left him to it. Al isn't a big fan of online R... | stackexchange_codegolf |
Introduction
Some time ago, I need to write function which split string in some specific way. At the first look, task looks trivial, but it was not so easy - especially when I want to decrease code size.
Challenge
As example we have following input string (it can be arbitrary)
Lorem ipsum dolor sit amet consectetur ad... | stackexchange_codegolf |
Given a set of items, each with a weight and a value, determine the number of each item to include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible.
Wikipedia for more information
For example you can be given a max weight of 15 and objects with ... | stackexchange_codegolf |
To celebrate the 2497th anniversary of the Greek victory at Salamis in 480 BC. Draw the lambda blazon.
The lambda blazon was the lambda painted on greek shields like so:
Puzzle: Given a positive odd integer n, produce an ascii art image of the above shield.
Specifications:
n=1:
( /\ )
n=3:
( /\ )
| / \ |
( /... | stackexchange_codegolf |
This challenge initially appeared in this challenge as a an extra brain teaser. I am posting it with permission from the original author so that we can have a formal competition.
Your task here will be to implement a function1 that forms a permutation on the positive integers. This means that each positive integer ... | stackexchange_codegolf |
Given a ragged list of positive integers, where the maximum depth is \$d_\text{max}\$, return the same list, except for every element \$e\$, its depth is \$d_\text{max}+1-d_e\$ (where \$d_e\$ is the depth of that element).
Your output should contain the minimal number of brackets, and you can assume the same from your ... | stackexchange_codegolf |
Imagine a countable infinite amount of empty rooms. When an infinite amount of guests come, they occupy the 1st, 3rd, 5th...(all odd) empty rooms. Therefore there's always an infinite amount of empty rooms, and occupied guests needn't move when new guests come.
- - - - - - - - - - - - - - - - -
1 - 1 - 1 - 1 - 1 - 1 - ... | stackexchange_codegolf |
You are James and four of your friends (Bjarne, Eich, Rossum, Ada) are called for an interview. There are n interviewers, and they can each serve one person at a time, alphabetically. Each round of interview takes 20 min.
Let's take n = 2,
So, the first round started with Ada and Bjarne, takes 20 min (they're handle... | stackexchange_codegolf |
Given a polynomial in one variable with rational coefficients, output an equivalent expression containing only 1, variables, and definite integrals. For example, -x2 can be expressed as ∫x∫111dtxdu.
E := 1 | var | ∫EEEdvar
Any reasonable input/output method is allowed.
Examples:
Your score will be the your code length... | stackexchange_codegolf |
Unlike many C&R challenges, this does not require a separate robbers post; the goal of the robbers is to crack the previous answer and then post a new one as a cop.
As answerers, you will write a series of polyglots that look like this (each column is a language, and each entry is the output of the answer in that langu... | stackexchange_codegolf |
Your challenge is to write a program which, given a year, outputs the number of "Friday 13ths" in it.
Rules & Details:
You can take input via STDIN, or as an argument passed to your program.
You should output the result to STDOUT.
You may assume that input will be a valid year, and does not pre-date the Gregorian cale... | stackexchange_codegolf |
Write a program that outputs a graph of the collatz sequence any way you want (ASCII Image Video etc). You have to implement it that way that you can adjust the size of the graph by either the maximum number of nodes or highest number in graph. A boring example here.
Try to present the graph in a creative / insightful ... | stackexchange_codegolf |
The world is a five by five array of cells. It wraps on all sides. It can be visualized like...
XXXXX
XXXXX
XXOXX
XXXXX
XXXXX
You are an O. You love to travel the world, and you do so according to the following rules (let C be the current day):
On prime days, you feel nostalgic. Return to where you started yesterday... | stackexchange_codegolf |
I have the following code which I've written to emulate Newton's method for deriving the square root of a number:
r=(x,y)=>
(z=((y=y||x)*y-x)/(2*y)>1e-15)?
r(x,y-(y*y-x)/(2*y)):y
Where r(37) would result in 6.08276253029822 which is great given the limitations of my browser.
I'd like to golf this code further seei... | stackexchange_codegolf |
Your job is to write a program that takes a number N as input and outputs all 2-by-N mazes that are solvable.
Output format can be in the form of any two distinct values representing wall and empty - I use x and . here but you can use anything. You can have a matrix, array, string, ascii art, whatever is convenient, an... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.