instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
This challenge is to write fast code that can perform a computationally difficult infinite sum. Input An n by n matrix P with integer entries that are smaller than 100 in absolute value. When testing I am happy to provide input to your code in any sensible format your code wants. The default will be one line per row of...
stackexchange_codegolf
The Pascal's triangle and the Fibonacci sequence have an interesting connection: Source: Math is Fun - Pascal's triangle Your job is to prove this property in Lean theorem prover (Lean 3 + mathlib). Shortest code in bytes wins. import data.nat.choose.basic import data.nat.fib import data.list.defs import data.list.nat...
stackexchange_codegolf
Given an integer N perform the following steps: (using 9 as an example). Receive input N. (9) Convert N from base10 to base2. (1001) Increase every bit by 1. (2112) Treat the result as base3 and convert it back to base10. (68) Return/Output the result. Input May be received in any reasonable number format. You only ...
stackexchange_codegolf
this challenge was based on a sandboxed post by @dmckee Old fashioned cell phones were and are used heavily as texting platforms, unfortunately the keyboard has only 12 + a few buttons, and is therefor ill-suited to naive text entry. Common solutions make use of the traditional telephone coding (generally with a modest...
stackexchange_codegolf
When we publish some software, we assign a version number to it. And users may want to update to the latest version of some software. So, it is the time to find out which version should be newer. Input Input two version numbers as strings. In the context of this challenge, we only support version numbers which are some...
stackexchange_codegolf
A twin of this. FizzBuzz is where a range of positive integers is taken, and numbers divisible by 3 are replaced with "Fizz", divisible by 5 with "Buzz" and divisible by 15 with "FizzBuzz". For example, FizzBuzz from 1 to 10 is 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz. Your challenge is to, given a list of Fizzes, B...
stackexchange_codegolf
Introduction This is the evolution of this previous challenge which was about checking satisfieability of normal formulae in conjunctive normal form (CNF). However, this problem is NP-complete and watching algorithms finish is just boring, so we're gonna simplify the problem! Specification Input You may tune the follow...
stackexchange_codegolf
List the coordinates of 8 squares adjacent to (0, 0) in a 2d grid. Namely, [(1,-1),(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1)] Order does not matter. The goal is to store the points into a list. Shortest answer wins.
stackexchange_codegolf
TailwindCSS is a utility that lets one write CSS code using only HTML classes, which are then converted to CSS code with the Tailwind compiler. Ordinarily, one would write CSS in a separate file from the HTML, and reference named classes: <!-- without Tailwind --> <p class="crazy-monologue">Crazy? I was crazy once. The...
stackexchange_codegolf
This challenge will be based on an R language trivia: every release is named and it's a reference to Peanuts comic strips (see here and here). Task Given a release name, output its number. For reference, use the below list: Great Pumpkin 2.14.0 December Snowflakes 2.14.1 Gift-Getting Season 2.14....
stackexchange_codegolf
Write a full program or a function taking an unsigned integer number N and doing this cut out work: Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/' Translate the piece above by 3 lines. Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon ...
stackexchange_codegolf
Notwen wants to study the kinematics of bodies thrown from big heights in a uniform gravitational field but unfortunately he doesn't have the technical possibility to go to sufficiently high places and observe the objects while falling. But who doesn't want to see advances in science so... Let's help Notwen build a gra...
stackexchange_codegolf
Note: There are some rude words in this question. There's an implicit puzzle posed in this classic Monty Python sketch (you can also ready the script online). Various phrases are described as being 'woody' or 'tinny', and one is described as being 'PVC'. Given a phrase, respond with its type according to the following...
stackexchange_codegolf
Main objective The main objective is to output a text, it doesn't mind which text or where the text gets its output (it can be on a browser window, the default console etc). It just requires the condition that what is output must be indeed "real chars" (the ones in UNICODE for example), it's not considered valid to dis...
stackexchange_codegolf
I don't like numbers, but I do like the Fibonacci sequence. I'm sure we could work something out. Please read one integer n from STDIN and output the nth Fibonacci number in base 26 (abcdefghijklmnopqrstuvwxyz instead of 0123456789) to STDOUT. The first Fibonacci number is 0. The second one is 1. The nth fibonacci num...
stackexchange_codegolf
Let's say I've got some ASCII art: ___ ,"---". : ; `-.-' | | | | | | _.-\_/-._ _ / | | \ _ / / `---' \ \ / `-----------' \ /,-""-. ,-""-.\ ( i-..-i i-..-i ) |`| |-------| |'| \ `-..-' ,=. `-..-'/ `------...
stackexchange_codegolf
Break two numbers up into their powers of 2, if they share any, return a falsey value. Otherwise, return a truthy value. If one input is 0, the answer will always be truthy. if one input is 255, the answer will be falsey if the other is not 0. Example Given 5 and 3 5 = 2⁰ + 2² 3 = 2⁰ + 2¹ Both share 2⁰, return falsey....
stackexchange_codegolf
Consider a finite, one-dimensional grid where each cell is marked with one of two symbols (I will use the symbols < and >, but you can use other symbols). When a pinball is placed on one of the cells, it moves according to the following rules: If the pinball is on a cell that is marked with <, the pinball moves one ce...
stackexchange_codegolf
This challenge requires a small amount of knowledge about chess. A description of the details required can be found at the bottom if you are not familiar with chess or want a refresher. For a certain board configuration consisting only of queens we can say that each queens threat number is the number of other queens i...
stackexchange_codegolf
Simple question! Given a string that contains a date in ISO8601 format, print the first of the next month in ISO8601 format. Example inputs: 2018-05-06 2019-12-20 Their respective outputs: 2018-06-01 2020-01-01 The rules: Imports are free and don't count towards your score. The date will be stored in a string called s...
stackexchange_codegolf
In this challenge we learned a way to encode every positive integer using factor trees. Here is how it works: The empty string has value of 1. (S) where S is any expression with a value of S evaluates to the Sth prime. AB where A and B are arbirary expressions with values of A and B respectively has value A*B. For ex...
stackexchange_codegolf
Requirement: Write a program (in any language) that counts the number of lines of code in files matching *.sh in the directory tree starting from the directory that the program is executed in, excluding lines that are empty, only contain whitespace, or are just single-line comments (a line which the first character tha...
stackexchange_codegolf
This is an answer-chaining question, which means that all answers are affected by those before them. The task The n-th answer to this question must run in all languages that are present in answers before it. They need not run in order, but must print the name of the language currently running, reversed. Additional rule...
stackexchange_codegolf
C/C++ use double quotes "" for making string literals. If I want the double-quote itself, or certain other characters, to appear in the string, I have to escape them, like so: char *s2 = "This is not \"good\".\nThis is awesome!\n"; Here, I used \" to represent a double-quote, and \n to represent the newline character....
stackexchange_codegolf
Introduction One day, you were showing your kid how to draw on a computer. You type mspaint.exe in the run bar. To your horror, it says "No items match your search". You must create a simple version of paint so your kid can draw! Challenge You must create a simple drawing program. To do this, open a white display windo...
stackexchange_codegolf
I have been going to puzzling.se, and people over there write stuff in rot13 a lot, sot this gave me an idea: Write a program that takes 2 inputs, a string and integer: the message to encode or decode how far to shift You can input in a function call, and output in any legal way twist: it must work with any printable...
stackexchange_codegolf
A Bayer matrix is a threshold map used for ordered dithering that gives the illusion of having more shades of color than actually present by using a crosshatch-like pattern. Bayer matrices are square with a side length that is a power of 2. Here are some examples: \$ \displaystyle\frac{1}{4} \times \begin{bmatrix} 0 & ...
stackexchange_codegolf
Input: A maze containing the characters: -- (horizontal wall); | (vertical wall); + (connection); (walking space); I (entrance); U (exit). I.e. an input could look like this: +--+--+--+--+--+--+--+--+--+--+ I | | | + +--+--+--+ + + + +--+ + | | | | | | +--+-...
stackexchange_codegolf
Thanks to this question for some inspiration In this challenge we will represent a line of dominoes as a string of |, / and \. You will be given a string of dominoes as input and you must determine what they look like when they have settled. Here are the rules for how dominoes fall over A standing domino, |, left ...
stackexchange_codegolf
Write a function (or a whole program) that outputs (or prints) an ASCII art of the initial position of Mölkky pins. Output : __ __ __ __(07)__(09)__(08)__ (05)__(11)__(12)__(06) | (03)__(10)__(04) | | | (01) (02) | | |__| | | | | |__| |__| |__| |__| |__| |__| Rules : This is code-go...
stackexchange_codegolf
Rolling the Dice So, I was rolling dice a while ago and thought of a challenge. Given the cube with a net taken from input and a list of moves, find the square on the bottom at the end. I will use this image for the examples here. Input You take in a string with a list of moves. The string contains only the capital A...
stackexchange_codegolf
(Similar: Through the bases) Normally, our number system is base ten, with the digits 0123456789. However, we can increase or decrease the base count (so hexadecimal uses 0123456789abcdef and octal uses 01234567. Your goal is: given a string, interpret it in all bases 2-36 for which it's valid, compute the total, and e...
stackexchange_codegolf
Task Your goal, should you choose to accept it, is to write a program, that, given an input string (or array of characters), outputs every possible permutation of the letters in that string. I'm finicky with my output, so it should be sorted alphabetically, with no duplicates. Example: Input: buzz Output: buzz bzuz bzz...
stackexchange_codegolf
For each row and then column of a matrix, we can add an extra entry with the sum of the last two entries in that row or column. For example with the following input matrix: [ 1 1 1 ] [ 2 3 4 ] The resulting matrix would be: [ 1 1 1 2 ] [ 2 3 4 7 ] [ 3 4 5 9 ] Given an input of an integer N and an [X,Y] matrix of siz...
stackexchange_codegolf
Background The Fibonacci sequence is defined as $$f(1) = 1 \\ f(2) = 1 \\ f(n) = f(n-1) + f(n-2)$$ The Fibonorial, similar to the factorial, is the product of the first \$n\$ Fibonacci numbers. $$g(n) = f(1) \times f(2) \times ... \times f(n-1) \times f(n)$$ The Fibonomial coefficient, similar to the binomial coefficie...
stackexchange_codegolf
Context After attempting to program in Grass for the entire morning, you decide to go outside and mow some real grass. The grass can be viewed as a string consisting exclusively of the following characters: wWv. w denotes tall grass which takes \$ 1 \$ unit of energy to mow. W denotes extremely tall grass which takes \...
stackexchange_codegolf
Given a list of words, output a square grid of characters, so that all the words can be read from the grid, by moving horizontally, vertically, or diagonally between characters, without reusing characters in the same word. The grid must be the smallest possible which allows all words to be read. Example B A D R E T E Y...
stackexchange_codegolf
The game of Ghost is played between two players who alternate saying a letter on each turn. At each point, the letters so far must start some valid English word. The loser is the player to complete a full word first. So, for example, if the letters so far are E-A-G-L, then the only valid next letter to say is "E" an...
stackexchange_codegolf
A simple one: Take a list of positive integers as input and output the numbers modulus their 1-based index in the list. If the input integers are {a, b, c, d, e, f, g} then the output should be {a%1, b%2, c%3, d%4, e%5, f%6, g%7} where % is the modulus operator. Test cases: 10 9 8 7 6 5 4 3 2 1 0 1 2 3 1...
stackexchange_codegolf
I want to write a function golf(C, A) that takes the height (C = 2*c) and the width (A = 2*a) of an oblate (left image) or prolate (right image) spheroid or a sphere as parameters and returns the volume V and the surface area S of the shape as tuple. The output must be rounded to two decimal places. All input and outp...
stackexchange_codegolf
Goal Write a function or a program that when given a string, for example "The quick brown fox jumps over the lazy dog", outputs: T h e q u i e r t h e c v k o l a b s z r p y o m g o d w u n ...
stackexchange_codegolf
I have 2 inputs: 1 single number and some numbers separated by whitespace: 1 1 2 3 4 5 I want to loop over the second input, and I don't need the first input. I did this, which works: input() for x in input().split():somecode() But can I go directly to the second input without doing the input() at the beginning or wi...
stackexchange_codegolf
In Wordle, you try to guess a secret word, and some letters in your guess are highlighted to give you hints. If you guess a letter which matches the letter in the same position in the secret word, the letter will be highlighted green. For example, if the secret word is LEMON and you guess BEACH, then the E will be high...
stackexchange_codegolf
The user will hide, and the computer will try to find them. First, the program will take an input, for the size of the grid. Like 5x5, 10x10, 15x15, etc. The grid won't always be a perfect square. The grid is sort of like a chessboard: _______________________________ | | | | | | | A1 | | | ...
stackexchange_codegolf
Let's consider a list \$L\$ (initially empty) and a pointer \$p\$ into this list (initialized to \$0\$). Given a pair of integers \$(m,n)\$, with \$m\ge 0\$ and \$n>0\$: We set all uninitialized values in \$L\$ up to \$p+m+n\$ (excluded) to \$0\$. We advance the pointer by adding \$m\$ to \$p\$. We create a vector \$[...
stackexchange_codegolf
Wanna be an Alchemist I've been watching Full Metal Alchemist these past days and I've been wondering, It is really possible to trans-mutate matter? In the real world, I don't know if it is possible, but in the machine world, we think we "can". Problem Your task is, Given an input of N chemical elements (K, Mg, C, O, ...
stackexchange_codegolf
I have the following code which I've written to emulate Newton's method for deriving the square root of a number: r=(x,y)=> (z=((y=y||x)*y-x)/(2*y)>1e-15)? r(x,y-(y*y-x)/(2*y)):y Where r(37) would result in 6.08276253029822 which is great given the limitations of my browser. I'd like to golf this code further seei...
stackexchange_codegolf
This is the robbers' thread. The cops' thread is located here. Robber rules Should work for all keys and secrets Should require the same number or fewer guesses as the cop's fault, to prevent brute forcing Does not need to be the same as the cop's intended fault Multiple cracks may be made for the same cop, as long as...
stackexchange_codegolf
Given a positive input \$n > 0\$, output the amout of two types based on their rarity. The two types are called \$A\$ and \$B\$, we know the followings: \$n\$ is a limited input and the maximum is \$nmax\$ At the start \$B\$ is twice as rare as \$A\$ As the presence of \$A\$ increade the rarity of \$B\$ decreases When...
stackexchange_codegolf
Writing questions for programming puzzles is tiring and takes many minutes to do. This is where you come in. Your job is to write a program that randomly generates plausible-sounding (but not necessarily interesting) code golf questions. Input: None Output: One sentence code golf question (see sentence structure) Guid...
stackexchange_codegolf
The game of xiangqi, also known as Chinese chess, is a chess-like game popular in China, Vietnam, Taiwan, and other East Asian countries. The colours of the two sides in xiangqi are red and black. There are 16 black pieces in xiangqi: the 1 general (G), 2 advisor (A), 2 elephant (E), 2 horse (H), 2 chariot (R), 2 canno...
stackexchange_codegolf
Challenge Let's have a list L of n elements. The task is to swap every two elements in this list. Constrains the list L has at least two elements size of the list L is a multiple of two (i.e. number of elements is even) Example input: [1,2,3,4,5,6] output: [2,1,4,3,6,5] input: [0,1,0,1] output: [1,0,1,0] Rules ...
stackexchange_codegolf
Daylight saving time (DST), is the practice of advancing clocks (typically by one hour) during warmer months so that darkness falls at a later clock time. The typical implementation of DST is to set clocks forward by one hour in the spring ("spring forward") and set clocks back by one hour in autumn ("fall back") to re...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Christmas is coming up, and Santa hasn't kept to his diet very well this year. Due to his size, he is getting the elves to collect a list of all the chimneys he will be able to fit down. Unfortunately, chimneys these days are a bit of ...
stackexchange_codegolf
Gringotts isn't just a vault, but a reputable financial institution and wizards need loans too. Since you don't want to be screwed over by the Gringotts goblins, you decided it would be a good idea to write a program to calculate interest. Interest is compounded only yearly. Your task is to calculate total owed amount ...
stackexchange_codegolf
Choose your favorite famous computer scientist or computer science pioneer who was born in 1942 or earlier (as 1943 marks the start of the creation of the 'first' computer). They should have a Wikipedia page or other site that lists their birth year and tells how their accomplishments relate to computer science. You ma...
stackexchange_codegolf
Basically the tron light-cycle game as a king of the hill competition! Leaderboard Updated as of 2022-04-05 #1) Player Avoid by Agent Biscutt #2) Dodge West by Imanton1 #3) Space Finder by Spitemaster #4) Blind Bot by TheSilican Judge/Leaderboard Website The Game Players will write bots that compete in a light-cyc...
stackexchange_codegolf
A regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length). Your job is to find out if a given polygon is regular or not. Specs You will be given a list of Cartesian coordinate 2-tuples which describe the polygon's vertices. The points will alw...
stackexchange_codegolf
The task is to make a function which returns random number, no build in functions allowed, returned value should be random or pseudo-random and no sequence allowed, no matter what the formula is and how scattered values are. To simplify task, returned value should be 32-bit integer or float from range [0; 1) It is code...
stackexchange_codegolf
Backstory Disclaimer: May contain made up information about kangaroos. Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry. In stage 1, the kangaroo is very little and cannot jump at all. Despite this, is...
stackexchange_codegolf
Background The number 1729 is the Hardy-Ramanujan number. An amazing property of it was discovered by S. Ramanujan (who is widely regarded as the greatest Indian mathematician1), when G.H. Hardy paid a visit to him in a hospital. In Hardy's own words: I remember once going to see him when he was ill at Putney. I had r...
stackexchange_codegolf
Ouput the following banner: _____ _ _____ _ __ / ____| | | / ____| | |/ _| | | ___ __| | ___ | | __ ___ | | |_ | | / _ \ / _` |/ _ \ | | |_ |/ _ \| | _| | |___| (_) | (_| | __/ | |__| | (_) | | | \_____\___/ \__,_|\___| \_____|\___/|_|_| The code ...
stackexchange_codegolf
Program: To count the sum of all Unicode characters of a given input. (No need to display the output. The final answer can be calculated in any base no need to convert back to hexadecimal.) Test case : XyZ= 0058+0079+005A=012B Condition: If the program is inputted, then its output must be an integral multiple of 1729 (...
stackexchange_codegolf
Your code-golf challenge is to find all occurences of a word in the 3d matrix. There is no restriction on I/O format. In the samples below, the word is presented, then a blank line, then the 2-dimensional layers from top to bottom, and the output, for each line, consists of a coordinate and a direction (x, then y, then...
stackexchange_codegolf
So the golf question was like this: You are given a number T and then a total of T number of 17-character strings. For each of the strings, output yes if it contains four consecutive identical characters or contains the substring DX, else output no. The following constraints are promised for each of the 17-character ...
stackexchange_codegolf
(Inspired by ASCII's 95 Characters...95 Movie Quotes) The Challenge Given input n, output the nth Fibonacci number. You can use either 0 or 1 indexing, please state which in your submission. Simple, yeah? The catch is you must take the character set of the immediate previous answer, remove two characters from it, and a...
stackexchange_codegolf
Objective Given a positive integer, spell it out in the conlang I made. Specification Let \$n\$ be the inputted integer. \$n\$ shall be spelled out in the following specification. The entire spelling is case sensitive. With the decimal expansion of \$n\$, let d be the least significant nonzero digit of \$n\$. First, d ...
stackexchange_codegolf
Your task is to create a program that will display the following text, wait for the user to press a key (it is okay to ignore keys like ctrl, alt, caps lock, etc., as long as keys like letters, numbers, symbols, and enter are not ignored), and then terminate the program: Press any key to continue... Trailing newlines...
stackexchange_codegolf
The challenge is rather simple: Take a positive whole number \$n\$ as input. Output the \$n\$th Fibonacci prime number, i.e. the \$n\$th Fibonacci number that is also prime. Input can be as an parameter to a function (and the output will be the return value), or can be taken from the command line (and outputted there...
stackexchange_codegolf
The new site header has some bits of source code from various questions as the background. Here are the first 3 lines: --<-<<+[+[<+>--->->->-<<<]>]<<--.<++++++.<<-..<<.<+.>>.>>.<<<.+++.>>.>>-.<<<+. Hello, World! IT'S SHOWTIME TALK TO THE HAND "Hello, World!" YOU HAVE BEEN TERMINATED "9!dlroW ,olleH"ck,@ 72a101a+7aa+3a4...
stackexchange_codegolf
Duolingo, the language learning app, has a lot of things going for it, but there is one major issue that drives me crazy. It tells me how many days in a row I've used the app with a message like You're on a 7 day streak! Setting aside hyphenation and whether the number should be spelled out, this works fine for most nu...
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
Input: Two strings (NOTE: the order of input is important). Output: Both words/sentences start on lines with one empty line in between them. They 'walk' horizontally 'next to each other'. But when they have the same character at the same position, they cross each other, and then continue walking 'next to each other'. C...
stackexchange_codegolf
Given a UTF-16 string, test its endianness. Rules: As long as the input is in UTF-16 without BOM, its type doesn't matter. In C++ on Windows, it can be std::wstring or std::u16string. In Haskell, it can be [Int16] or [Word16]. The endianness is tested by noncharacters. If the input contains a noncharacter, it is in wr...
stackexchange_codegolf
In the Anno video game series there are 6 games with a 7th one announced for early 2019. Their titles always feature a year in a specific pattern: Anno 1602, Anno 1503, Anno 1701, Anno 1404, Anno 2070, Anno 2205, Anno 1800 The digital sum is always 9. The years are four digits long. They contain at least one zero. Wi...
stackexchange_codegolf
Objective Given a date, spell it out in Romanized Japanese. I/O Format The input format is flexible. The output format is <month spelling> <day spelling>; note the space. You can freely mix cases in output. You may output trailing newline. Mapping Months Month Spelling January Ichigatsu February Nigatsu Mar...
stackexchange_codegolf
Create a program that interprets the programming language Bucket. Bucket works on two buckets: the first can hold A and the second can hold B units of liquid. The things you can do with these buckets are: f: fill bucket A F: fill bucket B e: empty bucket A E: empty bucket B p: pour units of liquid from A to B until one...
stackexchange_codegolf
Introduction I began studying the Collatz Conjecture And noticed these patterns; 0,1,2,2,3,3...A055086, and 0,1,2,0,3,1...A082375, in the numbers that go to 1 in one odd step, 5,10,20,21,40,42...A062052 Related like so; A062052()(n) = ( 16*2^A055086(n) - 2^A082375(n) ) /3 The formula for A055086 is $$\lfloor\sqrt{4...
stackexchange_codegolf
Tic-Tac-Latin! This is a true story, so names have been altered. My latin teacher, Mr. Latin, created his own proprietary (no joke) tic tac toe variant. Let's call it tic-tac-latin. The game is simple, it is essentially tic tac toe played on a four by four grid. Formal rule declaration A line is either a row, column o...
stackexchange_codegolf
Robbers post A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle shuffle a string: Split the string into equal sections. Reverse the strings, and starting from the start of each string. Pu...
stackexchange_codegolf
Given two numbers \$x,y > 2, x≠y \$ output all integers \$m\$ such that $$ x + y \equiv x \cdot y \pmod m $$ $$ x \cdot y > m > 2 $$ Input Two integers Output A list of integers Test cases 3, 4 -> 5 5, 8 -> 3, 9, 27 29, 9 -> 223 26, 4 -> 37, 74 13, 11 -> 7, 17, 119 6258, 571 -> 463, 7703, 3566489
stackexchange_codegolf
Definitions: A triangle is considered a right triangle if one of the inner angles is exactly 90 degrees. A number is considered rational if it can be represented by a ratio of integers, i.e., p/q, where both p and q are integers. A number n is a congruent number if there exists a right triangle of area n where all thr...
stackexchange_codegolf
The task is the following. Given an integer x (such that x modulo 100000000003 is not equal to 0) presented to your code in any way you find convenient, output another integer y < 100000000003 so that (x * y) mod 100000000003 = 1. You code must take less than 30 minutes to run on a standard desktop machine for any in...
stackexchange_codegolf
The goal of this challenge is to check and extend the OEIS sequence A334248: Number of distinct acyclic orientations of the edges of an n-dimensional cube. Take an n-dimensional cube (if n=1, this is a line; if n=2, a square; if n=3, a cube; if n=4, a hypercube/tesseract; etc), and give a direction to all of its edges ...
stackexchange_codegolf
A few days ago, I came up with a fun card game to play with my friends. We were having fun playing it, when I thought, "Why not make this a KoTH?" So, here it is! Overview In this game, the objective is to get the most points. Your bot starts with 0 points and 20 energy. Every turn (500 in a game), both bots play one c...
stackexchange_codegolf
Given an input integer from 1, 2, ..., n, the task to write code to make a number as close as possible (as measured by absolute distance) to e using only the four mathematical operations +, -, *, / and parentheses (brackets). You can use any of the integers up to n once but don't have to use all the numbers and you are...
stackexchange_codegolf
Introduction Each Unicode codepoint can be represented as a sequence of up to 4 bytes. Because of this, it is possible to interpret some 2, 3, or 4-byte characters as multiple 1-byte characters. (See here for a UTF-8 to bytes converter). Challenge Given a UTF-8 character, output it split into a sequence of 1-byte chara...
stackexchange_codegolf
Given a number n, print the nth prime Fermat number, where the Fermat numbers are of the form 22k+1. This code should theoretically work for any n (i.e. don't hardcode it), although it is not expected to terminate for n > 4. (It should not return 4294967297 for n=5, as 4294967297 is not a prime number.) Do note that wh...
stackexchange_codegolf
In English, there is the fun and simple difference between an and a: you use an when preceding a word starting with a vowel sound, and a when the word starts with a consonant sound. For the sake of simplicity in this challenge, an precedes a word that starts with a vowel (aeiou), and a precedes a word that starts with...
stackexchange_codegolf
The goal of this challenge is to generalise the bitwise XOR function to other bases. Given two non-negative integers \$ x \$ and \$ y \$, and another integer \$ b \$ such that \$ b \geq 2 \$, write a program/function which computes the generalised XOR, described the following algorithm: First, find the base \$ b \$ re...
stackexchange_codegolf
Introduction I crochet a lot, and lately I've started writing crochet patterns. However, while I work very well from notes such as rnds 2-6 (round number = x, original number of stitches = y): *dc x-2 stitches, 2 dc in next stitch* around (xy stitches), most published patterns spell out each row in more detail. I don't...
stackexchange_codegolf
Rotonyms 2 A "Rotonym" is a word that ROT13s into another word (in the same language). For this challenge, we'll use an alternate definition: a "Rotonym" is a word that circular shifts/rotates into another word (in the same language). For example: 'stable' < 'tables' < 'ablest' 'abort' > 'tabor' 'tada' >> 'data' The C...
stackexchange_codegolf
Let S be a set of sets, for example S = {{A},{B},{A,B}}. A maximal subset, Max, is an element of S such that no other set in S strictly includes Max. So in this example, {A,B} is a maximal subset as none of the other sets strictly contain {A,B}. A minimal subset, Min, is an element of S such that no other set in S is s...
stackexchange_codegolf
I do not believe this question to be a duplicate of this one, since this one requires more string manipulation, if it is still a duplicate feel free to close this question Introduction Your challenge today is to output the lyrics of "99 bottles of beer": 99 bottles of beer on the wall, 99 bottles of beer. Take one down...
stackexchange_codegolf
Given a non-empty list of digits 0 though 9, output the smallest number that can be produced by an expression formed by reordering these digits and introducing exponentiation signs ^, with adjacent digits getting concatenated as multi-digit numbers. Exponentiation is evaluated as right-associative. For example, [4, 2, ...
stackexchange_codegolf
A magic square is an \$ n \times n \$ square grid, such that the sum of the integers on each row and column are equal. Note that the definition which will be used in this challenge is different than the one used by Wikipedia, since diagonal sums are not accounted for the numbers are not required to be distinct or in t...
stackexchange_codegolf
I have this code : tr ' ' '\n'|sort -n|head -1 The code is pretty simple, it takes a list of integer in the standard input stream (like 5 9 8 7 5 2 -12 -30), it sort the integers and display only the first integer. But i need to ouput 0 if the given list is empty. And i can't find a short way to that. I have a solutio...
stackexchange_codegolf
Inspired by this xkcd You work for Shazam and they have a project for you. Some customers are complaining about their app taking up too much space on their phone, so they want you to code a lite version of the app. Unfortunately, your existing code can only understand the word "na", and you have to ship soon. That's o...
stackexchange_codegolf
Anyone remember Boaty? You could totally make any old word, right? Write a function to turn a string into Somethingy McSomethingface. It should accept one string as input. Ignore the case of the input. If the word ends in 'y', your function should not add an additional 'y' to the first instance, but should remove it i...
stackexchange_codegolf
(Note: I'm not in the army so feel free to correct me if my formation is wrong, but I will not be changing the question. I will change any terminology mistakes though, because I'm trying to avoid air-cadet-specific wording choices) (Note: this follows the standards for Canadian Air Cadets, not any actual army thing) Ch...
stackexchange_codegolf