instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Giving n(any amount) of points (x,y). What's the minimum amount of circles required to cross every point given? Task Your program will get n (you can have n as part of input or use EOF instead) points (x,y). The points might at same place => (x1,y1) = (x2,y2) can happen x and y will be integer of range -10000~10000, wh...
stackexchange_codegolf
This problem is "inspired" from a question that was originally asked on Quora (not for code golfing). I just want to make it a challenge for you guys (and my first problem submission here). Given an array of integer elements v and an integer d (we assume that d is lower or equal to the array's length), consider all th...
stackexchange_codegolf
Given a positive integer N, your task is to return the number of steps required by the following algorithm to reach N: Find the smallest triangular number Ti such that Ti ≥ N. Build the corresponding list L = [ 1, 2, ..., i ]. While the sum of the terms of L is greater than N, remove the first term from the list. If t...
stackexchange_codegolf
Challenge Create a function takes in two 2-dimensional arrays of characters (or strings if the programming language does not have characters as a datatype) as inputs: a and b. If your language does not support these inputs, you may use any other standard one-byte variable. Your task is to determine if b contains a. If ...
stackexchange_codegolf
For every given degree \$n\$ it is possible to construct (at least one) an integral polynomial \$p \in \mathbb Z[X]\$ such that \$p(k)\$ (\$p\$ evaluated in \$k\$) is the coefficient of the term \$x^k\$ in the polynomial for all \$0 \leqslant k \leqslant n\$. To make them unique, we require the leading coefficient (the...
stackexchange_codegolf
Introduction Just on Hacker news, John Resig contemplates transforming a query “foo=1&foo=2&foo=3&blah=a&blah=b” into one that looks like this: “foo=1,2,3&blah=a,b", https://johnresig.com/blog/search-and-dont-replace/. He claims "being 10 lines shorter than Mark’s solution". Query strings consist of sequences of name-v...
stackexchange_codegolf
You know how many and which kinds of chess pieces were murdered. Can you come up with any possibility for who killed whom and how? Background During the course of a game of chess, there are between 2 and 32 pieces on the board. Call the collection of all pieces on the board (both white and black), without regard to p...
stackexchange_codegolf
Description The Caesar cipher is a cipher, where every letter in the alphabet will be rotated by a secret number. If the rotation is \$7\$, then a -> h, g -> n, v -> c and z -> g. Today, we're playing Caesar's Cipher with ASCII chars, (0-127 inclusive). So, with rotation \$7\$, b -> i, Z -> a, x -> DEL (127), But, even...
stackexchange_codegolf
Background We define the two types of chain to be a string that contains only dashes, "-", or only underscores, "_". We link two chains using one equals sign, "=". Criteria: The type of chain must change following an equals sign. You must link the chains, you can do so multiple times, and it does not matter what lengt...
stackexchange_codegolf
Introduction Given five points in the plane, your task is to compute the area of the ellipse passing through these points. You can assume that exactly one non-degenerate ellipse can be constructed with the given input values. Rules Input is 10 integers in any convenient form, corresponding to the x and y coordinates of...
stackexchange_codegolf
JonoCode9374 had almost completely implemented my language EnScript except for the CHS command. I was impatient of waiting for them to implement this command, so I chose to put this question here. Challenge: Write a solution that takes an input and returns the chased output. Standard loopholes are forbidden. This is th...
stackexchange_codegolf
The Challenge Create a program that brute-force* decodes the MD5-hashed string, given here: 92a7c9116fa52eb83cf4c2919599c24a which translates to code-golf The Rules You may not use any built-in functions that decode the hash for you if the language you choose has such. You may not use an online service to decode the ...
stackexchange_codegolf
Challenge: A cipher (which is a positive integer) which has any substring not divisible by 2, or has a substring divisible by 11 (other than 0), is defined as 'bad'. All other ciphers are defined as 'good'. Find the kth cipher, in ascending order, which is 'good'. Input format The first line of input has a single integ...
stackexchange_codegolf
Given a string representing a series of aircraft marshalling hand signals, write a function or program to calculate the final position of an aircraft following these signals. N.B.: Co-ordinates in this challenge are represented as a pair of Cartesian co-ordinates, plus a compass direction heading: (x, y, h) where x is ...
stackexchange_codegolf
The task This is a simple challenge. Your input is a single non-empty string, containing only digits 0123456789 and hashes #. It will contain exactly one run of digits, which encodes a nonnegative integer and may wrap around the end of the string, and at least one #. The integer may have leading zeroes. For example, ##...
stackexchange_codegolf
My coworker, Jimmy is kinda new to C/C++. He's also kind of a slow learner. Now, to be fair, his code always compiles, but he has some really sloppy habits. For example, everybody knows that you can define an array like this: int spam[] = {4, 8, 15, 16, 23, 42}; Everybody that is, except for Jimmy. He is convinced tha...
stackexchange_codegolf
I have some books and a bookshelf. I would like to put as many books on the shelf as possible but I have a rule. All dimensions of the books (height, width and depth) should form a non-increasing sequence on the shelf. This means every books has to be at least as high as the ones after it on the self. The same goes for...
stackexchange_codegolf
Synopsis: Given the output of a generalised FizzBuzz program, return the list of factors and words used for the program. Challenge Description Imagine a generalised FizzBuzz program that takes in as input a list of factors and words to use and the number to start from. For instance, if the input of this program was 3...
stackexchange_codegolf
You must write a program or function that sorts a nested list. Here are the rules for sorting a nested list: Let's take this list as an example: ((5, 2), 2, 7, (2, 1, (3, 4)), 9) Each element in this list has a "priority". An element counts as a number or a sublist. First, get the priority of each element at the same ...
stackexchange_codegolf
Introduction One of the first things I learned in chemistry, was giving the formula for the combustion of alkanes. The most basic example was: 2CH4 + 4O2 -> 4H2O + 2CO2. Note that the equation could have been simplified by dividing every coefficient by 2, we would get CH4 + 2O2 -> 2H2O + CO2. To make things easier, we ...
stackexchange_codegolf
Challenge: Some ascii-art is a pain to make, but makes code comments easier to read, especially when the code is dense. The challenge is to make a simple tool that converts comments to simple ascii-art with arrows. The comments to modify are delimited by empty comments. For example, supposing Haskell comment syntax, co...
stackexchange_codegolf
You teach a class of students with interesting preferences for how their chairs are arranged. There are 3 very specific requirements they have for how the chairs are arranged: They most be arranged in a rectangle, even if it means some chairs go empty. There must be as few empty chairs as possible. They must be as "...
stackexchange_codegolf
We've been twice challenged to make 'error quines' (see Make an error quine! and Make a slow error quine maker!), so why don't we try the opposite? Instructions Write a "program" that, when run, produces an error. Copy the error message into a new program, and run it. Repeat Step 2 until the program runs without produ...
stackexchange_codegolf
Inspired by Digits in their lanes and 1, 2, Fizz, 4, Buzz Introduction Your task is to generate exactly the following output: 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz ...
stackexchange_codegolf
A friend of yours has given you directions to the best restaurant in town. It's a series of left and right turns. Unfortunately, they forgot to mention for how long you need to go straight ahead between those turns. Luckily you have a street map with all the restaurants on it. Maybe you can figure out which restaurant ...
stackexchange_codegolf
We haven't had a string question for a while (5 days to be precise), so let's go for one. Given a string s and a positive integer n, take every nth element of s, repeat it n times, and put it back into s. For example, if n = 3 and s = "Hello, World!", every third character is Hl r!. You then repeat each character n tim...
stackexchange_codegolf
Generate the following list of lists consisting of the unique last digits of the powers from 1 to 9 for the numbers [0..9] [[0], [1], [2, 4, 8, 6], [3, 9, 7, 1], [4, 6], [5], [6], [7, 9, 3, 1], [8, 4, 2, 6], [9, 1]] e.g. For the number 2 we have: \$2^1,2^2,2^3,2^4,2^5,... \to 2,4,8,16,32,64,128,... \to 2,4,8,6,4,8,.....
stackexchange_codegolf
In the game of sudoku, many players like to "pencil in" possible numbers that can go in each square: The above row can be represented as an array: [[1,2,9], [6], [5], [7], [1,2,9], [1,2,9], [3], [1,2,4], [8]] Now, notice that there is only 1 place where a 4 can go. This effectively lets us simplify the above list to...
stackexchange_codegolf
Recently I asked for tips on improving some code-golf of mine. The code was supposed to output every third value of the Fibonacci sequence starting with 2: 2,8,34,144,610,2584,10946,46368,196418,832040 However, I made a mistake in deriving my formula, and my code output a different sequence which is accurate for the ...
stackexchange_codegolf
(I am not sure that this is the best place to put this question, but I will give it a shot. Forgive me if it is improper. This is just a fun project with which I am tinkering and I am looking for advice on how best to implement it; but it is also something of a 'challenge' (not implying that it is hard!), so I thought ...
stackexchange_codegolf
Any two separate nodes in a binary tree have a common ancestor, which is the root of a binary tree. The lowest common ancestor(LCA) is thus defined as the node that is furthest from the root and that is the ancestor of the two nodes. The following are binary trees and the lowest common ancestors of the some of their n...
stackexchange_codegolf
Challenge Given a positive integer n, you must calculate the nth digit of \$e\$, where \$e\$ is Euler's number (2.71828...). The format of the output can be a number or a string (e.g., 3 or '3') Example # e = 2.71828... nthDigit(3) => 8 nthDigit(1) => 7 nthDigit(4) => 2 Shortest code wins.
stackexchange_codegolf
Calculate the area of a polygon. Inspired by this shoelace algorithm video. Task Your job is to create a program or function that calculates the area of a polygon. Program or function is defined according the the default definition in meta. Input You will receive the X and Y coordinates of each vertex of the polygon. Y...
stackexchange_codegolf
Print or return the following string: zottffssentettffssenttttttttttttttttttttffffffffffffffffffffsssssssssssssssssssseeeeeeeeeennnnnnnnnno This is the first letter of each of the numbers zero, one, two, all the way up to one hundred. Standard I/O rules apply, but the output must be exactly as shown above, optionally ...
stackexchange_codegolf
In this challenge posed by xnor, we were asked to implement XOR multiplication. In this challenge the goal is to find the first n XOR primes. XOR primes are very similar to regular primes as you can see by the following definitions: Definition of Prime Number: A positive number greater than 1 which cannot be formed thr...
stackexchange_codegolf
Make an upside down triangle of positive integers. Every number in the triangle must be distinct. Each number is the summation of its two parents (similar to how Pascal's triangle is constructed, but upside-down). Construct it in such a way that the bottom number is minimized. For example, for input n = 4, here is a po...
stackexchange_codegolf
A Latin Square is a square of size n × n containing numbers 1 to n inclusive. Each number occurs once in each row and column. An example of a 3 × 3 Latin Square is: [[1, 2, 3], [3, 1, 2], [2, 3, 1]] Another is: [[3, 1, 2], [2, 3, 1], [1, 2, 3]] Given an integer input n where n > 0, determine how many Latin Square...
stackexchange_codegolf
I have a hardware that has a 32-bit input register. The register has the following characteristics: The 32-bit register consists of eight 4-bit fields. Each 4-bit field holds a value in signed-magnitude; it can hold an integer between -7 and +7 inclusive, including -0 and +0 (signed zeroes). For example, the hexadeci...
stackexchange_codegolf
Your input will be an English sentence, phrase, or word. It will only contain a-zA-Z' -,.!?. Your task is to take the input, remove spaces, and then redistribute capitalization such that letters at indexes that were capitalized before (and only letters at indexes that were capitalized before) are capitalized. For examp...
stackexchange_codegolf
Given an integer n as input, return a list containing n, repeated n times. For example, the program would take 5 and turn it into [5,5,5,5,5]. The elements need to be integers, not strings. No built-in functions that accomplish the task are allowed. This is code-golf, so standard rules apply.
stackexchange_codegolf
Given (in any structure; flat list, two lists of lists, a tuple of matrices, a 3D array, complex numbers,…) the coordinates for two non-degenerate triangles ABC=[[Ax,Ay],[Bx,By],[Cx,Cy]] and PQR=[[Px,Py],[Qx,Qy],[Rx,Ry]], determine if they are similar, that is, they both have the same shape, or one has the same shape ...
stackexchange_codegolf
In this challenge, your task is to input a rectangle ASCII pattern (You may assume only printable characters need to be handled, and you may assume a trailing newline or not), C4_4 symmetrify, and output it. Here, C4_4 symmetric means symmetric under 90-degree rotation around a corner of the corner character. The corre...
stackexchange_codegolf
The Triforce is a fictional artifact in The Legend of Zelda, made of three identical-looking equilateral triangles representing power, wisdom and courage. Several games in the saga include an animation when the three parts finally join together. The purpose of this challenge is to draw a single 2D frame of such a simpl...
stackexchange_codegolf
I was trying to write a short MIPS32 code for computing the median of three registers. The rules: Assume that some values are pre-loaded into $t0, $t1, $t2. The median of the three values should be placed in $t0. No branches are allowed, but otherwise any instruction is okay. You may arbitrarily modify the values of a...
stackexchange_codegolf
Given one of the 50 U.S. state names on the left as input, output its two-letter postal code as shown to the right: Alabama AL Alaska AK Arizona AZ Arkansas AR California CA Colorado CO Connecticut CT Delaware DE Florida FL Georgia GA Hawaii ...
stackexchange_codegolf
Your task is to sort an array containing the strings "quarter", "dime", "nickel", and "penny" any number of times in no specific order and sort them so that they are in this order: quarter dime nickel penny (in other words, greatest to least monetary value). Rules Your program must take an array as input containing...
stackexchange_codegolf
I came across this picture, which I initially questioned and thought about posting to Skeptics. Then I thought they'll only tell me if this one case is true, but wouldn't it be great to know how true any "rule" really is? Today you're going program a skeptic-bot Challenge Write a program or function which when given a ...
stackexchange_codegolf
A simple way to scramble a 2x2x2 Rubik's cube is to make a sequence random moves. This is not how official scrambles are done, but can get pretty close to a uniform distribution of all possible scramble states. Due to the way a 2x2 only has two layers, doing one turn on one face is equivalent (without considering the p...
stackexchange_codegolf
Challenge You have one string of input bytes, output only the last byte in it. Rules Your submission may be a program or function outputting the last byte in the input which is either a string, stdin or command-line arguments, and is non-empty. I was trying to solve this with brainfuck, however all languages are allo...
stackexchange_codegolf
Given an integer \$n \geq 2\$, print a triangle of height \$n\$ of (triangles of height \$n\$ of asterisks), as in this SO question. For \$n=2\$, print: * *** * * * ********* For \$n=3\$, print: * *** ***** * * * *** *** *** *************** * * ...
stackexchange_codegolf
Input The input is a single positive integer n Output The output isn with its most significant bit set to 0. Test Cases 1 -> 0 2 -> 0 10 -> 2 16 -> 0 100 -> 36 267 -> 11 350 -> 94 500 -> 244 For example: 350 in binary is 101011110. Setting its most significant bit (i.e. the leftmost 1 bit) to 0 turns it into 001011110...
stackexchange_codegolf
For this challenge, you will be given a long string as an input. With this string, you must create a dictionary. Details: This dictionary will contain all the words from the string - a word being any sequence of letters surrounded by non-letter characters (ASCII). Letter case of the entries of the dictionary should alw...
stackexchange_codegolf
Introduction In this challenge, we will be dealing with a certain ordering of the positive integers. The ordering goes like this: 3, 5, 7, 9, 11, ... 2*3, 2*5, 2*7, 2*9, 2*11, ... 4*3, 4*5, 4*7, 4*9, 4*11, ... 8*3, 8*5, 8*7, 8*9, 8*11, ... 16*3, 16*5, 16*7, 16*9, 16*11, ... ... ... 64, 32...
stackexchange_codegolf
Story Martians have been observing Aussie rules football matches from space with great curiosity. Having totally fallen in love with the game, they have been inspired to start their very own football league. However, being dim-witted creatures, they are unable to comprehend the scoring system.* We know that in Aussie r...
stackexchange_codegolf
I assume everyone here is familiar with the Caesar Cipher that shifts letters to a certain index. https://en.wikipedia.org/wiki/Caesar_cipher for those who still needs introduction. But, we can all agree that plain Caesar is unfun and way too easy. So here's a version that also shifts characters around. This version fi...
stackexchange_codegolf
In this contest you have to write a program, that accepts a black and white pixel image, and tries to alter it, such that the white shape forms star domain, with as few changes as possible. Allowed changes are turning white pixels into black ones and turning black pixels into white ones. The output must again consist o...
stackexchange_codegolf
Challenge: Given the input array l with a list of strings, only keep the elements in the sequence that have a letter that's repeated at least 3 times. Like 'lessons' has 3 s letters, so it should be kept in the sequence. But, 'lesson' has only two s letters, so it should be removed. Notes: l will always be a sequence,...
stackexchange_codegolf
Given an ASCII representation of a piece of string, determine its length. Input An multi-line ASCII rendering of a piece of string, which runs from top to bottom, with one 'node' (corner) on each line of input. The delimiter may be assumed to be CR, LF, CRLF, or LFCR. Input may be accepted from STDIN, Command Line Argu...
stackexchange_codegolf
Subleq is a programming language with only one instruction. Each instruction contains 3 parameters. Code and data space is the same. How it works: A B C A, B and C are signed ints. Instructions are executed in the next way: *B = *B - *A if(*B <= 0) goto C; One post is one tip. Write your tips for Subleq here! Online ...
stackexchange_codegolf
Warm up: Regex, Paper, Scissors This is the challenge I originally wanted to post, before realising that some very short solution exist. Nevertheless, it can be an interesting problem to think about in preparation for the actual challenge below. Write three regexes R, P and S such that they match each other in a cyclic...
stackexchange_codegolf
Your job is to encrypt a string using a number key. Your program will receive 2 strings: one containing a sequence of characters to encrypt, and another one containing an even amount of digits (1-9, never 0). The encrypting will work like this: take the string to be encrypt and decode it to binary (ISO-8859-1) for eve...
stackexchange_codegolf
Challenge: Produce the following output using as few chars as possible: _ _ _ _ _ _ _ | | | | ___| | | ___ __ _____ _ __| | __| | | | |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | | | _ | __/ | | (_) | \ V V / (_) | | | | (_| |_| |_| |_|\___|_|_|\___( ) \_/...
stackexchange_codegolf
Introduction: After I posted two rainbow-related challenges: Codegolf Rainbow : Fun with Integer-Arrays 1 and Codegolf Rainbow : Draw in Black-and-White 2, the following comment was made by @ChrisM in the ASCII (Draw in Black-and-White) challenge: Maybe you know this and it's by design (I know that rainbows are not rh...
stackexchange_codegolf
Sometimes, while golfing, one needs to represent large number(s) in their code. Writing them as is can significantly increase the byte-count. What general1 tips do you have for representing long numbers concisely in code? Please post one tip per answer. 1With general, I mean tips that can be applied to more than a sin...
stackexchange_codegolf
A problem I sometimes encounter is that when writing comments using LaTeX, the comment is too long. Today you will solve this, by writing code which, given a LaTeX math expression, will produce the shortest equivalent expression. To define equivalent expressions, we will need to specify a (simplified) parser for LaTeX:...
stackexchange_codegolf
Two or more positive integers are said to be "friendly" if they have the same "abundancy". The abundancy of an positive integer \$n\$ is defined as $$\frac {\sigma(n)} n,$$ where \$\sigma(n)\$ is the sum of \$n\$'s divsors. For example, the abundancy of \$30\$ is \$\frac {12} 5\$ as $$\frac {\sigma(30)} {30} = \frac {1...
stackexchange_codegolf
hgl has a "scan" function called sc. What it does in general is a little bit abstract, so we will just talk about one specific way you can use it. If we want to take a list of integers and get the partial sums of every prefix we can scan with + for sums and 0 as a starting value: ghci> sc (+) 0 [1,2,3,4,5,6] [1,3,6,10...
stackexchange_codegolf
Challenge Given a positive integer, find the fastest way to iterate over its digits. Bytecode size doesn't matter as much as speed of execution. Examples For 6875, the program would output 6 8 7 5. For 199182, it would output 1 9 9 1 8 2. For 0, it would output 0.
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
Do randomly generated drum loops sound good? A drum loop is a \$5\times 32\$ matrix \$A\$ of \$1\$s and \$0\$s such that \$A_{1,1}=A_{1,17}=A_{2,9}=A_{2,25}=1\$, for each \$i\$, the \$i\$th row has exactly \$f(i)\$ different \$1\$s, where \$ f(1)=3, f(2)=2, f(3)=6, f(4)=8, f(5)=5\$, for each \$j\equiv 1\bmod 4\$, the ...
stackexchange_codegolf
Let's just see how this goes If you've ever listened to the radio program "I'm sorry, I haven't a clue", then you've probably heard of the game called "Mornington Crescent". For those who haven't, it's a game where players name random stations on the London Underground network. The first person to name "Mornington Cres...
stackexchange_codegolf
Behold! The Crystal Maze™ Time Matrix! 0 1 2 3 4 5 6 7 8 9 10 1 0 5 10 15 20 25 30 35 40 45 50 2 0 10 20 30 40 50 60 70 80 90 100 3 0 15 30 45 60 75 90 105 120 135 150 4 0 20 40 60 80 100 120 140 160 180 200 5 0 25 50 75 100 125 150 175 200 2...
stackexchange_codegolf
0xUsernames There's so many people using a messaging service that they're running out of space to store all the usernames! To fix this, they are going to start storing usernames as hexadecimal, where possible. If a username consists of only the characters 0123456789ABCDEF (case insensitive), it can be converted to a ...
stackexchange_codegolf
Write some statement(s) which will count the number of ones in an unsigned sixteen-bit integer. For example, if the input is 1337, then the result is 6 because 1337 as a sixteen bit binary number is 0000010100111001, which contains six ones.
stackexchange_codegolf
Given a number n, you must output a golden spiral with the number of quarter turns being n. The spiral must be completely black and the background must be completely white. This must be output as a φ⌊n/4⌋*4 by φ⌊n/4⌋*4 PNG file (you may output a PPM and convert it later). The shortest code wins. The radius of the small...
stackexchange_codegolf
Recamán's sequence (A005132) is a mathematical sequence, defined as such: $$A(n) = \begin{cases}0 & \textrm{if } n = 0 \\ A(n-1) - n & \textrm{if } A(n-1) - n \textrm{ is positive and not already in the sequence} \\ % Seems more readable than %A(n-1) - n & \textrm{if } A(n-1) > n \wedge \not\exists m < n: A(m) = A(n-1)...
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
This is a tips question for golfing in Python. In Python golfing, it's common for a submission to be a function defined as a lambda. For example, f=lambda x:0**x or x*f(x-1) computes the factorial of x. The lambda format has two big advantages: The boilerplate of f=lambda x:... or lambda x:... is shorter than the de...
stackexchange_codegolf
Related. Given a positive integer \$n\$, output all integers \$b\$ (such that \$1<b<n-1\$) where \$n\$ can be written as the sum of any number of consecutive powers of \$b\$. Example: Let's say \$n=39\$. \$3^1+3^2+3^3\$ \$= 3 + 9 + 27\$ \$= 39\$ This does not work for any other \$b\$, so our output is [3]. Test cases...
stackexchange_codegolf
We are doing a PCG challenge at work, and I'm submitting answers in C#. This is a modification of the "M'Kay" challenge. My solution has been deemed correct by the requirements, I'm just trying to shrink it further if possible. A filler word is an apparently meaningless word, phrase, or sound that marks a pause or h...
stackexchange_codegolf
Goal: Get every integer from the string (not a number, but integer) Multiply them Output the result Input: 5 kilograms of food eaten, 10 liters of water drank, 20 plates dirty, 40 mugs dirty, and only 3 people acted! Output: 120000 How: Result was 5 * 10 * 20 * 40 * 3 What do we count as an integer: General: If int...
stackexchange_codegolf
You are to make a program that can check the syntax of programs of its same language. For example, if you do it in python, it checks python syntax. Your program will receive a program on standard input, and verify whether or not its syntax is correct. If it is correct, output just "true" on standard output. If not, out...
stackexchange_codegolf
What general tips do you have for golfing in Starry? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Starry (e.g. "remove comments" is not an answer). Please post one tip per answer.
stackexchange_codegolf
Find the moves that bring a chess squad to a given destination. You control a chess squad consisting of a king and several other pieces, on a larger chess board. Your army is placed so that no piece is further than K=8 squares away (horizontally and vertically) from your king. You will receive a destination square for ...
stackexchange_codegolf
Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 5, Part 2. Santa needs help figuring out which strings in his text file are naughty or nice. He has already tried two sets of rules, but they're totally ad-hoc, cumbersome, and janky, so he comes up with ...
stackexchange_codegolf
Challenge Determine how many integer lattice points there are in an ellipse $$\frac{x^2}{a^2} + \frac{y^2}{b^2} \leq 1$$ centered at the origin with width \$2a\$ and height \$2b\$ where integers \$a, b > 0\$ . Input The Semi-major \$a\$ and Semi-minor \$b\$ axes. Output Number of interior and boundary points. Example E...
stackexchange_codegolf
On Math Stack Exchange, I asked a question about the smallest region that can contain all free n-ominos. I'd like to add this sequence to the On-Line Encyclopedia of Integer Sequences once I have more terms. Example A nine-cell region is the smallest subset of the plane that can contain all twelve free 5-ominoes, as i...
stackexchange_codegolf
Inspiration Conway's Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are: Any live cell with 2 or 3 living neighbours (the 8 cells immediately aroun...
stackexchange_codegolf
Surprisingly we haven't had a simple "find the highest digit" challenge yet, but I think that's a little too trivial. Given input of a non-negative integer, return the highest unique (ie not repeated) digit found in the integer. If there are no unique digits, your program can do anything (undefined behaviour), other th...
stackexchange_codegolf
The challenge today is very simple. The task is to determine the TI calculator for which the submitted datafile was made. The datafiles always start with a string **TI, the version (described below), and other data you can ignore. Now, the versions you need to recognize are: 95* => TI-95 92P => TI-92+ 92* => TI-92 89* ...
stackexchange_codegolf
Challenge Build the Wheat Wizard's stove using 2-input NAND gates. The solution with the fewest NAND gates wins. Externally, it works in the following way: (the first line is added from the original spec for physical output) It has 10 levels, from 0 to 9. The display has 9 lights, and if the current level is L, exactl...
stackexchange_codegolf
In your grandparents' day, dialing a phone number was done with a rotary dial like this: To dial each digit, put your finger in the corresponding hole, pull it over to the finger stop, and release it. A mechanism will cause the dial to spin back to its resting position, and the phone will disconnect and reconnect a c...
stackexchange_codegolf
Inspired by this badly received migrated post. The head of security at your company is concerned about your PIN generating system after it gave him 12345. He also didn't really appreciate the Spaceballs joke you made at his expense, so you've been delegated to re-write the PIN generator. Since it has to fit on some spe...
stackexchange_codegolf
The challenge How well can you gerrymander North Carolina into 13 voting districts? In this challenge, you use the following files to draw different maps for Republicans and Democrats. File 1: NC_2016_presidential_election.csv File 2: NC_county_adjacency.csv File 1 gives county-level voting data from the 2016 president...
stackexchange_codegolf
Given: A natural number S. A list of N rational weights W that sum to 1. Return a list L of N non-negative integers, such that: (1) sum(L) = S (2) sum((S⋅W_i - L_i)^2) is minimal In other words, approximate S⋅W_is with integers as closely as possible. Examples: 1 [0.4 0.3 0.3] = [1 0 0] 3 [0 1 0] = [0 3 0] 4 [0.3 0....
stackexchange_codegolf
The Challenge Given a rational number, determine the smallest number which is a positive integer multiple of it. Eg. Given: 1.25 x1: 1.25 x2: 2.5 x3: 3.75 x4: 5 Thus: Answer is 5 Clarifications Inputs will be a rational number in the range of (0,100] of which the Decimal Representation has no more than 4 ...
stackexchange_codegolf
Given a positive number n, output all distinct multiplicative partitions of n in any convenient format. A multiplicative partition of n is a set of integers, all greater than one, such that their product is n. For example, 20 has the following distinct multiplicative partitions: 2 * 2 * 5 2 * 10 4 * 5 20 Order does no...
stackexchange_codegolf
This is a cops-and-robbers challenge the Cops' Thread can be found here Your challenge, as robbers is to take outputs from the cops' thread and find anagrams of the output that when run as a program output the original output provided. The winner will be the person with the most valid cracks on this question. Rules Yo...
stackexchange_codegolf
Another sequence, another challenge.* Definition A prime p is in this sequence, let's call it A, iff for every digit d in p's decimal expansion, you replace d with d copies of d and the resulting integer is still prime; zeros are not permitted. For example, 11 is trivially in this sequence (it's the first number, incid...
stackexchange_codegolf
Typically, polyglots are constructed in such a manner that each language can ignore parts of the code that are present for other languages, by wrapping them in string literals, using comment syntax, or other similar tricks. Your goal is to write a polyglot where the output for each language is the code from the polyglo...
stackexchange_codegolf