instruction_seed
stringlengths
34
53.1k
_source
stringclasses
1 value
Giuga numbers (A007850) are composite numbers \$n\$ such that, for each prime factor \$p_i\$ of \$n\$, \$p_i \mid \left( \frac n {p_i} -1 \right)\$. That is, that for each prime factor \$p_i\$, you can divide \$n\$ by the factor, decrement it and the result is divisible by \$p_i\$ For example, \$n = 30\$ is a Giuga num...
stackexchange_codegolf
Though there is a prime factorization challenge and it's here, this, I feel, will be a bit more interesting than that one. To understand this, let's have an example; I will use 5,184 for this. \$5184 = 2^6 \times 3^4\$. However, for this challenge, such a factorization is insufficient - the reason is that 6 and 4 are c...
stackexchange_codegolf
You task for today: draw a dragon curve! In case you don't know what a Dragon Curve is, here is an introductory ViHart video (Really cool, please watch!) Your task: draw a dragon curve, iterated at least 9 times. You don't have to show iterations 1 through 9, you just have to show the final curve produced after complet...
stackexchange_codegolf
Yeah... it's confusing. Let me explain it a little better: With a string, get the unicode code points of each letter Let's use "Hello World!". The code points would be [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33] Of each digit of the code points, get their binary format Get the binary of 7, then 2, the...
stackexchange_codegolf
The game of Ghost is played between two players who alternate saying a letter on each turn. At each point, the letters so far must start some valid English word. The loser is the player to complete a full word first. So, for example, if the letters so far are E-A-G-L, then the only valid next letter to say is "E" an...
stackexchange_codegolf
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
Sometimes authors will write (s)he as a stand in for she or he and for some reason they don't want to use singular they. This is ok for the nominative but doesn't work so well when you want to write "her or him". You can write h(er)(im) which covers both cases but gives two extra "pronouns" h her him herim In formal...
stackexchange_codegolf
You end up having a lot of very long, boring-looking conditionals in your code: if flag == 1: while have != needed: if type == 7: These can be transformed into their much more lovable <3 conditionals counterparts: if abs(flag - 1) + 2 <3: while 3 - abs(have - needed) <3: if 2 + abs(type - 7) <3: Task Your task is...
stackexchange_codegolf
I was recently adding up the ages of myself and my wife and kids and realised that at some point in the not-too-distant future our ages will all add up to exactly 100 years. Challenge For an input consisting of a combined (total) age and a list of birth dates, output the date on which the combined ages all add up to th...
stackexchange_codegolf
This challenge is inspired by this fantastic animated diagram (thanks to flawr for posting it in chat). Given an input n, draw all of its prime factors as nested polygons of dots, as specified. For example, given the number 357 = 17x7x3, you arrange 3 dots in a triangle, 7 versions of those triangles in a heptagon, and...
stackexchange_codegolf
Steven Gerrard was born on 30th of May 1980. He is now 37 years old. Happy birthday, Steven! To celebrate his anniversary, your goal is to remind him the number of goals he has scored each year in premiere league for Liverpool. He doesn't want to remember the goals scored before or after playing for Liverpool. It is l...
stackexchange_codegolf
Challenge Given daily arrival and departure times of every train that reaches a railway station, find the minimum number of platforms required for the railway station so that no train waits. In other words, find the maximal number of trains simultaneously present in the station. Input a pair of lists of times: arrival...
stackexchange_codegolf
"A picture is worth a thousand words"—so the old saying goes. The average word is about four characters long, so a picture conveys 4kB of information. But how much entropy, rather than information, can a picture convey? Your task is to generate an image, exactly 4,000 bytes in size, with the highest entropy possible. Y...
stackexchange_codegolf
In this challenge, the goal is to create a pristine truth machine in as few bytes as possible. For reference, a truth machine does the following: Takes input, which is always 0 or 1 If the input is 0, it is printed and the program terminates If the input is 1, it is printed forever A pristine program is one that does...
stackexchange_codegolf
Task The task is to golf a real-time exact string matching algorithm of your choice. Input Two lines of text supplied on standard input, separated by a new line. The first line contains the "pattern" and will simply be an ASCII string drawn from the letters a-z. The second line contains the longer "text" and will also ...
stackexchange_codegolf
This is the inverse of "Encode the date in Christmas Eve format." Write a program that takes as input the string Christmas, possibly followed by Eve between 1 and 365 times, and outputs the date encoded in YYYY-MM-DD format, or any format from which the year, month, and date can be easily obtained. Assume that the "Ch...
stackexchange_codegolf
This challenge is not code golf. Please read the scoring before you attempt to submit an answer. You will be given a multi-line string as input. You should output the size of the largest contiguous chunk of non-space characters. Contiguous just means that the chunk is a single piece rather than multiple disconnect...
stackexchange_codegolf
Suppose you have a grid of cells that is 6 wide and arbitrarily tall. In each cell is a word. Let the bottom row, which is row #1, be the last 6 words of sample.txt in order. Let the second to last row, which is row #2, be the 6 words before those in order. (etc.) Then consider what happens when you remove some of the ...
stackexchange_codegolf
Sandbox Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep. A sheep is a single independent unbroken line of sheep length \$n\$ and thickness \$k\$. #|##|# | # #| | #|# are all valid sheep for \$n=2,k=1.\$ ##|###|## | ## ##|###| ## | ## ...
stackexchange_codegolf
For a while now, I've been running into a problem when counting on my fingers, specifically, that I can only count to ten. My solution to that problem has been to count in binary on my fingers, putting up my thumb for one, my forefinger for two, both thumb and forefinger for three, etc. However, we run into a bit of ...
stackexchange_codegolf
In Javascript you can recover the complete language using only the symbols ()[]!+. Here's the basics: false => ![] true => !![] undefined => [][[]] NaN => +[![]] 0 => +[] 1 => +!+[] 2 => !+[]+!+[] 10 => [+!+[]]+[+[]] Array => [] Number =>...
stackexchange_codegolf
You're a chef and you love cooking with your spices, but recently you've taken a liking to organizing your spices based on how often you use them. But you have no time to be writing down when you used your spice last. Simply, you swap and move spices around, and this seems to do the trick. But of course you're a chef a...
stackexchange_codegolf
ed is the standard text editor on Unix systems. Your goal is to write an ed clone. Task Write a program that reads an input stream and for every received end of line character, print ? followed by a end of line character. The communication has to interactive. Means the program needs to output as soon as possible and h...
stackexchange_codegolf
In some parts of the world, phone numbers are fixed-length, apparently. That sounds boring, though. For this challenge, your task is to take the digits of a what is presumed to be a valid phone number, and format it based on some simplified rules around what a phone number looks like. Input format Your input will consi...
stackexchange_codegolf
Say I have a pile of boxes: AAA BBB I can create it in two steps: BBB ↓ (empty) --- AAA ↓ BBB But with this: AB BA I need three steps: A ↓ (empty pile) --- BB ↓ A --- A ↓ B BA Your challenge Given a pile of boxes, output the minimum number of steps needed to create that pile. A step consists of dropping a ro...
stackexchange_codegolf
Key links: Troll question Chat room Game Controller Interface Dwarf league table <script src="https://ajfaraday.github.io/Thud/dist/data/tables.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><table> <thead> <tr> <th>Client</th> <th>Wins</th><th>Loses</th> <th>S...
stackexchange_codegolf
Premise So recently I was about half an hour early to an appointment, and decided to wait outside. I also determined that it would look strange if I just stood motionlessly in front of the house. Therefore, I decided to go on a quick walk, within a limited area. I also concluded that if I started walking in circles tha...
stackexchange_codegolf
A collection of positive integers d_1 d_2 ... d_k is a factorisation of a positive integer n if d_1 * d_2 * ... * d_k = n Each positive integer has a unique prime factorisation, but in general they also have factorisations in which some of the terms are composite. E.g. 12 = 6 * 2 = 4 * 3 = 3 * 2 * 2 Write a program, ...
stackexchange_codegolf
This time I will give you an easy challenge: Print the Om sign with \$\pi\$!(Sorry for many challenges with \$\pi\$) Here is the om sign drawn using pi numbers: 59 0 64 230781 3.14159 26 502884 535 83279 1971 89 433 6939 79 44 937 ...
stackexchange_codegolf
Given a ragged list of positive integers find the size of the largest list contained somewhere in it. For example: [1,[1,[8,2,[1,2],5,4,9]],2,[],3] Here the answer is 6 because one of the lists has 6 elements and all other lists have fewer. [1,[1,[8,2,[1,2],5,4,9]],2,[],3] ^ ^ ^ ^ ^ ^ The length doesn't ca...
stackexchange_codegolf
Our task is to, for each letter of the (English) alphabet, write a program that prints the alphabet, in a language whose name starts with that letter. Input: none Output: abcdefghijklmnopqrstuvwxyz uppercase and trailing newline optional Rules: The scoring metric is the length of the programming language name, plus t...
stackexchange_codegolf
Background In Boggle, a round is scored by adding up the points for each unique word a player has found (i.e. any word that more than one player has found is worth 0 points). The points are calculated based on the number of letters in each word, as follows: 3 letters: 1 point 4 letters: 1 point 5 letters: 2 points 6 le...
stackexchange_codegolf
Your task is when given a chemical formula as input, output the total number of atoms in the formula. Input A chemical formula in any reasonable format. Each chemical formula has the following: A leading coefficient, which is a number \$N > 1\$. At least 0 groupings of elements surrounded by parentheses. Groupings ca...
stackexchange_codegolf
This is a simple challenge which hopefully may lead to some creative answers. Quoting Wikipedia: "Dual-tone multi-frequency signaling (DTMF) is an in-band telecommunication signaling system using the voice-frequency band over telephone lines between telephone equipment and other communications devices and switching cen...
stackexchange_codegolf
As some of you may know, to get a language onto Dennis's wonderful Try It Online!, a Hello, World! program is required. Recently, Dennis pushed up a way to load these programs from the website. Here is a JSON pastebin of the characters used in those programs, by frequency, as of July 27, 2017. Some of those characters ...
stackexchange_codegolf
I'm currently converting a Float32Array to an Int32Array for input to a real-time audio raw PCM to MP3 recording application. new Int32Array([...new Float32Array(b)].map(f=>f<0?f*32768:f*32767) The examples in the wild I've seen convert each float individually to avoid static, gaps, glitches when the audio recording i...
stackexchange_codegolf
Full width text is text that has a space after every character, including the last one. For instance, the first sentence of this question becomes: F u l l w i d t h t e x t i s t e x t t h a t h a s a s p a c e a f t e r e v e r y c h a r a c t e r , i n c l u d i n g t h e l a s t o n e ....
stackexchange_codegolf
Given n=m^2, return a list of integers that do not border the m x m grid of integers from 1 to n. Examples n=1 (m=1) Grid: [1] Return: [] n=4 (m=2) Grid: [1,2] [3,4] Return: [] n=9 (m=3) Grid: [1,2,3] [4,5,6] [7,8,9] Return: [5] n=16 (m=4) Grid: [ 1, 2, 3, 4] [ 5, 6, 7, 8] [ 9,10,11,12] [13,14,15,16] Return: [6,...
stackexchange_codegolf
Objective Given a positive integer, spell it out in the conlang I made. Specification Let \$n\$ be the inputted integer. \$n\$ shall be spelled out in the following specification. The entire spelling is case sensitive. With the decimal expansion of \$n\$, let d be the least significant nonzero digit of \$n\$. First, d ...
stackexchange_codegolf
Thanks to HyperNeutrino for making more test cases Often in chat, someone will ask a question, and multiple people will answer it at the same time. Usually, the person who was beaten to the gun will say "ninja'd", creating even more unnecessary chat. Given a chat log similar to the following: Community: Hi Test: Hi Ran...
stackexchange_codegolf
Challenge Given any positive integer supported by your language: Take the input and divide it into two halves. For all divisions in this program, if the input is odd, round one half up and one half down (ex: 7 -> 3,4, not 7 -> 3.5,3.5). Divide either number in half, then take the larger of these two new halves and add...
stackexchange_codegolf
The random Fibonacci sequence is defined as follows: $$ f_n = \begin{cases} f_{n-1}+f_{n-2} \text{ with probability } 1/2 \\ f_{n-1}-f_{n-2} \text{ with probability } 1/2 \\ \end{cases} $$ $$ f_1 = f_2 = 1 $$ i.e. whether the next term is the sum or difference of the previous two is chosen at random, independently of ...
stackexchange_codegolf
I am a big fan of the game Creeper World, and especially the sequel. You don't need to know how this game works to answer the question, I just wanted to mention where my question originated from. In the game, your objective is to destroy the Emitters that are spawning Creeper, using a weapon known as a nullifier. Nulli...
stackexchange_codegolf
Background Famously, the acronym GNU stands for GNU's Not Unix. 1 It's recursive because, after expanding it once, it still contains the acronym GNU, and so must be exanded again: (GNU's Not Unix)'s Not Unix And so on, ad infinitum. Visualizing this, we get a kind of Droste effect: ┌─────────────────────────────────...
stackexchange_codegolf
Given two positive numbers \$x\$ and \$n\$ with \$x<2^n\$, write the shortest possible function to compute \$x^{-1} \mod 2^n\$. In other words, find \$y\$ such that \$xy=1 \mod 2^n\$. Your function must complete in a reasonable time for at least \$n=64\$, so exhaustive search will not work. If the inverse does not exi...
stackexchange_codegolf
You will be given as input an infinite stream of positive integers. Your task is to write a program which outputs an infinite sequence of lists with two requirements: All lists in the output are finite sub-lists of the input stream. Every sub-list must be output eventually by your program. Sub-lists are not necessari...
stackexchange_codegolf
This tweet lists the possible orders for Wings of a Chinese restaurant1: When ordering Pizza I usually calculate what size gives me the best Pizza-price ratio which is a simple calculation. However minimizing the price of an order at this restaurant isn't such a simple task, so I'd like to be prepared for my next orde...
stackexchange_codegolf
Note: This is #2 in a series of array challenges. For the previous challenge, click here. Separating Nested Lists To separate values in a nested list, flatten it, and then wrap each value so it is at the same nested depth as before. That is to say, this list: [1, [2, 3], [4, 4, [5, 2], 1]] Would become: [1, [2], [3]...
stackexchange_codegolf
Don't you hate it when you're trying to roughly sort a list based on user data, but you have to poll the user for thousands of comparisons? Hate no more, because the answers to this challenge are (going to be) here! Method The sorted-ness of a list is defined by how many possible comparisons it has which are correct. L...
stackexchange_codegolf
As you probably know, there is a war going on in Ukraine. I noticed that it seems nobody has posted a Ukrainian flag challenge yet, so I thought I'd do it myself in support of Ukraine. The Challenge Here is the flag: The flag is divided horizontally across the middle into two equally sized stripes. Stripe colors: (0,...
stackexchange_codegolf
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Oh no, Santa spilled wine all over his great book. Now most of the letters are illegible. How will Santa now know who is groovy and who is unspeakable? Challenge There was once a sequence of words, like this: groovy groovy groovy unspe...
stackexchange_codegolf
Background Inspired by a now deleted question by John Burger from which I quote: Now obviously no human made this mistake. It's a mis-decode of something - perhaps the ISBN? My question is: does anyone know of an existing algorithm that was so messed up it would invent an entirely new calendar? TFeld ingeniously com...
stackexchange_codegolf
It's very simple: Your program or function should generate the following text: Elizabeth obnoxiously quoted (just too rowdy for my peace): "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG," giving me a look. Fine print You may write a program or function, which returns the output as a string or printing it to STDOUT (or c...
stackexchange_codegolf
In this task, your goal is to write a program for generating hexdumps of files of arbitrary types. Input The input consists of a (relative or absolute) path to the file to be processed. It may be taken from STDIN, a function argument, or a command line argument. Output The output (which may be written to a separate pla...
stackexchange_codegolf
This is the second version of the task. The original task had a defect that the given range of integers was too small. This was pointed out by @harold that other methods couldn't defeat the way of hard-coding all the possible prime divisors. Now you have a larger range of integers to test from 0 to 2000000. Also, the r...
stackexchange_codegolf
Here is the program to return [[0, 0, 0], [0, 1, 0], [0, 0, 0]] [[0]*3,[0,1,0],[0]*3] Try it online! Can you shorten this code?
stackexchange_codegolf
Inspired by this question and refined by Luis Mendo. Challenge Given a 2D matrix of integers, each row has a maximum value. One or more elements of each row will be equal to the maximum value of their respective row. Your goal is to determine which column(s) contain the most entries which are equal to their respective ...
stackexchange_codegolf
We haven't had a string question for a while (5 days to be precise), so let's go for one. Given a string s and a positive integer n, take every nth element of s, repeat it n times, and put it back into s. For example, if n = 3 and s = "Hello, World!", every third character is Hl r!. You then repeat each character n tim...
stackexchange_codegolf
I have always failed to give an answer for kolmogorov-complexity challenges which require string compression, the main reason being that I don't know to use string compression tools as effectively as I should. For this reason, I have posted this question. Unlike my other tips questions, this is not language specific m...
stackexchange_codegolf
Challenge Given a positive integer \$N \ge 3\$, generate an alternating series of \$N\$ random numbers within the range \$[1, N]\$, such that their sum equals \$N\$. Expressed mathematically as $$N = \sum_{i=1}^{N} (-1)^{i-1} a_i$$ where \$a_i \in [1,N]\$ are random terms. Input \$N\$ Output A string representing the ...
stackexchange_codegolf
The challenge You are given an integer n, and you have to use these operations to make it 1. Divide it by 3. Divide by 2. Subtract 1. Examples: Input Output 1 0 (Its already 1, guys) 5 3 (3->2->2 or 3->3->1) 10 3 (3->1->1) 255 10(3->3->3->1->1->2->2->3->1->2)
stackexchange_codegolf
Background Set is a card game. The deck consists of 81 unique cards that vary in four features: number of shapes (one, two, or three), shape (diamond, squiggle, oval), shading (solid, striped, or open), and color (red, green, or purple). For convenience, let's write a card as a 4-tuple of numbers from 1 to 3, e.g. 111...
stackexchange_codegolf
Given a 24 hour time, e.g. 20:48, output the nearest time where each adjacent pair of digits has an absolute difference of 1, e.g. 21:01. That is, each number in the output must differ from the numbers next to it by 1, and the output must be the closest time, forwards or backwards, for which this is true. Time can be c...
stackexchange_codegolf
Draw an "apartment" building according to the specifications below. Basic Rules Take, as input, the number of floors of the building. Return a building with that many floors meeting the following specifications: The building will be eight characters wide, with eight underscore characters (_) on top and eight dashes (-)...
stackexchange_codegolf
Do While False At work today one of my colleagues was describing the use-case for do while(false). The person he was talking to thought that this was silly and that simple if statements would be much better. We then proceeded to waste half of our day discussing the best manner to write something equivalent to: do { ...
stackexchange_codegolf
JonoCode9374 had almost completely implemented my language EnScript except for the CHS command. I was impatient of waiting for them to implement this command, so I chose to put this question here. Challenge: Write a solution that takes an input and returns the chased output. Standard loopholes are forbidden. This is th...
stackexchange_codegolf
Most of us LOST fans out there remember the computer that Desmond had to type the characters "4 8 15 16 23 42" in every 108 minutes or the world would end (or would it?). The challenge here is to create a program that would do the same thing by requiring that every 108 seconds the input 4 8 15 16 23 42 is entered or it...
stackexchange_codegolf
You are given 4 positive integers: volume of the first container (v1), volume of the second container (v2), volume of the liquid in the first container (l1), and volume of the liquid in the second container (l2). Your task is to move some of the liquid from container 1 to container 2, making the amount of empty space i...
stackexchange_codegolf
Write the smallest program that maps strings injectively to outputs and maps itself to 2020. To be clear, your program \$p\$ must have the following properties: every possible input string \$s\$ has a well-defined output \$p(s)\$, for every pair of strings \$s\$ and \$t\$ with \$s\neq t\$, it holds that \$p(s)\neq p(t...
stackexchange_codegolf
Challenge Generate two \$16 \times 16\$ grids, each initially filled with "@" symbols and spaces. Each cell in the grids should be independently filled with an "@" or a space, with each character having an equal probability (\$50\%\$) of being chosen for each cell. This ensures that both grids start off identically, wi...
stackexchange_codegolf
My colleague recently sent me the following piece of JavaScript as a joke: let butScript = (nrOfButs) => { for(var i = 0; i < nrOfButs; i++){ if(i % 3 == 0){ console.log("Yeah") } if(i % 2 == 0){ console.log("But") } if(i % 3 == 1){ console...
stackexchange_codegolf
Your objective: Given a string of brackets, output the minimum Damerau-Levenshtein Distance required to turn the input string into a string where the brackets are balanced. Input The input string will only contain brackets and no other characters. That is, it is a combination of any of the characters in (){}[]<>. You m...
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
Challenge Calculate the strange sum of two natural numbers (also known as lunar addition): Given \$A=...a_2 a_1 a_0\$ and \$B=... b_2 b_1 b_0\$ two natural numbers written in the decimal base, the strange sum is defined, based on the maximum operation, as: \$A+B=... \max(a_2,b_2) \max(a_1,b_1) \max(a_0,b_0)\$ ... ...
stackexchange_codegolf
Some time after this incident… There are some of us who are against this defiling order of jQuery. It is an unholy presence, of which must be exterminated. I therefore call on you, the loyal to The New Kingdom of Reformation, to create a program that will eliminate such resistance. All code must be validated and search...
stackexchange_codegolf
We want to go on a night hike with the youth group, but of course not everyone has their torch, even though we told them we planned to split up. What options are there for group formation if n teens have m torches with them, but each group needs at least one torch? Example: Three teens with torches (X) and two without ...
stackexchange_codegolf
The task is simple, given two IP adresses a and b, output all addresses within that range. Examples Example #1: f(a = 192.168.0.1, b = 192.168.0.4) 192.168.0.1 192.168.0.2 192.168.0.3 192.168.0.4 Example #2 (TIO will truncate this, use a smaller range when testing): f (a = 123.0.200.0, b = 124.0.0.0)...
stackexchange_codegolf
Consider the 74 characters from the 2016 time capsule string (note the leading space): !!!!!#$$%&())))*+...1449:=@@@AHILOQQQTTZ\\^`````````eefmpxy{||||~~~~~~~~~ Your task is to write as many programs as possible (in the same language) using these characters. The output of each program must be nonempty. When all of th...
stackexchange_codegolf
Given a \$2\times N\$ maze, determine if you can get from the start top left corner to end bottom right corner using only up, down, left, and right moves. Input A \$2\times N\$ block (\$1 \le N \le 100\$) of your choice of two distinct characters, one representing walls and the other representing empty tiles that can b...
stackexchange_codegolf
Given a single positive odd integer as input, return a converging zigzag as a list of strings, list of lists of characters, or newline-separated string, in this form: # # # # # # # # # # # You can replace # with any consistent non-whitespace character. Trailing whitespace on each line is allowed...
stackexchange_codegolf
The Dutch system for naming one's ancestors is a lot more interesting than the English version. For English, the sequence goes "parent", "grandparent", "great-grandparent", "great-great-grandparent", "great-great-great-grandparent"; and in Dutch those terms are "ouder", "grootouder", "overgrootouder", "betovergrootoude...
stackexchange_codegolf
Write a program/function/script that takes a natural number i from 1 to 10 as input and outputs the URL of the Question with the i th hottest question on the Code Golf Portal The ordering should be like in https://codegolf.stackexchange.com/?tab=hot. For example: input 1 output https://codegolf.stackexchange.com/quest...
stackexchange_codegolf
There is a building with an infinite number of floors and you are the only passenger in an elevator which can lift an infinite number of people. You are going home, but before the elevator gets to your floor, the elevator stops at another floor to allow people to enter the elevator and input their destination floors. Y...
stackexchange_codegolf
The user will hide, and the computer will try to find them. First, the program will take an input, for the size of the grid. Like 5x5, 10x10, 15x15, etc. The grid won't always be a perfect square. The grid is sort of like a chessboard: _______________________________ | | | | | | | A1 | | | ...
stackexchange_codegolf
Given a number n, generate the first n columns of this pattern: # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ################################ ... The height of the column at (1-indexed) n is the numb...
stackexchange_codegolf
Challenge: Given a list of multi-line strings, overlap them (in the top-left) and output the result. Example: Input: ["aaaa\naaaa\naaaa\naaaa","bb\nbb\nbb","c"] Output: cbaa bbaa bbaa aaaa Challenge rules: Input-format is flexible. You are allowed to get the input as a 2D list of lines (i.e. [["aaaa","aaaa","aaaa","a...
stackexchange_codegolf
Intro Cookie Clicker is a popular browser game in which the player has to click a cookie to gain... Cookies! The player can buy upgrades which will automatically farm cookies for you. Sometimes a golden cookie will enter the screen, which will provide a bonus upon clicking it. Challenge This challenge will not be about...
stackexchange_codegolf
An old test for programmers, taken from here (Note: in italian). Along a road (denoted by '_'), there is a Magical Piper (denoted by 'P') and several mice (represented by the two characters 'o' and '~', that denote respectively the head and the tail of the small rodents). Write a program that prints how many mice are g...
stackexchange_codegolf
A number is whole if it is a non-negative integer with no decimal part. So 0 and 8 and 233494.0 are whole, while 1.1 and 0.001 and 233494.999 are not. Input A floating-point number in the default base/encoding of your language. For example, the default integer representation for Binary Lambda Calculus would be Churc...
stackexchange_codegolf
I haven't. :P So I decided to define one: A tralindrome is a string which contains three equal-length sections X, Y, Z such that all characters in the string are included in at least one of the three sections, X starts at the first character, Y starts at or right after the last character of X, and Z starts at or right...
stackexchange_codegolf
Background In the sport of Table Tennis (aka Ping-Pong or Whiff Whaff), two opponents play a sequence of rounds, where each round consists of players hitting a ball back and forth until one player (may or may not be the server) gains a point. Table Tennis has some official rules that make for a good game, but we will u...
stackexchange_codegolf
I hope this kind of "riddle" is ontopic in Programming Puzzles & Code Golf. Give an example of a situation where the C# method below returns false: public class Giraffe : Animal { public bool Test() { return this is Giraffe; } } Rules: The code lines above must not be changed in any way, but you would put th...
stackexchange_codegolf
Last time you were required to write program that output a file, such that no byte is same as original file. The request meant to let everyone carry part of information, but it ends up that everyone carry same info to reduce their storage... This challenge is similar. Write at most 1024 programs that output at least 85...
stackexchange_codegolf
The Dutch system for naming one's ancestors is a lot more interesting than the English version. For English, the sequence goes "parent", "grandparent", "great-grandparent", "great-great-grandparent", "great-great-great-grandparent"; and in Dutch those terms are "ouder", "grootouder", "overgrootouder", "betovergrootoude...
stackexchange_codegolf
Background As you maybe know Ramanujan made this magic square by \$4x4\$ Matrix: This works like all magic squares. But the special thing in this square is that his birthdate is hidden in the first row, the 22\$^{nd}\$ Dec 1887. Challenge Can you make one for your birthdate? Input The User will give Input in this form...
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
Given a word, get the indexes of each letter in the alphabet. For example: uncopyrightable becomes: [21, 14, 3, 15, 16, 25, 18, 9, 7, 8, 20, 1, 2, 12, 5] Convert these indexes to the given numeral system. For example, if the radix is 36, then the array above would become: ['l', 'e', '3', 'f', 'g', 'p', 'i', '9', '7',...
stackexchange_codegolf
Input None Output 52 cards. No duplicates. Cards are represented as their unicode characters, e.g. . The Unicode codepoints follow the following format: The first three digits are 1F0. The next digit is A, B, C, or D for spades, hearts, diamonds, and clubs respectively. The next digit is 1 through C and E for the vari...
stackexchange_codegolf
Your challenge is to query the SE API and find out whose rep on PPCG is tied, and output it. If these were all the users on PPCG: Martin Ender: 10000 rep Dennis: 10000 rep xnor: 5000 rep sp3000: 3000 rep You should output Martin Ender, Dennis. If these were the only users: Jon Skeet: 1000000 rep Martin Ender: 10000 re...
stackexchange_codegolf
Your goal is to map a piece of text to a sine curve of the form: a sin ( mx - b ) Where a and m are non-zero rational numbers, b is a rational number, and the calculations are in radians. It doesn't really matter where the origin of your graph is, as long as you fit all the letters in your output. Also, it must be ASCI...
stackexchange_codegolf