instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Well the title says it all. Standard loopholes apply Nothing to read from stdin, and output goes to stdout 1-byte-long programs are... nonsense. They don't qualify A program with a single byte repeated is also a nonsense (like aaa) Please mark it out if your program is a palindrome Sample: A program with source code...
stackexchange_codegolf
Input a decimal number and round it to an integer, randomly rounding up or down with a probability based on its fractional part, so the expected value of the output equals to the input value. If input \$x\$ is an integer, the program should output it as is. If \$x\$ is not an integer, the program has a \$x-\left\lfloo...
stackexchange_codegolf
Description "Imtiaz Germain primes" is not a technical name in Mathematics, but my weird creation, in the memoir of the famous mathematician Sophie Germain. These primes can be generated by the following process: 1. Take a Safe prime 2. Apply 2p + 1 on it to obtain a composite number 3. Apply 2p + 1 once more to obtain...
stackexchange_codegolf
Inspired/mostly copied but I don't think it's a dupe. Also Inspired. In this challenge, you will create polyglots that include all languages from previous answers, and another language which you won't share and others must guess. The first language prints 1, the second prints 2, etcetera. For example, if the first answ...
stackexchange_codegolf
When you look at the last decimal digit of each power of a non-negative integer a repeating pattern forms. For example, 3: 3^1 = 3 3^2 = 9 3^3 = 27 3^4 = 81 3^5 = 243 3^6 = 729 3^7 = 2187 3^8 = 6561 3^9 = 19683 The last digits go 3971 which repeats indefinitely. In fact any number we choose that en...
stackexchange_codegolf
Define that the natural number p is a +1 prime of the natural number n if p is a prime number and the standard binary representation (i.e., without leading zeroes) of p can be obtained by adding (i.e., prepending, appending or inserting) a single 1 to the standard binary representation of n. For example, the binary rep...
stackexchange_codegolf
The skip-pure numbers are defined with this rule: A(0) = 1 A(1) = 1 A(n) = the smallest positive number not in the sequence such that A(x) + A(x-2) for any x never appears For example, the term A(2) is 2, because 1 has already appeared. The term A(3) is 4, as A(2) + A(0) = 3 and 3 is disallowed by the third line of th...
stackexchange_codegolf
One of my kid's favorite toys is a set like this. Actually its one of my favorite toys - I've been playing with it and its been giving me some PPCG challenge ideas. Here's one: Write a program or function that takes an ASCII line drawing as input and decides whether or not it folds into a cube. Input Input will consi...
stackexchange_codegolf
Inspired by This answer to a Puzzling question Background - exponentiation by squaring If you don't want to read the background, or don't understand it, there's a worked example in Java, linked at the bottom of the post. \$a^{2^{x+1}} = a^{2^{x}} * a^{2^{x}}\$ Therefore to find \$a^b\$ (where \$a\$ and \$b\$ are base-1...
stackexchange_codegolf
In response to here. Unlike the previous one, this focuses on code-golf and a new logo, no longer consisting of 6 sticks and the graying-effect as the position of the sticks go deeper. Make the Stack Overflow logo using the following criteria: The tray: Make a gray tray shaped like a bracket facing upwards using th...
stackexchange_codegolf
You have a phone plan that lets you talk 180 minutes a day. Every day that you go over your daily limit you have to pay a fine of F = Men, where M is the number of minutes you went over and n is the number of days you have gone over (e.g if I went 20 minutes over the daily limit and it's my 2nd day going over, I have t...
stackexchange_codegolf
The fast growing hierarchy is a way of categorizing how fast functions are growing, defined the following way (for finite indices): \$ f_0(n)=n+1 \$ \$ f_k(n)=f_{k-1}^n(n)\$ with \$f^n\$ meaning repeated application of the function f Examples f0(5) = 6 f1(3) = f0(f0(f0(3))) = 3+1+1+1= 6 f2(4) = f1(f1(f1(f1(4)))) = 2*...
stackexchange_codegolf
The Setup You are given a simple web page with 11 elements: 10 input elements with IDs i1 thru i10, in order one output element with ID out The input elements have value attributes defined in the HTML source. The value of any given input may be any integer from 0 to 10 inclusive. The webpage is equipped with the core...
stackexchange_codegolf
Problem Recreate the UI from a torrent program Given no input, output the following: +----------+----------+----------+ |a.exe |##########|seeding | +----------+----------+----------+ |b.exe 10% |# |leeching | +----------+----------+----------+ |c.exe |##########|seeding | +----------+----------+--...
stackexchange_codegolf
Challenge I'm under attack by the larcenous Midnight Crew and I need to summon the Catenative Doomsday Dice Cascader in order to defend myself. Since I'm low on space, I need the code to be as short as possible. The algorithm for the Catenative Doomsday Dice Cascader is as follows: First, the six sided die in the Prime...
stackexchange_codegolf
Your Task: Write a program or function that, when given a number, outputs its persistence. The persistence of a number is the number of times you can add its digits before arriving at a one-digit number. All one digit numbers have a persistence of 0. Note that this is different from questions about finding the digit...
stackexchange_codegolf
The Narrative You are a bad musician. You never bothered to learn how to count rhythms. To remedy this shortcoming, you decide to write a program that will tell you how to count in any given time signature. You are still a bad musician, but you can at least pretend that you can count rhythms. The Objective Given a time...
stackexchange_codegolf
This challenge is straightforward, but hopefully, there are plenty of avenues you can approach it: You need to print/return a valid JSON object of at least 15 characters, not counting unessential whitespace. Your program should work without any input. In the interest of clarity, a JSON object starts and ends with curl...
stackexchange_codegolf
Inspired by A014486. Challenge Given an integer input in base 10, construct a representation for the binary forest corresponding to the input. Representations include, but are not limited to, nested arrays and strings. How? Convert the input to binary. 1s represent branches, and 0s represent leaves. To make this easier...
stackexchange_codegolf
Write program, which verifies Erdős–Straus conjecture. Program should take as input one integern (3 <= n <= 1 000 000) and print triple of integers satisfying identity 4/n = 1/x + 1/y + 1/z, 0 < x < y < z. Shortest code wins. Some examples: 3 => {1, 4, 12} 4 => {2, 3, 6} 5 => {2, 4, 20} 1009 => {253, 85096, 1974822872}...
stackexchange_codegolf
All the quine challenges on this site are focused on byte count, or the characters themselves. This one is different. Your challenge is to write a program that produces output which has a code point sum identical to the source's code point sum. To produce a code point sum: Find the values of the characters in the prog...
stackexchange_codegolf
AWG (American Wire Gauge) is a common way of specifying wire sizes. Your task in this challenge is to convert from a given gauge to the diameter of the wire in inches. The size in inches for the gauges from 4/0 to 40 are shown in the table below: Gauge to inches table | AWG | Diameter (Inches) | |-----|----------------...
stackexchange_codegolf
For this challenge, you will be given a long string as an input. With this string, you must create a dictionary. Details: This dictionary will contain all the words from the string - a word being any sequence of letters surrounded by non-letter characters (ASCII). Letter case of the entries of the dictionary should alw...
stackexchange_codegolf
Given a string that is potentially boxed in, toggle the box. This becomes clearer in the test cases and explanation. Input / Output Input Format The input will be either a single string separated by CR, LF, or CRLF, or a list of strings. The input format is up to you to decide. Output Format The output format must be i...
stackexchange_codegolf
I was asked this question in an interview but I was unable to figure out any solution. I don't know whether the question was right or not. I tried a lot but couldn't reach any solution. Honestly speaking, nothing came to my mind. Rocco numbers A positive integer \$n\$ is a Rocco number if it can be represented either a...
stackexchange_codegolf
+-= is a language created by Esolangs user Anonymous in 2017.The language consists of only three commands: + increases the accumulator by one. - decreases the accumulator by one. = outputs the accumulator and a newline. Rules This is code-golf, all usual golfing rules apply. Standard rules apply. You may assume inpu...
stackexchange_codegolf
I have the code below working. But there must be a better way. file <- "http://s3.amazonaws.com/assets.datacamp.com/production/course_1127/datasets/tmp_file.csv" x <- read.csv(file = file) ts <- xts(x = x, order.by = as.Date(rownames(x), "%m/%d/%Y")) cd=coredata(ts) for (j in 1:length(names(ts))) cd[,j]<-cd[,j]/cd[1,...
stackexchange_codegolf
I hate code bloat! So I have decided to replace my Windows 7 system by a golfed version. However, I know that it is not easy, so let's build a prototype first. It will take a list of windows from the user and show them using a pseudo-graphic display on the standard output. For example: user input: 0,0,15,10 15,10,20,1...
stackexchange_codegolf
We know that not all fractions have a terminating binary representation. However every fraction can be written as a leading portion followed by a repeating portion. For example \$1/3\$ starts with \$0.\$ and then just repeats \$01\$ endlessly. This corresponds to the bar notation taught in primary school. For examp...
stackexchange_codegolf
Background Conway criterion is a method to test if a given polygon can tile (i.e. cover without overlapping) an infinite plane. It states that a polygon can tile the plane if the following conditions are met: The given polygon does not have any holes in it. It is possible to choose six consecutive1 points \$A,B,C,D,E,...
stackexchange_codegolf
Since my use of Element has increased recently, I am interested in tips for golfing programs written in it. What general tips do you have for golfing in Element? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Element. Please post one tip per answer.
stackexchange_codegolf
Your toy in this challenge is a special abacus of 4 rows and 8 positions per row. There's one bead on the first row, 2 beads on the 2nd row, 3 beads on the 3rd row and 4 beads on the 4th row. Beads on a same row are glued together, which means that they can only be moved as a block. Below is a valid configuration of th...
stackexchange_codegolf
Task: Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole in it and one big trio...
stackexchange_codegolf
Conways' Game of Life is a well known cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves according to rules indefinitely. Those rules are: Any live cell with 2 or 3 living neighbours (the 8 cells immediately around it) lives ...
stackexchange_codegolf
Remove one stick and output the stack updated. Description You can remove only sticks on top( completely drawn). You can assume: there are 5 sticks on the table. there's one and only one stick you can remove. sticks are recognizable : there aren't overlapping sticks on the same orientation and there aren't sticks join...
stackexchange_codegolf
Goal Write a full program that generates a map showing the local train stations and which train station is the closest to every point on the map. Requirements Input A set of tuples. The first is the (Width,Height) dimensions of the map. The following tuples are the (X,Y) coordinates of each train station. Coordinate...
stackexchange_codegolf
Challenge Determine how many integer lattice points there are in an ellipse $$\frac{x^2}{a^2} + \frac{y^2}{b^2} \leq 1$$ centered at the origin with width \$2a\$ and height \$2b\$ where integers \$a, b > 0\$ . Input The Semi-major \$a\$ and Semi-minor \$b\$ axes. Output Number of interior and boundary points. Example E...
stackexchange_codegolf
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
Write a program that accepts chess moves, validate them and shows the results. The program should: Check wheter or not a move is valid Check if a king is in check or in checkmate Process the changes in position of the pieces Not procees invalid moves Use the format shown below, but format can be changed freely if you ...
stackexchange_codegolf
Remove all repeating words from an inputted sentence. Input will be something like cat dog cat dog bird dog Snake snake Snake and the output should be cat dog bird Snake snake. There will always be a single space separating words. Output order must be the same as input. (Refer to the example) You don't need to handle p...
stackexchange_codegolf
Create a routine to calculate the position of each unit of a clock with an arbitrary number of units (minutes, hours, half-days, days, years, parsecs, quarter-quells, etc), where each unit can be equally sub-divided into an arbitrary number of sub-units; after n base units have elapsed. Basically, figure out what a cl...
stackexchange_codegolf
Have fun with this one, The Powder Toy is a interesting challenge for golf, especially with filt logic. The thing that makes TPT a challenge is the many many many many ways to approach a problem: Should I use Cellular Automaton rules, SWCH logic, Filt logic, subframe filt logic, and/or wall logic? As such, a location f...
stackexchange_codegolf
We've all been burned by the grammar police on the internet. What we need is a regex that can be used in place of "there", "their", and "they're". This would shift burden of grammar parsing from the writer to the reader (a sort of "client-side" grammar, if we you will). So, here's what I have to start with: the([re]|[i...
stackexchange_codegolf
Background A maximal domino placement (MDP) on a rectangular grid is a non-overlapping placement of zero or more dominoes, so that no more dominoes can be added without overlapping some existing domino. Alternatively, it can be thought of as a tiling using dominoes and monominoes (single square pieces) so that no two m...
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
Your task will be to write a Haskell function that takes a list of integers and returns a sorted version of the same list. You are to do this without the use of builtins What are builtins? To keep ourselves from having to navigate edge case hell we are going to limit answers to Haskell (sorry if Haskell is not your fa...
stackexchange_codegolf
The flick input method is a way of inputting Japanese kana on a modern smartphone. It is arranged in a 12-key layout, with the following labels: あかさ たなは まやら 小わ、 When a key is tapped, it produces its respective kana. However, when the key is flicked in one of the four cardinal directions (up, down, left, right) it prod...
stackexchange_codegolf
Inverse function of this challenge To (properly) multiply an string by an integer, you split the string into characters, repeat each character a number of times equal to the integer, and then stick the characters back together. If the integer is negative, we use its absolute value in the first step, and then reverse t...
stackexchange_codegolf
Summary The aim of this challenge is to write a tenacious program. This is a stateful program designed to output a given string, but for which, if the program is aborted at any point during the writing of the string, rerunning the program will continue where it left off, writing only the characters that have not been w...
stackexchange_codegolf
Based on this challenge and this Math.SE question. Idea originally come from a Numberphile video. The goal is to reproduce the logic of Professor McKee when he builds this prime. Your task is to build the Trinity Hall Prime, at a much lower scale. You are given a single number N greater than 2, representing the length ...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. There's a good news and a bad news. Good news: you got a Christmas present from Santa. (Already?! Christmas is two weeks away!) Bad news: the present is locked with a laser lock. And a note next to it says: Only the ones who can prope...
stackexchange_codegolf
The Cashier's Algorithm is an algorithm for making change in the minimal number of coins that works quite well for most currency systems. However like most greedy algorithms it is not without its flaws. If a currency system is set up just right (or just wrong) there are certain values in which the Cashier's Algorithm...
stackexchange_codegolf
The flag of Bangladesh is very simple. It looks like below: The flag will be in bottle green (#006a4e) and rectangular in size in the proportion of length to width of 10:6, with a red circle in near middle. The red circle (#f42a41) will have a radius of one-fifth of the length of the flag. This image will help you to ...
stackexchange_codegolf
Challenge Your task is to generate a string using this sequence: 1,1,2,1,1,2,3,2,1,1,3,2,4,2,3,1,.... Which is more understandable in this format: 1 1 2 1 1 2 3 2 1 1 3 2 4 2 3 1 1 4 3 2 5 2 3 4 1 The pattern increases the number of Digits in the string by two for each increment in the Value of N For each integer val...
stackexchange_codegolf
This is a code-shuffleboard answer-chaining challenge, where the answers will aim to, together, output the lyrics to this beloved 80s song. This is the full lyrics of the song, line by line. The first answer will contain a program that will output the first line of the song (We're no strangers to love). The second wil...
stackexchange_codegolf
What general tips do you have for golfing in dc? dc is a calculator utility for UNIX/Linux that predates the C language. I am interested in how to make my dc programs (calculations?) shorter. I'm looking for ideas that can be applied to general code-golf that are at least a little bit specific to dc (eg. removing comm...
stackexchange_codegolf
INTRODUCTION I like Karma Fields : he's a music producer that creates original music tracks. His artwork also matches up really well his style. He has a logo witch I find really interessing : GOAL Your goal will be to reproduce that logo, graphically or in ASCII. Edit @NahuelFouilleul managed to provide a readable asc...
stackexchange_codegolf
If you have ever had any exposure to Japanese or East Asian culture you will have surely encountered the Amidakuji game: As Wikipedia explains, it is a type of lottery drawn on paper and used to randomly select a permutation of N items. For example, it may be used to randomly assign a starting sequence to N people, o...
stackexchange_codegolf
This challenge is rather simple: You are given an array of positive (not including 0) integers, and have to select a random element from this array. But here's the twist: The probability of selecting an element is dependent on the value of the integer, meaning as the integer grows larger, the probability of it to get s...
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
Question We are captured by robot army on their space station. Our space ship pilot is in the prison which is in level 1. There is only one way how to escape and it's rescuing your space ship pilot. It mean's moving from level N to level 1. However because it's very risky you need to get to the prison in the least numb...
stackexchange_codegolf
Make an upside down triangle of positive integers. Every number in the triangle must be distinct. Each number is the summation of its two parents (similar to how Pascal's triangle is constructed, but upside-down). Construct it in such a way that the bottom number is minimized. For example, for input n = 4, here is a po...
stackexchange_codegolf
We're going rootin' tootin' cow-poke shootin! This is a simple contest, first program to draw their pistol wins. How it works: I require 2 things from you, an executable, and a command to be run from a bash terminal. The executable needs to do one thing: wait until it receives 'draw!' from STDIN, and then print 'bang!...
stackexchange_codegolf
Challenge In this challenge, we will use a language that is very similar to Brainfuck but slightly different. This variant of BF does not have any input and output commands; instead, it simply takes a tape as input and modifies it until it halts. The final state of the tape is considered the output of the program. The...
stackexchange_codegolf
Goal: Given two natural numbers (integers from 0 to infinity), output a number that is not the sum of those numbers, but is a natural number. Example solutions (TI-Basic): A+B+1 not(A+B) Invalid solutions: A+B-1 (for inputs 0,0, it returns -1, which is not natural) "ABC" (ABC is not a number) Notes: The output...
stackexchange_codegolf
When I was a kid, and wanted to count the dollar bills in my life savings, I would count out loud: one, two, three, four, five, six, seven, eight, nine, ten; eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty; twenty-one, twenty-two, twenty-three, twenty-four, twenty-five.....
stackexchange_codegolf
Letter dice are common in word games. It can be fun to try to spell funny words with boggle dice, for instance. If you grab a handful of dice, chances are you won't be able to spell certain words. This challenge is a generalization of that idea. Challenge Given a list of dice which each have at least 1 face and a word,...
stackexchange_codegolf
A minifloat is a binary representation of a floating-point number that has very few bits. The minifloat in this question will be defined as an 6-bit number m, which has the following representation: 1 bit to repesent the sign of the number. This bit will be 0 if the number is positive, and 1 if the number is negative....
stackexchange_codegolf
Challenge We take three positive integers a, b, and c as input. Using these integers, first create a sequence in the range [0, c] (inclusive on both ends), in steps of b. For example, for a=4, b=2, c=100, the sequence would be [0,2,4,...,96,98,100]. For every number in this sequence which is divisible by a, replace it ...
stackexchange_codegolf
Objective Given a permutation of 4 distinct items, classify the permutation by the normal subgroup(s) it belongs. Input/Output Format You gotta choose the followings as the hyperparameters for your submission: The 4 distinct items. The permutation serving as the identity permutation. The input format is to accept a...
stackexchange_codegolf
A number spiral is an infinite grid whose upper-left square has number 1. Here are the first five layers of the spiral: Your task is to find out the number in row y and column x. Example: Input: 2 3 Out : 8 Input: 1 1 Out : 1 Input: 4 2 Out : 15 Note: Any programming language is allowed. This is a code-golf cha...
stackexchange_codegolf
Write a program (or function) that takes in a positive integer. If the input is 1, print (or return) two diamonds neighboring side-by-side, each with a side length of 1 slash: /\/\ \/\/ For every input N greater than 1, look at the output for N-1 and for each pair of neighboring diamonds, insert a new diamond in betwe...
stackexchange_codegolf
using Prefixed Length Code We are going to implement a compression of text (string, array/list of characters/bytes) by simple substitution of each character by a binary code, based on the frequency of that character in the text. The characters that occur more frequently will be replaced by shorter codes. The resulting ...
stackexchange_codegolf
This is a rewrite of the (currently closed) "Debunking Stroustrup's debunking of the myth “C++ is for large, complicated, programs only”" challenge. Challenge Write the shortest program or function that will: Download http://www.stroustrup.com/C++.html, and List all URLs contained in the HTML document. A "URL" for th...
stackexchange_codegolf
Write a function or program that accepts a date (as a string in YYYY-MM-DD format) as input and returns a truthy value if that date is "alphabetical," and a falsey value if it isn't. An alphabetical date is a date whose month, day and year are in alphabetical order when expressed as a string (and when considered speci...
stackexchange_codegolf
Universal Command Sequence Definition An \$n\$-maze is a \$n\times n\$ chessboard which has "walls" on some edges, and a "king" on the board that can move to the 4 adjacent cells, which cannot pass through any walls. Starting from any cell the king should be able to reach every cell on the board. A command sequence is ...
stackexchange_codegolf
Your task is to make a quine, that is a non-empty computer program that prints it's own source without reading it. In addition if you remove any one byte from your original program the new program should print the source of your original program. This is code-golf so answers are scored in bytes with fewer bytes being ...
stackexchange_codegolf
Background This challenge is about the game of Go. Go is a game played on a board with a square grid N x N. You don't have to know how to play the game to do this challenge, but if you are interested, google "Tromp-Taylor rules" for a minimal and precise set of rules to play a full game. Let's use a 4 x 4 board. As the...
stackexchange_codegolf
It's simple, simply output text to STDERR containing the string EOF. Input/Output Your input will be none; however, you should output the message to STDERR. Rules Since this is code-golf, the shortest answer wins. No standard loopholes please. Any method approved by Standard I/O is allowed. Your code may not contain t...
stackexchange_codegolf
Multi-level marketing related challenge. A peer wants to get rewarded. So it attracted N investors (N>=1), each i-th investor invested x[i]. When a total sum exceeds threshold x[0]+x[1]+...+x[N-1] >= T a peer could be rewarded. But only if a following conditions are satisfied: Minimum amount of investors should be gre...
stackexchange_codegolf
The Matoran Alphabet is the alphabet used by many of the characters in the Bionicle universe. Your challenge is to create a program or function that takes a string as input and creates an image of the input written in the Matoran alphabet. The input will only consist of uppercase letters (A-Z), numbers (0-9), and spac...
stackexchange_codegolf
Goal: Create a program to find the smallest file in the current folder. File size may be measured in bytes or characters. If multiple files have the same size, you can either choose one or display all of them. You can assume there will be at least one file in the folder, and no files will have a size of 0. Assume t...
stackexchange_codegolf
The Lisp language has a family of functions car, cdr, cadr, etc for accessing arrays. For each one, an a defines taking the first item of an array, and a d defines taking the rest. For example, running cadr on [[1,3,4],5,7] will return [3,4] as the a gets the first item ([1,3,4]) and the d removes the first item. We've...
stackexchange_codegolf
Keeping this challenge short. You are given 4 numbers: p1, p2, p3 and p4. The magic sum of the numbers are defined as follows: magic_sum = |p1 - p2| + |p2 - p3| + |p3 - p4| + |p4 - p1| You are only allowed to change one of the above integer values (p1, p2, p3 or p4). You need to change the value such that the magic su...
stackexchange_codegolf
Backstory: I think that my boss might finally realize that I don't any enough work, despite being paid by the hour. I want to throw him off track, by writing as many valid programs as I can to send to him. Unfortunately, due to budget cuts, my keyboard only allows each key to be pressed once. Specification: Write as ma...
stackexchange_codegolf
The goal is to make a two frame animation with ASCII art of a hammer smacking a table. Trailing white-space is allowed and the frames need to repeat continuously. The program should iterate over both frames with a time of 0.5 seconds between frames. Lowest byte count wins for each language! Sample: Animation Frames: Fr...
stackexchange_codegolf
In this challenge we'll compute an infinite minimal admissible sequence. The sequence for this challenge starts with a(1) = 1. We continue this sequence by finding a(n) as the smallest possible number such that a(n) > a(n-1) and for every prime p, the set {a(i) mod p : 1 ≤ i ≤ n} has at most p-1 elements. Write a progr...
stackexchange_codegolf
There are lots of different ways to explain matrix multiplication. I'll stick with a single figure since I believe most people here are familiar with it (and the figure is very descriptive). If you want more detailed information, I suggest you visit the Wikipedia-article, or the explanation on WolframMathWorld. Simple ...
stackexchange_codegolf
The task is as follows: Given a positive integer x and a prime n > x, output the smallest positive integer y such that (y * y) mod n = x. An important part of this question is the time limit specified below which excludes brute force solutions. If there is no such value y then your code should output N. Test cases (2...
stackexchange_codegolf
Given an Integer array: Start from the first number Jump forward n positions where n is the value of the current position Delete the current position, making what was the next position the current position. Goto step 2 until there is one number remaining Print that number Rules The array wraps-around (the next number...
stackexchange_codegolf
What are some tips on how to shorten this code even further? The code is meant to compute the parallel resistance of an electric circuit. Using scanf float r;main(){float a;scanf("%f",&a);r+=1/a;printf("%f",1/r);main();} Using command-line arguments #include<stdlib.h> float r;main(c,v)char**v;{for(int i=1;i<c;)r+=1/at...
stackexchange_codegolf
Upon the rumor that Codegolf will have a Rock-Paper-Scissors tournament you look into the topic of square-free words. A word made of the letters R, P, S is square-free if it does not contain a sequence that repeats twice. That is to say, the word can not be written as a x x b where a and b are words of any length and ...
stackexchange_codegolf
The Najdorf Variation of the Sicilian Defence is an opening often played at the highest level of chess. It is named after GM Miguel Najdorf and is known for being extremely sharp and theory heavy. Your task is to write a program that, given a Boolean-like input, prints a chessboard representation of the opening from ei...
stackexchange_codegolf
Given a fraction in the format m/n (where m and n are coprime integers), output the corresponding Unicode fraction. Your program/function will not be expected to take in any input that does not correspond to a Unicode character. Arrays, e.g. [2, 3] as opposed to 2/3, are accepted. m / n as opposed to m/n is also fine. ...
stackexchange_codegolf
Challenge: Read a string from user, print number of each vowel, then place all remaining chars in a line. Shortest answer wins! Output must look like this: Enter String: Input Vowel Count: a: #, e: #, i: #, o: #, u: # Remaining characters: Vowel-less Input For example: Enter String: LoremIpsumDolorSitAmetConsecuteurA...
stackexchange_codegolf
I want an n*n table that is filled with black or white and the following conditions are satisfied in it: All cells of a 2*2 square in this table should not be the same color. All black and white cells must be connected horizontally or vertically. Acceptable examples: Can anyone design a function that takes n as inpu...
stackexchange_codegolf
Background Imagine that I'm creating a really long necklace, consisting of only two characters, A and B. You must count the number of occurrences of the substring AB in the string. However, since it's a necklace, you must also consider if the last character and the first character join to make AB. For example, in BBBA,...
stackexchange_codegolf
I was asked this question in an interview but I was unable to figure out any solution. I don't know whether the question was right or not. I tried a lot but couldn't reach any solution. Honestly speaking, nothing came to my mind. Rocco numbers A positive integer \$n\$ is a Rocco number if it can be represented either a...
stackexchange_codegolf
Here is a fairly simple ASCII depiction of an open book: |\ | \ | \ | \ | \__________ | || | | || Lorem i | \ || psum do | \ || lor sit | \ || amet, | \ || consect | \||_________| Notice that the text portion is only on the right page and is 7 characters wide by 5 tall. Also notic...
stackexchange_codegolf
Lorem Ipsum is placeholder text used when preparing layout without wanted to have content already filled. One of its key features over using some arbitrary text is that it is nonsense. It isn't even valid latin (though it is close). This prevents anyone being shown the layout from becoming distracted reading the text. ...
stackexchange_codegolf