instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Often I need a simple Hello World! program to show some basic concepts of a programming language on my travels. As I usually travel only with light luggage I can't to carry a Hello World! program for each language. So a program that generates Hello World! programs in as many languages as possible would be a great help....
stackexchange_codegolf
Your challenge is very simple: output the previous answer, in reverse. However, as with this similarly-titled question, there's a catch: in this case, you cannot use characters from the answer before the last. For example: Let's say the first answer looks like this: 1 - Python print('hi!') And the second answer looks...
stackexchange_codegolf
In project management there's a method, called the critical path method, that is used for scheduling activities and for determining which activities' timings are crucial (i.e. critical) and for which activities the schedule offers a timing tolerance. Your program's task is to order a set of activities chronologically a...
stackexchange_codegolf
Sandbox For the purposes of the current task, a cube of unit length is rendered in oblique projection with ASCII symbols as follows: +-----+ / /| +-----+ | | | + | |/ +-----+ + for the vertices. - for the X edges. The unit length along X is represented by five - between two vertices. | for the Y edges....
stackexchange_codegolf
What is Crazyhouse Chess? Crazyhouse Chess is a chess variant that is basically normal chess except you can place a piece you previously captured back on the board instead of a regular turn. Bot interface Only JavaScript bots are allowed. A bot is a JavaScript function that takes 3 arguments (board, side, bank) and ret...
stackexchange_codegolf
John Horton Conway was a brilliant mathematician. Among his contributions were three Turing-complete esolangs: Game of Life (esolangs wiki), FRACTRAN (esolangs wiki), and Collatz function (esolangs wiki). Because we did an extremely amazing job around GoL, it is time for the challenge with the other two. Background A F...
stackexchange_codegolf
A variable-length quantity (also referred to as VLQ or uintvar) is a way to encode up to a 28 bit integer value using only as many bytes as necessary. This was used in MIDI file format as a way to minimize the size of certain event data. The way it works is fairly simple. As a big-endian series of bytes, the most sign...
stackexchange_codegolf
Oreoorererereoo Given an input string that is similar to the word "oreo", give an ASCII representation of the cookie that is as wide as the input string (to ensure cookie stability). Rules The input is lowercase, a non-empty string with no whitespace containing any combination of the strings "o" and "re", and contain...
stackexchange_codegolf
The problem #6 of IMO 2009 reads: Let a 1, a 2, a 3, ..., a n, be distinct positive integers and let T be a set of n-1positive integers not containing a 1+a 2+a 3+...+a n, A grasshopper is to jump along the real axis, starting at the point 0 and making n jumps to the right with lengths a 1, a 2, a 3, ..., a n in so...
stackexchange_codegolf
Display the 12 numbers on a clock face exactly like this: 12 11 1 10 2 9 3 8 4 7 5 6 To better see the grid, here's one with dots: ...........12............ ....
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
It's likely that anyone who used Twitter a couple of months ago would know about the 'Howdy! I'm the sheriff of X" meme. Where a simple image of a sheriff is drawn with emoji, and changes to fit a theme. So I thought it was time for the Sheriff of Code Golf. Here he is: ### ##### ### ### ### # ...
stackexchange_codegolf
Task Given a list of nodes representing a binary tree of positive integers serialized depth-first, return a list of nodes representing the same tree serialized breadth-first. To represent an absent child, you may use null, 0, 'X', Nothing, [], or any other value that is distinct from your representation of a node's val...
stackexchange_codegolf
The Fibtraction sequence (as I call it) is similar to the Fibonacci sequence except, instead of adding numbers, you subtract them. The first few numbers of this challenge are: 1, 2, -1, 3, -4, 7, -11, 18, -29, 47, -76, 123, -199, 322, -521, 843, -1364... The sequence starts with 1 and 2. Every next number can be calcu...
stackexchange_codegolf
The "prime frog" is a strange animal that jumps between integers, until it arrives on 3 or 19... Your program should accept an integer n as input and output the result of the below algorithm (3 or 19). For a given integer n >= 2: Let f be the position of the frog. It is initially set to n if f = 3 or f = 19 : the fro...
stackexchange_codegolf
Gobar primes (A347476) are numbers which give a prime number when 0's and 1's are interchanged in their binary representation. For example, \$10 = 1010_2\$, and if we flip the bits, we get \$0101_2 = 5\$ which is prime. Therefore, 10 is a Gobar prime As simple as that: print the series with any delimiter. Shortest code...
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
The graph of the modulo operation (\$y = x \mod k\$) looks like this: This is a very useful function, as it allows us to create "wrapping" behavior. However, it is very cumbersome when I want to use it to create an appearance of "bouncing" between two walls. The graph of the "bounce" function (\$y = \text{bounce} (x, ...
stackexchange_codegolf
Premise: Your reputation is in Stack-Exchange Form if it can be represented by decomposing your medal counts (gold, silver, and bronze counted separately) into their base-10 digits and joining them in any given order, with a few caveats. While decomposing, each Gold medal digit is worth three digits. Silver is worth...
stackexchange_codegolf
As you probably know, there have been multiple lovely Jimmy challenges recently popping up. In these challenges, you were challenged with our beloved friend's acrobatics skills. Now we've got a different challenge for you. Today you will be identifying different types of Jimmys! Explanation There are three varieties o...
stackexchange_codegolf
This is a Cops and Robbers challenge. For the Robbers' thread, go here. The Cops have three tasks. 1) Pick a sequence from the OEIS. 2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual code-golf rule...
stackexchange_codegolf
I am too bored and want a challenge to solve. But I do not see any interesting challenges, and I am too lazy to search for one. Can you (Well, technically your code) suggest me one? I/O Input: None. Output: A link to a random open(i.e. non-closed) challenge("Challenge" excludes tips!) on PPCG. You may not link to an a...
stackexchange_codegolf
(inspired by this challenge over on Puzzling -- SPOILERS for that puzzle are below, so stop reading here if you want to solve that puzzle on your own!) If a letter in a word occurs alphabetically later than the previous letter in the word, we call that a rise between the two letters. Otherwise, including if it's the sa...
stackexchange_codegolf
Dropsort, designed by David Morgan-Mar, is an example of a linear-time "sorting algorithm" that produces a list that is, in fact, sorted, but contains only some of the original elements. Any element that is not at least as large as the maximum of the elements preceding it is simply removed from the list and discarded. ...
stackexchange_codegolf
After all the fun we've had with polyglot challenges in the (recent) past, how about a challenge where the output can be in two languages? Your answer needs to accept boolean input b and output the text "true" or "false". The same code needs to output, when run in another language, "waar" or "onwaar" or any other trans...
stackexchange_codegolf
The code: function L(){N=null;E=[N,N];t=this;h=E;t.u=i=>h=[i,h]; t.o=_=>h==E?N:h[+!(h=h[1])];t.e=(i,l)=>h=(l||h)==E?[i, E]:[(l||h)[0],t.e(i,(l||h)[1])];t.s=_=>{o="";while(i=t.o()) {o+=i+","}return o}} For my response to this (old) question: https://codegolf.stackexchange.com/a/196783/72421 (my linked answer has a com...
stackexchange_codegolf
Please help me automate my discrete mathematics homework. Given a valid propositional formula, check if it is an instance of one of Łukasiewicz's axioms. Here's how it works. A term can be defined inductively as follows: Single lower-case letters of the Latin alphabet (a, b, c, etcetera) are terms. Given a term ϕ, ¬ϕ ...
stackexchange_codegolf
Consider an \$n \times n\$ grid and a circle of radius \$r \leq \sqrt{2} n\$ with its center in the top left. In each square there is an integer from the range -3 to 3, inclusive. For a given radius, there is a set of squares in the grid which are not at least half covered by a circle of radius \$r\$ but are at least ...
stackexchange_codegolf
A natural number (written in the decimal base) is qualified as digisible if and only if it fulfills the following 3 conditions: none of its digits is zero, all the digits that compose it are different, the number is divisible by all the digits that compose it. The challenge is to output all the digisibles (there are ...
stackexchange_codegolf
Background Here is a Halloween related challenge. As you may have seen from my last challenge I quite like what I term as ascii art animations, that is not just draw a pattern but draw a pattern that progresses. This idea came to me after I was asked a couple of years ago to liven up a (rather dull) presentation by mak...
stackexchange_codegolf
Construct a full program which outputs Hello, World!. The score of your submission will be equal to the sum of all of the ASCII values of the distinct characters. The lowest score wins! Rules It must be a full program which takes no input It must only print to STDOUT, nothing else It must be strictly less than 1000 by...
stackexchange_codegolf
Introduction This is a very simple challenge: simply count the divisors of a number. We've had a similar but more complicated challenge before, but I'm intending this one to be entry-level. The Challenge Create a program or function that, given one strictly positive integer N, outputs or returns how many divisors it ha...
stackexchange_codegolf
Recently, the PPCG design leaderboard has been having some trouble parsing answer html headers. In this challenge you'll be taking your own shot at parsing answer headers. Example Test Cases These example inputs (NOT actual test cases), just so you can get the idea of how inputs might be like Input: <h1>Python 3, 32...
stackexchange_codegolf
Your code-golf challenge is to find all occurences of a word in the 3d matrix. There is no restriction on I/O format. In the samples below, the word is presented, then a blank line, then the 2-dimensional layers from top to bottom, and the output, for each line, consists of a coordinate and a direction (x, then y, then...
stackexchange_codegolf
Output "Mozart - Alla Turca" to stdout (see the sample for "reference implementation") Try to find how to pack both synthesizer and the music into minimal size. Requirements: Format suitable for feeding into aplay -f cd (signed 16-bit little endian, 2 channels); Entire music should be played (no skipped notes or parts...
stackexchange_codegolf
Dropbox recently released Lepton (GitHub), a method that losslessly compresses JPEG images round-trip, saving an average of 22%. Because of the pigeonhole principle, any general compression algorithm cannot be guaranteed to result in a smaller file (general because it doesn't apply to inputs constrained to a specific ...
stackexchange_codegolf
Create the shortest program to check who has won in an nd tic tac toe game. Your program should work when n (width) and d (dimension number) are in these ranges: n∈[3,6]∩ℕ ie a number from this list: 3,4,5,6 d∈[2,5]∩ℕ ie a number from this list: 2,3,4,5 n = 3; d = 2 (32 ie 3 by 3): [][][] [][][] [][][] n = 3; d = 3...
stackexchange_codegolf
From Wikipedia: The centroid of a non-self-intersecting closed polygon defined by n vertices (x0,y0), (x1,y1), ..., (xn−1,yn−1) is the point (Cx, Cy), where and where A is the polygon's signed area, In these formulas, the vertices are assumed to be numbered in order of their occurrence along the polygon...
stackexchange_codegolf
We're getting markdown tables! I assume this is what they look like: data data data data --------------------- | | | | | | | | Your task is to make a program or function to generate one of these tables. You'll be given input (string, list of ...
stackexchange_codegolf
Recently, I was introduced to a puzzle game known as Solitaire Chess. I'll summarize the rules here: The board is a 4x4 checkerboard. All pieces are the same color (no teams) and all pieces can capture any other piece. Every move must be a capture. No moving to empty squares. There must be exactly one piece remaining ...
stackexchange_codegolf
You are given four integers: \$e,s,b\in\{0,1\}\$ and \$S\in \{0,1,2,4\}\$, where \$e,s,b,S\$ stand for egg, sausage, bacon and spam respectively. Your task is to figure out whether the corresponding ingredients match a valid entry in the following menu: [e]gg | [s]ausage | [b]acon | [S]pam -------+-----------+--------...
stackexchange_codegolf
An analog clock has 2 hands*: Hour and minute. These hands circle the clock's face as time goes by. Each full rotation of the minute hand results in 1/12th of a rotation of the hour hand. 2 full rotations of the hour hand signifies a full day. As these hands are fixed to the same central point, and rotate around that p...
stackexchange_codegolf
Your Challenge You must write a program/function etc. that takes a domain name of a StackExchange site and outputs the domain for the meta version of the site passed to it. Examples: stackoverflow.com => meta.stackoverflow.com codegolf.stackexchange.com => codegolf.meta.stackexchange.com mathoverflow.net => meta.mathov...
stackexchange_codegolf
In Java/.NET/C/JavaScript/etc. you can use ternary-ifs to shorten if-statements. For example (in Java): // there is a String `s` and an int `i` if(i<0)s="Neg";else if(i>0)s="Pos";else s="Neut"; Can be shortened with a ternary-if to: s=i<0?"Neg":i>0?"Pos":"Neut"; Challenge: Input: A regular if-else (possible with nes...
stackexchange_codegolf
A substitution cipher is an encoding method where each letter in the alphabet is replaced with a fixed, different one; for example, given the following substitution map: abcdefghijklmnopqrstuvwxyz || qwertyuiopasdfghjklzxcvbnm The phrase "we all love cryptography" would be encoded as "vt qss sgct eknhzgukq...
stackexchange_codegolf
You'll get a human-readable question matching one of the following syntaxes, and are expected to print/return the corresponding result. Finding similarities between the human-readable inputs and matching them with minimum size code is explicitly part of the task, so I won't give a formal definition. "Will October begi...
stackexchange_codegolf
Well the title says it all. Standard loopholes apply Nothing to read from stdin, and output goes to stdout 1-byte-long programs are... nonsense. They don't qualify A program with a single byte repeated is also a nonsense (like aaa) Please mark it out if your program is a palindrome Sample: A program with source code...
stackexchange_codegolf
Toki Pona is a linguist's code golf: A minimalist language with a vocabulary of around 120 words. Because of this, it has very few grammatical irregularities found in other languages, making it ideal for a code golf challenge. Your task is to take the most simple form of a Toki Pona sentence and translate it into Engli...
stackexchange_codegolf
inspired by thejonymyster's idea Rules This challenge is about finding languages that are very suitable for one task but quite the opposite in the other. The two tasks share a theme, but Task 1 is designed to be number-oriented while 2 is string-oriented. You can participate in three categories: Numbers: Choose a lang...
stackexchange_codegolf
Objective Given a positive integer, spell it out in the conlang I made. Specification Let \$n\$ be the inputted integer. \$n\$ shall be spelled out in the following specification. The entire spelling is case sensitive. With the decimal expansion of \$n\$, let d be the least significant nonzero digit of \$n\$. First, d ...
stackexchange_codegolf
For example, the gate A and B is a logic gate with 2 inputs and 1 output. There are exactly 16 of them, because: each logic gate takes two inputs, which can be truthy or falsey, giving us 4 possible inputs of the 4 possible inputs, each can have an output of truthy and falsey therefore, there are 2^4 possible logic ga...
stackexchange_codegolf
This challenge is inspired by this other challenge, which you may want to read first for some context. However, a competitive answer is likely to look very different, so after reading some posts on Meta I decided it was best posted as a separate question. The goal here is to write a polyglot program; that is, a program...
stackexchange_codegolf
It is Halloween and Jimmy (/o\) has gone into a mysterious neighborhood for trick-or-treating (ask himself why). Now some evil ghosts are chasing him. Can Jimmy escape the ghosts? Challenge: Input: A board showing position of Jimmy, ghosts, solid objects and empty spaces. An example 10x5 board, o is Jimmy (we needed a ...
stackexchange_codegolf
Tonight, 31 January 2020, Brexit will happen and the United Kingdom will leave the European Union, the first time that the number of EU member states will decrease. Your job is to take a date and output the number of EU1 members on that date, according to the following table: | Start | End | Number of memb...
stackexchange_codegolf
Write a full program or a function that takes a positive integer N as input via STDIN/command line/ARGV or function arguments and prints an ASCII double knot corresponding to the N to STDOUT. The ASCII double knot looks like this: __ __ __ __ __ __ / \/ \/ \/ \/ \/ \ | /\/ /\/ /\/ /\/ /\/ /\ | | \/ /\/ /\...
stackexchange_codegolf
It is quite simple, any language, make output show the time in the HH:MM or HH:MM:SS while the numbers and the colons being ascii art(The output is ascii art not the program) Sample output: ____________ ________ _____ .________ ________ /_ \_____ \ /\ \_____ \ / | | /\ | ____// _____/ | ...
stackexchange_codegolf
Plot contrivance You wake up to find that something has gone horribly wrong! Your time machine has malfunctioned and you are lost sometime between June 2022 and October 1991. You check the computer that you keep on the desk to see what time it is, but alas the positron interference from your quantum undetangler has fr...
stackexchange_codegolf
A little while back, data was frequently stored on punched card. A typical card would have 80 columns of 12 possible 'punch' positions. A plethora of encodings was used, each for their own specific purpose. These days we like to think of a byte as 8 bits. In this challenge, you're tasked to convert an 8-bit byte to a 1...
stackexchange_codegolf
Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro. I have a friend who is an architect, and, after explaining the concept of code-golf and this site to him, he said that I should code something actually useful for a change. I asked him ...
stackexchange_codegolf
Task Write a function/program that, given three positive integers a, b and c, prints a Truthy value if a triangle (any triangle) could have side lengths a, b and c and outputs a Falsy value otherwise. Input Three positive integers in any sensible format, for example: three distinct function arguments, f(2, 3, 5) a lis...
stackexchange_codegolf
Vim is a great text editor for unix systems, but it's notorious for being difficult to exit. Write a full program that will output :q to exit Vim. It should then read a single line of input, as it will then either be given a bash prompt, in which case the exit was successful, or an error, in which case there are unsave...
stackexchange_codegolf
Challenge Given a left- or right-stochastic matrix where the limit as x approaches infinity of the matrix to the power of x approaches a matrix with all finite values, return the matrix to which the matrix converges. Basically, you want to keep multiplying the matrix by itself until the result no longer changes. Test C...
stackexchange_codegolf
In this code-challenge you will write a hash function in 140 bytes1 or less of source code. The hash function must take an ASCII string as input, and return a 24-bit unsigned integer ([0, 224-1]) as output. Your hash function will be evaluated for every word in this large British English dictionary2. Your score is the ...
stackexchange_codegolf
Cops' Thread Your challenge is to find an uncracked, unsafe cop on the cops thread, and find an input value for which their code does not do as specified by the challenge. You must use values within the bounds specified by the cop and the challenge - if a float breaks their program but they specified integers only, it...
stackexchange_codegolf
Write a program that prints the RGB color of a given pixel on the screen. The program should read a line from stdin in the format x,y, where x and y are unsigned integers. The pixel (0,0) is the top left pixel in the screen. The program should then output a line to stdout in the format RRR,GGG,BBB, which represents the...
stackexchange_codegolf
Background In Python, function arguments are defined within the parentheses following the function name in the function definition. There are different ways to present function arguments, and they can be categorised into three types: Positional-only arguments, Positional or keyword arguments, and Keyword-only argument...
stackexchange_codegolf
You're a mouse. Your mouse friends have all been captured, and are unconscious and trapped in a maze that has only one entrance/exit. You happen to have a perfect map of the maze, so you can plot a solution to rush in and carry them all to safety. However, the maze is guarded with a security system that will trigger an...
stackexchange_codegolf
You will be given as input a non-empty list of positive integers. For example: [1,2,2,2,1] You want to produce a ragged list as output which has this as its "depth map". This list should have the same elements in the same order but each element n should be at the depth equal to its value. [1,[2,2,2],1] This is a li...
stackexchange_codegolf
Digesting a polygon is a process in which you take an input polygon, and create another polygon that can contain the entirety of the input polygon, while having one side less than it. The goal of this challenge is to generate the optimal polygon digest- a polygon digest that has the minimum area possible. Your challeng...
stackexchange_codegolf
Your task is to write a program that: Runs indefinitely Produces no output Consumes an unbounded amount of memory Specifications You must list the implementation used for your program. This is relevant because some implementations might preform optimizations while others do not. For example, the LISP code (defun f (...
stackexchange_codegolf
A while ago, I had a look at the prime factorization of 27000: 27000 = 23 × 33 × 53 There are two special things about that: consecutive-prime: The primes are consecutive: 2 is the 1st prime, 3 is the 2nd prime, 5 is the 3rd prime. constant-exponent: The exponent is the same for every prime (always 3) Mathematicall...
stackexchange_codegolf
This is a simple one: create the shortest browser script to change every appearance of force on a web page into horse. This script needs to be able to be pasted into the console and work on most modern browsers. You must replace all occurences of the word force and conjugates of the word force (forcing, forced, reinfor...
stackexchange_codegolf
(related) Your challenge is to output the highest number you can. You can output as a number or as a string. You must output something that matches the regex ^\d+$, as in only 0-9. The Twist Your source code must be: Same forwards and backwards 3 bytes long The middle byte must be different from the other two Exampl...
stackexchange_codegolf
Winner: Chilemagic, a massive 21 bytes! You may continue to submit your answer, however you can no longer win. Original post kept: Your goal is to find all numbers in a string, and multiply each one individually by a value input by the user You will not need to worry about decimals The user will input a number and a ...
stackexchange_codegolf
A loop is a pretty simple algebraic structure. It is a tuple (G,+) where G is a set and + is a binary operator G × G → G. That is + takes two elements from G and returns a new element. The operator is also required to fulfill two properties Cancellation: For every a and b in G there exists unique x and y in G such ...
stackexchange_codegolf
Note This is the encryption challenge. The decryption challenge can be found here. Challenge The challenge is to encrypt a given string, using the rules as specified below. The string will only contain lowercase alphabets, digits, and/or blank spaces. Equivalent of a Character Now, firstly you would need to know how to...
stackexchange_codegolf
Introduction Humans are a remarkable species, but we can be very awkward to understand sometimes—especially for computers. In particular, we seem to like writing polynomials in a very convoluted fashion with seemingly arbitrary rules. What is the shortest program you can write to format a polynomial correctly using t...
stackexchange_codegolf
Your task is to write a program which given an array and a number, you need to split the array into chunks with size is number. Rules Your program will receive an array A , as well as a positive integer n. The array should then be split into chunks of length n, if the length of the string isn't divisible by n any left...
stackexchange_codegolf
In elementary school, children learn about proper fractions, where the numerator is less than the denominator, and thus the value of the fraction is less than one. Later, they are taught about fractions where the value of the fraction is greater than one, and two different ways to express these fractions: mixed fractio...
stackexchange_codegolf
Key links: Troll question Chat room Game Controller Interface Dwarf league table <script src="https://ajfaraday.github.io/Thud/dist/data/tables.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table> <thead> <tr> <th>Client</th> <th>Wins</th><th>Loses</th> <th>S...
stackexchange_codegolf
A listening party is an event where a bunch of people get together to listen to some music (like a viewing party, but for music). In the age of the internet you can do Listening Parties online with friends, where you just all hit play together. The problem is on the internet everyone is in different time-zones so you ...
stackexchange_codegolf
Background Page 219 of A New Kind of Science (a book by Stephen Wolfram, the creator of Mathematica) shows an interesting 2D pattern generated by constraints. The relevant section in the book starts at page 210; you can browse other pages for more context. In short, the large binary image is the result generated by 12...
stackexchange_codegolf
Intro - Nearest neighbour comparison between two arrays is something that can be done very efficiently when only 1 variable per array is involved, because it can be done by sorting and then performing a rolling comparison. However, for a 2 variable comparison this sort operation cannot be done anymore and another smart...
stackexchange_codegolf
For this challenge you are going to make a function (your function may be a complete program) that takes a list as input and returns a permutation of that list. Your function must obey the following requirements. It must be deterministic. Composing your function with itself a variable number of times should be capabl...
stackexchange_codegolf
A quote from MO.SE answer: Although it is well known that Conway was able to quickly calculate the day of the week of any given date, it is less well known that one part of the algorithm is easy to remember and useful in practice: In any given year, the following dates all fall on the same day of the week: 4/4, 6/6, 8...
stackexchange_codegolf
This is a cops-and-robbers challenge, the robbers thread can be found here. Your task is to write some code that outputs an OEIS sequence, and contains the name of the sequence in the code (A______) and outputs a second separate sequence when the name of the sequence in the code is changed to the name of the second s...
stackexchange_codegolf
Write a function/program that accepts a string of lower/uppercase letters [A-Za-z] as input, that checks whether the occuring letters are unique and in alphabetical order (ignoring lower and uppercase) or not. The output must be truthy if they are unique and in alphabetical order and falsy if not. Here some testcases a...
stackexchange_codegolf
I am exploring a unique approach to the classic problem of Reverse Polish Notation on code.golf. Unlike the conventional solutions, my focus lies on leveraging the eval function in GolfScript. This twist was inspired by a comment in a related thread, where the absence of eval was deemed a limitation. "It's a shame no ...
stackexchange_codegolf
Much like this challenge, write a program or function that takes no input and prints or returns the string Hello, Earth! with an optional trailing newline. The catch is that your program must be an even number of characters long, and each two character chunk of your program must consist of identical characters. For ex...
stackexchange_codegolf
In the poker game there are 1277 unique 'High Card' ranks. It's 1287 (13 over 5) if we include all straights. The challenge is to write a function which returns an integer value corresponding to the rank of each 'High Card' poker combination including all straights. Possible cards are(in ascending order): '23456789TJQK...
stackexchange_codegolf
Given two strings, a parent string and a query string respectively, your task is to determine how many times the query string, or an anagram of the query string; appears in the parent string, in a case-sensitive search. Examples of Behaviour Input 1 AdnBndAndBdaBn dAn Output 1 4 Explanation The substrings are highlig...
stackexchange_codegolf
Introduction One question that I have come across recently is the possibility of dissecting a staircase of height 8 into 3 pieces, and then re-arranging those 3 pieces into a 6 by 6 square. Namely, is it possible to dissect the following into 3 pieces: x xx xxx xxxx xxxxx xxxxxx xxxxxxx xxxxxxxx And rearrange those 3 ...
stackexchange_codegolf
Background Hello golfers! I would like to learn all the programming languages! But I kinda have a short attention span... and copying all the Hello World examples gets boring... but I like fire! ^w^ Challenge So here is the plan! I want you all to write the smallest code that will compile, print Goodbye Cruel World!, ...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. As soon as the Elves get bored with the last week's game, Bin comes up with a new game. The rules are similar, except the Elves are supposed to say the numbers that have its "left side" equal to its "right side" when written in binary....
stackexchange_codegolf
Background Incident is a fairly unusual programming language, in that its list of tokens is not predetermined, but rather inferred from the input. As such, tokenising an Incident program can be fairly difficult, especially if you want to do so efficiently. This task is about doing that yourself. The task Your program w...
stackexchange_codegolf
The world is full of Turing-complete programming languages. Just about every useful language (and most useless ones) are Turing-complete. Some even became Turing-complete by accident. Often this is great, since every Turing-complete language supports the same power of universal computation. But the power of Turing ...
stackexchange_codegolf
One way to represent a natural number is by multiplying exponents of prime numbers. For example, 6 can be represented by 2^1*3^1, and 50 can be represented by 2^1*5^2 (where ^ indicates exponention). The number of primes in this representation can help determine whether it is shorter to use this method of representat...
stackexchange_codegolf
The Challenge Write two programs P and Q such that: P and Q are written in the same language The output of P is Q The output of Q is P P and Q are both non-empty Simple enough. Surely that's been done here before. Where this gets interesting is the scoring. Scoring P and Q are selfish, they don't want to sheir their...
stackexchange_codegolf
As part of its compression algorithm, the JPEG standard unrolls a matrix into a vector along antidiagonals of alternating direction: Your task is to take the unrolled vector along with the matrix dimensions and reconstruct the corresponding matrix. As an example: [1, 2, 5, 9, 6, 3, 4, 7, 1, 2, 8, 3], 4, 3 should yiel...
stackexchange_codegolf
Task Write a program or function that takes as input a time in UTC, and outputs the equivalent time in 5 different cities around the world. The cities displayed are up to the programmer, but the time must be different in each city. To prevent golfers from using overly obscure city names, the city names used must appear...
stackexchange_codegolf