instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Recently, I have found my reputation changing time to time. I would like to know my reputation changing real-time.
The job
Given an id of a user on PPCG (ex.64499), Print the user's reputation every 10 seconds. You may ignore the daily quota.
Examples
64499
3808
40695
Possible output format
12345
12,345
| stackexchange_codegolf |
JonoCode9374 had almost completely implemented my language EnScript except for the CHS command. I was impatient of waiting for them to implement this command, so I chose to put this question here.
Challenge:
Write a solution that takes an input and returns the chased output. Standard loopholes are forbidden.
This is th... | stackexchange_codegolf |
The Hamming distance between two strings of equal length is the number of positions at which the corresponding characters are different. If the strings are not of equal length, the Hamming distance is not defined.
Challenge
Write a program or function that finds the largest Hamming distance from among all pairs of str... | stackexchange_codegolf |
A standard, solved, 3×3×3 Rubik's Cube has 6 differently colored faces, where each face is a 3×3 grid of squares of one color. The white face is opposite the yellow, the red opposite orange, the blue opposite green, and when white points upward, red is to the left of blue:
Imagine an ant sits on the center square of t... | stackexchange_codegolf |
Stackylogic is a logic-based programming language I made up that take in 0's and 1's for input and outputs a single 0 or 1 upon completion.
A Stackylogic program consists of lines that can only contain the three characters 01? as well as exactly one < at the end of one of the lines. Lines may not be empty and the line ... | stackexchange_codegolf |
COBOL is a very old language, at the time of writing it is 58 years old.
It is so old, in fact, that it has a very interesting quirk: the first six characters of each line are comments.
Why is this, you ask? Well, those 6 characters were intended to be used as line numbers, back in the day where programs weren't comple... | stackexchange_codegolf |
What is the shortest way to secure a site with Javascript?
I am new to Code Golfing, and this is what I've come up with so far. I bet that this could be improved though:
Challenge:
Make a script which redirects http:// to https:// with the least bytes of code
Attempts:
Original code (150ish BYTES!):
if (window.locati... | stackexchange_codegolf |
Your Challenge is to take a binary string as input and get all binary numbers between itself and the reverse of its string representation (the reverse may be less than or greater than the original input).
Output must be padded with zeroes to be the same length as the input.
The Order in which the values are displayed d... | 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 |
Your Task:
Write a program or function that, when given a number, outputs its persistence. The persistence of a number is the number of times you can add its digits before arriving at a one-digit number. All one digit numbers have a persistence of 0. Note that this is different from questions about finding the digit... | stackexchange_codegolf |
Let's start by defining a reflection of a character in a string:
Given a string with distinct lowercase alphabetical letters with no spaces such
as abcdefg, define a reflection of a letter in the string c as
moving it (without changing the order of any other letter) to a new
place in the string such that the num... | stackexchange_codegolf |
Challenge
Create 2 programs A and B
The output of program A is exactly program B
The output of program B is exactly program A
Neither program should depend on inputs to yield the correct output
A and B are not identical programs
A and B are of different programming languages
Neither program may be equivalent to i... | stackexchange_codegolf |
The goal of this challenge is to extend the On-Line Encyclopedia of Integer Sequences (OEIS) sequence A038375.
Maximal number of spanning paths in tournament on n nodes.
A tournament on \$n\$ vertices is a directed graph where for each pair of vertices \$(v_i, v_j)\$ there is either a directed edge \$v_i \rightarrow ... | stackexchange_codegolf |
Given a 7-segment display with some segments switched on and some off, find a sequence of digits (0-9), such that after toggling the corresponding segments for each digit, all segments are switched off.
Example
_
_ [3] => | [1] => [OFF]
_ |
Numbers and their corresponding segments:
_ ... | stackexchange_codegolf |
A haiku is a poem with three lines, with a 5/7/5 syllable count, respectively.
A haiku-w is poem with three lines, with a 5/7/5 word count, respectively.
Challenge
Write a program that will return true if the input is a haiku-w, and false if not.
A valid haiku-w input must consist of 3 lines, separated by a newline.
L... | stackexchange_codegolf |
Background
Countless generations of children have wondered where they would end up if they dug a hole directly downwards. It turns out that this would, unsurprisingly, be rather dangerous, but anyway...
Antipodes are points that are directly opposite each other on the Earth's surface. This means that if a line was draw... | stackexchange_codegolf |
The task in this challenge is to put elements of an array into time bins. The input will be a non-decreasing array of positive integers representing the time of events, and an integer which represents the size of each bin. Let us start with an example. We call the input array A and the output array O.
`A = [1,1,1,2,7,... | stackexchange_codegolf |
This challenge is about implementing Shm-reduplication, originating in Yiddish, where one takes a word, duplicates it, and replaces the first syllable in the second word with "Shm" in order to indicate that one does not care. Some examples include:
"Isn't the baby cute?", "Eh, baby shmaby"
"Come buy from my store, we ... | stackexchange_codegolf |
This is not a duplicate of Sum of combinations with repetition. This question considers 1+2 to be the same as 2+1. The other question doesn't.
OEIS link - A000008
Background
If you have 4 types of coins (1, 2, 5 and 10 cents), in how many ways can you make an amount?
There are 4 ways of making 5 cents:
1 + 1 + 1 + 1... | stackexchange_codegolf |
Presumably everybody here knows that for the legacy BIOS, the tiniest bootable disk image is 512 bytes (the lower bound is due to the 2-byte magic at offset 510), and there is a bootsector demoscene where people try to fit the entire demo into the 510 bytes of usable space.
Now that the BIOS is being superseded by UEFI... | stackexchange_codegolf |
Introduction
Write a complete program that rotates a rectangular block of ASCII characters 90 degrees clockwise. When the program itself is rotated 90 degrees clockwise, it rotates a block of ASCII characters 90 counterclockwise.
Rules
You many not use built-ins that rotate or transpose matrices. For example, in MATLA... | stackexchange_codegolf |
A collection of N dimensional coordinates are provided. An example is below:
{2,3,4}
This can be thought of as a 3 dimensional array with 2x's, 3y's and 4z's; there may be any number of dimensions. In the example, there are 24 total nodes. Each node can be indexed using {x,y,z}. To access the 5th node, the provided in... | stackexchange_codegolf |
The famous constructed language Esperanto uses the Latin alphabet (mostly, see the linked wikipedia page for details). However, there are some characters with accents: ĉ, ĝ, ĥ, ĵ, ŝ, and ŭ. (C-circumflex, g-circumflex, h-circumflex, j-circumflex, s-circumflex, and u-breve.) Naturally, these characters are very hard to ... | stackexchange_codegolf |
Given an inconsistently indented piece of html code your task is to return the same text but correctly indented
Indent space = 4
Assume input will be non-empty.
Input can be taken as string or array/list of lines
Opening and closing tags must be on the same line as long as there is not any other tag inside. <td></td>... | stackexchange_codegolf |
Introduction
Our goal is to efficiently find the maximum of a large amount of (redundant) data.
We define the outer product of vectors \$A\$ and \$B\$ as a matrix containing the products of all entries of \$A\$ with each entry of \$B\$. (see outer Product)
$$
A\otimes B := A\cdot B^T = \left(\begin{array}{rrr}
A(1)\cdo... | stackexchange_codegolf |
Do you remember my mat properly grouped by colors?
Yesterday I was looking at it and realized that some letters fit inside others. Example: a letter P fits in the place where the letter R goes. So here's a simple challenge: given two letters, return a truthy value if any one of the letters fits inside the other (direc... | stackexchange_codegolf |
Make 2d ASCII buildings depending on what the input is. The submissions can either be a program that takes input, or a function that accepts input via its parameters.
e.g. An input of 5,3,6 would output
┌──┐
│┌┐│
┌──┐ │└┘│
│┌┐│ │┌┐│
│└┘│ │└┘│
│┌┐│ │┌┐│
│└┘│ ┌──┐ │└┘│
│┌┐│ │┌┐│ │┌... | stackexchange_codegolf |
Your task is to write the shortest algorithm in a language of your choosing that accomplishes the following:
Given two matrices it must return the euclidean distance matrix. The euclidean distance between two points in the same coordinate system can be described by the following equation:
\$D = \sqrt{ (x_2-x_1)^2 + (y_... | stackexchange_codegolf |
Given n numbers in an array (you can't assume they are integers), I would like to compute the product of all subsets of size n-1.
You can do this by multiplying all the numbers together and then dividing by each one in turn, as long as none of the numbers is zero. However, how quickly can you do this with no division... | stackexchange_codegolf |
I feel tired to do "find the pattern" exercise such as
1 2 3 4 (5)
1 2 4 8 (16)
1 2 3 5 8 (13)
Please write a program that finds the pattern for me.
Here, we define the pattern as a recurrence relation that fits the given input, with the smallest score. If there are multiple answers with the same smallest score, using... | stackexchange_codegolf |
You may be aware of the famous old rhyme, "I before E, except after C". It is a rule taught to aid in the spelling of certain English words.
Quoting Wikipedia:
If one is not sure whether a word is spelled with the digraph ei or ie, the rhyme suggests that the correct order is ie unless the preceding letter is c, in wh... | stackexchange_codegolf |
You are given four numbers. The first three are \$a\$, \$b\$, and \$c\$ respectively, for the sequence:
$$T_n=an^2+bn+c$$
You may take input of these four numbers in any way. The output should be one of two distinct outputs mentioned in your answer, one means that the fourth number is a term in the sequence (the above ... | stackexchange_codegolf |
If you wanted to compute a very large long problem, that on a machine that you could buy today for an inflation adjusted price, will take some amount of years/decades. The issue is, if you only have that budget, and so can only purchase one machine. So if you purchase the machine now, it may actually take longer to com... | stackexchange_codegolf |
Inspired by a tweet by Nathan W. Pyle
There is, now, a standard method of converting your boring, normal human name into a mysterious, ethereal Ghost Name™️. Ably described by Mr Pyle...
Use your first name:
a - add “t” after it
e - add “boo” after it
h - becomes “s”
n - add “oo” after it
r - add “eee” after it... | stackexchange_codegolf |
Your task is to write a full program or function that takes no input and runs any type of loop (while, for, foreach, do, do-while, do-loop, goto, recursion, etc) that will end in causing an error, which means that the program must stop itself running and exit.
Rules:
The error must be a run-time error, unhandled excep... | stackexchange_codegolf |
For the purposes of this challenge, a polyphthong is defined as a contiguous slice of a String, that only contains vowels, and has length at least 2. Given a non-empty String as input, your task is to output all the polyphthongs it contains.
For example, "abeoic" has the following contiguous slices (space-separated):
a... | stackexchange_codegolf |
Inspired by a tweet by Nathan W. Pyle
There is, now, a standard method of converting your boring, normal human name into a mysterious, ethereal Ghost Name™️. Ably described by Mr Pyle...
Use your first name:
a - add “t” after it
e - add “boo” after it
h - becomes “s”
n - add “oo” after it
r - add “eee” after it... | stackexchange_codegolf |
4, 32, 317, 3163, 31623, 316228, 3162278, 31622777, 316227767, 3162277661, 31622776602, 316227766017, 3162277660169, 31622776601684, 316227766016838, 3162277660168380, 31622776601683794, 316227766016837934, 3162277660168379332, 31622776601683793320, 316227766016837933200, 3162277660168379331999, 31622776601683793319989... | stackexchange_codegolf |
Sandbox
The major scale (or Ionian scale) is one of the most commonly used musical scales, especially in Western music. It is one of the diatonic scales. Like many musical scales, it is made up of seven notes: the eighth duplicates the first at double its frequency so that it is called a higher octave of the same note.... | stackexchange_codegolf |
Introduction:
I think we've all heard of it, but here a very brief summary: Noah gathered two of every species of animal on the planet, male and female, to save in his Ark during a great flood. The actual quote from the Bible is:
Genesis 7:2-3
You must take with you seven of every kind of clean animal, the male and it... | stackexchange_codegolf |
Each day you put up a new word on a marquee sign with movable letters, buying just the letters you need to write it. You re-use letters you've bought for earlier words whenever possible. Given the words you want to write each day in order, output the letters you buy each day.
Example
Input: ['ONE', 'TWO', 'THREE', 'S... | stackexchange_codegolf |
An isolated character is a character (other than a newline) that doesn't have an adjacent character of the same type. Adjacent characters can be to the left, the right above or below, but not diagonals. For example in the following text H is isolated:
Ybb
YH%
%%%%
All the other characters are not isolated because ea... | stackexchange_codegolf |
Can Alice win the game?
The game's rules are as follows. First, a finite non empty set of positive integers \$X\$ is defined. Then, Alice and Bob take turns choosing positive integers, with Alice going first. Each integer must be strictly less than the previous one, and the game ends when one of the players chooses \$1... | stackexchange_codegolf |
Generate the contents of an SVG file containing 6 bingo cards. Winner is the one that uses the shortest code. A qualifying answer has an output that can be directly pasted in a blank to get the required image. Rules are as follows.
The generated SVG code should comply with SVG version 1.1 described here.
The size of t... | stackexchange_codegolf |
I've invented an SQL-like language. Let's call it SelectQL. You can't INSERT anything, you can only SELECT, and I don't have the time for an interpreter. How about you help?
The Challenge
Write a full program or a function that takes in a database of tables and a valid SelectQL SELECT string, interprets the string, and... | stackexchange_codegolf |
Your task is to determine whether some arbitrary programming language has zero-indexed or one-indexed arrays based on sample inputs and outputs
Inputs
An array of integers with at least 2 elements
A positive integer index
The value of the array at that index
Output
One of four distinct values representing:
One-index... | stackexchange_codegolf |
Homologous series, any of numerous groups of chemical compounds in each of which the difference between successive members is a simple structural unit.
As an example, Alkane is a homologous group where the chemical compounds are in \$C_nH_{2n+2}\$ format. \$CH_4\$ (Methane) is part of the Alkane group because \$CH_4 \t... | stackexchange_codegolf |
In this challenge you are going to write an interpreter for a simple language I've made up. The language is based on a single accumulator A, which is exactly one byte in length. At the start of a program, A = 0. These are the languages instructions:
!: Inversion
This instruction simply inverts every bit of the accumula... | stackexchange_codegolf |
The flick input method is a way of inputting Japanese kana on a modern smartphone. It is arranged in a 12-key layout, with the following labels:
あかさ
たなは
まやら
小わ、
When a key is tapped, it produces its respective kana. However, when the key is flicked in one of the four cardinal directions (up, down, left, right) it prod... | stackexchange_codegolf |
Your task is to write a program that performs case conversion from plain text, and other case formats, into one of the specified formats below. Inputs will be either plain lowercase text, or one of the detailed cases below. You must remove non-alphabetic characters except (space), _ (underscore) and - (hyphen), then ... | stackexchange_codegolf |
Backstory:
I think that my boss might finally realize that I don't any enough work, despite being paid by the hour. I want to throw him off track, by writing as many valid programs as I can to send to him. Unfortunately, due to budget cuts, my keyboard only allows each key to be pressed once.
Specification:
Write as ma... | stackexchange_codegolf |
Your challenge, should you choose to accept it, is to take as input:
A program in DirectionLang (as an ASCII string consisting of DirectionLang instructions)
A list of pairs of integers, henceforth known as the pretty places. This list may be taken in any reasonable format.
You should then output a truthy value if th... | stackexchange_codegolf |
Specifically, this references JavaScript, a programming language that happens to be one you can run on StackExchange/StackOverflow. However, you may use any programming language to do this challenge. This is not actual JS golfing, but merely a "code-golfable" challenge. Actual complete parsing of JS is not needed.
An e... | stackexchange_codegolf |
Conways' Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are:
Any live cell with 2 or 3 living neighbours (the 8 cells immediately around it) lives ... | stackexchange_codegolf |
A bipartite graph is a graph whose vertices can be divided into two disjoint set, such that no edge connects two vertices in the same set. A graph is bipartite if and only if it is 2-colorable.
Challenge
Your task is to, given the adjacency matrix of an undirected simple graph, determine whether it is a bipartite grap... | stackexchange_codegolf |
On a toroidal square grid (you can wrap around) where each cell indicates one direction (^ > v <) if we pick a cell and start to walk following these directions, we will eventually get stuck in a loop.
We may end up in a different loop, depending on our starting cell.
Not all the cells we encounter constitute our term... | stackexchange_codegolf |
Write a program that adds or removes whitespace to format code nicely. Rules for what the code should look like when you're done:
No line should contain more than one of { and }.
A { should always be the last thing on a line.
A } should always be the only thing on a line (besides whitespace that comes before it).
The ... | stackexchange_codegolf |
Given a string as input find the longest contiguous substring that does not have any character twice or more. If there are multiple such substrings you may output either. You may assume that the input is on the printable ASCII range if you wish.
Scoring
Answers will first be ranked by the length of their own longest ... | stackexchange_codegolf |
Here's a challenge inspired by Programming Praxis:
http://programmingpraxis.com/2009/02/19/flavius-josephus/
Write a function josephus(n,m) that returns a list of n people,
numbered from 0 to n-1, in the order in which they are executed, every
mth person in turn, with the sole survivor as the last person in the
list.
... | stackexchange_codegolf |
Specifically, this references JavaScript, a programming language that happens to be one you can run on StackExchange/StackOverflow. However, you may use any programming language to do this challenge. This is not actual JS golfing, but merely a "code-golfable" challenge. Actual complete parsing of JS is not needed.
An e... | stackexchange_codegolf |
The bots are looking for love. Can you help them?
The rules
The goal of this game is find the bot you have the highest compatibility with. However, robots, who are inexperienced at dating are unable to tell how well a date went.
In the game, bots take turns "speed dating" some other bot. After each date, each bot choos... | stackexchange_codegolf |
Background
For the purposes of this challenge, we'll define a "perfect nontransitive set" to be a set \$A\$ with some irreflexive, antisymmetric relation \$<\$, such that for all \$a \in A\$ we have that \$|\{x \in A|x<a\}|=|\{x \in A|x>a\}|\$.
Okay, now in layperson's terms: \$A\$ is a set of elements with no duplicat... | stackexchange_codegolf |
This image was made by overlaying 7 differently colored rectangles on top of each other:
The black and maroon rectangles are unobstructed, that is, no other rectangles are above them.
Write a program that takes in an image such as this and remove any single unobstructed rectangle, outputting the resulting image.
Exam... | stackexchange_codegolf |
While I was traveling in the future, I noticed a funny game among kids circa 2275. When they don't want their great-great-great-great-grand parents to understand what they're saying, they use the BIBABOBU speak. Obviously, I couldn't understand anything either with my pre-cyborg era brain and I felt (or technically: I ... | stackexchange_codegolf |
Overview
Given a 3 line string, figure out if the structure falls to the left, balances, or falls to the right.
Input structure
You can imagine the structure as metal rod with stuff on top, all being balanced on top of a vertical rod.
1 7 4 a
===============
|
The first line is the items. Each item's w... | stackexchange_codegolf |
Strassen's algorithm was the first method of matrix multiplication in subcubic time complexity, namely O(n**log2(7)) for a pair of n*n matrices (assuming the numbers therein are large enough that their O(n*log2(n)) exact multiplication has become the constraint on your performance, and any nested structures and functio... | stackexchange_codegolf |
Your task is to create a plain hunt (a bell ringing pattern) with n bells. An example with 6 bells:
123456
214365
241635
426153
462513
645231
654321
563412
536142
351624
315264
132546
123456
Each number "bounces" off the side of the grid. From Wikipedia:
Each bell moves one position at each succeeding change, unless ... | stackexchange_codegolf |
With challenges like Output with the same length as the code and Create output twice the length of the code, I thought of a separate, but similar challenge.
The task is to produce an output. It can either be a string, a list of characters, or whatever is the default output format of your program. However, your output ... | stackexchange_codegolf |
Write a program or function that takes in a positive integer and prints or returns an ASCII art depiction of an archery arrow, scaled according to the input.
If the input is 1 the output is
/\
/ \
\__/
||
||
||
||
||
||
||
||
/||\
/ || \
/ || \
// \\
/ \
If the input is 2 the output is
/... | stackexchange_codegolf |
Your challenge is to take an array of strings and output the longest string in the array. So for
["tiny", "small", "bigger", "biggest"]
the output would be biggest.
If two elements of the array have the same length, you should choose the one that appears first in the array. That means if the array looks like this:
["o... | stackexchange_codegolf |
Challenge
Your challenge is to design an interpreter for a lisp-like language, which will from hence forth be coined: GLisp. The program code for GLisp will consist of an arbitrary amount of nested expressions denoted by brackets, in the following form:
(func arg1 arg2 ...)
Note that the interpreter must allow for ext... | stackexchange_codegolf |
One of my favorite memes is the bouncing DVD logo. Yet silly but extremely satisfying, a DVD logo keeps bouncing on a screen and if you ever happened to watch this screensaver, you were most likely anxiously waiting for the logo to exactly hit the corner.
I know part of the fun is the waiting, but let's try to predict... | stackexchange_codegolf |
Recently a friend of mine posed the following:
What subset of the integers satisfies the condition if distinct a and b are in the subset, their average is not in the subset? I know the set of non-0 squares satisfies the condition, but I wonder if there exists a more... dense set that satisfies the condition.
(It turn... | stackexchange_codegolf |
For the purposes of this challenge, we define a postfix regex dialect with alphabet {1, 0} and the following operations:
1 and 0 match themselves literally.
_ matches the empty string.
! always fails (i.e. it does not match anything).
ab; matches a, followed by b.
ab| matches both a and b.
a+ matches one or more insta... | stackexchange_codegolf |
Define f(a,b) := a if b=1; a^f(a,b-1) if b>1 (Tetration, where ^ means power) for positive integers a and b, given four positive integers a,b,c,d, compare f(a,b) and f(c,d).
Your program should output three constant values to mean "greater", "less" and "equal".
Samples:
a b c d f(a,b) output f(c,d)
3 2 2 3 27 > ... | stackexchange_codegolf |
It is easy to describe a finite state machine that recognizes multiples of 9: keep track of the digit sum (mod 9) and add whatever digit is accepted next. Such a FSM has only 9 states, very simple! By the equivalence between FSM-recognizability and regular languages, there is a regular expression for multiples of 9. Ho... | stackexchange_codegolf |
ISO Paper Sizes Defined:
The A series paper sizes are defined by the following requirements:
The length divided by the width is the square root of 2.
The A0 size has an area of 1 unit.
Each subsequent size A(n) is defined as A(n-1) cut in half parallel to its shorter sides.
Task:
given an input f[n] output A0 divided... | stackexchange_codegolf |
Your task is when given a chemical formula as input, output the total number of atoms in the formula.
Input
A chemical formula in any reasonable format. Each chemical formula has the following:
A leading coefficient, which is a number \$N > 1\$.
At least 0 groupings of elements surrounded by parentheses.
Groupings ca... | stackexchange_codegolf |
The Challenge
Given an integer input, return the first Fibonacci number that contains the input within itself along with the index of that Fibonacci number (indexes starting at 0 or 1 - up to you, but please mention which in your answer). For example, if given the input of 12, the program would return 26: 121393 as 12 ... | stackexchange_codegolf |
Let's consider a list \$L\$ (initially empty) and a pointer \$p\$ into this list (initialized to \$0\$).
Given a pair of integers \$(m,n)\$, with \$m\ge 0\$ and \$n>0\$:
We set all uninitialized values in \$L\$ up to \$p+m+n\$ (excluded) to \$0\$.
We advance the pointer by adding \$m\$ to \$p\$.
We create a vector \$[... | stackexchange_codegolf |
let S, a and b each represent a string
Goal: Write a standard string replace function where the you replace all occurrences of a in a string S with b so long as a is not already part of an instance of b
for example, if we have the string S = My oh my that there is a big ol' that
and we wanted to do a fancy replace with... | stackexchange_codegolf |
Introduction
Some days ago I needed a metronome for something. I had none available so I downloaded an app from the App Store. The app had a size of 71 MB!!!
71 MB for making tic-toc...?!
So code-golf came into my mind and I was wondering if some of you guys could improve this.
Challenge
Golf some code that outputs s... | stackexchange_codegolf |
This! is an RGB colour grid...
Basically it's a 2-dimensional matrix in which:
The first row, and the first column, are red.
The second row, and the second column, are green.
The third row, and the third column, are blue.
Here are the colours described graphically, using the letters R, G, and B.
Here's how we calcu... | stackexchange_codegolf |
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 |
Satisfying Rounding
You know when you're in science class, and asked to round to 2 sig figs, but your answer is 5.2501...? You should round to 5.3, but that's just so unsatisfying! By rounding to 5.3, you're off by a whole 0.05, which is a large amount compared to 0.1 (the place value you're rounding to)! So help me ro... | stackexchange_codegolf |
A magic sequence is a sequence of non-negative integers x[0..n-1] such that there are exactly x[i] instances of i
For instance, 6,2,1,0,0,0,1,0,0,0 is a magic sequence since there are 6 0's, 2 1’s, and so on.
Write a function which when given n, outputs all magic sequences of length n
The program that can produce the ... | stackexchange_codegolf |
2fuck is a simple 2D variation on brainfuck. Like traditional brainfuck, there is an 1D memory tape that extends 30000 bytes to the right from its beginning, consisting of values between 0 and 255.
Arithmetic should wrap around, adding 1 to 255 sets the cell to 0, and moving right from memory cell 29999 should move the... | stackexchange_codegolf |
Task
You're in charge of making a compass, of sorts.
Imagine your source code as the compass "needle" where running at different orientations produces distinct output.
Supported source code orientations are North, East, South, and West.
Example
Let's say you have source code:
ABCD
J K
WXYZ
We'll consider this the Nor... | stackexchange_codegolf |
Just like jQuery's $.fn.text, write one or two functions that can get and set the text on an element.
You can't use textContent or innerText, and even less innerHTML.
Plain javascript. No DOM library. It has to work on major browsers. (No need to care about old IE.)
Shortest code wins.
Enjoy!
| stackexchange_codegolf |
Introduction
Write a solver for integer linear programming.
Challenge
Your task is write a solver for integer linear programming (ILP). In ILP, linear inequalities of a set of unknowns (all of which are integers) are given, and the goal is to find the minimum or maximum of a linear function.
For example, for the inequa... | stackexchange_codegolf |
The following problem is taken from the real world — but indubitably code-golf!
In this puzzle, the programming language is fixed, and your job is to write the most efficient program in this fixed language. The language has no loops; a program is a straight-line sequence of instructions. Each instruction consists of ex... | stackexchange_codegolf |
Background
In C, there is a function to help parse command-line arguments: getopt.
Getopt takes the argument count (argc), the argument list (argv), and a string representing the options the program should take (optstring).
The option string (optstring) is a series of option characters each followed by one colon (for a... | stackexchange_codegolf |
The Post's Correspondence Problem (PCP) gives you a list of pairs of strings, P_1 ... P_n. Your task is to find a k, and some sequence of k indices such that fst(P_i1) ... fst(P_ik) = snd(P_i1) ... snd(P_ik)
We're trying to find some sequence of the pairs where the word we build from the first part is equal to the word... | stackexchange_codegolf |
Let \$\sigma(n)\$ represent the divisor sum of \$n\$ and \$\sigma^m(n)\$ represent the repeated application of the divisor function \$m\$ times.
Perfect numbers are numbers whose divisor sum equals their double or \$\sigma(n) = 2n\$. For example, \$\sigma(6) = 12 = 2\times6\$
Superperfect numbers are numbers whose twic... | stackexchange_codegolf |
The fast growing hierarchy is a way of categorizing how fast functions are growing,
defined the following way (for finite indices):
\$ f_0(n)=n+1 \$
\$ f_k(n)=f_{k-1}^n(n)\$ with \$f^n\$ meaning repeated application of the function f
Examples
f0(5) = 6
f1(3) = f0(f0(f0(3))) = 3+1+1+1= 6
f2(4) = f1(f1(f1(f1(4)))) = 2*... | stackexchange_codegolf |
In a desolate, war-torn world, where cities have been overrun by thugs and thieves, civilization has reinvented itself in the form of small, isolated, industrial cooperatives, scattered throughout the previously uninhabited landscape. The existence of these communities is reliant on teams of mercenary workers called "s... | stackexchange_codegolf |
Alice is an intern in a company that uses Brainfuck as a primary language for both client-side and server-side development. Alice just has written her first code and she's a bit nervous as she's getting ready for her first code review.
Alice wants to make her code properly formatted and look nice, but she has no time t... | stackexchange_codegolf |
Input:
A list of integers
Output:
Put each digit (and the minus sign) in its own lane, in the order -0123456789, ignoring any duplicated digits.
Example:
Input: [1,729,4728510,-3832,748129321,89842,-938744,0,11111]
Output:
-0123456789 <- Added as clarification only, it's not part of the output
1
2 7 ... | stackexchange_codegolf |
Background
Peter's Father, the Teacher of a dance-club, asks Peter a question:
Given are two natural numbers (\$\mathbb{N}\$ \$x\$ and \$y\$).
\$x\$ is the number of the garment types (e.g. shorts, shirts\$\dots\$) we have
\$y\$ is number of colors (e.g. green, blue, \$\dots\$) of each garment we have.
In the dance cla... | stackexchange_codegolf |
This question is about moving stacks around in the card game FreeCell, but here it will be presented more abstractly.
Given three integers \$0\le n,m<10000,0<k<10000\$.
There are \$m+2\$ columns, \$m\$ of them empty and two of them contain cards (from bottom to top) \$[0,-2,k]\$ and \$[0,-3,k-1,k-2,\cdots,1,0]\$. Besid... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.