instruction_seed stringlengths 34 53.1k | _source stringclasses 1
value |
|---|---|
Now that I'm thoroughly addicted to Code Golf, it's probably about time that I try to pick up a few golfing languages.
Given that I play almost exclusively in JavaScript, Japt seems like the logical language to start with. I'll be diving into the documentation at the next opportunity I get but, in the meantime, please ... | stackexchange_codegolf |
The goal of this Code Golf is to create a program that sorts a list of strings (in ascending order), without using any built-in sort method (such as Array.Sort() in .NET, sort() in PHP, ...). Note that this restriction excludes using a built-in method that sorts an array descending, and then reversing the array.
Some ... | stackexchange_codegolf |
Brachylog is a language that's beginning to rise in prominence in code-golfing recently (and just received a major update with a terser syntax). Like Prolog, it has the advantage that it can often solve a problem (typically via brute force) merely from a sufficiently accurate description of what a problem looks like, a... | stackexchange_codegolf |
Note: In this post, the terms 'character' and 'color' mean essentially the same thing
This image:
can be represented as
....'''333
.eeee'''3e
..dddd33ee
%%%dd####e
(mapping colors to ascii characters)
The four color theorem states that
"given any separation of a plane into contiguous regions, producing a figure cal... | stackexchange_codegolf |
Background
Slowsort is an in-place, stable sorting algorithm that has worse-than-polynomial time complexity. The pseudocode for Slowsort looks like this:
procedure slowsort(A[], i, j) // Sort array range A[i ... j] in-place.
if i ≥ j then
return
m := floor( (i+j)/2 )
slowsort(A, i, m) ... | stackexchange_codegolf |
Intro:
A Frobenius number is a number which cannot be made from numbers in a set.
For example, 43 is the Frobenius number of the set {6, 9, 20}, because you cannot get 43 from those numbers, and it is the largest number which cannot be made.
42 is not a Frobenius number of the set {6, 9, 20}, because it can be made fro... | stackexchange_codegolf |
Minecraft inventory management is hard. You have 17 diamonds, but you need 7 to craft an enchantment table, a pickaxe, and a sword. Do you pick them up and right click 7 times? Or do you right click once and right click twice and take the 7 left? It's so confusing!
for those of you who are now confused, don't worry, I'... | stackexchange_codegolf |
Background
K functions have a feature called projection, which is essentially partial application of values to a function. The syntax for projections is a natural extension of the regular function call syntax:
f[1;2;3] / call a ternary function f with three arguments 1, 2, 3
f[1;2;] / the third argument is missi... | stackexchange_codegolf |
Yeah... it's confusing. Let me explain it a little better:
With a string, get the unicode code points of each letter
Let's use "Hello World!".
The code points would be [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
Of each digit of the code points, get their binary format
Get the binary of 7, then 2, the... | stackexchange_codegolf |
We already have challenges dealing with simulating vanilla Conway's Game of Life, Wireworld and rule 110, but so far none corresponding to a (specific) non-totalistic rule. So here is one.
In June 2000 David Bell described the Just Friends rule, which uses the same square grid and two states as regular Life but has the... | stackexchange_codegolf |
Here is a relatively simple two dimensional array challenge.
Imagine a battlefield of 625 foot soldiers. You command the odd troops, but unfortunately the strength of the even troops overwhelms you. Thankfully, your soldiers have a secret power: If the power of each odd troop and the fellow odd allies surrounding them ... | stackexchange_codegolf |
You have come across an old Indian manuscript, one that describes mounds of buried treasure. The manuscript also tells you the location of the treasure, except that some crucial numbers have been encoded indirectly into the text. You figure out that the text uses a 'Kaadi' system, a restricted subset of the more common... | stackexchange_codegolf |
Cellular Automata are truly fascinating. The ones that are usually talked about are the binary ones, i.e., the ones representable by a number. However, those, in my opinion, have been done to death. Ternary CAs are more interesting, but we have all of ASCII to consider! What fun could that be!
Instead of deciding a rul... | stackexchange_codegolf |
We can write mathematical expressions using the standard math operators (,),+,*,/,- available pretty much universally. We allow the symbols a, b, c, d and integers (e.g. 1, 45, etc.) but will restrict to just these four symbols. (Bonus points if you can handle more.) The goal is to take an expression as input and outpu... | stackexchange_codegolf |
Task
The letters spell out actual words, but if you replace each letter with a digit from 0–9, it also “spells” an arithmetic equation. The trick is to figure out which letter maps to each digit. All the occurrences of each letter must map to the same digit, no digit can be repeated, and no “word” can start with the di... | stackexchange_codegolf |
This is the robbers' thread. The cops' thread goes here.
In the cops thread, the task was to write a program/function that takes a positive (or non-negative) integer and outputs/returns another number (not necessarily integer). The robbers task is to unscramble the code the cops used to produce this output.
The cracked... | stackexchange_codegolf |
Based on the "Pretty Ugly" poem.
Input consists of a number of stanzas (positive integer), and four arrays/lists of strings, called the "negatives", "negations", "positives", and "filler" sentences.
You must output a "pretty ugly" poem with the specified number of stanzas. A stanza consists of a negative, negation, pos... | stackexchange_codegolf |
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 |
Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro.
My boss has gotten a new toy robot, and he wants me to help program it. He wants to be able to enter simple arrow instructions to get it to move. These instructions are: ^ (for move fo... | stackexchange_codegolf |
Scoring a Go game is a task that is not all too easy. In the past there have been several debates about how to design rules to cover all the strange corner cases that may occur. Luckily, in this task you don't have to do complicated stuff like life and death or seki detection. In this task, you have to implement a prog... | stackexchange_codegolf |
You have a program which creates an index for a catalogue. The last step is missing: it must find and consolidate page ranges within the list of pages for each entry.
Each entry is currently an array of unique integers in order, e.g:
[18,19,20,21,22,47,56,57,62,67,68,69,70]
Write a function which returns a consolidat... | stackexchange_codegolf |
Challenge description
Let's define an W x H grid as a two-dimensional array of length H whose each subarray is of length W. Example: a 2x3 grid (. character used as a blank):
..
..
..
A unit is a single point of a grid. A block is either a single unit or a set of contiguous units (meaning each unit of a block has at l... | stackexchange_codegolf |
Given a non negative integer number \$n\$ output how many steps to reach zero using radicals, divisions or subtractions.
The algorithm
Get digits count ( \$d\$ ) of \$n\$.
Try the following operations in order:
$$\sqrt[d]{n}$$
$$n/d$$
$$n-d$$
Take the first integer result not equal to \$n\$.
Floating point errors ... | stackexchange_codegolf |
Graph theory is used to study the relations between objects. A graph is composed of vertices and edges in a diagram such as this:
A-----B
| / \
| / \
| / E
| / /
|/ /
C-----D
In the above diagram, A is linked to B and C; B is linked to A, C, and E; C is linked to A, B, and D; D is linked to C and... | stackexchange_codegolf |
The Pascal's triangle and the Fibonacci sequence have an interesting connection:
Source: Math is Fun - Pascal's triangle
Your job is to prove this property in Lean theorem prover (Lean 3 + mathlib). Shortest code in bytes wins.
import data.nat.choose.basic
import data.nat.fib
import data.list.defs
import data.list.nat... | stackexchange_codegolf |
Befunge is a 2-dimensional esoteric programming language. The basic idea is that (one-character) commands are placed on a 2-dimensional grid. Control flow walks across the grid, executing commands it passes over, and changing direction when it hits an arrow (>^<v). Commands are stack-based; see this list. See also http... | stackexchange_codegolf |
Goal
You are given an integer n (n > 1). You must output how many permutations of the integers 1 to n there are which start at 1, end at n, and don't have two consecutive integers which differ by 1.
Alternatively, if you take the complete graph K_n and remove the edges of the path 1-2-3-...-n you must count the Hamilto... | stackexchange_codegolf |
Let's see how good your language of choice is at selective randomness.
Given 4 characters, A, B, C, and D, or a string of 4 characters ABCD as input, output one of the characters with the following probabilities:
A should have a 1/8 (12.5%) chance to be chosen
B should have a 3/8 (37.5%) chance to be chosen
C should h... | stackexchange_codegolf |
Can you decrypt me?
Cops
Cops, post obfuscated code that hides a number \$n\$ (n must not be greater than the program length) inside its code. If \$n\$ chars are changed (no additions or deletions), the program outputs exactly one \$n\$ (any amount of whitespace before or after is allowed.) Otherwise, it outputs someth... | stackexchange_codegolf |
When translating DNA into proteins, the ribosomes read the sequence of DNA nucleotides 3 by 3. Each set of 3 nucleotides is called a codon, and each codon encodes for an amino acid, with some redundancies. Here's the conversion table used by most organisms (table is read left, top, right):
Humans and most other organi... | stackexchange_codegolf |
This is a fairly simple challenge. Given a lower-case word, you must "interpolate" between letters. Here's some examples to hopefully clarify this:
Input: test
Output: tsrqponmlkjihefghijklmnopqrst
Between letters you must add, in alphabetical order, the letters between those two letters. So if you have ad, you must ou... | stackexchange_codegolf |
Programming is very rigid. You can't tell a program to "output the banana count", you have to tell it to print(bananas).
But when you do that, you end up with a problem: you don't know how many bananas you have beforehand, so you don't know whether to use a plural.
Sometimes, programmers go the lazy way. Instead of che... | stackexchange_codegolf |
Robbers thread
Your task is to create a method for hiding information in an image. You will post three encoded messages of your choice (keep them classy), each with its associated image. Reveal the messages for the first two images and do not reveal the third. Robbers have the task of determining what your third hidden... | stackexchange_codegolf |
Scenario
I often cook lasagne, but I also have a few mistakes. Since I repeat these faults so often, I thought I maybe could do a program that checks if I did everything right.
Valid lasagne
A valid lasagne is
At least 5 columns wide
At least 4 layers high
Excluding extra cheese
The top layer is cheese (represented... | stackexchange_codegolf |
We live in a wonderful age of technology where we can have beautifully detailed 8K screens on our TVs, and even 2K displays on our phones for our mobile browsing pleasure. We've come a long way in recent years in terms of screen technology.
One of the products of this is a term that was made popular by Apple, Retina. ... | stackexchange_codegolf |
Fairly obviously, you have to print the Greek alphabet. But I thought I'd make it slightly more interesting, so there's a twist: when your program is ran with an argument (anything), it should output the Greek alphabet in lowercase.
Information
Greek alphabet (Capitals): ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ
Greek alphabet (Lower... | stackexchange_codegolf |
Everybody loves geometry. So why don't we try and code golf it? This challenge involves taking in letters and numbers and making shapes depending on it.
The Input
The input will be in the form of (shapeIdentifier)(size)(inverter).
But what are shapeIdentifier, size, and inverter?
The shape identifier is the identifie... | stackexchange_codegolf |
There's a little-known secret in Banjo-Kazooie that you can interleave the three Cheato codes on the Treasure Trove Cove Sandcastle floor and it will still recognize all of them. So you could, for instance, enter BLUREEGOLDDFFEEGEAATHTHEEGSRSRS, activating BLUEEGGS, REDFEATHERS, and GOLDFEATHERS all at once.
Challenge
... | stackexchange_codegolf |
Every Unicode character has a name, like "LATIN CAPITAL LETTER A". A Unicode character name may contain only uppercase letters, white spaces, and the minus sign.
Write a program that reads a text and outputs the names of each character on a new line. For example, if the input were "Hello, World!", the output would be
L... | stackexchange_codegolf |
Your task is to take in one integer input and print a zigzag pattern using slashes and backslashes.
The integer input determines the length of each zig and zag, as well as the number of zigs and zags
The pattern always starts from right to left
Test Cases
4->
/
/
/
/
\
\
\
\
/
/
/
/
\
\
\
\
2-... | stackexchange_codegolf |
Your task is to build a natural number using the fewest number of ones and only the operators + or -. For example, the number seven can be written 1+1+1+1+1+1+1=7, but it can also be written as 11-1-1-1-1=7. The first one uses 7 ones, while the latter only uses 6. Your task is to return the minimum number of ones that ... | stackexchange_codegolf |
there is only one rule: get accept for this problem http://acm.ut.ac.ir/sc/problemset/view/1032!
to submit your code, you need to create an account(if you don't want to do so, just post your code here and I'll submit it). so far shortest code is written with C and has 85 character length.
winner will be the shortest C... | stackexchange_codegolf |
The idea is simple. You've to create a "visualised" letter-replacement, by providing 3 strings (input can be comma separated, separate inputs, or as an array). The first segment is the word you want to correct, and the second segment is the letters you want to replace, and the third segment is the replacement for the l... | stackexchange_codegolf |
Description
Given a length n, and an alphabet size k>0, your program must determine the number of strings with those parameters which have a maximal number of unique substrings. In the case of k=2, this generates OEIS A134457.
Example
For example, 2210 has the substrings , 2, 22, 221, 2210, 2, 21, 210, 1, 10, and 0, ... | stackexchange_codegolf |
Given a unicode character C (or the first character of a string input), output that character's hex representation. Case does not matter. The output ranges from \u0000 to \u9999.
Test cases
A => 41 (65_10 === 41_16)
ʣ => 2A3 (675_10 === 2A3_16)
Ω => 3A9 (937_10 === 3A9_16)
7 => 37 (55_10 === 37_16)
(null byte) => 0 (... | stackexchange_codegolf |
Challenge
Given a list of unique colour names as input, sort them in the order that they first appear in Joseph's Amazing Technicolour Dreamcoat.
Example
Input: green, blue, red, brown
Output: red, green, brown, blue
The full list of colours, in order, is:
1. red
2. yellow
3. green
4. brown
5. scarlet
6. black... | stackexchange_codegolf |
In this challenge you are to write a program or function, that takes a string as input and outputs one of two possible values. We will call one of these values truthy and one falsy. They do not need to actually be truthy or falsy. For an answer to be valid it must meet four additional criteria
When you pass your pro... | stackexchange_codegolf |
Given a natural number c as input, our task is finding the fastest way to calculate one -atleast- availabe integer solution (a,b) of pell equation c=a²-b².
Rules
Built-in functions and loopholes arent given any interest.
The program deals with integers (signed), the input is not supposed to abuse this range.
Output can... | stackexchange_codegolf |
Following the great advice (what do you mean it's not advice?!) on Adding unnecessary fluff we can devise the following task:
Take a list of positive integers and a positive integer \$m\$ as input.
Only keep the prime values from the list.
Define \$f(n) = F_{n^2 + 1}\$ (the \$n^2+1\$-th element in the Fibonacci sequen... | stackexchange_codegolf |
Chess960, a.k.a. Fisher random chess, is a variation of the game of chess.
In classic chess the starting positions are always the same. In chess960 they vary.
Before each game of chess960 one random number from 0 to 959 is drawn. Both players then arrange their pieces in the same way according to this number from a loo... | stackexchange_codegolf |
Introduction
I defined the class of antsy permutations in an earlier challenge.
As a reminder, a permutation p of the numbers from 0 to r-1 is antsy, if for every entry p[i] except the first, there is some earlier entry p[i-k] such that p[i] == p[i-k] ± 1.
As a fun fact, I also stated that for r ≥ 1, there are exactly ... | stackexchange_codegolf |
Description :
Given an array of strings representing a grid of cells
With the key :
0 = 'dead cell'
1 = 'live cell'
write a function that returns the next iteration following the rules of Conway's Game of Life .
Rules
Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
Any live ... | stackexchange_codegolf |
proposed by @Adám in chat
Given an even number of finite points return a line \$y=mx+b\$ that evenly splits the points on both sides.
Specs
Take a list of distinct points \$(x,y)\$ (or a list of x-coordinates and a list of y-coordinates), output a possible \$(m,b)\$ pair
Half of the points should be true for \$y>mx+b\... | stackexchange_codegolf |
EDIT (Jan 19, 2022, 18:00 UTC): This challenge is now over. The winner is Citty with this Pyth answer. Congratulations!
This is an answer-chaining challenge where each answer must take an integer \$N\$ as input and return the 1-indexed ID of the answer which was written by the user whose ID is \$N\$.
You may want to s... | stackexchange_codegolf |
What general tips do you have for golfing in Emotinomicon? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Emotinomicon (e.g. "remove comments" is not an answer).
Please post one tip per answer.
| stackexchange_codegolf |
Carry sort is an \$O(n)\$ "sorting" algorithm. Here's how it works. The algorithm moves left to right along a list. As it traverses a list it "carries" a single item, the largest item it has encountered so far. Once it encounters a larger item it picks up that item and drops the item it is already carrying in place. W... | stackexchange_codegolf |
CHALLENGE
This is a fastest-code challenge.
Count how many n-dimensional hypercubes with n=1,2,3,4 exist, with vertices labeled with either 1 or 0, such that there does not exist any rectangle formed by 4 vertices such that one diagonal is 1-1 and the other diagonal is 0-0. To be more clear, the forbidden rectangles ha... | stackexchange_codegolf |
Some two-dimensional esolangs, such as Forked, and some non-esolangs, such as Python, can sometimes require spaces before lines of code. This isn't very golfy. Also, I'm lazy and writing a 2d lang that needs lots of spaces before code. Your task is to write a tool that makes these languages golfier.
Of course, this wil... | stackexchange_codegolf |
You are given two strings \$a\$ and \$b\$ consisting of characters from a to z in lowercase. Let \$n\$ be the length of \$a\$. Let \$m\$ be the length of \$b\$. Let \$a'\$ be the string \$a\$ repeated \$m\$ times. Let \$b'\$ be the string \$b\$ repeated \$n\$ times. Check whether \$a'\$ is lexicographically less than \... | stackexchange_codegolf |
Modern British number plates (a.k.a. registration marks or license plates) use the format AANNXXX where AA is a "DVLA memory tag" (basically a location code), NN is the age identifier, and XXX is three random letters.
Your task is to, given a date, generate a random valid number plate with a date code matching the supp... | stackexchange_codegolf |
Write three different programs such that when any one program is provided as input to one of the other two, you get the source of the remaining program as output. More explicitly, given programs \$A\$, \$B\$, and \$C\$, where \$f(g)\$ denotes the output obtained from inputting the text of program \$g\$ into program \$f... | stackexchange_codegolf |
If I want to type the string aaa, the least keystrokes I can type it in is 3: a a a. But if I want to type the string aaaaaa, I can do it in 5: a a a ctrl-c ctrl-v, where the ctrl-c refers to copying aaa and the ctrl-v refers to pasting it.
Specifically, starting with an empty "buffer" and an empty "clipboard":
The ke... | 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 |
Wren is a small, fast, class-based concurrent scripting language. Does anyone have any tips for this language?
Please make sure to post 1 tip per answer, and don't post answers like "remove whitespace".
| stackexchange_codegolf |
Notation and definitions
Let \$[n] = \{1, 2, ..., n\}\$ denote the set of the first \$n\$ positive integers.
A polygonal chain is a collection of connected line segments.
The corner set of a polygonal chain is a collection of points which are the endpoints of one or more of the line segments of the chain.
Challenge
T... | 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 |
Introduction
All the possible moves and their combinations of a Rubik's Cube form a group. A group in general is a set with some binary operation defined on it. It must contain a neutral element with respect to this operator as well as inverses for every element of the set. For instance the integers \$\mathbb Z\$ with ... | stackexchange_codegolf |
Write the shortest program or function that will determine if an input is a valid Go type.
Spec
This challenge will use the following simplified subset of Go types. For more information, see the Golang specification.
"Primitive" types:
bool
int,uint,float(32|64),complex(64|128),byte,rune
string
*T where T is any ty... | stackexchange_codegolf |
Challenge
Given a positive-length string \$S\$, a divisor of \$S\$ is another (not necessarily distinct) string for which there exists a number \$a\$ such that when we repeat the divisor \$a\$ times, we get the string \$S\$.
For example, the string abcd is a divisor of the string abcdabcd with \$a=2\$.
Your challenge i... | stackexchange_codegolf |
Lets play a game of Meta tic-tac-toe!
This is a king-of-the-hill tournament of Meta tic-tac-toe. The rules of Meta tic-tac-toe are as follows:
All of the regular rules of tic-tac-toe apply.
There are nine boards arranged to make one master board. Like so:
0|1|2 || 0|1|2 || 0|1|2
----- || ----- || -----
3|4|5 || 3|4... | stackexchange_codegolf |
It's mentioned last time that, in Hearts,
Each round every player gets a non-negative amount of points. The sum of the points is 26, and at least one player gets 13 or more points.
Actually, it's the game part:
Average the 52 cards (♠♡♢♣ * 23456789 10 JQKA) to the 4 players
The player with a ♣2(the smallest value) s... | stackexchange_codegolf |
From here. Every new game is the first day of the month, 12:00 PM UTC.
The goal is to create the Stack Overflow logo using ASCII characters.
It looks like this.
The exact output should look like this:
\\
\\
\= \\
\= \\
\= \\
\== \\
¯¯¯ \==
¯¯¯... | stackexchange_codegolf |
A word search is a matrix of letters as defined in Word Search Puzzle Generation. For a word search to contain a word, it means that that word appears somewhere in the matrix horizontally, vertically, or diagonally.
Your task is to write a program that takes a list of strings and outputs the dimensions of the smallest-... | stackexchange_codegolf |
Yes, I know there is a similar question, but this one specifically concerns any possible words, even with letters left over, while the linked one restricts to a permutation of the input
Objective
Have you ever had those moments in a Scrabble game where you're staring at your letters, trying to find a good word, and y... | stackexchange_codegolf |
Given a pattern and a ragged list of positive integers, your task is to decide whether the pattern matches the ragged list.
The pattern is also represented by a ragged list. But in addition to positive integers, it may contain a wildcard value.
Here is the rule for matching:
A positive integer matches the same positiv... | stackexchange_codegolf |
Challenge
Robin likes having his variables declaration in the shape of an arrow. Here's how he does it:
Input any number of strings
Order them by ascending length
Output them ordered by the middle to roughly form a negative arrowhead, like this (whichever order golfs the best):
5 or 4
3 2
1 1
2 3
4 ... | stackexchange_codegolf |
I was trying to write a short MIPS32 code for computing the median of three registers.
The rules:
Assume that some values are pre-loaded into $t0, $t1, $t2.
The median of the three values should be placed in $t0.
No branches are allowed, but otherwise any instruction is okay.
You may arbitrarily modify the values of a... | stackexchange_codegolf |
Related: Cleaning up decimal numbers
Background
A continued fraction is a way to represent a real number as a sequence of integers in the following sense:
$$
x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{\ddots + \cfrac{1}{a_n}}}} = [a_0; a_1,a_2,\cdots,a_n]
$$
Finite continued fractions represent rational number... | stackexchange_codegolf |
Intro
You like cats. Naturally, you like cat’s games in tic-tac-toe. So, you’ve come up with a little party trick.
You ask someone what square on the board they want you to make a move in. And you ask someone else on which turn they want you to make that move. You also let that person decide whether you play Xs or Os. ... | stackexchange_codegolf |
I was looking around on the web and I found this Google Code Jam Puzzle. I really liked it so I decided to post it here.
New Lottery Game
The Lottery is changing! The Lottery used to have a machine to
generate a random winning number. But due to cheating problems, the
Lottery has decided to add another machine. Th... | stackexchange_codegolf |
Challenge :
\$\pi\$ is supposed to be infinite. That means every number is contained inside the decimal part of \$\pi\$.
Your task will be to take a positive integer on input and return the position of this number in \$\pi\$ digits on output.
For example, if the input is 59, we'll return 4
Here is why : we will look fo... | stackexchange_codegolf |
Challenge
Output the person on PPCG who has cast the most upvotes and the person who has cast the most downvotes.
Voters
You should only look at the people who have cast more than 1000 votes in total.
To find the person who upvotes the most, you should the find the person with the highest upvotes/total votes value. Sim... | stackexchange_codegolf |
The natural numbers including 0 are formally defined as sets, in the following way:
Number 0 is defined as the empty set, {}
For n ≥ 0, number n+1 is defined as n ∪ {n}.
As a consequence, n = {0, 1, ..., n-1}.
The first numbers, defined by this procedure, are:
0 = {}
1 = {{}}
2 = {{}, {{}}}
3 = {{}, {{}}, {{}, {{}}}... | stackexchange_codegolf |
It's strange that I haven't seen this, as Excel seems to be a valid language for code golfing (despite its 'compiler' not being free).
Excel is somewhat of a wildcard in golfing, being good at golfing challenges of medium complexity, and sometimes simpler challenges as well. More often than not, Excel is good at challe... | stackexchange_codegolf |
Here is a list of the 118 (current) elements of the periodic table (in a collapsed Stack Snippet for your convenience):
Hydrogen
Helium
Lithium
Beryllium
Boron
Carbon
Nitrogen
Oxygen
Fluorine
Neon
Sodium
Magnesium
Aluminium
Silicon
Phosphorus
Sulfur
Chlorine
Argon
Potassium
Calcium
Scandium
Titan... | stackexchange_codegolf |
Your program is supposed to create a full red screen in MSDOS. The source of the binary (.com file) must be 5 bytes or less. No wild assumptions, the binary must work in MsDos, DosBox, and FreeDos alike. For winning, you have to post x86 assembler code which can be assembled with NASM (FASM) or directly the hex code of... | stackexchange_codegolf |
In ValiDate ISO 8601 by RX, the challenge was to use only standard regular expressions to validate standard date formats and values (the former is a common job for RX, the latter was unusual). The winning answer used 778 bytes. This challenge is to beat that using any language of your choosing, but without special date... | stackexchange_codegolf |
Bitshift Variations in C Minor by Robert Miles is a Code Golf music piece written in C (with some additional bash commands). It was originally presented in a 2016 Computerphile video Code Golf & the Bitshift Variations. You can listen to clean renderings of it here (by Lucia Ceionia).
The original 2016 source code pres... | stackexchange_codegolf |
The mean of a population \$(x_1,\dots,x_n)\$ is defined as \$\bar x=\frac1n\sum_{i=1}^n x_i\$. The (uncorrected) standard deviation of the population is defined as \$\sqrt{\frac1n\sum (x_i-\bar x)^2}\$. It measures how dispersed the population is: a large standard deviation indicates that the values are far apart; a lo... | stackexchange_codegolf |
Challenge
Premise
Bob is a novice pianist who can only play sequences of single notes. In addition, he does quite an interesting thing: for every note after the first, if it's higher than the previous note was, he uses the finger directly to the right of the previous finger used; if lower, to the left; if the same pitc... | stackexchange_codegolf |
Starting with a positive integer N, find the smallest integer N' which can be computed by repeatedly dividing N by one of its digits (in base-10). Each selected digit must be a divisor of N greater than 1.
Example #1
The expected output for N = 230 is N' = 23:
Example #2
The expected output for N = 129528 is N' = 257:... | stackexchange_codegolf |
The totient function \$\phi(n)\$, also called Euler's totient function, is defined as the number of positive integers \$\le n\$ that are relatively prime to (i.e., do not contain any factor in common with) \$n\$, where \$1\$ is counted as being relatively prime to all numbers. (from WolframMathworld)
Challenge
Given an... | stackexchange_codegolf |
The Animal-Alphabetical Sequence is an infinite string of letters built accordingly to the following procedure:
Start with the letter A;
Replace each letter with the name of the animal starting with such letter in the table below;
Go back to step 2.
For instance, the first four steps of the procedure give:
A
ADD... | stackexchange_codegolf |
ASCII boxes look like this:
++ +---+ +------+ +---+ +---+
++ | | | | | | | |
| | | | | | | |
+-+ | | | | | | | |
+-+ | | | | | | +---+
+---+ | | | |
+--+ | | | | ++
| | ... | stackexchange_codegolf |
I am a robot. I bought this keyboard because of its easy rectangular layout:
~` !1 @2 #3 $4 %5 ^6 &7 *8 (9 )0 _- +=
tab Qq Ww Ee Rr Tt Yy Uu Ii Oo Pp {[ }] \|
Aa Ss Dd Ff Gg Hh Jj Kk Ll :; "' [-enter-]
Zz Xx Cc Vv Bb Nn M... | stackexchange_codegolf |
Inspired by the Codewars Kata.
Your goal is to take an input string such as this one:
"'Twas a dark and stormy night..."
and return a string containing the position of each character in the alphabet, separated by spaces and ignoring non-alphabetical characters, like this:
"20 23 1 19 1 4 1 18 11 1 14 4 19 20 15 18 13 ... | stackexchange_codegolf |
The goal of this challenge is to generalise the bitwise XOR function to other bases. Given two non-negative integers \$ x \$ and \$ y \$, and another integer \$ b \$ such that \$ b \geq 2 \$, write a program/function which computes the generalised XOR, described the following algorithm:
First, find the base \$ b \$ re... | stackexchange_codegolf |
In combinatorics, the rook polynomial \$R_{m,n}(x)\$ of a \$m \times n\$ chessboard is the generating function for the numbers of arrangements of non-attacking rooks. To be precise:
$$R_{m,n}(x) = \sum_{k=0}^{\min(m,n)} r_k x^k,$$
where \$r_k\$ is the number of ways to place \$k\$ rooks on an \$m \times n\$ chessboard ... | stackexchange_codegolf |
What I want:
Take an input, x
Take a formula. It has to be capable of reading something in the format:
ax^m + bx^n + cx^o ... where m, n, o and any terms after that can represent any value.
coefficients, again for any number. For example, 6x^2. (That means 6(x^2))
Doesn't necessarily have to put up with spaces
times, ... | stackexchange_codegolf |
Given an array of integers A, the task is to output another array B of the same length so that B[i] is the maximum over A for every index that is not i. That is \$B[i] = \max_{i' \ne i} A[i']\$.
Examples:
A = [1, 5, -3, 4, 2]. B = [5, 4, 5, 5, 5]
A = [1, 2, 3]. B = [3, 3, 2]
A = [-1, -2, -3, -1]. B = [-1, -1, -1, -1]
... | stackexchange_codegolf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.