instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
I want format a JSON string into human-readable form. A string like this: '{"foo":"hello","bar":"world","c":[1,55,"bye"]}' would be formatted as: { "foo": "hello", "bar": "world", "c": [ 1, 55, "bye" ] } Rules: For objects and arrays properties and items should be starting in new line with indent...
stackexchange_codegolf
There's a lot of questions about Conway's Game of Life, but nothing about customization (Related: 2-Player Life). Given an input, determine the result on a 100x100 grid after some iterations. The input is given as a string. For example: Using the character #, follow the following rules: If there are 2 or 3 neighboring ...
stackexchange_codegolf
Getting the area covered by a rectangle is really easy; just multiply its height by its width. However in this challenge we will be getting the area covered by multiple rectangles. This is equally easy ... so long as the rectangles don't overlap. If the rectangles don't overlap the total area covered is the sum of th...
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
Given an input of a list of words and their abbreviations, output the pattern by which the abbreviations can be formed. Let us take the example input of potato ptao puzzle pzze as an example (that is, the abbreviation for potato is ptao, and the abbreviation for puzzle is pzze). Consider all possible ways to obtain pt...
stackexchange_codegolf
Write a script, program or function which takes one input of type string and outputs or returns some sort of indication wether the input string was 'hi whats up' (without the apostrophes) or not. You can for example return true if it was and false if it wasn't. Or print something to the screen, like 1 or 0. It just has...
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
Background The task is simple but every programmer has implemented it at least once. Stackoverflow has a lot of samples, but are they short enough to win? Problem story You're a grumpy programmer who was given the task of implementing file size input for the users. Since users don't use bytes everyone will just enter "...
stackexchange_codegolf
Given a number from 1 to 24, output the kissing number to the best of current knowledge (some numbers will have more than one acceptable output). Knowledge of geometry is not essential as the outputs are all listed below. From the Wikipedia page on the Kissing Number Problem: a kissing number is defined as the number ...
stackexchange_codegolf
m|Y bR|ain is We|iRd. F(o)R T(h)E La|sT fi(v)e YE|ars O|R s|o, (I) ha|ve C(u)T wO|rds in h(a)lf wh|En (I) s(e)e Th|em. Wh|EN I started Do|ing it, it To|oK a meN|TaL effort - B(u)T I almost cou(l)dn't N(o)T d|o it. N(o)w, I d|o it in the back of my head, a(n)d hardly ev|en not|iCe it. However, I thought this wo|uld make...
stackexchange_codegolf
Thanks to @KritixiLithos for helping me out with this challenge! V is a programming language that I wrote so that I could use and extend vim for code-golf challenges. The very first commit was on March 3rd, 2016, meaning that today V turns one year old! Woo-hoo Over V's first year of existence, there have been 176 com...
stackexchange_codegolf
⢣⠃⢎⠆⣇⡇⡯⡂⠈⡏⢰⢵⢐⡭⢸⠪⡀⢸⢐⡭⠀⢹⠁⢎⠆⢸⣱⢸⡃⢎⠰⡱⢸⣱⢸⡃⠈⡏⢸⡃⡱⡁⢹⠁⢸⡀⡇⡗⢅⢸⡃⠈⡏⢸⢼⢸⢐⡭⠀ ⣇⢸⡃⢹⠁⢹⠁⣟⢸⢕⢐⡭⠀⡮⡆⡯⡂⣟⠀⡯⠰⡱⢸⣸⢸⢕⠀⣏⡆⢎⠆⢹⠁⣪⠅⢸⢼⢸⠰⣩⢸⢼⠀⡮⡆⡗⢼⢸⣱⠀⢎⠆⡯⠀⢇⠇⡮⡆⡯⡂⡇⡮⡆⣟⡆⣇⢸⡃⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀ ⢎⠆⡗⢼⢸⡃⢸⡃⡗⠔⡇⡯⠂⢹⠁⢣⠃⠸⡸⢸⡃⡯⡂⢹⠁⡇⢎⢰⢵⢸⡀⢸⡀⡇⡗⢼⢸⡃⢐⡭⢸⡃⡯⠂⡮⡆⡯⡂⡮⡆⢹⠁⣟⢐⡭⠀⢎⢸⢼⢰⢵⢸⢕⢰⢵⠰⡁⢹⠁⣟⢸⢕⢐⡭⠀ ⡮⡆⢐⡭⢸⠕⢰⢵⠰⡁⣟⠀⡇⣪⠅⢈⣝⢸⡃⡯⡂⢎⠆⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀ ⣪⠅⢎⠆⢸⠈⡏⠀⣇⠰⡱⠰⡱⢸⠪⡀⣪⠅⢸⡀⡇⡗⢅⢸⡃⠸⡰⡸⠰⡱⢸⢕⢸⣱⢐⡭⠀⡮⡆⡯⡂⣟⠀⣪⠅⣟⢸⠕⢰⢵⢸⢕⢰⢵⠈⡏⢸⡃⣏⡆⢸⣳⠘⡜⠀...
stackexchange_codegolf
Overview The sharpness of a word is the sum of the sharpness of each of its letters, using the following rules: Sharp letters A, and V each have a sharpness of 1 N and Z each have a sharpness of 2 M and W each have a sharpness of 3 Dull letters C and U each have a sharpness of -1 S has a sharpness of -2 O has a shar...
stackexchange_codegolf
Your challenge is to write a Python program to print all the primes (separated by whitespace) less than a given integer N with an asterisk (*) next to each twin prime in ONE statement. A twin prime is a prime number that is either two more or two less than another prime. All output should be to stdout and input should ...
stackexchange_codegolf
Your program should print the following: **Language, XXX bytes** ``` CODE ``` or its equivalent. XXX should be substituted by the actual number of bytes your program takes, and CODE should be substituted by the source code of your program. Language should be substituted by the actual language your program is in. Your...
stackexchange_codegolf
Basing on this SO question. Challenge is rather simple: given a date period in the format YYYYMM output it in the format MMMYY. Rules: The input will be a number or a string exactly 6 characters long, consisting only of digits. Last two digits will be between 01 and 12. Output must be in the form MMMYY, where MMM repr...
stackexchange_codegolf
Alternesting, is the act of taking a string and nesting it in alternating brackets. Here is how you alternest a string. For a string of length N, take the center N characters, and surround them in parenthesis. So if our string was Hello world! (12 characters), we'll end up with (Hello world!) Then, take the remaining...
stackexchange_codegolf
Each natural number (including 0) can be written as a sum of distinct powers of integers (with a minimum exponent of 2). Your task is to output the smallest power required to represent \$n\$. For example: 2 = 1^2 + 1^3 // Output 3 9 = 1^2 + 2^3 = 3^2 // Output 2 15 = 2^2 + 2^3 + 1^4 + 1^5 + 1^6 // Output 6 20 = 2^2 + ...
stackexchange_codegolf
I'm surprised this hasn't come up in a challenge yet. Output the IP address of the machine you're running on. You are required to output both the local and external IP addresses. Local IP address, ie along the default format of 192.168.x.x Public IP address can be verified by using google https://www.google.co.uk/searc...
stackexchange_codegolf
So the golf question was like this: You are given a number T and then a total of T number of 17-character strings. For each of the strings, output yes if it contains four consecutive identical characters or contains the substring DX, else output no. The following constraints are promised for each of the 17-character ...
stackexchange_codegolf
Choose a set of four bytes without replacement (i.e. no byte repeated), and not necessarily in any particular order, from any one of the following four sets: The characters of any one single-byte encoding The Unicode characters in the range 00–FF The signed decimal integers in the range −128–127 The unsigned decimal i...
stackexchange_codegolf
Imagine that there are \$n\$ different types of objects \$O_1,O_2,O_3,\ldots,O_n\$ and they each have a conversion factor \$k_1,k_2,k_3,\ldots,k_n\$. You can, for any \$1\le i\le n\$, convert \$k_i\$ amount of \$O_i\$ into \$1\$ of any other type of object. Task Your objective is to output all the possible ending confi...
stackexchange_codegolf
This challenge is based on a video in which Andrew Huang discusses unusual time signatures... https://www.youtube.com/watch?v=JQk-1IXRfew In it, he advises that you can understand time signatures by dividing them into 3's and 2's. So you count to a small number a few times, instead of counting to a large number. Here's...
stackexchange_codegolf
It's time for CGCC to demonstrate our musical talent! In this challenge, you're going to compose songs while keeping your byte count as small as possible. On Day 0, multiple answerers will post a function or program that outputs nothing/an empty string. They will also give a single line that next day's answers must out...
stackexchange_codegolf
Credit to Geobits in TNB for the idea A post without sufficient detail recently posited an interesting game: 2 children sit in front of an array of candy. Each piece of candy is numbered 1 to x, with x being the total amount of candy present. There is exactly 1 occurrence of each number. The goal of the game is for the...
stackexchange_codegolf
The challenge Find the smallest feedforward neural network such that, given any 3-dimensional input vector \$(a,b,c)\$ with integer entries in \$[-10,10]\$, the network outputs the largest (i.e., "most positive") root of the polynomial \$x^3+ax^2+bx+c\$ with error strictly smaller than \$0.1\$. Admissibility The notion...
stackexchange_codegolf
Problem Let's define a generalized Cantor set by iteratively deleting some rational length segments from the middle of all intervals that haven't yet been deleted, starting from a single continuous interval. Given the relative lengths of segments to delete or not, and the number of iterations to do, the problem is to w...
stackexchange_codegolf
Introduction The rain finally subsided. Most of humanity drowned due to a bug in @user12345's code. Survivors are scattered across a worldwide archipelago. Radio communication is up, and humanity is poised to thrive once more. For no reason whatsoever, zombie pirates have gathered at the Prime Meridian, and are sweepin...
stackexchange_codegolf
The Challenge In this challenge you have to do two different (but related) tasks depending of the order of the input. Your program will recieve a string s and an integer n as input and will split s into pieces of length n if s comes first. The last element will be shorter if necessary. split s into n pieces of equal l...
stackexchange_codegolf
Write a program or function which, when run, outputs another program or function which is valid in the same language as the original program, and which itself will output another program or function that has the same properties. You must at one point end up back to your initial program or function. Example Suppose you ...
stackexchange_codegolf
The challenge is to find a string of characters that cannot appear in any legal program in your programming language of choice. That includes comments, strings, or other "non-executable" parts. Challenge Your program may be specific to a particular version or implementation of your language's compiler/interpreter/runt...
stackexchange_codegolf
(This is part 1 in a two-part challenge.) Your task is to solve a Hexasweep puzzle. A Hexasweep puzzle is set out on a grid of diamonds arranged in hexagonal shapes, of which the board looks like a hexagon, like so: _____ /\ \ _____/ X\____\_____ /\ \ / XX /\ \ /X \____\/____/X \____\ \ X/...
stackexchange_codegolf
Similar in spirit to Number of distinct tilings of an n X n square with free n-polyominoes and Partition a square grid into parts of equal area, this challenge will have you count ways of partitioning a triangle in a triangular grid. The goal of this code-golf challenge is to write a program that outputs \$ a(n,m)\$, t...
stackexchange_codegolf
Background The number of values for a given type is called the cardinality of that type, and that of type T is written as |T|. Haskell and a few other languages have a certain set of enum types, each of which has a small finite number of values (the exact names vary, so this challenge uses some arbitrarily chosen names...
stackexchange_codegolf
Challenge The challenge is to write a code that takes a positive integer 'n' as an input and displays all the possible ways in which the numbers from 1 - n can be written, with either positive or negative sign in between, such that their sum is equal to zero. Please remember that you may only use addition or subtractio...
stackexchange_codegolf
I came across an interesting tiling of the plane using squashed hexagons in a popular math book. All the six edges of the squashed hexagon are the same length. Two opposite corners are right angles and the rest four corners are 135 degrees each. This shape allows four squashed hexagons be arranged so that they meet at ...
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
You should get string of chemical equation (no spaces, only letters (upper-case and lower-case), numbers, brackets and math signs) from user and print the answer if equation is balanced or not (any pair of positive/negative answers: Yes/No, true/false, 1/0). To make code shorter you can assume that input strings can co...
stackexchange_codegolf
Just for fun, I wanted to see how little lines I could solve this problem in, using python. I managed to condense my code into 9 lines. size = int(input("Size: ")) a = [x for x in range(size-2, -1, -1)] if size % 2 == 0 else [x for x in range(size-2, 0, -1)] b, counter = a[::-1], 0 print("\n"+"\\"+"#"*size+"/") #top f...
stackexchange_codegolf
Challenge For a given positive integer \$n\$: Repeat the following until \$n < 10\$ (until \$n\$ contains one digit). Extract the last digit. If the extracted digit is even (including 0) multiply the rest of the integer by \$2\$ and add \$1\$ ( \$2n+1\$ ). Then go back to step 1 else move to step 4. Divide the rest of...
stackexchange_codegolf
So, normally, this is a forbidden loophole to fetch the desired output from an external source. But this challenge is an exception ! In this challenge you will have to fetch data from the internet and output it to the SDTOUT. The task For the purpose of this challenge, you'll be the owner of the imaginary a.pi domain!...
stackexchange_codegolf
This is a simple task. Given a positive or negative real number, round it to the next whole integer closer to zero. The challenge Take input through any reasonable form (stdin, function, etc.) of one positive or negative real number. Round this number "towards zero" - this means if it is positive you will round down,...
stackexchange_codegolf
Dedicated to Martin Gardner, taken from his book Background In the old days, the Slavs had a divination method for finding out whether a girl would get married. The girl would clutch six straws in her hand so that the ends would poke out the top and bottom of her fist. Then her friend would join together the ends of pa...
stackexchange_codegolf
Marshall Lochbaum's online BQN REPL has an interesting(and aesthetically pleasing) method of displaying arrays. Your task is to implement a version with simpler rules. [2,[3],4,[[[6,[5],7]]]] becomes: ┌─ · 2 ┌· 4 ┌· · 3 · ┌· ┘ ...
stackexchange_codegolf
The task here is simple: given a target location on an XY grid, and a rectangle on that grid, find the length of the shortest path from the origin to the target which does not intersect the rectangle. All parameter values are integers. You can assume that neither the target point nor the origin is inside or on the bord...
stackexchange_codegolf
Story There is a woman, named Sarah, whom likes smooth horse rides. She's going to go for a ride down a path too thin to pass any other horses she may come across - and so that her ride can be as smooth as possible she does not want to have to change speed though she would prefer to get to her destination as fast as p...
stackexchange_codegolf
Input: An integer n Output: A string A * B Example 12 Possible 2 divisible numbers: 12 * 1, 6 * 2, 4 * 3 12-1 = 11 6-2 = 4 4-3 = 1 4 and 3 has the minimal absolute difference of 1 Therefore, Output: 4 * 3 Order of the numbers does not matter This challenge idea was taken from a puzzle in Clash of Code in https://www...
stackexchange_codegolf
This time, you are working on a regex. Your regex is meant to approximately full-match the base-10 representations of primes \$0 \le p < 1000\$, while ignoring any non-numeric string or composite in the range. You can full-match 2, 53 or 419, but not 0, 82 or example. The approximately is important -- a minimum of 900 ...
stackexchange_codegolf
Traditionally when you compare two strings you use lexicographical comparison. That can be described by the recursive algorithm: $$ f(x, y)= \left\{\begin{array}[rr] \\ \mathrm{EQ} & \mathrm{if}\,\mid x\mid=0\,\mathrm{and}\,\mid y\mid=0 \\ \mathrm{GT} & \mathrm{if}\,\mid x\mid>0\,\mathrm{and}\,\mid y\mid=0 \\ \mathrm{L...
stackexchange_codegolf
Background Sometimes, people think you didn't work at your git project. But - you can prove yourself with git shortlog -n. Now, the problem is you are a programmer and programmers are lazy. So you want to write a program which shows the person who committed at most. Rules You may not do the following things: use git s...
stackexchange_codegolf
Challenge Create a 3D word puzzle where the cube's dimensions match the length of the input word. The uppercase word (A-Z) must be validly placed within the cube in one of the fixed orientations: horizontally, vertically, or diagonally. The program should randomly place the hidden word and fill the rest of the cube wit...
stackexchange_codegolf
Every odd degree polynomial has at least one real root. However this root does not have to be a rational number so your task is to output a sequence of rational numbers that approximates it. Rules Your input is an odd degree polynomial \$f\$ with integer coefficients in any reasonable format. You must output a sequen...
stackexchange_codegolf
Problem: Given a string representing a mathematical expression with constants (pi, e, psi, i), basic arithmetic operations (+, -, *, /), parentheses, fractions, and exponentiation, write a program or function to convert a string to its equivalent LaTeX code. The input string will only contain digits, arithmetic operato...
stackexchange_codegolf
Create the shortest program/function/whatever that splits an inputted string along un-nested commas. A comma is considered nested if it is either within parentheses, brackets, or braces. Input and output Output should be a list or a string joined with linebreaks. The input may contain any characters. All testcases wil...
stackexchange_codegolf
Fennel is a lispy language which compiles to Lua. From its page: Fennel is a programming language that brings together the speed, simplicity, and reach of Lua with the flexibility of a lisp syntax and macro system. I am looking for general tips for golfing in this language. Tips should be specific to Fennel, "Remove ...
stackexchange_codegolf
The magic music box (MMB) This explains the motivation for the challenge, feel free to ignore. The magic music box is a word game played by a group of people, where one is the owner of the magic music box and the other people are trying to put words inside the magic music box. Rules for the game with humans: the game g...
stackexchange_codegolf
Subleq is a Turing-complete esolang with only one instruction, SUBLEQ. This instruction takes in three parameters, A, B, and C, all of which are memory addresses. The instruction subtracts the value in memory address A from that in memory address B, storing it in address B. If the value at B is now less than or equal t...
stackexchange_codegolf
This is going to be relatively quick... Challenge Given a lower-case word as input, calculate the Pearson's Correlation Coefficient between the letter position of the word (nth letter within the word, x), and the letter position within the alphabet (nth letter of the alphabet, y). Background Pearson's Correlation Coeff...
stackexchange_codegolf
This is the Robbers thread. For the Cops challenge, see here As the robbers, your job is to crack the cops' answers. Choose an uncracked, unsafe cop answer and attempt to figure out which languages, in which order, the cop used. Note that a crack is valid even if the languages are different. So long as the the language...
stackexchange_codegolf
In this challenge, you need to find a specific pixel within an photograph (taken with a real camera). You are passed an (R, G, B) tuple and an image, and you need to return a point (x,y) within the image that matches the RGB color given. The image may have multiple points that match the color; you only need to find 1....
stackexchange_codegolf
Task FizzBuzz, but instead of 3 and 5, you'll take the numbers and corresponding strings as input. You can assume all inputted numbers are coprime (and \$\ge 2\$). You'll receive one or more numbers, and a string to print with each of them. The normal FizzBuzz would be something like [[3, "Fizz"], [5, "Buzz"]], but you...
stackexchange_codegolf
Note: This challenge has nothing to do with actual assembly language. As the head of Code-Golf Factory Inc., you must create an assembly line to generate a specific piece of code. Today, the foreman has asked you to produce quines. Specification: In this challenge, the goal is to write a quine such that a proper subse...
stackexchange_codegolf
The challenge: Assuming you have \$ X \$ collections, each collection \$ C_i \$ has a name \$ N_i \$ and a capacity \$ N_i \$ of elements - Determine which collection will be overflowed first while counting the occurrences of the names in a cyclic list. Also print how many cycles of the list occurred. Example: 4 Collec...
stackexchange_codegolf
Strangely never asked before, this question pertains to the generation of a list of prime numbers within a given range using the shortest possible code. Several algorithms, such as the Sieve of Eratosthenes and trial division, are known to be effective for this purpose, but require significant code length. Is there an ...
stackexchange_codegolf
The Universal Crossword has a set of guidelines for crossword puzzle submissions. In this challenge we are going to be concerned with their rules for hidden word themes. A hidden word clue consists of a clue and a word. It can either be a "word break" or a "bookend". For a word break the word must not appear as a cont...
stackexchange_codegolf
The objective Given a string of Hangul syllables, sort the characters in North Korean dictionary order. Introduction to Hangul syllables Hangul(한글) is the Korean writing system invented by Sejong the Great. Hangul syllables are allocated in Unicode point U+AC00 – U+D7A3. A Hangul syllable consists of an initial consona...
stackexchange_codegolf
Obviously, code golfing is all about making the most of the least code. Who really cares what the actual output is? While we have had a challenge for highest input-to-output ratio, this is a call for most finite and deterministic output with given code lengths. Ironically, this challenge is then not code-golf. Rules: ...
stackexchange_codegolf
Introduction (may be ignored) Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the second challenge in this series. The first challenge can be found here. In this challenge,...
stackexchange_codegolf
Sandbox post In this code-golf challenge, you are provided with a series of y values at even x-values as well as a console width and height. The desired output is an ASCII-art representation of a ribbon plot of the y-values scaled to the desired size. If all values are positive or negative, the x-axis should be display...
stackexchange_codegolf
Challenge Given a string with any characters a-z or A-Z, return an 'encrypted' string, where all characters are replaced by the character next to it (assuming a QWERTY keyboard). Case (uppercase, lowercase) does not matter. The input will only have characters a-z and A-Z. Shortest code in bytes wins. Example Input a...
stackexchange_codegolf
Given an integer \$n > 1\$, output a balanced binary tree with \$n\$ leaf nodes. The tree should be constructed out of (space), \ and / (slashes). Each slash represents a branch. A node is represented by adjacent slashes: /\. There must be a root node at the top of the tree (i.e. the first row of the output). To con...
stackexchange_codegolf
Golf Me An OOP! Two important components of object-oriented programming are inheritance and composition. Together, they allow for creating simple yet powerful class hierarchies to solve problems. Your task is to parse a series of statements about a class hierarchy, and answer questions about the hierarchy. Input A seri...
stackexchange_codegolf
Challenge : Given an integer n as input. Create a diamond that is 2x the given number n. Input : Input is integer n and 2 < n ≤ 3000. Output : Output will be a string and it will be in form of a diamond consisting of + with an addition line at the start showing n using + Examples : D(3) : +++ + +++ +++++ +++++ ++...
stackexchange_codegolf
Heading into the final day of regular season games for the 2023 NBA season, the fifth to ninth seeds in the Western Conference were still very undecided. Four games would determine the seeding: New Orleans (N) at Minnesota (M) Utah at LA Lakers (L) Golden State (G) at Portland LA Clippers (C) at Phoenix Let the Boole...
stackexchange_codegolf
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 which together form a lossless round-trip String × String → String → String × String. More specifically, defi...
stackexchange_codegolf
Write a program or function that takes input and outputs/returns a full program (in the same language) that outputs said input. Note that the input may contain any printable ASCII character or newline (AKA 0x20-0x7f and 0x0a). However, the input will not have trailing whitespace nor preceding whitespace, nor will it be...
stackexchange_codegolf
Sandbox Your challenge is to write a program that when first run, will do one of the actions below at random with equal chances of both: A cat program A standard cat program: read everything from STDIN and put it on STDOUT (or your language's closest equivalent). Do nothing and halt This shouldn't output anything....
stackexchange_codegolf
In the spirit of Hello world! with NO repetition Write a program that prints the string "the quick brown fox jumps over the lazy dog" with optional newline. The entire program must not repeat any characters. Note that the string to be printed does repeat characters, so you will have to get around that limitation someho...
stackexchange_codegolf
This challenge is related Challenge Your task is to write as many programs/snippets as you can, where each one outputs/prints/ returns an alphabet. The first program must output the letter A or a, the second one B or b and so on. You can not reuse any characters between the programs (Except Whitespace, it can be reused...
stackexchange_codegolf
The standard long addition method: The standard algorithm for adding multidigit numbers is to align the addends vertically and add the columns, starting from the ones column on the right. If a column exceeds ten, the extra digit is "carried" into the next column. (wikipedia) A long addition example: 145 + 98 ----- ...
stackexchange_codegolf
Background "Fly straight, dammit" (OEIS A133058) is a sequence of integers, which has these rules: \$a_0 = a_1 = 1\$ \$a_n = a_{n-1}+n+1\$ if \$gcd(a_{n-1}, n) = 1\$ Otherwise, \$a_n = \frac{a_{n-1}}{gcd(a_{n-1}, n)}\$ In pseudocode: a[0] = a[1] = 1 if gcd(a[n-1], n) == 1 then a[n] = a[n-1] + n + 1 else a[...
stackexchange_codegolf
Can you decrypt me? Robbers Find any combination of \$n\$ working chars to change and what they should change into, where \$n\$ is chosen by the cop. You cannot change less than n chars, only exactly \$n\$. Example print(2) N is 1. Robbers' post: print(1) Scoring For the robbers, the user with the most cracks wins. ...
stackexchange_codegolf
The Challenge Write a program or function that takes two input integers, i and j, and outputs their greatest common divisor; calculated by using the Euclidean algorithm (see below). Input Input may be taken as a space-delimited string representation of i and j or as two separate integers. You can assume that integers ...
stackexchange_codegolf
Objective Given an unlabelled binary tree, decide whether it is contiguous in indices. Indices This challenge gives one-indexing on binary trees. The exact definition expresses all indices in binary numeral: The root is indexed 1. For every node, to get the index of its left child, replace the most significant 1 by 1...
stackexchange_codegolf
Simple task, write a program/function that returns error if and only if presented with itself. The program must give a valid output for any input other than itself. For the error part, you can only use errors already built in errors that comes with your language of choice. New/ self-defined error messages are not allow...
stackexchange_codegolf
This function should take four integer inputs (a,b,c,d) and return a binary word based on which values equal the maximum of the four. The return value will be between 1 and 0xF. For example: a = 6, b = 77, c = 1, d = 4 returns 2 (binary 0010; only 2nd-least significant bit is set corresponding to b being sole max value...
stackexchange_codegolf
Given a polynomial function f (e.g. as a list p of real coefficients in ascending or descending order), a non-negative integer n, and a real value x, return:    f n(x) i.e. the value of f (f (f (…f (x)…))) for n applications of f on x. Use reasonable precision and rounding. Solutions that take f as a list of coefficien...
stackexchange_codegolf
This question asks for a T9 dictionary matching functionality which is a very interesting problem. But T9 has another way of typing and that is typing character-by-character. You would NOT need a dictionary to implement this keyboard. Here is key-map of a T9 keyboard if you forgot: +-------+-------+-------+ | 1 | ...
stackexchange_codegolf
We all know about the Fibonacci sequence. We start with two 1s and keep getting the next element with the sum of previous two elements. n-bonacci sequence can be defined in similar way, we start with n 1s and take the sum of previous n elements to get the next element. Challenge Given a positive integer m > 1, output t...
stackexchange_codegolf
Is there any javascript-like language? Something that can be interpreted by browsers?
stackexchange_codegolf
Your task today is to implement a time limit for getting input, a task I've found rather annoying to achieve in most languages. You will create a program function which prompts the user for input. Immediatly after the user supplies input, print the message input received and end execution/return. However, if the user w...
stackexchange_codegolf
Your task is to make a program in L that takes n as an input number, output a program p in L that prints its own first n characters. Rules The program p has to be irreducible, See an example below. PAY ATTENTION TO THIS RULE: If a program takes an input as n, the first n characters of the output would be the same as...
stackexchange_codegolf
Consider an \$n \times n\$ grid of integers which is part of an infinite grid. The top left coordinate of the \$n \times n\$ grid of integers is \$(0, 0)\$. The task is to find a circle which when overlaid on the grid gives the largest sum of values inside it. The constraints are: The circle has its centre at \$(x, x...
stackexchange_codegolf
Consider the following string: Tin Snips This string contains several atomic symbols on the periodic table. We could rewrite this string to identify several of them: [Ti][N] [Sn][I][P][S] Of course, we could also write it this way: T[In] [S][Ni][P][S] The rules for rewriting the input are as follows: The case of th...
stackexchange_codegolf
Background Stick Bomber is a two-player game I just made up. Initially, some sticks are placed in one or more groups, and the sticks in each group are laid out in a straight line. So a configuration with three groups of 3, 5, and 8 sticks each may look like the following. For conciseness, we can call it a (3,5,8) confi...
stackexchange_codegolf
Write an interactive program or function which allows the user to play The Coinflip Game! The object of the game is to repeatedly flip a coin until you get the same result \$n\$ times in a row. Specific behavior of the program/function is as follows: At the start of the game, the user inputs a positive integer \$n>1\$...
stackexchange_codegolf
For today's challenge, you must write a program or function that alternates the case of a string. However, you must ignore non-alphabetic characters. This means that every alphabetic character must have a different case than the preceding and following alphabetic character. This is slightly more complex than uppercasin...
stackexchange_codegolf
Consider a horizontal line with vertical lines centered on the x-axis and placed at gaps of \$\sqrt{2}/2\$. For a positive integer \$n \geq 3\$, the first half of the lines have lengths \$0, \sqrt{2}, 2\sqrt{2}, 3\sqrt{2}, \dots, (n-1)\sqrt{2}\$ and then the second half have lengths \$(n-2)\sqrt{2}, (n-3)\sqrt{2}, \do...
stackexchange_codegolf
Introduction After a day of drinking and watching the world cup, you sit down to play friendly game of boggle. Tempers rise as you are accused of wasting everyone's time with nonsense words that aren't even on the board! You may be seeing double, but surely you're thinking straight enough to write a program that will v...
stackexchange_codegolf
This challenge has ended. To see the final scores of the competitors, click here In this challenge, each submission is one bot. Each bot should be a Javascript function. Bots will fight to obtain the highest total worth in gold. Gold can be farmed, or earned from killing other bots, and is used to upgrade healing, at...
stackexchange_codegolf