instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
For this challenge you need to implement two functions, f and g, on the integers, such that f ∘ g is a strictly decreasing function while g ∘ f is a strictly increasing function. In other words, if you take any two integers a < b, then f(g(a)) > f(g(b)) and g(f(a)) < g(f(b)). There are no restrictions on f and g indivi...
stackexchange_codegolf
Some chess variants use interesting non-standard pieces. In order to concisely describe new pieces or to describe pieces without requiring everyone to memorize a bunch of non-standard names some new notation can be invented. In this challenge we are going to look at Parlett's movement notation and convert it to nice at...
stackexchange_codegolf
Given the ASCII art of two vectors, find the resultant vector's magnitude and degree. Input This can be received via STDIN, read from a local file, or provided through a function call. Here is an example of a two vector input: ^------> | | | x This represents a change of 4 units north and 7 units east. Every input's ...
stackexchange_codegolf
The challenge Create a function which takes an array of numbers and subtract from each element the lowest element in the array that has not yet been subtracted from another. After using the lowest value, It can not be used again. Numbers in the array are decimal numbers, and not necessarily integers. Example: Input: ...
stackexchange_codegolf
ello all, I hope this finds you well. There are 118 elements on the Periodic table at the moment, each one corresponds to the number of protons in an atom's nuclei. Each element also has a 'symbol'. Hydrogen has 'H', Helium has 'He' and so on. I want to know about these! Challenge: Given 1 string as input, output true ...
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
Shortest program wins, of course.
stackexchange_codegolf
This is a copy cat question of Simplify ijk string applied to the other nonabelian group of order 8. See also Dihedral group composition with custom labels. Challenge Given a string made of r and s interpret it as the product of elements of the dihedral group \$D_8\$ and simplify it into one of the eight possible value...
stackexchange_codegolf
Write a program that: if a compiled language is used, compiles without errors if an interpreted language is used, runs without syntax errors for every major release of your language, and produces different output for every major release under which it is compiled/run. (It may produce the same or different output for ...
stackexchange_codegolf
Background (feel free to skip) Ordinals are the abstract representation of well-orders. A well-order of a set is a total order, which basically means that every element in the set can be compared against any other element in the set, and one of them is either smaller or larger. Also there are no cycles. The crucial dif...
stackexchange_codegolf
You will be given two Arrays / Lists / Vectors of non-negative integers A and B. Your task is to output the highest integer N that appears in both A and B, and is also unique in both A and B. You may assume that there is at least one such number. Any reasonable Input and Output method / format is allowed. These Looph...
stackexchange_codegolf
Jelly has an "untruth" atom: Ṭ. This takes a non-empty array of positive integers and returns a Boolean array with 1s at the indexes in the input. For example: [1,3,5,6]Ṭ ⁼ [1,0,1,0,1,1] [5]Ṭ ⁼ [0,0,0,0,1] [2,1,1,2]Ṭ ⁼ [1,1] [5,4,3]Ṭ ⁼ [0,0,1,1,1] [1]Ṭ ⁼ [1] Try it online! Note that Jelly uses 1-indexing...
stackexchange_codegolf
Description There have been quite a few other challenges concerning these numbers before, and I hope this one is not among them. The n th triangular number equals the sum of all natural numbers up to n, simple stuff. There are a wikipedia page and an entry at OEIS, for those who wish to inform themselves further. Now, ...
stackexchange_codegolf
Version 2 here. Simple challenge: given an integer, draw a house of cards with the given number of stories. If the number is negative, draw the house upside-down. Examples: Input: 2 Output: /\ -- /\/\ Input: 5 Output: /\ -- /\/\ ---- /\/\/\ ------ /\/\/\/\ -------- /\/\/\/\/\ Input: 0 Output...
stackexchange_codegolf
Introduction Suppose I have a list of integers, say L = [-1,2,2,1,2,7,1,4]. I like having balance in my life, so I'm happy to see it has as many odd elements as even elements. What's more, it also has an equal number of elements in all modulo classes of 3 that it has elements in: [-1,2,2,1,2,7,1,4] 0 mod 3: 1 ...
stackexchange_codegolf
Like Brainfuck or JSFuck would be efficient in terms of number of characters needed, but what languages would have the highest amount of information per character? I was thinking of APL and J but there has to be more. My goal with this question is to find a program that would allow a person with theoretically infinite ...
stackexchange_codegolf
Your task is to write a computer program or function that takes a list of nonnegative integers of at least length 2 and determines if they are a "zigzag". A sequence is a zigzag if and only if the numbers alternate in being larger and smaller than the number that comes before them. For example \$[1,2,0,3,2]\$ and \$[...
stackexchange_codegolf
Given a positive integer N, output this doubling pattern of slash squares/rectangles. For N=1, the base is: /\ \/ The next square is added in the bottom right direction for N=2: /\ \/\ \/ After that, a 2x1 rectangle is added in the bottom left direction for N=3: /\ /\/\ \ \/ \/ Then a 2x2 square is added in the t...
stackexchange_codegolf
The Puzzle You have to write a program or function p(n) that returns the square of what is entered into it and you may assume that the input is a non-negative integer. Put in simpler terms, return n2. Rules You are not allowed to use * or / (or any other power or square root operator, such as POW or SQRT, if your lang...
stackexchange_codegolf
Challenge I've checked that there is a question Compute the Discrete Cosine Transform which is a competition for implementing a shortest solution to compute the one dimensional discrete cosine transform. The goal of this challenge is to implement a program to calculate three dimensional discrete cosine transform which ...
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
I came across this picture the other day: (Credit to Josep M Batlle I Ferrer) Your job is to generate this picture. This graph is generated by repeatedly applying newton's method to the graph of: $$f(x)=\cosh(x)-1$$ In other words, repeatedly apply the following function to every point till the rectangular distance is...
stackexchange_codegolf
Challenge You will create a function which takes a matrix filled with letters from the alphabet and determine if a 2x2 square composed of vowels exists. If a 2x2 square of vowels is found, your function should return the top-left position (row-column) of the square. If no 2x2 square of vowels exists, then return the ...
stackexchange_codegolf
Challenge Given a size s, print a cube net of that size made of hash symbols (#) and spaces (). Examples: 1: # # # # # # 2: # # # # # # # # # # # # # # # # # # # # # # # # 3: # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #...
stackexchange_codegolf
Snaking Number Challenge I wonder how many snaking numbers there are between 1 and 50,000? Snaking Numbers, in this game, are numbers which can be typed out on a traditional numberpad (format below) by moving one key up, down, left, or right. 7 8 9 4 5 6 1 2 3 0 For example, if you start with the number 5, you could...
stackexchange_codegolf
CLOSED to competing entries New bots are welcome but are not part of the main competition and probably won't be officially tested. You stand on a dusty stretch of code, watching the other programs stare at you. Will they shoot? How much ammunition do they have left? All you know is that you want to be the last one stan...
stackexchange_codegolf
Your task is to write a computer program or function that takes a list of nonnegative integers of at least length 2 and determines if they are a "zigzag". A sequence is a zigzag if and only if the numbers alternate in being larger and smaller than the number that comes before them. For example \$[1,2,0,3,2]\$ and \$[...
stackexchange_codegolf
Write the shortest possible code cause an error due to recursion too deep Example error in python RecursionError: maximum recursion depth exceeded Example error in c Segmentation fault My Python version (15 bytes): def f():f() f()
stackexchange_codegolf
It is possible to compress some kinds of data, such as human text or source code, with straight-line grammars. You basically create a grammar whose language has exactly one word – the uncompressed data. In this task, you have to write a program that implements this method of data compession. Input The input is a string...
stackexchange_codegolf
It's time for another Mesoamerican calendar! The Xiuhnelpilli was used by the Aztecs (more properly, the Mexica) to name their years. Each year has a number and a sign. Here's part of the cycle: Input; Output 1089; 13 Calli 1090; 1 Tochtli 1091; 2 Acatl 1092; 3 Tecpatl 1093; 4 Calli 1094; 5 Tochtli 1095; 6 Acatl ...
stackexchange_codegolf
A regular string looks like this: Hello,IAmAStringSnake! And a string snake looks something like this: Hel l rin o,IAmASt g S !ekan Your Task String snakes are dangerous, so you must make a program that takes a string snake as input and outputs it as a regular string. Specification...
stackexchange_codegolf
Imagine a very simple language. It has just 2 syntax features: () indicates a block scope, and any word consisting only of 1 or more lower case ASCII letters, which indicates a identifier. There are no keywords. In this language, the value of identifiers is not important except when they appear multiple times. Thus for...
stackexchange_codegolf
Given a string and integer n, split the string at n character, and print as follows: Ex) laptop 3 should print lap top laptop 2 should print la pt op (see how it splits the string at every 2nd char) Special cases: laptop 0 should print laptop (since we split at every 0th char, thus none) laptop 9 should print laptop (...
stackexchange_codegolf
Objective Find the most expensive path from the top-left of a square grid to the bottom-right such that its total cost is below a given threshold. Scenario You are given a square NxN grid. You are given a maximum cost. Every cell in the grid has a cost. The top-left cell has cost 0. The cost of a path is the sum of th...
stackexchange_codegolf
The task Today's special offer: consonants and punctuation for FREE! Your program or function will be given as input the first 6 paragraphs of Lewis Carroll's famous novel Alice's Adventures in Wonderland, with all vowels [aeiouAEIOU] removed and all other characters left intact. It must output the original text, byte-...
stackexchange_codegolf
Question Write a program to accept one string on the console only and print back its letters arranged in alphabetical order. The string must only have the following characters: 0123456789abcdefghijklmnopqrstuvwxyz Rules The ascending alphabetical order is defined in the given string. All repeated characters must be ...
stackexchange_codegolf
This is a king of the hill challenge for Dots and Boxes (aka Pen the Pig). The game is simple, on your turn just draw a line on an empty fence. Every time you complete a square you get a point. Also, since we are playing by championship rules, if you complete at least one square on your turn you get an extra turn. This...
stackexchange_codegolf
Given an input value \$n\$, construct an array of \$n\$ random 128 bit (unsigned) integers. The integers should be uniformly random. Your code can use any in built random number generation function it has or you can implement your own. Clearly this challenge is harder (and more fun) in lower level languages.
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
Given an input n, your program or function must output the smallest positive integer k such that n rounded to the nearest multiple of k is greater than n. Example. Given an input 20, the output value should be 3: The nearest multiple of 1 is 20, which is not greater than 20. The nearest multiple of 2 is 20, which is...
stackexchange_codegolf
We have some new sheriffs moderators in town, Mego and DJMcMayhem. We need a challenge to properly honour them for their new positions, so there we go. Here's something that has caught my attention when hovering over their profiles – their user IDs are \$31716\$ and \$45941\$. If you perform digit-wise subtraction, y...
stackexchange_codegolf
Given a natural number \$n\$, return the \$n\$-th cuban prime. Cuban Primes A cuban prime is a prime number of the form $$p = \frac{x^3-y^3}{x-y}$$ where \$y>0\$ and \$x = 1+y\$ or \$x = 2+y\$ Details You may use 0 or 1 based indexing, whatever suits you best. You can return the \$n\$-th prime given the index \$n\$ or...
stackexchange_codegolf
This code golf challenge is to show directions through numbers. When the user enters a number, then that means a direction change as follows: 0 means stay still 1 means forward (initially from left to right and initially start with `:`) 2 means turn right 3 means turn left 4 means go backward I will show you an exampl...
stackexchange_codegolf
(Inspired by an early draft of PhiNotPi's fractal line challenge.) You're given a width W > 1, a height H > 1 and string consisting of 2(W+H-2) printable ASCII characters. The task is to print this string wrapped around a rectangle of the given width and height, starting in the top left corner, in a clockwise sense. Th...
stackexchange_codegolf
Challenge: Given an NxN matrix where \$N\geq2\$ and one of eight distinct 'folding options', output a 2D array/list with the subtracted values. The eight folding options are: left-to-right; right-to-left; top-to-bottom; bottom-to-top; topleft-to-bottomright; topright-to-bottomleft; bottomleft-to-topright; bottomright-t...
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
You know how you get a voicemail message and the person's connection wasn't great, and you're trying to figure out how to call them back, but you're not sure if that was a "5" or an "8" they said? That's this challenge. The good news is that the caller read off their number twice, but it's garbled in both places. Your ...
stackexchange_codegolf
Someone gave my wife a decorative calendar consisting of four cubes. Here it is showing today's date (as of the posting of this challenge) on the front: When I first saw it, I looked at it from the wrong angle (from directly above) and couldn't figure out why it gave this information: [["February", "January"], [3], [7...
stackexchange_codegolf
This question is inspired by the fact that I love seeing questions with equal vote and answer counts... So here's a simple stack-exchange-api challenge for y'all: Challenge: Given a codegolf.stackexchange question id, output the ratio between the question's votes and number of answers (e.g. votes/answers). Specifics: ...
stackexchange_codegolf
Challenge Given a whole number divisible by 9 and one missing digit, find the missing digit. The missing digit may be represented by any character other than the digits 0-9 as long as it is consistent. If the missing digit could be 0 or 9, output something to signify so. Assume the user is intelligent enough to put onl...
stackexchange_codegolf
Introduction Every letter in the English alphabet can be represented as an ASCII code. For example, a is 97, and S is 83. As we all know, the formula for averaging two numbers \$x\$ and \$y\$ is \$\frac{x+y}{2}\$. I'm pretty sure you can see where this is going. Your challenge is to average two letters. Challenge Yo...
stackexchange_codegolf
Your challenge is to construct a proper quine using as few distinct characters as possible. Scoring Your score is equal to the number of distinct characters in your code, aiming to minimise this. Standard quine rules apply.
stackexchange_codegolf
This sequence is defined as Starts with 1, 2, 3 The next element of the sequence is the first number greater than the previous three that is co-prime with each of the previous 3 elements in the sequence. In other words, if the previous 3 elements are a, b, c, then the next is the first integer n>c such that gcd(a,n)=...
stackexchange_codegolf
If we have a finite list of elements we can determine the probability of any one element being drawn at random as the number of times it occurs divided by the total number of elements in the list. For example if the list is [2,3,2,4] the probability of drawing 2 is \$\frac 1 2\$ since there are \$2\$ 2s and \$4\$ eleme...
stackexchange_codegolf
In this game of cops and robbers, each cop will make a vault: a program that stores a secret, and requires a key to unlock. The robbers should find a way to get the vault to reveal its secret without knowing the key. Cop rules Cops will write two short segments of code: A vault, which takes a key and secret, then allo...
stackexchange_codegolf
This is a code golf version of a similar question I asked on stack earlier but thought it'd be an interesting puzzle. Given a string of length 10 which represents a base 36 number, increment it by one and return the resulting string. This means the strings will only contain digits from 0 to 9 and letters from a to z. B...
stackexchange_codegolf
Background MQTT (Message Queuing Telemetry Transport) is an ISO standard publish-subscribe-based messaging protocol (Wikipedia). Each message has a topic, such as the following examples: myhome/groundfloor/livingroom/temperature USA/California/San Francisco/Silicon Valley 5ff4a2ce-e485-40f4-826c-b1a5d81be9b6/status Ge...
stackexchange_codegolf
It's time for CGCC to demonstrate our musical talent! In this challenge, you're going to compose songs while keeping your byte count as small as possible. On Day 0, multiple answerers will post a function or program that outputs nothing/an empty string. They will also give a single line that next day's answers must out...
stackexchange_codegolf
Your goal is to create an alphabet song as text in the following form (in order): A is for <word starting with A> B is for <word starting with B> C is for <word starting with C> ... Z is for <word starting with Z> Example output: A is for Apple B is for Banana C is for Carrot D is for Door E is for Elephant F is for F...
stackexchange_codegolf
We have a square 10x10 meter garden outside our house. We want to plant grass and make a terrace. We have decided how to divide the garden, but we haven't decided the ratio between amount of grass vs terrace. We need help visualizing it, and ASCII-art is clearly the best way to do so. Challenge: Take an integer in the...
stackexchange_codegolf
Write a program which will take for input 2 integer arrays and return a truthy value if there exists an element which is present in both of arrays, or a falsy one otherwise. The obvious solution to this problem would be to iterate through each element in the first array and compare it against each element in the second...
stackexchange_codegolf
Introduction A circle-tangent polynomial is a polynomial of degree \$N\ge3\$ or above that is tangent to the unit circle from inside at all of its N-1 intersection points. The two tails that exits the circle are considered tangent at their intersection points from inside as well. You may consider such polynomials are w...
stackexchange_codegolf
The challenge is to assign people to tasks randomly~. From stdin you get 2 lines. Line one is a comma-separated list of names. Line 2 is a comma-separated list of jobs. The output required is one line per task person combo. The line should be formatted as Name:task. If there are not enough people for jobs or vice verse...
stackexchange_codegolf
Objective Given a 2D array of any size, write a program or function to shift alternatively the columns and rows Example a b c d e f g h i j k l m n o All elements in the first column shift down one row, the second column shift up one row, the third shift down one row and so on, wrapping when they reach the edge. k g m...
stackexchange_codegolf
Background A bijective base b numeration, where b is a positive integer, is a bijective positional notation that makes use of b symbols with associated values of 1 to b. Unlike its non-bijective counterpart, no symbol has a value of 0. This way, each non-negative integer n has a unique representation in bijective base ...
stackexchange_codegolf
Write a program or function to produce the following output in the correct order. EDIT: The symbols are not mathematical! The numbers just represent unique data and the + and - could be any two arbitrary symbols. Take an non-negative integer input n. The first line is always -, even for n=0. If the current line is -, ...
stackexchange_codegolf
Input A string s of printable ASCII characters, newlines, and spaces (0x20 ( ) to 0x7E (~)), and a non-negative integer n. Challenge To write a program that outputs either another program, or s depending on n. If n = 1, Then your code should output code which outputs s. If n = 2, Your code should output code which outp...
stackexchange_codegolf
An palindrome is a word that is its own reverse. Now there are some words that might look like palindromes but are not. For example consider the word sheesh, sheesh is not a palindrome because its reverse is hseehs which is different, however if we consider sh to be a single letter, then it's reverse is sheesh. This...
stackexchange_codegolf
This is the cops' challenge. To post a robber, go here. In this challenge, cops will invent a (likely simple) programming language, and write an interpreter, transpiler, or compiler that allows you to run it. Robbers will write a program in this language that manages to inject arbitrary code into the interpreter, trans...
stackexchange_codegolf
Given a number n, calculate the amount of bases in the range of [2, n) in which b(n) is a Palindrome. Example n = 8 has the base conversions: 2 = 1000 3 = 22 4 = 20 5 = 13 6 = 12 7 = 11 Of which 2 of them, 3 = 22 and 7 = 11 are palindromes. So return 2. Clarifications For the sake of convenience, Your answer only ne...
stackexchange_codegolf
Now that I'm thoroughly addicted to Code Golf, it's probably about time that I try to pick up a few golfing languages. Given that I play almost exclusively in JavaScript, Japt seems like the logical language to start with. I'll be diving into the documentation at the next opportunity I get but, in the meantime, please ...
stackexchange_codegolf
According to TIO there are two types of programming languages: Practical (seen in many corporate environments as a development standard). Recreational (if seen in a corporate environment, you're probably fired). Your Task Mix together one language from each of these realms to achieve the simple goal of calculating th...
stackexchange_codegolf
(no, not those ones) The Challenge You'll be given two inputs. The first is a positive integer n > 0, which is used to output an n x n right triangle of the numbers 1, 2, 3, ... n. This triangle starts in a corner and increases horizontally and vertically by one and diagonally by two. See examples below for clarificati...
stackexchange_codegolf
I was wondering if there is any way to assign 2 values (G and H) to say a list of ["egg", "chicken"] in Pyth. In python it would be something along the lines of G, H = ["egg", "chicken"] At the moment the shortest way I can think of would be something like =N["egg""chicken")=G@N0=H@N1 which uses the lookup function t...
stackexchange_codegolf
sandbox (deleted) Lets define a matrix of 9s as: $$ N = \begin{bmatrix} 9&9&9\\9&9&9\\9&9&9 \end{bmatrix} $$ Lets define an exploding number as a number at position \$(x,y)\$ that can be decomposed into equal integers between all its adjacent neighbors (including itself) and the absolute value of each portion is great...
stackexchange_codegolf
Lets define a pointer sequence to be any sequence such that a(n) = a((n-1)-(a(n-1))) forall n greater than some finite number. For example if our sequence begun with 3 2 1 Our next term would be 2, because a(n-1) = 1, (n-1)-1 = 1, a(1) = 2 (this example is zero index however it does not matter what index you use the...
stackexchange_codegolf
Every programmer knows that rectangles □ are really fun. To exacerbate this fun, these cute and fuzzy diagrams can be transformed into groups of interwoven brackets. This challenge is the inverse of my previous. Let's say you have a group of interlocking rectangles like so: +------------+ | | +--+-+ ...
stackexchange_codegolf
I have not laughed as much from Stack Exchange content as I have from this. I think you all will enjoy this challenge, as it is inspired by what is over there. You will write a function or program that is code-golf, i.e. it would have to be as short as you can make it. Given a text, return (both by any means) the text ...
stackexchange_codegolf
The Riemann R function is as follows: $$R (x)=\sum _{n=1}^{\infty } \frac{\mu (n) \text{li}\left(x^{1/n}\right)}{n}.$$ This uses the Möbius function as well as the logarithmic integral. From Wikipedia, the Möbius function is defined so that for any positive integer \$n\$, \$μ(n)\$ is the sum of the primitive nth roots...
stackexchange_codegolf
Write a script, program or function which takes one input of type string and outputs or returns some sort of indication wether the input string was 'hi whats up' (without the apostrophes) or not. You can for example return true if it was and false if it wasn't. Or print something to the screen, like 1 or 0. It just has...
stackexchange_codegolf
Your task: write a program/function that when given a string containing only ASCII characters, outputs/returns the string in reverse-ish. Example: 1) Input Hello, World! 2) Number unique characters in input. (Input string separated by pipes (|) for readability) H|e|l|l|o|,| |W|o|r|l|d|! 1 2 3 4 5 6 7 8 9 10 3) ...
stackexchange_codegolf
Create a function or program that takes two inputs: A list of integers that shall be sorted (less than 20 elements) A positive integer, N, saying how many comparisons you should take The function shall stop, and output the resulting list of integers after N comparisons. If the list is fully sorted before N comparison...
stackexchange_codegolf
Arrr... Ahoy there, me maties! Unfurl tha' mainsail! Full to starboard! Ah, feel th' wind in yer hair! Right, me hearties... I be needin' a bit of yer codin' skills! Me crew are a li'l more modernized than meself... I still be preferrin' th' points of th' compass (see here for more info, Arrr...) while me crew are alwa...
stackexchange_codegolf
A rigid transformation of a square array is a mapping from square arrays of a certain size to square arrays of the same size, which rearranges the elements of the array such that the distance to each other element remains the same. If you printed out the matrix on a sheet of paper these are the transforms you could do ...
stackexchange_codegolf
Note: This is the radiation-hardening version of my previous challenge Pristine Bit Checking. This should be much more difficult than that one. Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different. Fo...
stackexchange_codegolf
The game is played on a 1x8 board with the following setup: KNR..rnk White's pieces are on the left, while black's pieces are on the right. The king (K) can move 1 space in any direction. The knight (N) can jump 2 spaces in any direction, regardless of bordering pieces. The rook (R) can move any number of spaces in an...
stackexchange_codegolf
PROBLEM For a list of numbers, list: Find the lowest possible integer, x, which is optimally close to the whole number even-harmonics of the values in list. list has a length of n, and all of the values in list are <= 2000 x has a precision of 1.0 (integers only), and must be a value in the range [20, 100] An even-har...
stackexchange_codegolf
In this challenge you have to make an ascii pulsing heart with rhythm problems (Heart arrhythmia) and then measure the pulse.Don't worry it's easy! Making the heart The heart alternates between these 2 states: state 1 ,d88b.d88b, 88888888888 `Y8888888Y' `Y888Y' `Y' state 2 d8b d8b ...
stackexchange_codegolf
It is Halloween and Jimmy (/o\) has gone into a mysterious neighborhood for trick-or-treating (ask himself why). Now some evil ghosts are chasing him. Can Jimmy escape the ghosts? Challenge: Input: A board showing position of Jimmy, ghosts, solid objects and empty spaces. An example 10x5 board, o is Jimmy (we needed a ...
stackexchange_codegolf
Related: Read a crossword Task Given a completed Crossword puzzle, extract the words in it with their respective clue numbers, with "across" (horizontal) and "down" (vertical) words grouped and ordered like a real crossword puzzle. The words are numbered in the row-major order of their first letters. If an "across" wor...
stackexchange_codegolf
Prologue After installing an anti-XSS browser extension, Stack Snippets suddenly stopped working all across the Stack Exchange network. I could no longer learn from Stack Overflow, see working demos on User Experience and, worst of all, could not test JavaScript answers on Programming Puzzles and Code Golf! Desperately...
stackexchange_codegolf
Introduction Congratulations! You've been selected to do research a a newly discovered animal called a fuzzy, a docile, simple creature that strongly resembles a cotton ball. Fuzzies love to be near other fuzzies, but not all fuzzies want to be near each other. There are 6 types of fuzzies, 1a, 1b, 2a, 2b, 3a, and 3b. ...
stackexchange_codegolf
Introduction A quine is a program that outputs its own source code. For example, a well-known Python quine is _='_=%r;print(end=_%%_)';print(end=_%_). Running it outputs _='_=%r;print(end=_%%_)';print(end=_%_), therefore it is a valid quine. An error quine is similar to a regular quine, however it must output to STDERR...
stackexchange_codegolf
Consider a non-empty binary matrix M and a natural number n. For the purposes of this challenge, M is said to have blockiness n if it can be built using adjacent square blocks of size n, where each block has equal entries; and it cannot be formed using square blocks of any larger size. Intuitively, n can be thought of ...
stackexchange_codegolf
Story I need to remember a lot of passwords and don't want to use the same one for multiple websites so I came up with a rule, but the rule shouldn't be transparent so what I do is: Think of a long word or concept such as breadpudding. Replace the first letter with the site we are logging into. If we are logging into ...
stackexchange_codegolf
Given an \$m \times n\$ matrix of integers A, there exist a \$m \times m\$ matrix P, an \$m \times n\$ matrix D, and an \$n \times n\$ matrix Q such that: \$A = P D Q\$. P and Q are unimodular matrices (i.e. matrices which are invertible and whose inverses are also integer matrices); D is diagonal; each diagonal entry...
stackexchange_codegolf
I have the code: marks = tuple(tuple((input("Enter subject: "), input("Enter marks: "))) for _ in range(int(input("Enter number of tuples: ")))) print(tuple((s[:3].upper(), max(int(m) for t, m in marks if t == s)) for s in set(t for t, m in marks))) #INPUT (("Physics",131),("Chemistry",30),("Physics",100),("Computers"...
stackexchange_codegolf
Background This is a standard textbook example to demonstrate for loops. This is one of the first programs I learnt when I started learning programming ~10 years ago. Task You are to print this exact text: ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** Spe...
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
Construct a program or function that takes input in form of <width>, <height>, <color1>, <color2> and generates an output such that first row alternates between pixels of color <color1> and <color2> with a period of <height>. For each row that follows, the period shall be <height> - <row number>. Note that <color1> a...
stackexchange_codegolf