instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Long time ago, when I was spending more time playing RPG, one of the issues what some players had, was to track party movement and to draw proper map. So I come with idea, to check how you guys come deal with this issue. Task is to write a function, which takes as input parameter list of directions (passed as structure...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. I've got an infinite supply of \$n\$-dimensional chocolate for some positive integer \$n\$. The shape of the chocolate is not important. You may assume that they are just \$n\$-dimensional hypercubes with side length \$1\$. To celebrat...
stackexchange_codegolf
Think of cleave as the conceptual inverse of map. If map applies a function to each number in a list... map([1, 2, 3], x -> x * 5) -> [5, 10, 15] then cleave applies each function in a list to a number. cleave(5, [x -> x * 2, x -> x - 1, x -> x * x]) -> [10, 4, 25] More formally, given: \$n\$, an integer, and \$L\$, a...
stackexchange_codegolf
Intro The Tetris Guidelines specify what RNG is needed for the piece selection to be called a Tetris game, called the Random Generator. Yes, that's the actual name ("Random Generator"). In essence, it acts like a bag without replacement: You can draw pieces out of the bag, but you cannot draw the same piece from the ba...
stackexchange_codegolf
Backstory You own a tiny jewellery shop in the suburbs of the city. The suburbs are too much overpopulated, so your shop has a thickness of only one character to fit in the busy streets. Recently, there has been lots of cases of robbery on the neighborhood, and you fear that robbers will also come to get your bounty. T...
stackexchange_codegolf
Given an integer n>0, write a program that will output an "isosceles" Triangle out of #'s of height n. Examples: n=3 # ### ##### n=1 # n=5 # ### ##### ####### ######### This would be invalid: # ### ##### ####### #########
stackexchange_codegolf
We want to go on a night hike with the youth group, but of course not everyone has their torch, even though we told them we planned to split up. What options are there for group formation if n teens have m torches with them, but each group needs at least one torch? Example: Three teens with torches (X) and two without ...
stackexchange_codegolf
Related to, but not a duplicate of, this challenge. Basics This is a clock: ****** ** | ** ** | ** * | * * | * * | * * | * * | * * ...
stackexchange_codegolf
If we have a binary matrix then we will say that a \$1\$ is stable if it is in the bottom row or it is directly adjacent to a \$1\$ which is stable. In other words there must be a path to the bottom row consisting only of \$1\$s. So in the following matrix the \$1\$s highlighted in red are not stable. $$ 0110\color{red...
stackexchange_codegolf
Find the outcome of a game of War When I was in elementary school, there was a "Rock-Paper-Scissors"-ish game we'd play during assemblies, when waiting for our teacher, at recess etc. We called it "War". After some searching however, it turns out this is a much simpler variant of the "Shotgun Game" (according to WikiHo...
stackexchange_codegolf
Challenge Create a function or program that, when given an integer size, behaves the following way: If size is equal to 1, output ┌┐ └┘ If size is greater than 1, apply the following substitutions : Source Target ┌ ┌┐└┌ ┐ ┌┐┐┘ └ ┌└└┘ ┘ ┘┐└┘ Note: this is basically a Unicode box-drawing version of the...
stackexchange_codegolf
Description You are given the results of a range function where every element has been rounded down to the nearest whole number. Your goal is to recover the original list. For example, the following function (in Python3) will produce an input for your program: from numpy import arange, floor def floored_range(A, B, C):...
stackexchange_codegolf
Swapping two elements in a vector/matrix is very simple in Octave: x='abcde'; x([4,1])=x([1,4]) x = dbcae Unfortunately, I have yet to find a way to do this inside an anonymous function. While the function below is syntactically correct, it only gives back the two elements that are swapped, not the entire x vector...
stackexchange_codegolf
In a 9 by 9 grid some points have been marked. The task is it to make a program that counts all distinct squares that can be made using four marked points. Note that squares can also be placed diagonally (any angle). Input can be one of the following: A character string of length 81 containing two distinct characters ...
stackexchange_codegolf
Ultrafactorials The ultrafactorials are a sequence of numbers which can be generated using the following function: $$a(n) = n! ^ {n!}$$ The resulting values rise extremely quickly. Side note: This is entry A046882 in the OEIS. Also related are the hyperfactorials, a still quite huge, but a bit smaller sequence: A002109...
stackexchange_codegolf
Background The Sidi polynomial of degree \$n\$ – or the \$(n + 1)\$th Sidi polynomial – is defined as follows. $$S_n(x) = \sum^n_{k=0}s_{n;k}x^n \text{ where } s_{n;k} = (-1)^k\binom n k (k+1)^n$$ The Sidi polynomials have several interesting properties, but so do their coefficients. The latter form OEIS sequence A0755...
stackexchange_codegolf
Elixir is a programming language with a feature called the pipe operator, |>, similar to the pipe in Bash and other languages. It passes the result of an expression on the left as the first parameter of a given function on the right. To clarify, here are some examples. 2 |> myFunction() is equivalent to myFunction(2) ...
stackexchange_codegolf
Quines are fun. Polyglots are fun, too. Polyglot Quines exist, but we can raise the bar even higher. Write a file that contains a valid program for languages α, β, and γ. When the file is executed (possibly after compiling it) as a language α or β program, the program's output shall be of the same form as a valid submi...
stackexchange_codegolf
Given an ASCII-art shape made of the characters /\|_, your challenge is to return the number of sides it has. A side is a straight line of one of those, for example: \ \ \ / / | | | | _____ Are all sides. For example, this shape: ___ / \ /_____\ Has four sides. You can assume the input will be a single va...
stackexchange_codegolf
Introduction There have been a few examples of the smallest possible OCI container that does "X". However these examples never correctly handle termination signals. Challenge Produce the smallest possible container that correctly handles PID 1 signal responsibilities. The container does not need to manage child process...
stackexchange_codegolf
This challenge is inspired by one of my other challenges: Pointlessly make your way down the alphabet That challenge asked you to take a string of text, and for each letter produce a sequence of letters moving down the alphabet to 'a'. For this challenge I'd like to decode the output of that challenge (minus the line b...
stackexchange_codegolf
As many of you will know, almost every programming language has a standard casing system; unfortunately, we have not been able to agree on a singular system to use and now must frequently switch between camelCase, snake_case, PascalCase and kebab-case. Now I know what you're thinking... wouldn't it be nice if we had a ...
stackexchange_codegolf
Inspired by this and this question Challenge Your challenge is to print any 100 consecutive digits of Champernowne's Constant. You must give the index at which that subsequence appears. The 0 at the beginning is not included. For example, you could print any of the following: +-----+------------------------------------...
stackexchange_codegolf
Challenge: Given two inputs, x and y, round x to one less significant figure, then repeat until it has y number of unrounded digits left. (the decimal point does not count as a digit) Input & Output Input can be a combination of strings and integers, e.g. you can have the input as a string and the output as an int, o...
stackexchange_codegolf
Introduction You are the manager of the electronics department in a major retail store and the biggest sales day of the year is this Friday. To help manage the crowds, your store is implementing a ticket system for the biggest deals, where customers must present a ticket before purchasing an item. Your job is to write ...
stackexchange_codegolf
One of my colleagues proposed us a challenge: to write the shortest C/C++ program to determine if a number is even or odd. These are the requirements: Get a number from keyboard, at run-time (not from command line) Output the string pari if the number is even Output the string dispari if the number is odd We can assum...
stackexchange_codegolf
Rules You will receive as input a list that contains integers and strings. Your task is to move all of the strings to the end of the list and all of the integers to the beginning of the list. This is code-golf so the answer with the least number of bytes wins.
stackexchange_codegolf
I recently created a new language called ;# (pronounced "Semicolon Hash") which only has two commands: ; add one to the accumulator # modulo the accumulator by 127, convert to ASCII character and output without a newline. After this, reset the accumulator to 0. Yes, 127 is correct. Any other character is ignored. It ha...
stackexchange_codegolf
Given a positive integer, write it as the sum of numbers, where each of them is in \$\{kt|k\in{1,9,81},t\in{1,2,3,...,64}\}\$. How many numbers at least are used? Shortest code win. Samples: Input Output Method 1 1 1 2 1 2 64 1 64 65 2 64+1 72 1 72 343 2 342+1 576...
stackexchange_codegolf
Description Write a program or function that takes in a positive integer \$n\$ as input and outputs all Sophie Germain primes that are safe primes less than or equal to \$n\$. A prime number \$p\$ is a Sophie Germain prime if \$2p+1\$ is also a prime. A prime number \$p\$ is a safe prime if \$p=2q+1\$, where \$q\$ is a...
stackexchange_codegolf
Task Write a function or a program to find the number of rotations required by a wheel to travel a given distance, given its radius. Rules Input can be 2 positive rational numbers and can be taken in any convenient format. Both inputs are of same unit. There must not be any digits 0-9 in your code. The output will be a...
stackexchange_codegolf
On December 4, 2017, the Google Doodle was a graphical programming game featuring a bunny. The later levels were nicely non-trivial and they seemed like a great candidate for an atomic-golf challenge. Details Game There are four available moves: hop forward, turn left, turn right, and loop. Each of these moves is one ...
stackexchange_codegolf
Stevin's Notation is a way to represent decimals in a non-fractional way. The Flemish mathematician and engineer Simon Stevin is remembered for his study of decimal fractions. Although he was not the first to use decimal fractions (they are found in the work of the tenth-century Islamic mathematician al-Uqlidisi), it ...
stackexchange_codegolf
Pure data is a graphical programming language designed for audio processing. This makes it unsuitable for most general programming but especially unsuitable for code-golf. It would then be nice to have a tips question so that people can get a first foot up in this language. What tips are there for golfing in Pure Data...
stackexchange_codegolf
Write a program or function that can distinguish the following 12 trigonometric functions: sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh. Your program is given one of the above functions as black box and should output the function's name either as given above or the way it is named in your lan...
stackexchange_codegolf
Challenge Draw lines in ASCII corresponding to given inputs: in the first line there are given size of rows and columns of the view and number of separators between each point in the second line is given list of lines separated by space a line contains the position of head and tail coordinates (within the size of colum...
stackexchange_codegolf
Background This challenge is based on a personal project I did, UnitDC. This challenge is a super-miniaturized version of UnitDC. Challenge Please write a simple unit-aware calculator that evaluates a sequence of positive integers, units and operators in RPN (postfix) notation, while checking whether the units are comp...
stackexchange_codegolf
Merge sort is a sorting algorithm which works by splitting a given list in half, recursively sorting both smaller lists, and merging them back together to one sorted list. The base case of the recursion is arriving at a singleton list, which cannot be split further but is per definition already sorted. The execution of...
stackexchange_codegolf
Below on the left is a picture of a sorting network that can sort 4 inputs. On the right you can see it sorting the input 3,2,4,1. A sorting network of size n consists of a set of n horizontal wires where two wires can be connected by a vertical wire. The inputs to a sorting network move from the left to the right on ...
stackexchange_codegolf
Given 2 positive integers in any format you'd like, return their sum using only logic gates and bit shifts (see example below). Don't worry about overflow. EDIT: Using pre-written addition is obviously not allowed. So no a + b, Add(a, b), a - (-b) etc. This is code golf, so standard loopholes apply. Shortest program in...
stackexchange_codegolf
I'm sure you're all familiar with Z̃͗̇̚͟Ḁ̬̹̈̊̂̏̚L̜̼͊ͣ̈́̿̚G̱̮ͩ̃͑̆ͤ̂̚Õ̷͇͉̺̜̲ͩ́ͪͬͦ͐ ̪̀ͤͨ͛̍̈͢ĝ̭͇̻̊ͮ̾͂e̬̤͔̩̋ͮ̊̈ͭ̓̃n͖͎̘̭̯̳͎͒͂̏̃̾ͯe͕̖̋ͧ͑ͪ̑r̛ͩa̴͕̥̺̺̫̾ͭ͂ͥ̄ͧ͆t͍̻̘̆o͓̥ͤͫ̃̈̂r̹̤͇̰̻̯̐ͮ̈́ͦ͂͞. If not, you can play with the classical generator a bit. Zalgo text is unicode text that started as English text and had a bunch of combining ...
stackexchange_codegolf
Let's say we have a n × n lattice; we can then divide the lattice into two sections by drawing a line through the lattice. Everything to one side of the line is in one set and everything else in another. How many ways can we divide the lattice in the manner? For example lets take a 2 × 2 lattice: . . . . We can make ...
stackexchange_codegolf
In mountaineering terminology, a "14er" is any mountain with an elevation of 14 000 feet or more. However, there is another distinction. For a peak to count as a 14er, it must also have a "geographic prominence" of 300 or more feet. This means that to move from one 14er to another, you must first descend at least 300 f...
stackexchange_codegolf
Challenge Given an ASCII operator from the list below and a number n, draw an ASCII representation of the operator using that operator as the character with the line segments of the operator having length n. Input An ASCII character from the list = + - x / and an integer n where n >= 1. (I'm using x instead of * and /...
stackexchange_codegolf
I hate hashes because they remind me of hashtags, help me find them in the input Input A piece of text This is an #example text, #designed for demo #purposes, #to demonstrate the challenge.# You may add a optional newline character at the end of the input if your program requires this You may assume that there will ...
stackexchange_codegolf
A string can be shifted by a number n by getting the byte value c of each character in the string, calculating (c + n) mod 256, and converting the result back to a character. As an example, shifting "ABC123" by 1 results in "BCD234", shifting by 10 in "KLM;<=", and shifting by 255 in "@AB012". The Task Pick as many num...
stackexchange_codegolf
Given a strictly positive integer, return the shortest possible Roman numeral using only the additive rule. Output must consist of zero or more of each of the characters MDCLXVI in that order. The number 14 must therefore give XIIII rather than XIV. The characters' numeric values are M=1000, D=500, C=100, L=50, X=10, V...
stackexchange_codegolf
The tetration operation consists of repeated exponentiation, and it is written ↑↑. For instance, 3↑↑3 =3 ^(3^3) = 3^27 = 7,625,597,484,987 A tetrate of two is an integer that is equal to 2↑↑n for some nonnegative integer n. As an edge case, we say that 2↑↑0=1. In this challenge, you will be given a positive integer as...
stackexchange_codegolf
Rules In this challenge, I'm going to redefine the definition of "quotes" a bit. Quotation marks (AKA quotes) are any identical characters used in pairs in various writing systems to set off direct speech, a quotation, or a phrase. The pair consists of an opening quotation mark and a closing quotation mark, which is t...
stackexchange_codegolf
Related: Multiply Quaternions Challenge Given a string made of ijk, interpret it as the product of imaginary units of quaternion and simplify it into one of the eight possible values 1, -1, i, -i, j, -j, k, -k. The evaluation rules are as follows: $$ ii = jj = kk = -1 \\ ij = k, \quad jk = i, \quad ki = j \\ ji = -k, \...
stackexchange_codegolf
Disclaimer: The story told within this question is entirely fictional, and invented solely for the purpose of providing an intro. I am an evil farmer, and to drive up the price of wheat in my area, I've decided to burn the fields of all the farmers around me. I would really like to see the fields go up in flames (...
stackexchange_codegolf
In these previous challenges[1][2] I've been dealing with "mushroom forests". To help with these I draw little diagrams of the forests to help. In this challenge we are going to reverse engineer the data from these diagrams. To recap ha! mushroom forests are a list of pairs of non-negative integers. Each pair repres...
stackexchange_codegolf
This is the robbers' challenge. The cops' one is here. In Fewest (distinct) characters for Turing Completeness, the goal is to find the minimum number of characters which make a language Turing Complete...in other words, allow it to do any computation possible with any other language. In this challenge, we'll be doing ...
stackexchange_codegolf
This is based on how my company deals with the monitoring of the working times for every employee. Each one of us has a card that can be passed in front of a sensor, so that a clock registers the times at which the employees check in or out the office. Every time register is linked to a code: Code 0: the employee arri...
stackexchange_codegolf
Similar to this question, but this is a crossword variation! Instead of only one letter per grid square, you can have one or two. Input: A 2d array, or whatever works in your language. You can assume valid inputs Any array size must work Output: An array of all the words Across and down All words must be joined to...
stackexchange_codegolf
Given two strings of letters, transfer the capitalization pattern of each string onto the other one. Fewest bytes wins. Input: CodeGolf xxPPCGxx Output: coDEGOlf XxppCgxx Both strings will be equal-length and nonempty, with only letters a..z and A..Z. You may output the two resulting strings in either order rel...
stackexchange_codegolf
Given an input integer, output the volume corresponding to the value. The value will always be in the range \$[0,100]\$. Examples If the input \$=0\$: _/| | |\/ |_ |/\ \| If the input \$>0\$ and \$<33\$: _/| | |\ |_ |/ \| If the input \$\ge33\$ and \$<66\$: _/| \ | |\ \ |_ |/ / \| / If the input \$\ge66...
stackexchange_codegolf
Given a German string and an indication of a case (lower/upper/title), fold the string to that case. Specifications Input will consist only of a–z plus äöüß-,.;:!?'" in uppercase and/or lowercase. The target case may be taken as any three unique values (please specify what they are) of a consistent type; either three ...
stackexchange_codegolf
The Eulerian number A(n, m) is the number of permutations of [1, 2, ..., n] in which exactly m elements are greater than the previous element. These are also called rises. For example, if n = 3, there are 3! = 6 permutations of [1, 2, 3] 1 2 3 < < 2 elements are greater than the previous 1 3 2 < > 1 ... 2 1 3 > ...
stackexchange_codegolf
Given a number n, calculates BB(n) (the maximum number of 1s finally on the tape, among all halting 2-symbol n-state Turing machines with tape of zeros). To solve the problem, you are given an extra (black-box) function H as input, which takes a function in your language (f) and returns a truthy/falsy value indicates w...
stackexchange_codegolf
Huge omega thanks to @wasif for emailing me this challenge idea in its basic form Everyone knows that questions on StackExchange require tags - labels that allow posts to be grouped together by category. However, most of the time, I barely know which tags exist, because there's just so many of them. Henceforth, today's...
stackexchange_codegolf
Write a program which, when every nth character is skipped, it prints n. For example, if every 2nd character is skipped, it prints 2. Example n=0 foobar Output: 0 n=1 foa Output: 1 n=2 fobr Output: 2 Rules If n=0 (no characters are skipped), 0 must be returned. Must print to STDOUT. Standard loopholes are forbid...
stackexchange_codegolf
Background In Haskell and many other functional languages, function application f(x) is simply written as f x. Also, this form of function application is left-associative, which means f x y z is ((f x) y) z, or ((f(x))(y))(z). Haskell also has a binary operator called $. f $ x does function application just like f x, b...
stackexchange_codegolf
You have a bunch of cities on a grid which you wish to link up. Roads can be placed on any tile that doesn't contain a city, and connect to all roads or cities adjacent to them, vertically, horizontally or diagonally. Roads can link up via cities, for example C \ C-C is fully linked up. However, there are some moun...
stackexchange_codegolf
Challenge You will be given a string as an argument. You need to convert that string to upper case. But you can't use any built in method or function nor any external programs. Rule No use of built in methods or functions or external programs. Only arithmetic, bitwise, logical operators, regex, replace, split, join, A...
stackexchange_codegolf
A self number (also called a Colombian or Devlali number) is a natural number, x, where the equation n + <digit sum of n> = x has no solutions for any natural number n. For example, 21 is not a self number, as n = 15 results in 15 + 1 + 5 = 21. On the other hand, 20 is a self number, as no n can be found which satisfie...
stackexchange_codegolf
This question is based on a question I asked in Spanish language. Yes, I asked for an algorithm in Spanish Language. :) In Spain, current license plates have this pattern: 1234 XYZ where XYZ are three consonants taken from the full set of Spanish consonants (except the 'Ñ', I think). Sometimes, when traveling with ...
stackexchange_codegolf
Introduction This challenge was inspired by a seemingly simple task requested at work that couldn't easily be done in Microsoft Teams. At least not from what we could find! Task Your task, if you choose to accept it, is to output the last week day of any month in any year. Input You can input the desired month/year in ...
stackexchange_codegolf
Task Given a winning Wordle play results (clues), the target ("secret") word and a list of words, output a possible sequence of words leading to such results. The words in the list will be distinct and so should be the output. You may assume that for given inputs a solution exists. If there is more than one, you may ou...
stackexchange_codegolf
Input: Ten unique integer coordinates, between (0,0) and (100,100). Output: The coordinates arranged in the order/an order such that a path drawn between the coordinates in that order is the shortest path possible. This is code golf so the shortest code wins!
stackexchange_codegolf
The stock market is all about the speed of knowledge. Unlike previous challenges, the current stock price is not random: it is determined by those playing the game. If you can identify an under-priced stock before anybody else, then you've written yourself a money-making program. Price refers to the how much people ar...
stackexchange_codegolf
Introduction Finding the closest power to a number is a common enough problem. But what if you need both the next-highest and next-lowest power? In this challenge you must find the closest powers to a given number - the 'power sandwich' if you will, where the given number is the filling and the powers are the bread. Mm...
stackexchange_codegolf
This is a window: --- | | --- Let's add some walls |. Put two spaces on either side of it so that the window has plenty of room. | --- | | | | | | --- | Now let's add a roof and a ceiling. To keep the window in the middle of the room, let's add one more row above it and below it. --------- | | | --- | |...
stackexchange_codegolf
Introduction A pure word (or perfect word), as defined by me, is a word where the sum of the position in the alphabet of each letter in the word is perfectly divisible by the total length of the word. For example, abcb is a perfect word because 1 + 2 + 3 + 2 = 8, and 8 / 4 = 2. Your task Given a word as input, output w...
stackexchange_codegolf
Write a function which takes in a list of positive integers and returns a list of integers approximating the percent of total for the corresponding integer in the same position. All integers in the return list must exactly add up to 100. You can assume the sum of integers passed in is greater than 0. How you want to r...
stackexchange_codegolf
Input: from STDIN number of vertices in Graph \$2 \leq N \leq 100\$. Rules: [Code size] = max ([code length without spaces, tabs and newlines], [total code length divided by 4]) Math formulation: In the graph of N vertices, between each pair of vertices can be 3 road states: there is no road there is a road from A to ...
stackexchange_codegolf
Yesterday, I left my sandwich on the table. When I got up today, there was a bite in it... Was it mine? I can't remember... Problem: Take a representation of the sandwich and my bite pattern and tell me if it was my bite or not. Examples: Example 1: My bite pattern: .. . Sandwich: ##### .#### ..### Output: truthy Ex...
stackexchange_codegolf
Several Mathematica functions have system-defined short forms, e.g., /@ for Map. Many of them are listed here: https://reference.wolfram.com/language/tutorial/OperatorInputForms.html However, there also exist some system-defined short forms for function-option combinations. E.g., Log2@ninstead of Log[2, n] and Log10@...
stackexchange_codegolf
Challenge : Given a string rotate every char by its index. e.g --> 'Hello' should be 'Hfnos'. Input : Input is given as string s length of string is 2 < s ≤ 100. Input will either be alphabet , number or one of the following whitespace , ! , @ , # , $ , % , ^ , & , * , ( , ) Output : Output will be a string with all...
stackexchange_codegolf
Given a rectangular board of cells with some number of holes in it, determine whether it is possible to complete a "holey knight's tour" (That is, a path that visits every non-hole cell exactly once using only chess knight moves, not returning to the starting cell) that starts on the top-left cell. For the sake of comp...
stackexchange_codegolf
Given 2 inputs (m=minimum starting id, n=number of ids), generate a sequential list of ids, starting at >=m, made up of the digits 0-9 where no 2 contiguous numbers are the same, e.g. 1232 is ok, 1233 is not (contains 2 '3's next to each other). Example for m=985, n=6, below shows what ids would be generated/skipped .....
stackexchange_codegolf
In this challenge, submissions will be programs or function which, when given an emoticon such as :-), :(, or :D, will rate their happiness from 0 to 3. An emoticon will be one of the following: :(: 0 :|: 1 :): 2 :D: 3 Emoticons may also have noses (a - after the :). Test cases: :( -> 0 :-| -> 1 :D -> 3 :-) -> 2 :|...
stackexchange_codegolf
Almost all operating systems allow you to run multiple programs at the same time. If your system does not have enough processors to run all the programs you want to run, it starts to give each program just a tiny slice of time on the processor it runs on. This is normally not noticeable but can lead to strange artefact...
stackexchange_codegolf
Forth is one of the few non-esoteric stack-based languages. For this challenge, we will use a small subset of Forth, which simply executes a sequence of words in a linear fashion — without any definitions or loops. In good Forth code, each word definition includes a stack effect comment, which explains the layout of th...
stackexchange_codegolf
The purpose of this challenge is to figure out whether all the dominoes will fall, given an input string representing a top view of the table. Input format The program can take the input as a single string with newlines or a list of strings. Spaces denote, well, empty spaces, and the rest represent dominoes. The start ...
stackexchange_codegolf
Given no input, output this interesting alphabet pattern in either case (the case has to be consistent) via an accepted output method: A AB ACBC ADBDCD AEBECEDE AFBFCFDFEF AGBGCGDGEGFG AHBHCHDHEHFHGH AIBICIDIEIFIGIHI AJBJCJDJEJFJGJHJIJ AKBKCKDKEKFKGKHKIKJK ALBLCLDLELFLGLHLILJLKL AMBMCMDMEMFMGMHMIMJMKMLM ANBNCNDNENFNGN...
stackexchange_codegolf
(l, r) defines a line whose left end is at l and the right end is at r, on a 1-dimensional space. Given 2 lines b = (0, bz) and f = (i, i + fz), v = (l, r) is the overlapping part of these lines. When b and f do not overlap (when v cannot have a positive length), v = (0, 0). (input) -> (output) bz, fz, i -> l, r The...
stackexchange_codegolf
Given the following input: An integer n where n > 0. A string s where s is not empty and s~=[0-9A-Z]+ (alpha-numeric capitals only). Using a standard, simplified QWERTY keyboard (as shown below): 1234567890 QWERTYUIOP ASDFGHJKL ZXCVBNM Perform the following operation: Find the original row that each character is in...
stackexchange_codegolf
Backstory Not really real, sshh! It all started one day when a coworker brought in a homemade loaf of bread for my boss's birthday. My boss really liked this loaf of bread, and he wanted another. Unfortunately, my coworker has quit, so my boss needs me to give him another loaf. The problem is, I have no idea how to mak...
stackexchange_codegolf
You know how you get a voicemail message and the person's connection wasn't great, and you're trying to figure out how to call them back, but you're not sure if that was a "5" or an "8" they said? That's this challenge. The good news is that the caller read off their number twice, but it's garbled in both places. Your ...
stackexchange_codegolf
Write an infinite list of triangle codes, defined as code where the i-th line has i bytes for all lines, such that the i-th code generates (i-1)th code and has 1 more line than the (i-1)th code. The score is the number of lines in the initial code. Lowest score wins. For example, if . .. ... .... is outputted by . .. ...
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
Background The newest version of the C standard, C23, adds preprocessor macros like INT_WIDTH, ULONG_WIDTH, and SIZE_WIDTH that tell you the bit width of various integer types (here, int, unsigned long, and size_t, respectively). However, while the majority of us are stuck with pre-C23 compilers/standard libraries, it...
stackexchange_codegolf
Given a ray with a point and a vector and a plane with a point and a normal vector to the plane. You have to find the intersection point of the plane and the ray.. So your job if you choose to accept is to write a shortest function that will do the job. RULES: The submission must be a complete program And that's all I...
stackexchange_codegolf
The problem Through a terrible procastination accident you are reborn as Scrooge McDuck for a day. To make the most out of the situation you decide to give away food to the poor. Since you also are a mathematician you store the food in a vector v(1,2,3). You want to give each family approximately the same food. To mak...
stackexchange_codegolf
Inspired by How do you write dates in Latin? Challenge Given a month-and-day date, output that date in abbreviated Latin, as explained below. Input Input is flexible, following conventions from other date and sequence challenges. You may choose to: Take a date in mm/dd or dd/mm format or two separate month,day argumen...
stackexchange_codegolf
Part of the Code Golf Advent Calendar 2022 event. See the linked meta post for details. As a Christmas gift, you were given a toy solar system. In this toy, all the orbits are circular and happen in the same plane. Each planet starts at a fixed location, has a fixed circumference orbit, and moves at a fixed speed (all...
stackexchange_codegolf
This is a relatively simple question. I'm trying to golf a Snake game I've written, and I'm trying to work out if there's a way to golf the following conditional assignments which control x and y coordinates of the snake ensuring a wrap around of the play area: if (P<0) { P = T-1; } if (P>T-1) { P = 0; } if (Q<0) {...
stackexchange_codegolf
Write a program that outputs the exact string: jan ale o, toki! ("Hello, world" but in toki pona to prevent builtins.) with an optional trailing newline. Additionally when all copies of any one byte present in your program are removed the program must fail to produce a correct output no matter what byte is selected. T...
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