text
stringlengths
180
608k
[Question] [ The quaint hamlet of Кодгольф in the Russian far east has a problem: their population is low (below 66), and no new people have arrived for years. Moreover, after centuries of near-isolation, just about everybody is related to each other. Mayor Стекобмен has a solution that should keep the morale high:...
[Question] [ ## Description Imaginary programming language (IPL) uses Polish Reverse Notation. It has the following commands: * **i** -- input number and push it to the stack * **o** -- non-destructive output top of the stack (number stays on the stack) * **d** -- discard top of stack * **integer number** -- push t...
[Question] [ You find yourself on a chessboard, as one does. You can see the exit but it is awfully far away and you would rather not walk all the way. Luckily some locals have offered you a ride. A Knight, a Rook, a Bishop and a King are all willing to take you to your destination, but seeing how this is a chessbo...
[Question] [ > > **Defenestration** is the act of throwing someone or something out of a window. > > —[Wikipedia](https://en.wikipedia.org/wiki/Defenestration) > > > ## Input The input will consist of two parts: * A floor plan and a person inside the house/building. + `v><^` represents a person, pointing in...
[Question] [ # The Challenge Given a valid regex, output a regex that that matches the same set of strings, but reversed. # The Task This challenge uses the most basic regex operations: `^`, `$`, `?`, `+`, `*`, `[]`, `{}`, `|`. There's no such thing as capture groups or any of that complicated stuff. Special charac...
[Question] [ *(inspired by [Helka's response](http://chat.stackexchange.com/transcript/message/36343516#36343516) to my random pairing of "chess" and "Fibonacci" tags in chat)* --- ### Fibonacci The [Fibonacci numbers](https://en.wikipedia.org/wiki/Fibonacci_number) are one of the more well-known sequences in mathe...
[Question] [ Write a self-contained program which when given a polynomial and a bound will find all real roots of that polynomial to an absolute error not exceeding the bound. ### Constraints I know that Mathematica and probably some other languages have a one-symbol solution, and that's boring, so you should stick...
[Question] [ Donald Trump is very impressed with the work of the people on this site. He saw how amazing of a job you did [helping Ben Carson](https://codegolf.stackexchange.com/questions/64316/make-american-maps-great-again), so he even hired you to [build his wall](https://codegolf.stackexchange.com/questions/674...
[Question] [ I love BATCH, despite its shocking lack of functional commands, despite even due to its lack of non-integer support. Why? Because this works: ``` SET var=SET %var% i=0 ``` This would evaluate to: ``` SET var=SET SET i=0 ``` Fantastic, isn't it? I've used this technique in a [BATCH program](https://code...
[Question] [ ## The Challenge Write a program that outputs `Hello World, from line X!`, where `X` is the line number, in the source code, of the actual print statement itself. ## The Rules * In this context, we want **the *first* line number of the statement which outputs the string** to be displayed to `stdout` * ...
[Question] [ The cops thread can be found here: [The Mystery String Printer (Cops)](https://codegolf.stackexchange.com/questions/60328/the-mystery-string-printer-cops) # Your challenge * Choose a submission from the cops thread, and print out the string from an answer in that thread. * The submission that you choos...
[Question] [ A nice simple one # Input Given a boolean array (Or an acceptable alternative), you can assume the array will never be more than 32 elements long. ``` [false, false, true, false, false] ``` # Output Invert every element of the array and output it. ``` [true, true, false, true, true] ``` # Rules * You c...
[Question] [ Please read the rules, **and the bold areas as well**. Write a program in any language, so long as it has GUI support for a window system (cannot be text-consoles, etc., and must be a GUI/toolkit/window). The program must say hello world in any manner (splash image, menu bar, status bar, title, video, ...
[Question] [ # What? *Many programming languages, both practical and esoteric, have functions, methods, etc to convert a given string to a decimal number.* This is how the process might work: * For each character in the given string. + Take the character's ASCII value and subtract it by 48. + Multiply the output ...
[Question] [ I have a problem at work. I need to compare two numbers that come as strings from two different databases. The numbers may come with leading zeroes and/or leading/trailing spaces. So I may have `"0001 "` from one database and `" 1 "` from the other one. I solved the problem in C# with the following cod...
[Question] [ The challenge is simple: Draw a rainbow in as few bytes as possible The specs for the rainbow are as follows: * The figure must be exactly 400 pixels wide and 200 pixels high (optionally 401x201 if you want a single center pixel) * The red ring should touch all borders of the figure (outer radius = 200...
[Question] [ # The objective Given the non-negative integer \$n\$, output the value of the hyperfactorial \$H(n)\$. You don't have to worry about outputs exceeding your language's integer limit. # Background The [hyperfactorial](https://mathworld.wolfram.com/Hyperfactorial.html) is a variant of the factorial functi...
[Question] [ Saw this in a PHP challenge. The objective is to make a chessboard with 64 squares (8\*8) with the minimum amount of code. Simple enough, I made mine in PHP in 356 bytes (not impressive, I know) and I would like to see some other aproaches. This can be made in a language of your choice, as long as you ...
[Question] [ What are some clever (brief and idiomatic) approaches to taking a list of strings and returning a single properly punctuated string built from the list, with each element quoted. This came up for me while [experimenting with Groovy](https://stackoverflow.com/q/25793522/656912), for which my too-literal...
[Question] [ ### Your task Take a list of strings as the input, and output the maximum average `ord`. ### Example Given the list `['hello', 'world', 'bye']`: * The average `ord` of `'hello'` is: + (`ord(h)` + `ord(e)` + `ord(l)` + `ord(l)` + `ord(o)`) / `len('hello')` + = 106.4 * The average `ord` of `'world'` = ...
[Question] [ You will be given two arrays of floating-point numbers. Your task is to pair the corresponding elements of the two arrays, and get the maximum of each pair. *However*, if the two corresponding elements are equal, you must take their sum instead. For example, given the lists `[1, 3, 3.2, 2.3]` and `[3, ...
[Question] [ Here is another simple one: # The Challenge Given two points in an n-dimensional space, output the distance between them, also called the Euclidean distance. * The coordinates will be rational numbers; the only limits are the restrictions of your language. * Lowest dimension is 1, highest is whatever y...
[Question] [ Given two positive integers \$n\$ and \$b\$, such that \$n > 2\$ and \$n > b > 1\$, count the trailing zeros when converting \$n\$ to base \$b\$. Your program should be able to handle any value of \$b\$ within your integer maximum. The digits of \$n = 18\$, \$b = 3\$ are \$[2,0,0]\$, so the correct out...
[Question] [ [Sandbox](https://codegolf.meta.stackexchange.com/a/18335/85052) Given two positive integers a and b, return the smallest multiple of b that is greater than or equal to a. ## Examples Definitions: `true` = `is a multiple of b`, `false` = `is not a multiple of b`. * `f(1,3) = 3` because `1` is false, `1...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/9266/edit). Closed 3 years ago. [Improve this question](/posts/9266/edit) # ...
[Question] [ I was browsing Stack Overflow when I saw [this post in Puzzling](https://puzzling.stackexchange.com/q/112984) in the hot network questions and decided to make a challenge out of it (all credit goes to the creator of the challenge). ## Overview A Chess Number is a number that, when converted to base 18,...
[Question] [ # Background For this challenge, a 'metasequence' will be defined as a sequence of numbers where not only the numbers themselves will increase, but also the increment, and the increment will increase by an increasing value, etc. For instance, the tier 3 metasequence would start as: `1 2 4 8 15 26 42 64...
[Question] [ **This question already has answers here**: [Images with all colors](/questions/22144/images-with-all-colors) (50 answers) Closed 3 years ago. Challenge: Write a program that outputs a graphic file 1920 pixels wide by 1080 pixels high. Every one of the 2,073,600 pixels within the graphic must be...
[Question] [ The alternating factorial is an alternating sum of decreasing factorials. For example, we could calculate the alternating factorial of 4 as follows: * First, calculate the factorials from 4 down to 1: $$ 4!\quad3!\quad2!\quad1!\quad = \\ 4\cdot3\cdot2\cdot1\qquad3\cdot2\cdot1\qquad2\cdot1\qquad1\quad= ...
[Question] [ Given the output of the cop's program (`o`), the byte-count (`n`) and the number of unique bytes (`c`) used, come up with a corresponding piece of code that is `n` bytes long with `c` unique bytes which matches the cop's output `o`. --- # This is the ***cops thread***. Post solutions that are to-be-cra...
[Question] [ Sometimes, I will think it is one day of the week (e.g Friday) when in reality, it's earlier in the week (e.g Tuesday). Your challenge is to display the number of days my estimates are off by. ## Challenge Given a day of the week I think it is, and the day of the week it actually is, output/return the ...
[Question] [ # Challenge Your task is to write a program which, once a second (including immediately when your program is started), prints the elapsed time from the time your program was started. # Rules * Time must be printed in `hh:mm:ss` format. (leading zeros for single-digit values) * The time stamps must be s...
[Question] [ **This question already has answers here**: [Display number of occurrences for every character in an input string](/questions/19068/display-number-of-occurrences-for-every-character-in-an-input-string) (66 answers) Closed 4 years ago. Given a string of printable ASCII, output the frequency of ea...
[Question] [ ## Rules Given an ISO3166-1-Alpha-2 country code your task is to decide on the traffic direction for that country: * Input will be a valid country code (valid as in it's an element of the two lists provided) * Input may be a list of two characters instead of a string if it helps * You may choose to tak...
[Question] [ In [this question](https://codegolf.stackexchange.com/questions/111190/anagram-quines-cops-thread) I asked you to guess an anagram quine based on its output. However it looks like we don't have a question asking to golf an anagram quine yet. So your task will be to make the shortest anagram quine that ...
[Question] [ **This question already has answers here**: [Stop, stand there where you are!](/questions/55293/stop-stand-there-where-you-are) (29 answers) Closed 6 years ago. I'm currently cooking us some cup noodles, but we're really sleepy at the moment. They'll be finished in 50 seconds from now, can you w...
[Question] [ The task is simple. Write an interpreter for the language [\*](https://esolangs.org/wiki/*). [Here's a bigger link to the wiki.](https://esolangs.org/wiki/*) There are only three valid \* programs: * `*` Prints "Hello World" * `*` Prints a random number between 0 and 2,147,483,647 * `*+*` Runs forever....
[Question] [ Given a textual representation (case-insensitive full name or 3 character abbreviation) of a month return the number of days in the month. For example, `december`, `DEC`, and `dec` should all return 31. February can have either 28 or 29 days. Assume the input is a month in one of the correct forms. ...
[Question] [ I thought this would be a fun challenge for everyone and I'm curious to see the solutions people come up with. Print the "12 Days Of Christmas" lyrics ``` On the first day of Christmas, my true love gave to me, A partridge in a pear tree. On the second day of Christmas, my true love gave to me, Two ...
[Question] [ Title misspelled on purpose. Read more to find out why. Your task: given a delimited string or list including the characters `A,B,C,D`, output the indexes of all the adjacent equal characters. Output can be multiple strings/integers on multiple lines, a list/array, or a delimited string. All output sho...
[Question] [ Given a list of integers, output a list where the \$ i \$th element of the list equals the first number in the input list which is \$ \ge i \$, until there are no such numbers. For example, if the input is: ``` 2 3 5 7 11 ``` then we "expand" the sequence out to show where the gaps are: ``` _ 2 3 _ 5 _...
[Question] [ The challenge here is to take a string and output all its rotations, by repeatedly moving the first character to the end, once per character in the string, ending with the original string: ``` john -> ohnj, hnjo, njoh, john ``` You may also cycle in the other direction, moving characters from the end: ...
[Question] [ Given an integer \$x\_1\$ and some [black box function](https://codegolf.meta.stackexchange.com/a/13706/24877) \$f: ℤ → ℤ\$ find a fixed point of \$f\$ in the sequence defined by \$x\_{k+1} := f(x\_k)\$. ### Details * A value \$x\$ is said to be a fixed point of \$f\$ if \$x = f(x)\$. For instance if \...
[Question] [ **Story:** Lucy asked George what his Lucky Number was. After some contemplation, George replied that he had several Lucky Numbers. After some brief confusion, Lucy asked George what his first `n` Lucky Numbers are. George then asked you, his buddy, to write him a program to do the work for him. **The ...
[Question] [ The goal of this code golf is to draw a regular polygon (one with equal side lengths) given the number of sides and radius (distance from center to vertex). * The number of sides and the radius can be entered via a file, STDIN, or just a plain old variable. Use whatever is shorter in your language. * -...
[Question] [ The code has a lot of names, but is very simple: ``` 1 2 3 4 5 1 A B C D E 2 F G H I J 3 L M N O P 4 Q R S T U 5 V W X Y Z ``` A letter is coded by its coordinates, with the row first, then the column. Ex: ``` M = 3, 2 V 1 2 3 4 5 1 A B C D E 2 F G H I J >3 L M N O P 4 Q R S T U 5 V W X...
[Question] [ ### Your task Given a string, output the range of ASCII values. ### Example Let's say we have the string `Hello`. We get the ASCII values: * `H` = 72 * `e` = 101 * `l` = 108 * `l` = 108 * `o` = 111 Now, we get the range (`max - min`): * 111 - 72 = 39 Our answer is 39. ### Test cases ``` Input ...
[Question] [ # Challenge: Given a list of integer, sort descending by their single largest digit(s). The order for numbers with the same largest digit are then sorted by second largest digit, etc. We ignore duplicated digits in numbers. And if all digits in a number are the same, the order of those numbers in the...
[Question] [ In my room, I have this geeky clock (click for full size): [![enter image description here](https://i.stack.imgur.com/lx2F2m.jpg)](https://i.stack.imgur.com/lx2F2.jpg) Most of these are not difficult to figure out, but the one for 4-o-clock is particularly tricky: [![two to the power of negative one mo...
[Question] [ Given a list of positive integers that contains at least 3 distinct entries, output a permutation of that list that isn't sorted in ascending or descending order. ### Examples ``` 1,2,3 -> 2,1,3 or 3,1,2 or 1,3,2 or 2,3,1 1,2,3,3 -> 2,1,3,3 or 3,1,2,3 or 1,3,2,3 etc.. ``` Thanks @Arnauld and @NoOneIsHe...
[Question] [ **This question already has answers here**: [Output the Hebrew alphabet](/questions/96950/output-the-hebrew-alphabet) (27 answers) [Print the Greek alphabet!](/questions/97049/print-the-greek-alphabet) (48 answers) Closed 6 years ago. [Apparently](https://codegolf.stackexchange.com/questions/...
[Question] [ Simple challenge inspired by the popularity of my previous [print invisible text](https://codegolf.stackexchange.com/questions/122703) and [print real invisible text](https://codegolf.stackexchange.com/questions/123447) challenges, and the [same length different string](https://codegolf.stackexchange.c...
[Question] [ There’s a [famous tricky algorithm for counting the number of set bits](https://en.wikipedia.org/wiki/Hamming_weight#Efficient_implementation) in a 32-bit unsigned integer: ``` int popcount(unsigned x) { x = (x & 0x55555555) + ((x >> 1) & 0x55555555); x = (x & 0x33333333) + ((x >> 2) & 0x333333...
[Question] [ ### Display the remaining battery charge, as a percentage of maximum charge Remember if you can't run your code on a phone, calculator, etc, you can probably install your environment on a laptop at least. If you absolutely can't run on a device that has a battery, then unfortunately your language isn't...
[Question] [ When Alice was touch typing on her QWERTY keyboard (Figure 1), she accidentally shifted both of her hands rightwards by one key, so `q` became `w`, `w` became `e`, etc. (`p` became `[`). Spaces were not affected because the space bar was quite big. Your task is to help her fix her message using the sho...
[Question] [ # Challenge Given a positive integer, return the product of its divisors, including itself. This is [sequence A007955 in the OEIS](http://oeis.org/A007955). # Test Cases ``` 1: 1 2: 2 3: 3 4: 8 5: 5 6: 36 7: 7 8: 64 9: 27 10: 100 12: 1728 14: 196 24: 331776 25: 125 28: 21952 30: 810000 ``` # Scoring Th...
[Question] [ I read [this](https://stackoverflow.com/q/43593278/5401763) question and thought it would make a nice challenge. ## Task Give an input `0<n<10` generate a random number with * exactly n digits * the first not a `0` + so `f(n)>10**(n-1)-1` * distinct digits ## Winning criteria This is [code-golf](/ques...
[Question] [ # Challenge Create the image of a pride flag (rainbow flag), i.e. a six coloured striped flag (from top to bottom): red, orange, yellow, green, blue, and violet. # Output [![enter image description here](https://i.stack.imgur.com/BPJiB.png)](https://i.stack.imgur.com/BPJiB.png) # Example (R) ``` barplo...
[Question] [ I'd like you to build me a clock that displays time in this format: ``` 18 ---------- 19 -------------------------------------------------- ``` This displays '18:10'. The current hour and the next hour are shown at the front of the line, followed by a space and a number of dashes: on the first line the...
[Question] [ *(Inspired by [ASCII's 95 Characters...95 Movie Quotes](https://codegolf.stackexchange.com/q/40562/42963))* ## The Challenge Given input `n`, output the `nth` [Fibonacci number](https://oeis.org/A000045). You can use either `0` or `1` indexing, please state which in your submission. Simple, yeah? The c...
[Question] [ *[Cross posted from my anagolf post (note: may contain spoilers, post mortem).](http://golf.shinh.org/p.rb?ASCII+Pylon)* Output the following text exactly. * You may have additional trailing whitespace on each line, and trailing newlines as well. * Shortest code, in bytes, wins. ``` ...
[Question] [ The objective of this challenge is to take an array of positive integers, and enumerate its indices, grouping like elements. An enumeration without any duplicates is done by just outputting an array of pairs `(value, index)`, for example, `[3, 4, 13, 9, 2]` => `[[3,1],[4,2],[13,3],[9,4],[2,5]]`. Howeve...
[Question] [ Using the following table ([source](http://theplanets.org/distances-between-planets/)) write some code that takes the names of two planets and returns the distance between them: ``` +-------------------+---------------+ | Planets | Distance (km) | +-------------------+---------------+ | Mercu...
[Question] [ A [regular dodecahedron](https://mathworld.wolfram.com/RegularDodecahedron.html) is one of the five [Platonic solids](https://mathworld.wolfram.com/PlatonicSolid.html). It has 12 pentagonal faces, 20 vertices, and 30 edges. [![dodecahedron](https://i.stack.imgur.com/vx9WU.png)](https://i.stack.imgur.co...
[Question] [ A good resolution for 2015 is to live more sustainably. We'll start by recycling. Recycling code, that is! Your task is to print the number `2015` to STDOUT, with or without trailing newline (and *only* that). However, you have to do so by *recycling* some old code from PPCG. Here is how that works: * ...
[Question] [ # Challenge Write a function/program that outputs either the `n`'th element, or the first `n` elements, in the well known number sequence: ``` 1, 2, 4, 8, 16 ... ``` Oh, wait... I forgot the first few numbers: ``` 1, 1, 1, 1, 2, 4, 8, 16 ... ``` Heck, I'll add a few more for good measure: ``` ...
[Question] [ # Task description Given an integer, swap its **(2k–1)**-th and **2k**-th least significant bits for all integers **k > 0**. This is sequence [A057300](https://oeis.org/A057300) in the OEIS. (The number is assumed to have “infinitely many” leading zeroes. In practice, this simply means prepending a sin...
[Question] [ *We seem to [never](https://codegolf.stackexchange.com/questions/89283/print-an-alphabet-wave/89306#comment217718_89283) get [tired](https://codegolf.stackexchange.com/questions/89283/print-an-alphabet-wave/89306#comment217928_89283) of alphabet-related challenges...* --- # The recipe Given * a string ...
[Question] [ Write a program or function that given *n ≥ 1* returns the number of solutions to ±1 ± 2 ± 3 ± ... ± n = 0. For n = 6 there are no solutions, so the answer is 0. For n = 4 there are two solutions, so the answer is 2 (the two solutions are 1 - 2 - 3 + 4 = -1 + 2 + 3 - 4 = 0). This is OEIS sequence [A063...
[Question] [ Given a number N, the challenge is to get the sum of the pyramid of N primes. To clarify things, here is an example: ``` Input: 4 ``` We will list the first `4` primes, and then compute the sum of them. After that, we will compute the sums of the sums, and so on: ``` 2 > 5 3 > 13 > 8 ...
[Question] [ Do you recognize the PPCG logo? it looks like this, when you do an ascii art of it. ``` +---+ |PCG| +---+ v ``` Now, In this Code Golf, You will make a code, that makes logos for other sites, similar to the PPCG logo. # What You should do The "Shortened" string will be the string, with all upper cas...
[Question] [ # Challenge Find an expression, at most 100 bytes long, with the longest type signature. # Rules * Any statically typed language with type inference is allowed * The type must be non-ambiguous, but otherwise may include types without defined instances. For example `Num [a]` and `Eq [a]` are allowed, ev...
[Question] [ [Brain-flak](https://github.com/DJMcMayhem/Brain-Flak) is a stack-based turing-tarpit language, written collaboratively between me, [DJMcMayhem](https://codegolf.stackexchange.com/users/31716/djmcmayhem), and [1000000000](https://codegolf.stackexchange.com/users/20059/1000000000). Some users are very e...
[Question] [ [Ash](https://github.com/Radvylf/ash) has a bit of an interesting float division algorithm. It's designed to never return `NaN`, and things like signed zero and infinity need to be handled. **How it works:** Assume the inputs are positive for the rules below. One input being negative will always result...
[Question] [ I'm surprised this hasn't come up in a challenge yet. Output the IP address of the machine you're running on. You are required to output both the local and external IP addresses. Local IP address, ie along the default format of 192.168.x.x Public IP address can be verified by using google <https://www....
[Question] [ Print or return the following text: ``` Hello world! The quick brown fox jumps over a lazy dog. ``` However, your submission will not be scored in bytes. Instead, primarily it will be scored by the width in pixels of the program when written in Arial in a 12pt font. In particular, the score is: $$ (\te...
[Question] [ In this code golf challenge, you will verify hashtags! # #What\_your\_code\_should\_do Input is a string. Output a truthy value if it is a valid hashtag, and a falsy value otherwise. We define a string as a valid Hashtag if ... * It starts with a hash (`#`). * It doesn't have a number right after the h...
[Question] [ ### Task Write a program or function that takes as input a time in UTC, and outputs the equivalent time in **5 different cities** around the world. The cities displayed are up to the programmer, but the **time must be different** in each city. To prevent golfers from using overly obscure city names, th...
[Question] [ Given list of integers `{0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}`. For those who interested these numbers are used in weekday calculation. Weekday = `(m[n] + d + y + y>>2 + y/400 - y/100) % 7;`, where `m[n]` - expression I'm searching, `d` - day of month, `y` - `year - (month <= 2)`. Construct expression c...
[Question] [ Given string `s` of even length as input, randomly capitalize exactly half of the letters. * You can assume the input will always be a non-zero, even length * You can assume the input will consist of only lowercase letters (`[a-z]`) * Exactly half of the letters should be capitalized in the output * Ev...
[Question] [ #### Task [FizzBuzz](https://codegolf.stackexchange.com/questions/58615/1-2-fizz-4-buzz), but instead of 3 and 5, you'll take the numbers and corresponding strings as input. You can assume all inputted numbers are coprime (and \$\ge 2\$). You'll receive one or more numbers, and a string to print with e...
[Question] [ Your challenge is to generate this string: ``` 0110101101011010011010110101101011010110101101001101011010110100110101101011010110101101011010011010110101101001101011010110101101011010110100110101101011010000110101101011010011010110101101011010110101101001101011010110100110101101011010110101101011010011...
[Question] [ The [Home Prime](https://en.wikipedia.org/wiki/Home_prime) of an integer \$n\$ is the value obtained by repeatedly factoring and concatenating \$n\$'s prime factors (in ascending order, including repeats) until reaching a fixed point (a prime). For example, the Home Prime (\$\text{HP}(n)\$) of \$10\$ i...
[Question] [ We all know `true` and `false`, but what do speakers around the globe say? ``` +----------------------+------------+------------+ | **Language** | **True** | **False** | +----------------------+------------+------------+ | Arabic | sahih | zaif | | Armeni...
[Question] [ I like to think of a 10-adic number as a number that goes infinitely to the left, or an integer modulo a very very large power of 10. Things carry infinitely to the left and vanish. To see what I mean, note that `...6667 * 3 = 1` in the 10-adic land, since the "2" that carries to the left goes to infin...
[Question] [ # End the tabs versus space war So, there has been a great deal of debate of whether to use tabs or spaces to indent/format code. Can you help the university settle the dispute, by going to an incredibly ~~crazy~~ unique method of formatting. --- Your job is to write a full program or function which ex...
[Question] [ ## Input Your input is a list of single-digit numbers in any reasonable format, including a string of digits. The input will not be empty. ## Output Your output shall be the input list, but with each maximal run of nonzero digits being reversed. ## Example Consider the input ``` 95883007414830 <---> <...
[Question] [ # Task Given a positive integer return the geologic era and period it was that many million years ago. ## Input/output The input is a string or integer; the output is a string. Eras and periods are separated by slashes (`/`). Input will always be between `0` and `542` inclusive # Data The possible outp...
[Question] [ This is a CMC (chat mini challenge) that I posted in our chatroom, [The Ninteenth Byte](http://chat.stackexchange.com/rooms/240/the-nineteenth-byte), a bit ago. ### The Challenge Given a positive integer `x`, depending on the last 2 bits of `x`, do the following: ``` x & 3 == 0: 0 x & 3 == 1: x + x x &...
[Question] [ Given a string, character list, byte stream, sequence… which is both valid UTF-8 and valid Windows-1252 (most languages will probably want to take a normal UTF-8 string), [convert it](https://en.wikipedia.org/wiki/Mojibake "Mojibake - Wikipedia") from (that is, *pretend* it is) [Windows-1252](https://e...
[Question] [ ### Introduction It's 2600 BC and people are building pyramids now. They already made the basis of the pyramid but don't know how to continue. So, they called you for help. The rules of making a pyramid is quite simple. For the layer above the previous layer, all you need to do is follow this step-by-s...
[Question] [ The [Cheela](http://aliens.wikia.com/wiki/Cheela) (from the book [*Dragon's Egg*](https://en.wikipedia.org/wiki/Dragon%27s_Egg) by Robert L. Forward) are creatures that live on the surface of a neutron star. Their body is flat and circular with twelve eyes on the perimeter, so they naturally use a base...
[Question] [ ## Challenge Given a positive integer \$N\$, repeat each of its digits \$d\_1, d\_2, d\_3, \cdots, d\_n\$ a number of times corresponding to its position in \$N\$. In other words, each digit \$d\_k\$ should be repeated \$k\$ times (for each \$1\le k\le n\$, 1-indexed), thus creating the new number: $$\...
[Question] [ Although [related](https://codegolf.stackexchange.com/questions/2958/check-if-number-is-a-sum-of-consecutive-numbers-or-not) [challenges](https://codegolf.stackexchange.com/questions/66193/sums-of-consecutive-integers) have been asked, this one is different to warrant its own question. --- # Challenge ...
[Question] [ [3var](http://esolangs.org/wiki/3var) is a variant of [deadfish](http://esolangs.org/wiki/deadfish) which uses three variables called A, B and R. A and B are accumulators, while R is used as a result variable. In this [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challeng...
[Question] [ You will be given a string `s`. It is guaranteed that the string has equal and at least one `[`s and `]`s. It is also guaranteed that the brackets are balanced. The string can also have other characters. The objective is to output/return a list of tuples or a list of lists containing indices of each `[...
[Question] [ # Divinacci ([OEIS](https://oeis.org/A000458)) **Perform the Fibonacci sequence but instead of using:** ``` f(n) = f(n-1)+f(n-2) ``` **Use:** ``` f(n) = sum(divisors(f(n-1))) + sum(divisors(f(n-2))) ``` For an input of `n`, output the nth term, your program should only have 1 input. --- **First 14 term...
[Question] [ # Prime Wednesdays Your task is to count the number of Wednesdays that fall on a prime day of the month in a particular year. For instance, `7-13-16` is a prime Wednesday. For consistency use the [Gregorian calendar](https://en.wikipedia.org/wiki/Gregorian_calendar) for all dates. ## Input The input to...
[Question] [ In this challenge you will be converting a mixed number to an improper fraction. Because improper fractions use fewer numbers, your code will need to be as short as possible. --- ## Examples ``` 4 1/2 9/2 12 2/4 50/4 0 0/2 0/2 11 23/44 507/44 ``` ## Specification You may assume the denominator of the i...
[Question] [ Given a number *N*, output/return ***X* so that *N+X* is a palindrome, where *|X|* has to be as small as possible.** **Palindrome:** A number is a palindrome, if its sequence of digits is the same when reading them from left to right as when reading from right to left. `95359` and `6548456` are symm...