instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Notice: I'm willing to give a bounty to any answer that I find interesting. Your challenge is to design a Turing-complete one instruction set computer (OISC): An OISC is an abstract machine that uses only one instruction – obviating the need for a machine language opcode. With a judicious choice for the single instruc...
stackexchange_codegolf
Scientists have made contact with a parallel universe. Just one problem: They write math differently. Help the scientists make a program that can convert normal math expressions to their equivalent in alternate universe math. The connection through the portal is bad so your code needs to be as short as possible Given a...
stackexchange_codegolf
Generate the contents of an SVG file containing 6 bingo cards. Winner is the one that uses the shortest code. A qualifying answer has an output that can be directly pasted in a blank to get the required image. Rules are as follows. The generated SVG code should comply with SVG version 1.1 described here. The size of t...
stackexchange_codegolf
Description : You are given a string of numbers (positive and negative but not decimals) along with the number of entries like so. Like so 8 '1 2 5 0 7 -9 12 -8' Task : Your job is to return the number closest to zero be it +ve or -ve. Your input will be separated by spaces only. You are free to return the answer in a...
stackexchange_codegolf
Input no input for this challenge The Challenge Write a code that outputs: The first 10 prime numbers whose sum of their digits equal the number of bytes of your code Examples Let's say your code is Co&%423@k"oo" which is 13 bytes your code must output [67, 139, 157, 193, 229, 283, 337, 373, 409, 463] those are the fi...
stackexchange_codegolf
The task here is simple: given a target location on an XY grid, and a rectangle on that grid, find the length of the shortest path from the origin to the target which does not intersect the rectangle. All parameter values are integers. You can assume that neither the target point nor the origin is inside or on the bord...
stackexchange_codegolf
Introduction Every string has an "alphabet", composed of the characters that make it up. For example, the alphabet of \$abcaabbcc\$ is \${a, b,c}\$. There are two operations you can do with alphabets: getting the alphabet of a string, and seeing if another string has a given alphabet. Challenge Given two strings, you m...
stackexchange_codegolf
Task Given a string of English names of digits “collapsed” together, like this: zeronineoneoneeighttwoseventhreesixfourtwofive Split the string back into digits: zero nine one one eight two seven three six four two five Rules The input is always a string. It always consists of one or more lowercase English digit nam...
stackexchange_codegolf
Background A classical logic gate is an idealized electronic device implementing a Boolean function, i.e. one that takes a certain number of Boolean inputs and outputs a Boolean. We only consider two-input logic gates in this challenge. There are \$2^{2 \times 2} = 16\$ distinct two-input logic gates (2×2 input combina...
stackexchange_codegolf
This is my first time here at Code Golf SE so feel free to add your input/advice/suggestions to improve my post if necessary. The week after my computer science exam, the solutions were publicly published. One problem had a 45 line example solution but my solution was only 18 lines, (which I was very proud of), but I b...
stackexchange_codegolf
In golf, a knowledgable caddie helps an already good golfer to be even better. In this challenge, you build a "caddie" to help you code golf. In particular, your caddie will compress golfed code in such a way that another program can uncompress and then run the code. A good caddie will compress golfed code to be much s...
stackexchange_codegolf
Challenge Given the Cartesian coordinates of two or more distinct points in Euclidean n-space (\$\mathbb{R}^n\$), output the minimum dimension of a flat (affine) subspace that contains those points, that is 1 for a line, 2 for a plane, and so on. For example, in 3-space (the 3-dimensional world we live in), there are a...
stackexchange_codegolf
Overview This is the XKCD tic-tac-toe cheetsheet: It's rather big, I know. But it's also your most valuable resource in your challenge. The challenge Create a program (in your language of choice) that uses the Optimal Move Cheatsheet (henceforth OMC) to output the optimal move when given a sequence of moves. The input...
stackexchange_codegolf
Sound synthesizers use envelope generators to control how certain parameters of the sound (such as overall loudness) change with time. In many synthesizers an envelope is defined by four parameters, as represented in the following figure from Wikipedia: Attack time (A): time taken for the envelope to reach its maximum...
stackexchange_codegolf
I could not think of a better title. This is a tips question. I'm asking for tips on golfing my code. I recently took part in a code golf competition in C. The competition ended and I lost. The problem is: Input a line with a number n. Then input n lines, each line contains only a set of cards in descending order, e. ...
stackexchange_codegolf
Some text-based rogue-likes don't let you walk into walls, and give you your move back if you try to. Why do that when you can make the player move in the closest valid direction? The challenge Write a program of function that, given a direction and a 3 by 3 grid of characters, outputs the same grid after the player ha...
stackexchange_codegolf
The Halloween is upon us, and I haven't decorated my house yet, so I gonna need your help to do this task Input The input will be a list of 4 digits numbers, where each digit represent a portion of decoration: EMBU |||| |||+-upper decoration ||+-bottom decoration |+-mouth/nose +-eyes Eyes: 0 - ° 1 - ¯ 2 - - 3 - ^ 4 - ...
stackexchange_codegolf
The code: function L(){N=null;E=[N,N];t=this;h=E;t.u=i=>h=[i,h]; t.o=_=>h==E?N:h[+!(h=h[1])];t.e=(i,l)=>h=(l||h)==E?[i, E]:[(l||h)[0],t.e(i,(l||h)[1])];t.s=_=>{o="";while(i=t.o()) {o+=i+","}return o}} For my response to this (old) question: https://codegolf.stackexchange.com/a/196783/72421 (my linked answer has a com...
stackexchange_codegolf
Overview Some of you might be aware of the Kolakoski Sequence (A000002), a well know self-referential sequence that has the following property: It is a sequence containing only 1's and 2's, and for each group of 1's and twos, if you add up the length of runs, it equals itself, only half the length. In other words, the...
stackexchange_codegolf
The purpose of this challenge is to produce an ASCII version of the cover of this great album by the rock band Pink Floyd. The brick junctions are made of characters _ and |. Bricks have width 7 and height 2 characters, excluding junctions. So the basic unit, including the junctions, is: _________ | | | | _...
stackexchange_codegolf
Task: Given two positive integers, generate a random integer between them (inclusive) and then output all its prime factors. Examples: Input: Random Number: Output: 1,2 2 [2] 12,46 18 [2,9] 142,17 40 [2,2,2,5] Scoring: This is code-golf so the least by...
stackexchange_codegolf
Write a program that reviews posts for the Close Votes queue on Stack Overflow. Since it's near-impossible to write a bot that can accurately review posts in the actual queue, we're instead going to use a grossly oversimplified version of the queue and its rules. Your program should take in the body of a question as a ...
stackexchange_codegolf
The goal is to create a preprocessor for the C language, as small as possible in terms of source code size in bytes, in your preferred language. Its input will be a C source file, and its output will be the pre-processed source code. The items that it will need to be able to process shall be: Comment removal (line/bloc...
stackexchange_codegolf
Introduction I'm a real big fan of the SBU (Short But Unique) challenges that crop up on PPCG all of the time. The CUSRS is a system designed to refactor strings, a CUSRS function takes 2 parameters and outputs 1 String. Challenge Produce a program, function, lambda or acceptable alternative to do the following: Given ...
stackexchange_codegolf
Chess960, a.k.a. Fisher random chess, is a variation of the game of chess. In classic chess the starting positions are always the same. In chess960 they vary. Before each game of chess960 one random number from 0 to 959 is drawn. Both players then arrange their pieces in the same way according to this number from a loo...
stackexchange_codegolf
The code lock for my garage has 5 buttons, labeled "1 2", "3 4", "5 6", "7 8", and "9 0". To open the garage door, you have to enter the correct 4-digit PIN. As you can see, every button represents two numbers. Thus some PINs, like "1357" and "2367", are essentially identical because they require the same sequence of b...
stackexchange_codegolf
Inspired by Golf me an ASCII Alphabet, of which this challenge is (almost) a direct inverse. Task: Take a string of ASCII-art text and output the content of the text as regular ASCII text. Input: String of ASCII-art text. Input will only contain instances of ASCII character #, spaces and 4 or 5 newlines (a trailing n...
stackexchange_codegolf
Objective Given a nonempty multiset of Rock, Paper, and Scissors, output the winning figure according to the special rule. Background For a multiplayer RPS, if all three figures come out, usually it's considered a draw. But by that rule, the probability to draw would dramatically increase when there are many and many p...
stackexchange_codegolf
This challenge is inspired by this very nice answer by TidB. In TidB's answer, every eight character is in the correct order: gnilwoB edoC (Code Bowling backwards). The other strings however are were in a strange, random order. Your challenge is to fix this. Take a (non-empty) string and a positive integer n as input....
stackexchange_codegolf
You work for a social media platform, and are told to create a program in a language of your choice that will automatically flag certain post titles as "spam". Your program must take the title as a string as input and output a truthy value if the title is spam, and a falsey value if not. To qualify as non-spam, a title...
stackexchange_codegolf
Introduction "Muhuhuhahahah!" The mad scientist laughs. "You're trapped in my own little game!" In front of you is a deadly pit of snakes, while behind you is a bottomless chasm. There's no way out, you're stuck! "Two steps in front of you is the snake pit, and two steps behind you is the chasm. But! Before you move, y...
stackexchange_codegolf
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. For example, \$1\$ and \$0\$ have binary forms 00000001 and 00000000, which are one bit apart. Similarly, \$152\$ and \$24\$ are 010011000 and 000...
stackexchange_codegolf
Write a regular expression substitution string which can base64 decode a string using only a regular expression engine built into the language. Eg: # Example in python import re print(re.sub(..., ..., "SGVsbG8gd29ybGQK")) # "Hello world\n" # ^^^ ^^^ # These count towards your byte count, the...
stackexchange_codegolf
Your task is, to count how many pluses I have. What Pluses? The no plus: 0 Points - The naïve Plus: 1 Point + The double Plus: 2 Points + +++ + The mega double plus: 3 Points + +++ + + + + +++++++++ + + + + +++ + Pluses of higher order than 3 must be ignored. Rules Input will ...
stackexchange_codegolf
Once upon a time, I was reading this question/answer on Quora Are there really programmers with computer science degrees who cannot pass the FizzBuzz test This code is given as the obvious answer for i in range(1, 100): if i % 3 == 0 and i % 5 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz"...
stackexchange_codegolf
Related: Let's design a digit mosaic, Print/Output the L-phabet. Sandbox post here Given 2 inputs C = columns and rows, S = starting point output a matrix as follow: Input 4, 3 1 2 3 0 2 2 3 0 3 3 3 0 0 0 0 0 Explanation Given C = 4, S = 3 1) Create a C x C matrix filled with 0 4 colu...
stackexchange_codegolf
Introduction I can type at a moderate pace, using the QWERTY keyboard layout. But if a word like yellowwooddoor has a ton of repeated letters, it takes a bit longer to type it. Even worse is when a word like "jump" has the same finger used for multiple different consecutive letters. Here's how long it takes me to type ...
stackexchange_codegolf
Implement a function or program which raises x to the power of y. Inputs are 16-bit signed integers. That is, both are in the range [-32768, 32767]. The output should be in the same range. I chose this range because it should make it possible to do exhaustive testing to ensure all edge-cases are covered. If the output ...
stackexchange_codegolf
I am trying to find the shortest code in python 3, to solve this problem: You are driving a little too fast, and a police officer stops you. Write code to take two integer inputs, first one corresponds to speed, seconds one is either 1 or 0, corresponding to True and False respectively to indicate whether it is birthd...
stackexchange_codegolf
zipwith is a functional construct that takes three arguments: one binary function and two lists of the same length, and returns a single list where each element is constructed by applying the binary function to each pair of elements from the two lists: zipwith (a+b) [1,2,3] [4,5,6] = [5,7,9] You are to take a black-bo...
stackexchange_codegolf
Background The Python code ((((((((n%35)^11)*195)|53)&181)+n)%168)*n)+83 produces 74 distinct primes for \$0 \le n \le 73\$. This code also works in Java. The operators are as follows: + is addition * is multiplication % is modulus & is bitwise AND | is bitwise OR ^ is bitwise XOR The produced primes are: 83, 97, 11...
stackexchange_codegolf
Inspired by this 3Blue1Brown video Given a square matrix \$ M \$, compute its matrix exponential \$ \exp(M) \$, which is defined, using an extension of the Maclaurin series for \$ e^x \$, as $$ \exp(M) = \sum_{r=0}^\infty \frac {M^r} {r!} = M^0 + M^1 + \frac 1 2 M^2 + \frac 1 6 M^3 + \cdots + \frac 1 {n!} M^n + \cdots ...
stackexchange_codegolf
These are the hosts of the "Weekend Update" news segment on Saturday Night Live, with the years they hosted and their initials: Chevy Chase 1975-1976 CC Jane Curtain 1976-1980 JC Dan Aykroyd 1977-1978 DA Bill Murray 1978-1980 BM Charles Rocket 1980-1981 CR Gail Matthius 19...
stackexchange_codegolf
The basic idea is to write a program that twists itself, and the twisted version untwists itself. The first program will just be the twisting algorithm described here, and when given its own source code as input, outputs a program that reverses the twisting algorithm. How strings are twisted The twisting algorithm is v...
stackexchange_codegolf
Your task is to write 2 functions/programs. They may share code. The first function must, given a string and a character, output a new string that does not contain that character. The second function must, given the string from the previous function and the excluded character, reconstruct the original string. All input...
stackexchange_codegolf
The McGill Billboard Project annotates various audio features of songs from a random sample of the Billboard charts. I scraped this data to produce the following file of chord progressions: chords.txt Write the shortest code that outputs the above file (or its contents). Edit: Here's a quick description of the notation...
stackexchange_codegolf
Inspired by this challenge Given an integer in the range 0 <= n < 2**64, output the minimum sized container it can fit in out of bit: 1 nibble: 4 byte: 8 short: 16 int: 32 long: 64 Testcases: 0 -> 1 1 -> 1 2 -> 4 15 -> 4 16 -> 8 123 -> 8 260 -> 16 131313 -> 32 34359750709 -> 64 This is code-golf, so the shortest ans...
stackexchange_codegolf
EDIT It appears that there has been some confusion following my typo in the original post which used a lowercase o to define the plane and then an uppercase later. Unfortunately this bug did not get picked up in the Sandbox. Since many members have written answers with both and since the typo was my fault I will allow ...
stackexchange_codegolf
Imagine we get a slice of some mountainous region, this would result in a shape similar to this: 4 _ 3 _ _ __/ \ 2 / \__/ \ _/ \_ / 1 / \ / \_/ 0 \/ 12322223210012233343221112 As we can see, we can represent this (to a certain degree) with a sequence o...
stackexchange_codegolf
Your mission today is to create a vortex given a single parameter. This parameter determines the length of each arm in characters. Each "layer" of each arm contains one more character than the last. Here's how the vortex will look, given the arm length: 0: # 1: # ### # 2: # # # ### # # # 3: ## # ...
stackexchange_codegolf
fastest relay time = lowest possible total integer value of (a freestyle swimmers time) + (1 breastroke swimmers time) + (another backstroke swimmers time) + (another butterfly swimmers time) Each swimmer must be unique to the relay (no duplicates) Each stroke must be used once Input Data: array of dictionaries, wh...
stackexchange_codegolf
We are all used to the old-school telephone keypad, right? For reference, here is what it looks like: Given a String consisting only of lowercase ASCII letters and single spaces, your task is to return the number of taps one should make in order to type down the full String with a telephone keypad as the one above. F...
stackexchange_codegolf
Given Google's recent announcement of official Kotlin support for Android development, I thought it might be timely to poll the community for some awesome golfing tips for this relatively new JVM language. Kotlin includes a unique combination of features among it's JVM siblings which makes it potentially attractive for...
stackexchange_codegolf
This question is inspired by Kevin Cruijssen's question. Now that the carpet is laid out, we want to roll it. Your task is to write a program that takes a string and returns a spiral made from this string (representing a rolled carpet viewed from the side). The procedure for one step of rolling the carpet is the follow...
stackexchange_codegolf
Klein is a 2D language I have designed that can be embedded on 12 different topological surfaces. A Klein program can be run on different surfaces by changing the command line arguments. The topology determines where the instruction pointer goes when it goes off the edge of the program. When moving off of the edge th...
stackexchange_codegolf
The code: function L(){N=null;E=[N,N];t=this;h=E;t.u=i=>h=[i,h]; t.o=_=>h==E?N:h[+!(h=h[1])];t.e=(i,l)=>h=(l||h)==E?[i, E]:[(l||h)[0],t.e(i,(l||h)[1])];t.s=_=>{o="";while(i=t.o()) {o+=i+","}return o}} For my response to this (old) question: https://codegolf.stackexchange.com/a/196783/72421 (my linked answer has a com...
stackexchange_codegolf
Introduction Tensor contraction is an operation that can be performed on a tensor. It is a generalization of the idea of the trace of a matrix. For example, if we have a rank-2 tensor (a matrix) and we contract along both of its axes, we take the sum of each entry in which the indices of these axes are equal. In this c...
stackexchange_codegolf
Related, related Introduction The ruler sequence is the sequence of the largest possible numbers \$a_n\$ such that \$2^{a_n}\mid n\$. It is so-called because its pin plot looks similar to a ruler's markings: However, with a slight modification, we can also get a similar sequence. This sequence is \$\{a_1,a_2,a_3,…\}\$...
stackexchange_codegolf
This is part of a Cops and Robbers challenge. Go here for the cops' part. For the purpose of this challenge, we'll define whitespace as only linefeeds (0x0A) and spaces (0x20). Note that most languages and regex flavours consider many other characters as whitespace as well, both inside and outside the ASCII range so yo...
stackexchange_codegolf
Create a function that accepts a list of dates (unsorted with possible duplicates) and returns the days of the week in one of the following formats: A format similar to MTWTFSS or SMTWTFS (i.e. beginning with Monday or Sunday), with non-days replaced by an underscore _, illustrated below. WEEKDAY if all the dates are ...
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
The alphanumeric characters have ASCII-values: 0-9 -> 48-57 A-Z -> 65-90 a-z -> 97-122 Your challenge is to take an integer as input, and output how many characters can be made using consecutive digits of that number. The character codes may be overlapping. 666 should result in 2, since you have 66 twice. Test c...
stackexchange_codegolf
A \$k\$-hyperperfect number is a natural number \$n \ge 1\$ such that $$n = 1 + k(\sigma(n) − n − 1)$$ where \$\sigma(n)\$ is the sum of the divisors of \$n\$. Note that \$\sigma(n) - n\$ is the proper divisor sum of \$n\$. The sequence of \$k\$-hyperperfect numbers begins $$6, 21, 28, 301, 325, 496, 697, \dots$$ This ...
stackexchange_codegolf
On Pomax's Primer on Bézier Curves this "fairly funky image" appears: This is related to the fact that every cubic Bézier curve can be put in a "canonical form" by an affine transformation that maps its first three control points to (0,0), (0,1) and (1,1) respectively. Where the fourth and last control point lies afte...
stackexchange_codegolf
The Cabbage, Wolf, Goat riddle with a twist! Backstory: There’s an intergalactic river than needs to be crossed! Being a space-ferryman you’ve offered some aliens on your small space ferry that can only carry two entities: you and a passenger. However, you know that because politics, some of these aliens will instantly...
stackexchange_codegolf
Introduction One question that I have come across recently is the possibility of dissecting a staircase of height 8 into 3 pieces, and then re-arranging those 3 pieces into a 6 by 6 square. Namely, is it possible to dissect the following into 3 pieces: x xx xxx xxxx xxxxx xxxxxx xxxxxxx xxxxxxxx And rearrange those 3 ...
stackexchange_codegolf
In graph theory, a Cactus is a connected graph such that any distinct two simple cycles in the graph share at most one vertex. Here is a Cactus with 3 simple cycles outlined with dashed lines. The following graph is similar to the one pictured above but is not a Cactus because the two vertices labeled in red are share...
stackexchange_codegolf
Blokus is a board game in which players take turns placing pieces on a \$ n \times n \$ square grid. In this version of the game, there will be just one person playing. The person is given \$ 21 \$ unique polyominoes, ranging from \$ 1 \$ to \$ 5 \$ tiles each. They then proceed to place down a subset of the pieces ont...
stackexchange_codegolf
Background I want to display rich, vibrant images on my theoretical fancy custom display, but due to budget constraints, it displays everything in 3-bit colour! Whilst Regular Dithering would work, I don't want to sacrifice resolution, so I would like my images to be dithered through time! Specs Provided an Input Image...
stackexchange_codegolf
I've recently been indulging myself in some nostalgia in the form of Bookworm Deluxe: In case you haven't seen it before, it's a word game where the goal is to connect adjacent tiles to form words. In order to determine whether a string is a valid word, it checks it against its internal dictionary, which is stored in ...
stackexchange_codegolf
I keep hearing that thinking outside the box is a goal worth achieving, but how can I tell if I'm successfully doing it? To solve this dilemma I have already wrote a Brainwave-to-ASCII-translator which in theory should produce outputs like # +------------+ # | thinking | # | ...
stackexchange_codegolf
Given a ragged list of positive integers, where the maximum depth is \$d_\text{max}\$, return the same list, except for every element \$e\$, its depth is \$d_\text{max}+1-d_e\$ (where \$d_e\$ is the depth of that element). Your output should contain the minimal number of brackets, and you can assume the same from your ...
stackexchange_codegolf
TL;DR: Given an array of chars and a robot in a starting position of the array, write an algorithm than can read a string with movements (F for "go forward", R for "rotate 90 degrees right" and L for "rotate 90 degrees left") and calculate the ending position of the robot. More details in the complete text. We have a...
stackexchange_codegolf
Challenge Given a real number as input, calculate the number of times which the natural logarithm function ln can be applied to it before the resulting number becomes imaginary. Explanation Applying ln to a negative number results in a non-real number. This means that, by repeatedly applying ln to a number, you will ev...
stackexchange_codegolf
The bank has been broken into, and all the local mafia thugs have an unusual alibi: they were at home playing Connect 4! In order to assist with the investigation, you are asked to write a program to validate all the Connect 4 boards that have been seized in order to check that the positions are indeed positions from ...
stackexchange_codegolf
Challenge: I want to know about the real roots of polynomials. As a pure mathematician, I care about the existence of such roots, rather than their numeric values. The challenge is to write the shortest program that takes a polynomial, of degree at most 4, and simply returns how many distinct real roots said polynomial...
stackexchange_codegolf
In Vim, you can repeat a command by preceding it with a number, like 3dd is equivalent to dd dd dd. Well, this repeating pattern is not restricted to Vim commands. String can be replicated in this way, too. Specification: Given a string, consisting of only digits, alphabetical characters (both upper-case and lower-case...
stackexchange_codegolf
So I got kinda bored and was wondering if it was possible to make this code shorter without modifying anything except a file named coin.py... from random import*;c=['heads','tails'];print('u win'if choice(c)==input(' / '.join(c)+': ')else'u lose') The program asks the user for either "heads" or "tails", if the result ...
stackexchange_codegolf
This is a Cops and Robbers challenge. For the Cops' thread, go here. The Cops have three tasks. 1) Pick a sequence from the OEIS. 2) Pick a language (this is suggested to be a golflang, but doesn't have to be) that, when given input n, outputs A(n) (where A(n) is the sequence chosen) using all usual code-golf rules. ...
stackexchange_codegolf
Shift Tac Toe Shift Tac Toe is a game that combines Tic Tac Toe and Connect 4 together. In this game, you start with a 3 by 3 board, and each row is connected to a slider that you can move left and right. At the start, the sliders all start to the very right(this means that you can't move the slider to the right on the...
stackexchange_codegolf
Today, we're going to make an ASCII hexagon. You must write a program or function that takes a positive integer n, and outputs a hexagon grid of size n, made up of asterisks. For example, a hexagon of size 2 looks like this: * * * * * * * While a hexagon of size 3 looks like this: * * * * * * * * * * * * * * * *...
stackexchange_codegolf
Sandbox Have y'all ever written an answer with unprintable ASCII characters in it and wished that there was an easy way to represent those characters in a printable way? Well, that's why the Control Pictures Unicode block was invented. However, manually substituting these characters into one's answer is time-consumin...
stackexchange_codegolf
Write a quine which attempts to invert the case of as many ascii characters in the source code as possible. For example in javascript: (x=function(y){return ('(x='+y+')(x)').toUpperCase();})(x) Standard quine rules apply. The score is given by number of bytes in the source code - number of case inversions. For examp...
stackexchange_codegolf
A Latin square is a square that has no repeated symbols in the rows or columns:. 13420 21304 32041 04213 40132 And as many Sudoku players know, you don't need all of the numbers to deduce the remaining numbers. Your challenge is to compress a Latin square into as few bytes as possible. You need to provide one or two...
stackexchange_codegolf
The Cornu Spiral can be calculated using Feynman's method for path integrals of light propagation. We will approximate this integral using the following discretisation. Consider a mirror as in this image, where S is the light source and P the point where we collect light. We assume the light bounces in a straight ray f...
stackexchange_codegolf
Objective Simulate an edge-triggered D Flip-Flop. What is D Flip-Flop? A D flip-flop is an electronic digital device that outputs an inputted data (abbr. D) with synchronization to a clock (abbr. CLK). Usually CLK is a uniform pulse, but in this challenge, CLK may be not uniform. Input A bitstring with length \$n\$ wil...
stackexchange_codegolf
As you all know, today is election day! Your task today is to print out a ballot, given an input. If the input is Hillary Clinton, print: Hillary Clinton ===-----===> Donald Trump === ===> ____________ === ===> However, if the input is Donald Trump, print: Hillary Clinton === ===> Donald Trum...
stackexchange_codegolf
Background We already have a challenge about throwing SIGSEGV, so why not a challenge about throwing SIGILL? What is SIGILL? SIGILL is the signal for an illegal instruction at the processor, which happens very rarely. The default action after receiving SIGILL is terminating the program and writing a core dump. The sign...
stackexchange_codegolf
Disclaimer: This does not do any justice on the rich topic of elliptic curves. It is simplified a lot. As elliptic curves recently got a lot of media attention in the context of encryption, I wanted to provide some small insight how "calculating" on an elliptic curve actually works. Introduction Elliptic curves are set...
stackexchange_codegolf
Note: the title was misspelled intentionally. Given a string s, swap the first vowel runs of every 2 words. For this challenge, y is considered a vowel. For example, given an input of "great day sir": 1. Input: "great day sir" 2. Identify pairs of words: "[great day] [sir]" (No word for sir to pair with) 3. Identify th...
stackexchange_codegolf
Build a regex that will accept a regex string as input and check if it's valid. Basically, your regex should be able to validate itself. (Any invalid regex should not be validated, so you can't use .*. ;)) Your flavor must be fully supported by well known implementations (Perl, sed, grep, gawk, etc), and it must fully ...
stackexchange_codegolf
Not sure if this is the correct community to post this is. But as I see this problem as an interesting puzzle to solve, I'd thought to give it a shot... Problem Statement: Let`s say we have: N collections of parts: A, B,C,D,...etc Each collection consists of n parts: 1,2,3,4,5 ... All these parts are randomly present...
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
Write a program that is a polyglot in three languages that plays rock–paper–scissors. The input for any version of the program is always one of the strings rock or paper or scissors. In the first language the program must output the rock–paper–scissors choice that beats the input: Input Output rock paper paper...
stackexchange_codegolf
I'm posting my code for a LeetCode problem copied here. If you have time and would like to golf for a short solution, please do so. Requirement It has to only pass the LeetCode's Online Judge, if the language would be available. If the language is not available, simply we should possibly keep the class Solution as we...
stackexchange_codegolf
Introduction - What is a necklace? A necklace is something that OEIS people are obsessed with. The OEIS challenge has like 5 necklace sequences. A binary necklace of length n is a loop with n beads that are either 0 or 1. Two necklaces are the same if one can be rotated to become the other, and two reversible necklaces...
stackexchange_codegolf
What is the shortest selector (by character count) to select ALL html elements on a web page, without using asterisk (*)? Some examples are the following: a,:not(a) /*9 chars*/ :nth-child(n) /*12 chars*/ :link,:not(:link) /*17 chars*/
stackexchange_codegolf
Write a function (using as few bytes as possible) that takes a bi-dimensional array of any number of columns and rows in which: 0 represents empty block, 1 represents snake block. The function must return the number of possible paths the snake traveled. Example 1: Input: [ [1,1,1,1,1], [0,0,0,0,1], [0,0,0,0,1...
stackexchange_codegolf
Simpler version of this Task You must create a program that outputs a triangle of a given size N. A triangle is made of 3 identical triangles A triangle of size N should be made of N lines A triangle's line starts from 1 star, and increases by 2 stars each line Test Cases: 1 -> * * * 3 -> * *** ***** ...
stackexchange_codegolf
Objective Given an input of text that does not contain characters [ or ], perform the following actions: For every instance of Amen with at least one capital letter (so all instances of Amen excluding amen), output that same Amen (retain capitalization). For every instance of /all the people said[?: ]/i (that's a Regu...
stackexchange_codegolf