instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
The Corpus are a fictional faction from the popular video game Warframe who have a somewhat interesting language. Whilst other factions in the game such as the Grineer have some logic behind their language, the Corpus is simply a lossy substitution of the English language. All Corpus words are the same as their English...
stackexchange_codegolf
Challenge This is a simple one: Given a positive integer up to 1,000,000, return the closest prime number. If the number itself is prime, then you should return that number; if there are two primes equally close to the provided number, return the lower of the two. Input is in the form of a single integer, and output sh...
stackexchange_codegolf
Your task is to decipher a non-empty string consisting of printable ASCII characters in the range [32..126]. Reading the string character per character: each time you encounter a letter in lowercase, associate it with the next letter in uppercase, starting with 'A' each time you encounter a letter in uppercase, replac...
stackexchange_codegolf
Challenge Return the full contents of your program, but inverted. How do your invert something? Well, Letters: Take the position of the letter in the alphabet, subtract from 26, and use the letter at that position and flip the case of the letter. E.g A becomes z, and p becomes J. Digits: Subtract from 9. E.g 6 becomes ...
stackexchange_codegolf
Given a positive input \$n\$, output a random pair of primes whose difference is \$n\$. It's fine if there's another prime between them. Every pair should possibly appear and the program should have zero possibility to fall into infinite loop. It's promised that such pair exist, but not always infinite, so beware. You ...
stackexchange_codegolf
Minesweeper is a popular puzzle game where you must discover which tiles are "mines" without clicking on those tiles. Each tile is either a mine (represented by *) or a clue, i.e. a number from 0 to 8 representing how many of the 8 neighboring tiles are mines. Your task today is to take a board containing the mines and...
stackexchange_codegolf
Challenge: Write a code that, when executed will output the source code of a second program that can be executed in another language. The second program should output the source code of a third program that can be executed in a third language and so on. The last program should output PPCG with an optional single traili...
stackexchange_codegolf
Given a ragged list, e.g. [[4, 7], [5, 3, [], [6, [2]]]] Your challenge is to sort only the numbers in it. For example, with the above, the result would be [[2, 3], [4, 5, [], [6, [7]]]] The shape of the output should remain the same, only the numeric contents should change. This is code-golf, shortest code wins! All...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. On the flight to Hawaii for vacation, I'm playing with a deck of cards numbered from 1 to \$n\$. Out of curiosity, I come up with a definition of "magic number" for a shuffled deck: The magic number of a shuffle is the minimum number ...
stackexchange_codegolf
I have a set of colored plastic cups. They come in four colors: green, yellow, pink, and blue. When I put them on my shelf, I like to stack them in a certain pattern. Your job is, given a list of any number of four distinct values (to represent the four cup colors), output a visual representation of how I would stack t...
stackexchange_codegolf
Inspired by this challenge, which got closed. This is meant to be an easier, but no less interesting version of that. This is the robbers thread of a cops-and-robbers challenge. For the cops thread, see here. Cops will provide a program/function and a flag. Robbers will guess a password. When the password is given to t...
stackexchange_codegolf
Looking at the following hackerrank problem: https://www.hackerrank.com/challenges/flatland-space-stations You are given a number n where cities can be at indices 0 to n-1 and also given an unsorted list of indices of cities where there are stations. The goal is to find the maximum distance from a city to a station. Fo...
stackexchange_codegolf
Brainfuck is an esoteric programming language that is Turing Complete, meaning you can't tell whether a given program will halt without running it. It's cell-based and has an infinite tape of cells, values containing an unsigned integer from 0 to 255, but if you give it arbitrary-size cells, just three is enough to mak...
stackexchange_codegolf
Given a positive integer \$n\$ and another positive integer \$b\$ (\$1 < b < 36\$), return the number of digits/length of \$n\$ in base \$b\$ 1597 16 -> 3 1709 9 -> 4 190 29 -> 2 873 24 -> 3 1061 27 -> 3 289 26 -> 2 1575 34 -> 3 1135 15 -> 3 1161 22 -> 3 585 23 -> 3 1412 23 -> 3 1268 14 -> 3 714 12 -> 3 700 29 -> 2 100...
stackexchange_codegolf
Challenge Generate two \$16 \times 16\$ grids, each initially filled with "@" symbols and spaces. Each cell in the grids should be independently filled with an "@" or a space, with each character having an equal probability (\$50\%\$) of being chosen for each cell. This ensures that both grids start off identically, wi...
stackexchange_codegolf
Given a matrix like this: 1 1 3 -2 3 -4 1 -1 1 1 1 0 0 -1 0 0 By taking a 2×2 "sliding sum", where the sum of every 2×2 region of the matrix is one element of the resulting matrix, we get: 1 1 1 1 -1 1 1 1 1 We can do this for sliding windows of any size. For example, a 1×3 sliding sum of the same input ...
stackexchange_codegolf
Task Your task is to convert strings like this: abc^d+ef^g + hijk^l - M^NO^P (Ag^+) To strings like this: d g l N P + abc +ef + hijk - M O (Ag ) Which is an approximation to abcd+efg + hijkl - MNOP (Ag+) In words, raise the characters directly next to carets to the upper line, one character for on...
stackexchange_codegolf
There is an app called Hard Puzzle which is a game where there is a red circle, and you have to fill all of the surface area with five smaller white circles it may seen easy, but it's harder than it looks (it just takes a while to figure out). The circle dimensions change from device to device in the image above the re...
stackexchange_codegolf
I was annoyed the other day when I got a point off in math class because I didn't distribute the factors of my function. That is, I put (x+2)(x-3) when I should have put x^2 - x - 6. Your job is to write a program that takes a string with the expression and convert it to the expanded form so I don't miss future points...
stackexchange_codegolf
Task Given a positive integer number and a threshold, split into every possible way without generating any numbers above the threshold. Examples Input: 15008 Threshold: 400 Valid Output: [[1, 5, 0, 0, 8], [15, 0, 0, 8] [1, 50, 0, 8], [150, 0, 8]] Invalid outputs: [[1, 5, 0, 0, 8], [15, 0, 0, 8], [150, 0, 8], [1, 500...
stackexchange_codegolf
The generalised harmonic number of order \$m\$ of \$n\$ is $$H_{n,m} = \sum_{k=1}^n \frac 1 {k^m}$$ For example, the harmonic numbers are \$H_{n,1}\$, and \$H_{\infty,2} = \frac {\pi^2} 6\$. These are related to the Riemann zeta function as $$\zeta(m) = \lim_{n \to \infty} H_{n,m}$$ Given two positive integers \$n > 0\...
stackexchange_codegolf
Does your language have a maximum recursion depth (MRD)? Let's say your language has MRD=500 Write a code that finds the recursion depth and outputs the exact value For the case above your program (or function) should output 500 Code-Golf Shortest answer wins!
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
Task: Make a program that generate a 24-digit password. Rule: None of the character can be repeated more than once Must include at least one upcase, one locase, one number, five special character. The answer which got most votes win. SPECIAL CHARACTER LIST: `~!@#$%^&*()_+-={}|[]\:";'<>?,./ or other
stackexchange_codegolf
Inspired by this challenge. Goal: Given a pre-configured switchboard and a list of indexes, invert the switches at the given indexes. A switchboard is made up of some number of switches (v or ^) wrapped in -'s and arranged into rows of varying length. Here is an example switchboard: -v-^-v- -^-v- -v-^-v- To invert/fli...
stackexchange_codegolf
One way to generalize the concept of a range from the integers to the Gaussian integers (complex numbers with integer real and imaginary part) is taking all numbers contained in the rectangle enclosed by the two ends of the range. So the range between two Gaussian integers a+bi and c+di would be all Gaussian integers x...
stackexchange_codegolf
Given an input string consisting of only letters, return the step-size that results in the minimum amount of steps that are needed to visit all the letters in order over a wrapping alphabet, starting at any letter. For example, take the word, dog. If we use a step-size of 1, we end up with: defghijklmnopqrstuvwxyzabcde...
stackexchange_codegolf
Guidelines Task Write a function that takes in a sentence (a string, or list of characters) and reverses all the words that are greater than or equal to 5 in length. Examples "Hey fellow code golfers" -> "Hey wollef code sreflog" "I aM noT a cAr" -> "I aM noT a cAr" "I Am a tRaiN" -> "I Am a NiaRt" Rules Since this ...
stackexchange_codegolf
You must make a polyglot that outputs the square of the input in one language and the square root of the input in another. The shortest answer in bytes wins! You must have a precision of at least 3 decimal places, and the input will always be a positive float.
stackexchange_codegolf
Given a constructible point \$(x, y) \in \mathbb R^2\$, output the steps required to construct \$(x, y)\$ Constructing a point Consider the following "construction" of a point \$(\alpha, \beta)\$ in the Cartesian plane: Begin with the points \$(0, 0)\$ and \$(1, 0)\$. Then, more points can be added by performing a fini...
stackexchange_codegolf
Your task is to write a program, function or snippet (yes, snippets are allowed) that simply outputs an integer. However, you must be able to separate your submission into prefixes that also produce distinct integers. You cannot use any bytes that have appeared in previous prefixes. For example, we can have the prefixe...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2017 Day 14. To recap: The disk is a rectangular grid with \$r\$ rows and \$c\$ columns. Each square in the disk is either free (0) or used (1). So far, you have identified the current status of the disk (a 0-1 ma...
stackexchange_codegolf
Challenge Write a program that takes as input a day from April 30, 1789 to August 21, 2019 and returns as output who was president of the USA that day. Notes For the list of US presidents, the format of their names, and the period of their presidency, see below: April 30, 1789 - March 4, 1797 George Washington...
stackexchange_codegolf
Haplology Haplology is a linguistic term: the omission of one occurrence of a sound or syllable that is repeated within a word, for example probly for probably. For this challenge, it means specifically, replacing any sequences of two or more letters that are repeated two or more times with just one copy. For example...
stackexchange_codegolf
Your task is simple: write a program that receives an integer as input and outputs it if it was odd, and does nothing otherwise (not halting is allowed). The challenge is, that you can only use odd bytes. You can optionally append a trailing newline to the output. This is code-golf, shortest answer in (odd) bytes wins....
stackexchange_codegolf
Challenge The primitive circle problem is the problem of determining how many coprime integer lattice points \$x,y\$ there are in a circle centered at the origin and with radius \$r \in \mathbb{Z}^+ \$ such that \$x^2+y^2 \le r^2 \$. It's a generalization of Code-Golf: Lattice Points inside a Circle. Input Radius \$r...
stackexchange_codegolf
Background Based on a game my four-year-old got from his rabbi. The "goal" is to "find" the letters in a given order, e.g. aecdb. You are given a stack of letter cards, e.g. daceb. You can only search through the stack in the order given, albeit cyclically. When you meet a letter you need, you take that out of the stac...
stackexchange_codegolf
The event scheduler is a recurrent theme in event-driven architectures: something triggers an event that needs to be checked in the future one or more times. I has particular use in trading where you want to correlate one market event with price movements in the future at several time deltas (1ms, 100ms, 1s, 1 min, etc...
stackexchange_codegolf
I often have to take character data and categorize it numerically at work. A common thing I do is to take character type variables and convert them to numeric type characters, keeping same categories according to the level of work I'm doing. (The longer the substring, the more in depth and specific, shorter substrings ...
stackexchange_codegolf
To increase data safety at our company, we are planning to start using Gray code numbers (where successive values differ by only one bit) instead of classical binary ones. Please help us to make a program that converts numbers to Gray code (single number to single number), but the program needs to be safe as well. This...
stackexchange_codegolf
Some numbers can be represented as perfect powers of other numbers. A number x can be represented as x = base^power for some integer base and power. Given an integer x you have to find the largest value of power, such that base is also an integer. Sample Input: 9 Sample Output: 2
stackexchange_codegolf
For robbers' post, Cheapo Enigma machine (Robbers) A cop's submission will consist of a program/function that accepts a single byte of data and return a single byte of data. Every possible input must produce a unique output. (In the other words, your function must be bijective) Robbers will attempt to create the invers...
stackexchange_codegolf
When this question was posted, it was caird coinheringaahing's birthday! (source: 1, 2, 3, 4) (It was also World Emoji Day.) As a bit of some CGCC lore, caird's name came from a Jelly answer by Dennis (source) - the compressed form of "Code Golf" in Jelly is “½ċṭ6Ỵ», and if you insert a space (“½ċṭ6 Ỵ»), it becomes "ca...
stackexchange_codegolf
Unsurprisingly, fibonacci primes are primes that are also Fibonacci numbers. There are currently 34 known Fibonacci primes and an additional 15 probable Fibonacci primes. For the purpose of this challenge, the Fibonacci numbers are the sequence \$F_n\$ defined as \$F_1 = 1\$, \$F_2 = 1\$, and \$F_n = F_{n-1} + F_{n-2}\...
stackexchange_codegolf
The aim of this post is to gather all the tips that can often be applied to radiation-hardening challenges. Please only post answers which can apply to a large number of languages, and one tip per answer.
stackexchange_codegolf
Task The task is to convert a string to a number. It must accept the string via stdin and output the number via stdout. You convert a string to a number by replacing each letter of the string by its index (mind that you don't need to replace it with the index, that's just an example. You are allowed to replace it with ...
stackexchange_codegolf
My kids have an alphabet mat to play with, something like this: After months with the tiles of the mat randomly placed, I got tired and placed all the tiles of the mat grouped by sections according to their background colors. So, if the letters represent the background color, I got a mat like this: AABBCDDDE ABBCCCDEE...
stackexchange_codegolf
My school has its Homecoming dance next week, and there's someone in mind I want to ask. But I don't want to ask her the normal way. I want to send her a program that prints "Rachel, will you go to Homecoming with me?" However, if I just send her print"Rachel, will you go to Homecoming with me?", it'll be way too obvio...
stackexchange_codegolf
I've tried this question on two forums and have been told this is the best place for this type of question. I'm trying to print from 0 to 1000 then back to 0 again (and all numbers in-between), printing 1000 only once. Also, each number must be on a separate line using vanilla PHP. My current code is 60 characters long...
stackexchange_codegolf
Given an array of integers, count the number of contiguous subarrays with an even sum. You may assume that the array is non-empty, and contains only non-negative integers. This is code-golf, so the shortest code in bytes wins. Test Cases Input -> Output [7] -> 0 [8] -> 1 [3, 5] -> 1 [6, 2] -> 3 [2, 4, 5] -> 3 [7, 4, 0,...
stackexchange_codegolf
Your task is to generate an emoticon of three characters, the first character being one eye, the second the mouth, and the third another eye. Each eye is a random one of these characters: $'*+-;O^`ox~, and the mouth is a random one of these: ,-._coux. Each eye and the mouth must be on the same general level. These eyes...
stackexchange_codegolf
Let's say we have some arbitrary number: For example 25. We also have some "tokens" (poker chips, money, something similar) with different values. Values of tokens are 2; 3; 4; 5. "Tokens" are limitless You need to achieve number 25 using exactly n tokens (for example, 8) and to output all possible ways of doing so. F...
stackexchange_codegolf
What are some tips on how to shorten this code even further? The code is meant to compute the parallel resistance of an electric circuit. Using scanf float r;main(){float a;scanf("%f",&a);r+=1/a;printf("%f",1/r);main();} Using command-line arguments #include<stdlib.h> float r;main(c,v)char**v;{for(int i=1;i<c;)r+=1/at...
stackexchange_codegolf
Given a string and a substring and a positive integer n. Remove the n occurences of a substring from the end of the originally given string. If the substring is not present in the string or the number of times the substring appears is less than n, then the output is the original string. No space should be present in pl...
stackexchange_codegolf
Given a square matrix, output the matrix's eigenvalues. Each eigenvalue should be repeated a number of times equal to its algebraic multiplicity. The eigenvalues of a matrix A are scalar values λ such that, for some column vector v, A*v = λ*v. They are also the solutions to the characteristic polynomial of A: det(A - λ...
stackexchange_codegolf
Convert a number to a sum of digits Not any sum: we need the shortest sum Not any digits: you can use only digits of the number Example You will be given as input an integer n>0 Let's say n=27. You have to express 27 as a sum, using only the digits [2,7], in the shortest way possible. You don't have to use all the digi...
stackexchange_codegolf
This question is based on what I came up with to answer another question. Sometimes the questions here ask to draw some ASCII art. One simple way to store the data for the art is RLE (run-length encoding). So: qqqwwwwweeerrrrrtttyyyy becomes: 3q5w3e5r3t4y Now to draw a big ASCII art you maybe be getting data like t...
stackexchange_codegolf
Background Tents and Trees (try here) is a puzzle played on a square (or rectangular) grid, where the objective is to place tents horizontally or vertically adjacent to each of the trees, so that no two tents touch each other in 8 directions (horizontally, vertically, and diagonally) and the number of tents on each row...
stackexchange_codegolf
Introduction I would like to drawn a nice spinner by using eight braille patterns on two lines, drawing a square of 8x8 pixel, for showing a kind of snake growing and reducing: declare -a shapes=([0]=$'\E[A⠁⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [1]=$'\E[A⠈⠀⠀⠀\E[B\E[4D⠀⠀⠀⠀' [2]=$'\E[A⠀⠁⠀⠀\E[B\E[4D⠀⠀⠀⠀' [3]=$'\E[A⠀⠈⠀⠀\E[B\E[4D⠀⠀⠀⠀' [4]=$'\E...
stackexchange_codegolf
Challenge Given a n-dimensional array of integers and a permutation of the first n natural numbers, permute the array dimensions accordingly. Details This challenge is inspired by MATLABs permute. demonstration The permutation is given as a list of integers, e.g. [1,3,2] means 1 gets mapped to 1, 2 gets mapped to 3 and...
stackexchange_codegolf
This time I will give you an easy challenge: Print the Om sign with \$\pi\$!(Sorry for many challenges with \$\pi\$) Here is the om sign drawn using pi numbers: 59 0 64 230781 3.14159 26 502884 535 83279 1971 89 433 6939 79 44 937 ...
stackexchange_codegolf
This rar file, when decompressed, gives a 65024-byte exe file. Requiring you to output the contents of that file would be absolutely no fun. But you aren't required to do that. Actually, you're to do something opposite: Output a binary of the same length (65024 bytes), such that no byte equals the byte at same position...
stackexchange_codegolf
Your task Given two positive integers \$x\$ and \$d\$ (such that \$d<x\$), output the 5th term of the \$d\$th difference of the sequence \$n^x\$ Example Let's say we are given the inputs \$x=4\$ and \$d=2\$. First, we get the series \$n^4\$: \$0^4 = 0\$ \$1^4 = 1\$ \$2^4 = 16\$ \$3^4 = 81\$ ... These are the first 10...
stackexchange_codegolf
Write 2 programs in the same language which count the number of shared subsequences of consecutive elements from 2 given sequences. For example, given "test" and "enter", there are 5 shared subsequences of consecutive elements: t t e e te One possible algorithm consists in counting, for each subsequence of consecutive...
stackexchange_codegolf
Inspired from Is this site down or is it just me? Challenge You have to print if a website server is online or not, for you. Input The domain name, like codegolf.stackexchange.com Output 1/True if online 0/False if offline Rules Any kind of web access is allowed URL shorteners allowed Except 2 no. Rule, all standa...
stackexchange_codegolf
A ragged matrix, is a matrix that has a different number of elements in each row. Your challenge is to write a program in any favorable language to find the indices of all occurrences of target in the ragged matrix. Input: A list of ragged lists (can be empty) of positive integers and a target range e.g. 26-56. The tar...
stackexchange_codegolf
For this challenge, a word is defined as a string of letters, separated by spaces. Given a string of words, and an integer i representing an index into that string, output the whole word which contains the character at index i. For example (using 0-based indexing), with the string code golf, and the index 6, the 7th ch...
stackexchange_codegolf
The Corpus are a fictional faction from the popular video game Warframe who have a somewhat interesting language. Whilst other factions in the game such as the Grineer have some logic behind their language, the Corpus is simply a lossy substitution of the English language. All Corpus words are the same as their English...
stackexchange_codegolf
You are an employee of Microteque, a leading Silicon Valley startup creating smart microwave ovens for all kinds of strange places. Your customers can get their microwaves printed with patterns to match their kitchens, campers, man caves; even the kitchens of large nation-state facilities have shiny new branded microwa...
stackexchange_codegolf
Given a positive integer n > 1 determine how many numbers can be made by adding integers greater than 1 whose product is n. For example if n = 24 we can express n as a product in the following ways 24 = 24 -> 24 = 24 24 = 12 * 2 -> 12 + 2 = 14 24 = 6 * 2 * 2 -> 6 + 2 + 2 ...
stackexchange_codegolf
Consider a binary tree built the following way: The root node is \$1\$ For a given node \$n\$: If \$n\$ is odd, its only child is \$2n\$ If \$n\$ is even, one of its children is \$2n\$. If \$\frac {n-1} 3\$ is an integer and not already part of the tree, its right child is \$\frac {n-1} 3\$ Recursively and infinite...
stackexchange_codegolf
Have you ever found a good challenge to answer, answered it and then found out somebody posted a solution with a better score in the same language? Challenge Write a program/function that takes a PPCG question ID and outputs a leaderboard. A leaderboard consists of the rank, the language, the score, the author and the ...
stackexchange_codegolf
Introduction The telephone numbers or involution numbers are a sequence of integers that count the ways \$n\$ telephone lines can be connected to each other, where each line can be connected to at most one other line. These were first studied by Heinrich August Rothe in 1800, when he gave a recurrence equation where th...
stackexchange_codegolf
Toki pona is a minimalist constructed language, and thus it has minimalist phonotactics (rules describing what sounds make valid words). Toki Pona has 8 consonant sounds m, n, p, t, k, s, w, l and j and 5 vowel sounds a, e, i, o, u. A single basic syllable in toki pona consists of any 1 consonant, any one vowel and op...
stackexchange_codegolf
Challenge Detect the newest file in a specific folder and pass it as an argument to another process. The first argument to your program will be the folder, and the second argument will be the full path to the process. Please specify the platform(s) your code works on. Examples Windows newestfile "C:\Public_domain_movie...
stackexchange_codegolf
This code-golf challenge will give you two positive integers n and k as inputs and have you count the number of rectangles with integer coordinates that can be drawn with vertices touching all four sides of the \$n \times k\$ rectangle $$ \{(x,y) : 0 \leq x \leq n, 0 \leq y \leq k\}. $$ That is, there should be: at le...
stackexchange_codegolf
Write a program or function that takes two numbers - x>3 and n>0 - as input, and finds all possible bases b where the digit 3 appears at least n times in (x in base b). Input and output may be through command line or function arguments, stdin/stdout, graphical input/output, error messages, function returns, etc. The co...
stackexchange_codegolf
Challenge Given a number x, output the first x powers of two, starting with 2¹ (2). Example 2 2 4 3 2 4 8 1 2 6 2 4 8 16 32 64 You may output numbers separated by non-numerical characters. You may not just output them mashed together like 248163264128. Rules In your code, you may only use the number 2. You m...
stackexchange_codegolf
Consider depicting a simple, open, two-dimensional curve on a W wide by H high grid of text where X represents part of the curve and . represents empty space and no other characters are used. Every grid space has 8 neighboring grid spaces, its Moore neighborhood. Grid spaces beyond the borders are considered empty. A g...
stackexchange_codegolf
Befunge Chess is an esolang mini-game I invented that is centered around the Befunge esolang. The general gist of the game is to make the instruction pointer land on a specific target cell while avoiding the opponent's target cell. Today's challenge isn't to play the game, but to simply execute arbitrary boards. The Ru...
stackexchange_codegolf
Write a function or program that determines the cost of a given string, where the cost of each character equals the number of how many times the character has occurred up to this point in the string, and the cost of the string is the sum of its characters' costs. Example For an input of abaacab, the cost is computed...
stackexchange_codegolf
Your task is to output a spaceship of size n with shooters/guns and n bullets of character - (with spaces in between each bullet) for each gun Rules If n is odd, you must output the guns every even numbered row If n is even, you must output the guns every odd numbered row All rows with guns must have n+1 # character...
stackexchange_codegolf
Does anyone have tips on how to golf in this language? Please one tip per answer and avoid posting simple and general tips such as "remove whitespace". Here is the github link and here is the esolang page.
stackexchange_codegolf
We define \$V(x)\$ as the list of distinct powers of \$2\$ that sum to \$x\$. For instance, \$V(35)=[32,2,1]\$. By convention, powers are sorted here from highest to lowest. But it does not affect the logic of the challenge, nor the expected solutions. Task Given a semiprime \$N\$, replace each term in \$V(N)\$ with an...
stackexchange_codegolf
You know those Windows boxes where you can only do one thing? Let's take this to the next level! Challenge Make a dialog box with a button that follows your cursor everywhere! Specs No input may be taken. There may be output to either STDOUT or STDERR. You must open a window with one button (no text is necessary, but ...
stackexchange_codegolf
Write a program or function that transforms an input string into Zalgo text. For example, for an input string Zalgo, a possible output might look like: Z̗̄̀ȧ̛̛̭̣̖̇̀̚l̡̯̮̠̗̩̩̥̭̋̒̄̉̏̂̍̄̌ģ̨̭̭̪̯̫̒̇̌̂o̢̟̬̪̬̙̝̫̍̈̓̅̉̇ Zalgoification specs Each letter (upper or lower case) must be zalgoified, and nothing else (spaces, pun...
stackexchange_codegolf
Input Your program will take in the integer coefficients of the equation \$ax^3+bx^2+cx+d=0\$ as inputs (a, b, c, and d). Output All real solutions of the input equation, with an accuracy of at least the thousandths place, sorted from smallest to largest. Rules Built-in equation solver are not allowed Native math ...
stackexchange_codegolf
I hope this picture looks familiar to you. It's one of Pacman's ghosts in his "vulnerable" state, after Pacman has eaten a power pill. The challenge Picture our ghost in a little frame, using ASCII art. At normal scale (more about this later), each square in the above image should correspond to one character, and the ...
stackexchange_codegolf
There was recently (a few years back) some buzz on programming websites about an implementation of Tetris in 140 Bytes. ... It turns out that although it is small, it is a simplified version of Tetris, and not even a complete implementation. Only the core logic function fits in 140 bytes of Javascript. To actually run ...
stackexchange_codegolf
Something I found while looking through some old files. It seemed like a neat idea for a code golf challenge. The intro One of the most popular events at the annual Cyclist's Grand Competition for Charity (CGCC) is the rocket bike parcours. The rules are simple: Inspect the parcours and place a bet on wheather is it po...
stackexchange_codegolf
Mama Say Mama Sa Mama Coosa I'm sure all of you have heard of Michael Jackson and some of you have listened to MJ's song "Wanna be starting something". The line "Mama Say Mama Sa Mama Coosa" is repeated throughout the song. Specification In this line, the word "Mama"occurs three times, "Say", "Sa", "Coosa" occurs once...
stackexchange_codegolf
Simple challenge: The code must be both valid Lisp and valid Fortran, and must print out "hello world" in both. Note: I've sunk about 5 hours into this at this point, I'm not even sure it's possible at this point... Details: Must be in a single source file. Any version of Fortran and any Lisp are allowed (specify whic...
stackexchange_codegolf
Your task is to determine whether some arbitrary programming language has zero-indexed or one-indexed arrays based on sample inputs and outputs Inputs An array of integers with at least 2 elements A positive integer index The value of the array at that index Output One of four distinct values representing: One-index...
stackexchange_codegolf
Your task is to write a program or a function that prints an ASCII triangle. They look like this: |\ | \ | \ ---- Your program will take a single numeric input n, with the constraints 0 <= n <= 1000. The above triangle had a value of n=3. The ASCII triangle will have n backslashes (\) and vertical bars (|), n+1 line...
stackexchange_codegolf
A Russian nesting doll, more commonly known as a Matryoshka doll, is a doll which contains a smaller version of itself, which then contains another smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself... - until fi...
stackexchange_codegolf
Background The Collatz Conjecture is quite well-known. Take any natural number. Triple and increment if odd; cut in half if even. Repeat, and it will reach 1 eventually. This famous conjecture, however, is only that, for it is yet unproven. Little-known to the world, that was not Lothar Collatz's first attempt at fame....
stackexchange_codegolf
Given a description of the base state of a recursive ASCII pattern, output an expanded state somewhere along the recursion steps. More specifically: Let the following be an example: ##.. ##.. ..__ ..__ Where # is filled, . is empty, and _ is recursive. This describes a pattern wherein the top left quarter is filled, t...
stackexchange_codegolf
A palindrome is a word that is its own reverse. I will define the left palindromic root of a word as the shortest prefix of the word for which the shortest possible palindrome that begins with that prefix is the original word. So the left palindromic root of racecar is race and the left palindromic root of ABBA is ABB....
stackexchange_codegolf
I found this YouTube video with a table on it showing some card suits with ampersands. You might not understand what it is about, but I still want to make a challenge about it. The input is two suits, being one of the following: heart diamond spade club You can do anything for any other input. Then the output is their...
stackexchange_codegolf
This challenge is inspired by a series of young children's books by Fiona Watt and Rachel Wells, which I've recently been enjoying with my daughter. In each book a mouse (illustrated, but not part of the text) complains that a succession of 5 things of the same type are not its thing. It then backs this up by declarin...
stackexchange_codegolf