# What is the Sandbox?

This "Sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to the main page. This is useful because writing a clear and fully specified challenge on the first try can be difficult. There is a much better chance of your challenge being well received if you post it in the Sandbox first.

See the Sandbox FAQ for more information on how to use the Sandbox.

## Get the Sandbox Viewer to view the sandbox more easily

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

Output a number $$\n\$$ such that:

1. $$\n\text{mod}10=5\$$
2. $$\n^2\text{mod}10^{10000}=n\$$

Shortest code win. You should be able to try it rather than purely know it work.

Sandbox mainly to check duplication

• Wouldn't this be easy to just hardcode the number? – Jo King Dec 13 '18 at 13:22
• @JoKing We must have $n^2\ge 10^{10000}$, so $n\ge 10^{5000}$ which if naively hardcoded takes $5000 \log_2{10}$ bits. – user202729 Dec 13 '18 at 14:24
• However, we already have modular multiplicative inverse challenge, I expect most answers to be very similar. – user202729 Dec 13 '18 at 14:42
• @user202729 It's likely that you'll get 1 in that way or be too slow so I need time requirement – l4m2 Dec 13 '18 at 15:00
• @l4m2 Most solutions there use extended Euclid algorithm so they will not be too slow... – user202729 Dec 13 '18 at 15:06
• @user202729 So they'll get 1 – l4m2 Dec 13 '18 at 15:22
• Get 1 what? The correct answer is 810...90625. – user202729 Dec 13 '18 at 15:31
• Will how many languages use this? – l4m2 Dec 13 '18 at 15:57

# Integer or decimal to array and array to decimal or integer

Write two functions

1) Convert an integer or decimal to array of integers that potentially includes a single decimal

2) Convert array including integers and potentially a single decimal to integer or decimal

## Input

Integer or decimal to array

• An integer or decimal

Array to integer or decimal

• An array

## Output

Integer or decimal to array

• An array containing each digit of the input at an individual index with the first decimal portion of input containing the decimal character.

Array to integer or decimal

• An integer or decimal equal to input

# Specification

When the first digit of a decimal is a 0 , and a digit follows, that value includes all 0's up to and including the last digit of that decimal, else the decimal portion is spread or expanded to the remainder of the decimal portion for the remainder of indexes of the array, that is: -0.01 <-> [-0.01], 100.01 <-> [1,0,0,0.01], 100.0001 <-> [1,0,0,0.0001]

# Test cases

Input <----------> Output

-123               [-1,-2,-3]
4.4                [4,0.4]
44.44              [4,4,0.4,4]
-0.01              [-0.01]
123                [1,2,3]
200                [2,0,0]
2.718281828459     [2,0.7,1,8,2,8,1,8,2,8,4,5,8,9]
321.7000000001     [3,2,1,0.7,0,0,0,0,0,0,0,0,1]
809.56             [8,0,9,0.5,6]
1.61803398874989   [1,0.6,1,8,0,3,3,9,8,8,7,4,9,8,9]
1.999              [1,0.9,9,9]
100.01             [1,0,0,0.01]
545454.45          [5,4,5,4,5,4,0.4,5]
-7                 [-7]
-83.782            [-8,-3,-0.7,-8,-2]
1.5                [1,0.5]
100.0001           [1,0,0,0.0001]


# Winning criteria

Least amount of total (each of function or programs 1 and 2) bytes used.

code-golf

• 1) What should output be for test cases 0, 200, and 1.0015? 2) I would suggest a more descriptive title. 3) Bonuses are generally discouraged in code golf, so make sure they add something to this challenge. – lirtosiast Dec 18 '18 at 23:43
• The string method thing is very iffy. Won't a print function in any language be converting a number/list of numbers to a string? – Jo King Dec 19 '18 at 0:16
• @lirtosiast [0], [200], [1,0.001,5]. What title do you suggest? Not using string methods does add something to the challenge. – guest271314 Dec 19 '18 at 0:47
• @JoKing Not sure what you mean by a print function converting a number or list to a string? If JavaScript is used it means not using , '', String, template literal, RegExp.prototype.match(), etc. to create or convert the input to output or add, subtract, divide, multiply, manipulate arrays are what is meant, not print(output) or console.log(output). A user is not obligated to try for the bonus in their answer. – guest271314 Dec 19 '18 at 0:49
• @guest271314 The challenge is not clear to me: why is 200 [200] but 100.01 [1,0,0,.01]? Maybe a worked-through example in the question as well as a reference implementation would help. For a title "Modified decimal expansion of a number" is a start. – lirtosiast Dec 19 '18 at 0:57
• @guest271314 Some languages have builtins for the digits of an integer or float e.g. Mathematica RealDigits[3.14159] = [{3,1,4,1,5,9},1] . Do those count as string methods? – lirtosiast Dec 19 '18 at 0:59
• @lirtosiast 200 does not contain a decimal, 100.01 contains a decimal. The reference implementation is at the question. Created the requirement from scratch while attempting to solve another inquiry. Does Mathematica have a method to check if a value is a string, integer or decimal? – guest271314 Dec 19 '18 at 1:03
• I don't see any reference implementation. It might be better if you explicitly listed the rules behind the transformation – Jo King Dec 19 '18 at 1:05
• @JoKing See "Test cases". That goes back to whether to post the question here or at Software Engineering. The question does not ask users to write an entire specification (frequently edited; maintained; an entire process in and of itself). Observing the test cases: when the first digit of a decimal is a 0 , and a digit follows, that value includes all 0's up to and including the last digit of that decimal, else the decimal portion is spread or expanded to the remainder of the decimal portion for the remainder of indexes of the array, that is: [-0.01], [1,0,0,0.01], [1,0,0,0.0001]. – guest271314 Dec 19 '18 at 1:09
• Right, you should include those rules in the question, along with what happens when the input is an integer and/or ends in zero. I'm not sure what you'd achieve by posting on Software Engineering because I doubt any form of this question would be on-topic. – Jo King Dec 19 '18 at 1:22
• Also, the specification should be given as a specification, not as a set of test cases to reverse-engineer. – Peter Taylor Dec 19 '18 at 9:42
• "The specification ... is WIP." That's fine: that's what the sandbox is for. I'm trying to identify things which need addressing before the question leaves the sandbox. "A users' answer could redefine the specification, in a good way" This is completely against the ethos of this site. All users should implement the same specification, because otherwise it's not a fair contest. – Peter Taylor Dec 19 '18 at 14:56
• I'm guessing he means move the specification from below the test cases to the task section and remove the Observing the test cases part. And perhaps make it a bit clearer, for example giving us the inputs that led to [-0.01], [1,0,0,0.01], [1,0,0,0.0001] rather than having them in isolation. – Jo King Dec 20 '18 at 5:36
• Specifically? Nothing is clear to me. Try reading through the spec yourself without the test cases and forgetting that you already know in your head how everything should work - is it clear to you? As for a solution to making it clearer: start by having a look through the specs of recent, well-received challenges and note the detail they go into about what is expected of solutions and what is & isn't allowed. Then rewrite your own spec in a similar manner so there's no (or very little) room for doubt or confusion. (1/2) – Shaggy Dec 20 '18 at 19:11
• Ah, I didn't realise you'd deleted the bounty post. I think you misunderstood what I meant when I commented. I was just clarifying that if an answer were to be posted, the 500 rep would come from me, though you could add some rep if you wanted. There was no censorship of your post and I'm not sure why you deleted it. Typically on PPCG, we post the bounties after a valid answer has been posted, in order to make sure the rep doesn't go to waste, especially if the task is very hard or possibly impossible – Jo King Feb 19 '19 at 10:37

# Introduction

The original creator of this meme has gone blind, lost his internet and accidentally deleted all his memes. Except this one. He has this one last meme on his desktop, and since he can't see, he wants to know what this meme is.

By hearing it.

# Challenge

Your challenge is to write the shortest program that will produce a playable audio file that the meme creator will play to hear the text in this meme.

• The input is the meme below
• The output will be a audio file that reads the output text in English and has a slight pause after a colon or a new line. But don't read out 'colon'

• You can use any programming language
• You can use any existing library
• Output audio must be playable by vlc
• Networking is not allowed, you cannot connect to any internet services

# Input and Output

Input:

Output:

Me: spends 8 hours per day on the internet

Eyesight: gets worse

me:

• The output would always be hardcoded, so there's no point in the input – Jo King Mar 8 '19 at 9:43
• This challenge would be nice with different memes as test cases. Otherwise it would be hardcoded as said previously. – Belhenix Mar 20 '19 at 19:35

# Compress briefly

Compress and decompress the first chapter of Worm, beginning with the opening words "Class ended" and ending with the closing words "my best friend." (including the period). You do not need to include any of the formatting (copy and paste as plain text).

## Rules

• You may not use any built-in or imported compression functions or procedures. You must implement the compression yourself.

• You may either write one program to compress and another to decompress, or one program that does both. If you wish, the second option can be a polyglot, where compiling as one language compresses and compiling as the other decompresses.

• Your program must be no more than 2000 bytes long. You may, at your option, compress your program with bzip2 or gzip before measuring its size for the purpose of meeting this limit.

• Your program does not need to work for any other text.

• Standard loopholes apply.

• Standard I/O rules apply.

## Scoring

• The score is the sum of the total number of bytes of your program(s) and the total number of bytes in the compressed text.

• If you use a single program to compress and decompress, then you may have to pay a penalty. Specifically, you must pay a number of bytes equal to the Levenshtein distance between the shell command needed to (compile and) run your compression program and the one needed to run your decompression program. You can calculate this online. A special exception: if you choose to write a polyglot, then you can leave out the paths to the compilers/interpreters when you calculate the penalty.

Tags: code-challenge, compression

• Related – Beefster Mar 19 '19 at 22:31
• @Beefster, a bit, but I think there are enough differences to make competitive answers largely incompatible. – dfeuer Mar 19 '19 at 22:36
• I don't think any answers are going to outperform gzip/bzip/whatever. There's no obvious patterns to exploit in the text. – Beefster Mar 19 '19 at 22:37
• Also: how is this different from kolmogorov-complexity? – Beefster Mar 19 '19 at 22:38
• @Beefster, it's different because I don't allow the code to be big enough to have much chance of encoding the text in it. It doesn't have to outperform industrial-strength algorithms. That mention had to do with the source code size limit, intended to give extremely verbose languages the opportunity to participate. – dfeuer Mar 20 '19 at 0:28
• Every answer will be some variant of import gzip; gzip.compress(story) – Beefster Mar 20 '19 at 16:21
• @Beefster, is my explicit prohibition of that insufficient? My first rule is that you can't use a built-in or imported compression function. – dfeuer Mar 20 '19 at 16:42
• That sounds a lot more interesting than it actually is. There's a reason "do X without Y" questions have fallen out of favor. Compression challenges are hard to write. At the very least, you need some exploitable pattern common to a class of strings. This simply isn't the case in the linked text. – Beefster Mar 20 '19 at 19:29
• Even without using built-ins the best answer will use some variant of Huffman coding that fits in 2000 bytes. LZ77 is also pretty easy to implement and works well on text. – Beefster Mar 20 '19 at 19:44

# Output an alphabet suite

A successor to the ŋarâþ crîþ alphabet challenge.

Outputting the alphabet song with as few letters as possible was too easy, but what about outputting many of them?

Your challenge is to write as many programs as you can, with no two programs sharing any Unicode codepoints, and each program outputting the names of the letters of the alphabet (or the glyphs of some other kind of phonetic script) used by a different language. For instance, one program can output

a bee cee dee e eff gee aitch i jay kay el em en o pee cue ar ess tee u vee double-u ex wye zed


and another program can output

a be ce de e efe ge hache i jota ka ele eme ene eñe o pe cu erre ese te u uve uve doble equis ye zeta


Notes:

• For a given language, there will probably be some leeway in what you can output.
• Unlike in the previous challenge, you don't need to worry about any particular punctuation. You should at least separate each letter name with whitespace.
• You must output the names of the letters, not the letters themselves (so A B C... is invalid), unless the letters are literally pronounced so in the language in question.
• If a language uses both capital and lowercase letters, then you may output the letter names in either case. If it uses only one of them, then you must output the alphabet in that case.
• You must use a different language's alphabet for each program, but you are allowed to use the same script in the context of different languages.
• Constructed languages are allowed, as long as they predate the challenge.
• You may use different programming languages for each program. Or the same.
• Standard loopholes are forbidden.

TODO:

• is the requirement against sharing any codepoints too strict?
• I haven't downvoted you, but suspect that the major reason that you're getting downvoted is that it's totally unclear what outputs are valid or not, and skimming the edges of that is where most of the byte savings are going to come from in a code-golf. That said, I don't think this is code golf, despite having the tag. You'll probably find that, when any golfing aspect is removed, the strings to print are more or less irrelevant, so you might as well use a fixed, objective set of strings instead of the ones you have. – ais523's temporary account May 13 '19 at 16:24

# add two numbers in string representation

### Idea:

Given two strings representing non-negative integers in base 10, return the string corresponding to their sum - without any explicit arithmetic operations. This means you have to implement incrementing (probably with a lookup and indexing) and carrying (probably with iteration or recursion) on your own. Comparisons and boolean operations are allowed.

### Examples:

"1" + "1" = "2"
"5" + "6" = "11"
"0" + "8" = "8"


### I/O:

Write a function or program which takes the two strings in a way you want to.
Output, print or return the solution in whatever way you want.

Ah, and also don't forget that this is code-golf, so shortest answer in bytes will win. Also, all standard loophole rules and so on apply (you should know from all the other challenges!)

# Sandbox

This challenge changed, evolved and got compressed during discussion with Adám starting from here (feel free to review the edits and chat of this post on how we got here)

### Tags for cgcc post:

• This is still "Do X without Y", and Y is not always clear-cut. What counts as an "explicit arithmetic operation" in lambda calculus? – Peter Taylor Jul 25 '19 at 15:22
• @PeterTaylor my english is not the best in the world and also i am not a pro in thins like loopholes or coding terminus around maths. you have any idea how to propose this or what kind of operations to prohibit? I would just come up with explicite "+" "-" "*" and "/" operations directly on the string representations (also to exklude languages which can handle interpreting strings as numbers). But are there furter operations I forget? – pixma140 Jul 26 '19 at 5:43
• I don't think it can be fixed. – Peter Taylor Jul 26 '19 at 5:53
• I agree this can't be defined objectively. The only way I can see this working is if the output was required to include the steps of calculation so that it's no longer an non-observable requirement. That would probably involve specifying a particular approach to implement though. I can't guess whether such a restriction would make the challenge interesting, but I suspect it would not. – trichoplax Jul 28 '19 at 18:58
• Guess then I will better not post this question outside of the sandbox.. But thanks to you all so far! :) – pixma140 Jul 29 '19 at 5:41

The goal is to make a program that is compilable in as many languages as possible.

• The program must be compilable with a specific compiler version and compiler parameters without any errors.
• The program may result in an error when run.
• The source code must not be empty or whitespace.
• This is somewhat similar in spirit but not the same. This probably is a duplicate of something, strictly or less so, but that's the first thing that came to mind – Unrelated String Aug 27 '19 at 7:48
• A null program is compilable in most(if not all) languages. (Including specific compilers of C(in IOCCC).) – user85052 Aug 27 '19 at 10:15
• @A_ I've added an additional rule. – user11909 Aug 27 '19 at 10:58
• As-is, this will be closed as Too Broad, since there's no "thing" for the program to do. Have a look at the polyglot tag and see what others have done. – AdmBorkBork Aug 27 '19 at 14:25
• Define "compile". – pppery Aug 28 '19 at 23:23

Writing a WebCrawler

Challenge

Design a web crawler that recursively extracts all the hyperlinks from the HTML of the web page and does the same for every hyperlinked page it finds. The webcrawler must store the hyperlinks in a separate file

How The WebCrawler Works

First the webcrawler should download the HTML file of the URL the user inputted.

Second the webcrawler will copy every single hyperlink embedded in the hyperlink and paste it into an output text file. The best general way to do this based on my experience is to have the webcrawler iteratively search through the HTML file for an "a href" tag. Be careful about what kind of hyperlinks are embedded in those tags. Sometimes only the subdomain directories of a complete hyperlink are embedded in this

For example: https://en.wikipedia.org/wiki/Toyota may simply have an a href tag in the HTML file of a webpage as: "/wiki/Toyota"

After extracting all the hyperlinks of the first webpage, visit all the hyperlinks found on the base webpage starting from the the first hyperlink found and repeat all the steps above. The only exception to doing this is obviously if the hyperlink fails to lead to an HTML page.

Input

The program must accept only one URL as input.

Output

A text file that lists every hyperlink that it finds. Note:

Your webcrawler must avoid revisiting webpages it has already crawled. This can cause the crawler get trapped in a "circular link loop" where it continously visits the same pages endlessly.

Note:

Special consideration will be given to submissions that prove they are capable of crawling deep web websites, including those with the .onion sites.

# Output the number of lines of your code

Your task is to write a program that counts the number of its lines of code and outputs them.

Specs:

• The number mustn't be hardcoded into the program, nor in any other external resource;

• Internet access is forbidden;

• Your program's output must be the number of lines only;

• Your program should not use any tool, macro, function, or similar device designed with the specific purpose of counting lines.

$instnm corresponds to the number of the instruction, the count of things displayed, starts from 1. Your program may take an input, and send the data, in any way (except the ones in Rules) to the Reciever. Remember there's no internet. The winner will be the user with shortest bytes of code. # Rules ## As a good code golfer, you may not: • You can't use program arguments to send the data. • It must be an application. • If you apply for the bonus, mind you have to make both programs, if not, just the sender. • The string you have to send it has to be STRICT, no different ones, if not, unvalid answer. (I decided to call that "Strict JASON Protocol", get the joke?) # Bonus You can make the reciever program, and you get -1 byte. Not much, but k. (In bytes, you must not decrement your byte result, you must do: "n Bytes + Bonus") # Example Input and Output ## Input: From Sender program: Dance! or Stop! ## Protocol: Inbetween both commands $displaytext:"Dance!";$instnm:5 ## Output: In Reciever program: Dance! (9) or Stop! (187) # Overall objective: Send data between two programs, without internet connection. Edit: i can't post an example answer, because then i can give ideas of how to do this codegolf/puzzle, while the ideas are limited, i'm finding for the creativity of the user. • I have no idea what you're asking me to do. – Peter Taylor Feb 3 '16 at 21:26 • It is pretty clear what is asking you to, is defined in Task (You must make the shortest (and winner) code possible, that sends data to the reciever, using this protocol), all the story and background is defined on Introduction. I dont see any hole on the post. – TheCrimulo Feb 3 '16 at 22:11 • @TheCrimulo Example answer? – Xwtek Feb 7 '16 at 7:06 • There is no Example, because you are just sending the same info you wrote in. If you type ´Dance!´, the output will be Dance! (n), n being the number of the sequence. The idea isn't to read input, and append (n) to it. You have to make it, in anyway (except command args/internet), dropping out the enoded data (input in the protocol), and, if necessary, make a reciever program, the reciever program its a bonus that discounts 1 byte, also, it can help you making your sender smaller. I can, i.e., make a file with the info on it. As explained, the reciever will read it. – TheCrimulo Feb 7 '16 at 15:54 # Biggest single character This challenge is simple, its like the challenges we've had before where the goal is to produce the biggest output one can. But in this one, you can only use one character in your code. You get no input, your code has to be a single character (not byte), and the person with the largest output in byte wins, ties broken by posting time. • Doesn't this boil down to which language has the biggest output stored in a predefined variable? – Denker Apr 3 '16 at 20:50 • @DenkerAffe true. maybe i should make it 2 byte src code. that might allow some interesting stuff – Maltysen Apr 3 '16 at 20:52 • I think I would raise the char amount a bit more to allow for some competition between the same language. Also you should keep in mind that this rules out every non-golfing language. While this should be allowed per meta consensus, I am not sure how much the community likes this. – Denker Apr 3 '16 at 20:58 • G for pyth wins :D :D – Leaky Nun Apr 4 '16 at 4:45 • Befunge & co. would probably win via infinite output. If output has to be finite though, I wouldn't consider this a very interesting challenge since it would just be one big language hunt. – Sp3000 Apr 4 '16 at 10:27 • Actually, N in Seriously wins. 11752 bytes output. – Mego Apr 6 '16 at 4:06 • @Mego Vitsy wins. 0 bytes, 11752 bytes of output. – Addison Crump Apr 7 '16 at 17:07 # The FitnessGram™ Code Golf Test Same concept and rules to the well-known Rick Astley post a while back, only instead of using samples of various sizes, sample length is limited to what number sample it is. And different text for the program to write. It's code golf, so standard loopholes apply, and fewest bytes wins. • Closed as a dupe. And/or unclear. – Rɪᴋᴇʀ May 19 '16 at 20:04 • Paragraphs of text are boring for compression. Unless there's some particular structure in the text, the same techniques apply to all of them. – xnor May 19 '16 at 20:07 • First off, thank you for using the Sandbox before posting on main. That said, I don't understand what your challenge is supposed to be: what is the sample length? What is a sample? In addition to that, if this challenge winds up being "print some fixed string" then it is a duplicate of the rick astley post, as the techniques used for compression will be identical. – FryAmTheEggman May 19 '16 at 20:09 • we want to give them a challenge, not a flashback.... – user56309 Aug 4 '16 at 19:42 • This sandbox post has had little activity in a while and little positive reception from the community. Please improve / edit it or delete it to help us clean up the sandbox. – programmer5000 Jun 9 '17 at 14:12 # Obfuscate your program In this challenge, you must create a program which does something but you need to obfuscate it so that it becomes hard to understand (so don't explain it in your post). It can accept anything as input and output anything. Score The shorter program (in bytes) which hasn't been understood wins. Example Can you guess what does this code calculate? var t=1e5,s=t/1e4,n=s*0.1,i=n*s*7.5,r=!true,b=1,t='01'.split('').map(c=>parseInt(c)).concat(Array(i).join('.').split('.').map(m=>{a=r+b;(r=b)&&(b=a);return a})),t=t.join('').length,b=s,t=r,s=4+NaN;  Rules • You should say what language you used • You must not use any obfuscation tool • At a minimum, you should state an actual objective: "obfuscate a program that does x". Otherwise it's just too broad and will likely be closed as such. You'll also need something else to explain the scoring, since "shortest that isn't understood" seems odd to me. Understood when? How do you show that it hasn't been understood? Do you mean something like Cops and Robbers?. – Geobits Jun 4 '16 at 19:06 • This sandbox post has had little activity in a while and little positive reception from the community. Please improve / edit it or delete it to help us clean up the sandbox. – programmer5000 Jun 9 '17 at 14:12 ## "01_firstHole" Challenge for Performance Golf First there was code golf. Now, there is Performance Golf. FORE! ## Motivations This is a crowd-sourced approach to easier and better performance troubleshooting. Performance problems are everywhere, so java technicians need access to easy-to-use diagnostic tools at every step of the SDLC. ## How to play? 1. Start by installing the live demonstrations of Java Performance Problems in this repo. 2. Pick one of the six holes of golf to play. You can do this by picking one of the six numbered folders in the repo. This particular codegolf.stackexchange.com challenge is for the 01_firstHole. 3. One at a time, run the 'a' load test and the 'b' load test for the hole you selected. The a & b tests are two different implementations of the same REST/SOA service. See the 'installing' link, above, for how to run the tests. 4. Compare the performance of the two tests, a & b. Which has better response time / throughput? 5. Using the least amount of tooling/instrumentation, identify the performance problem of the slower test. Hook it up your self and run the tests. 6. At codegolf.stackexchange.com, there is one "Stack Exchange Challenge" for each hole of golf. Post the following two things for your solution to that challenge: • Post a description of the tools/techniques you used to detect the performance problem. Must be detailed enough so that others can reproduce your work. Performance golf always compares two different loads -- a & b. The solution must identify the inefficient code in the slower of the two examples. It must also show the absence of that inefficient processing in the faster of the two examples. • Tally the number of strokes for your approach, using the "Scorecard" below. All solutions must specify the # of strokes incurred, and it must be specified in the answer heading/title. 7. Upvote the solutions that best identify the performance problem and have the fewest strokes (see Scorecard, below). Similar solutions on different platforms (Mac/Linux/MS-Win) deserve roughly the same number of upvotes. ## Scorecard This scorecard determines the approach with the least amount of tooling/instrumentation. Lowest score wins! • 1 stroke if JVM restart is required to hook up your monitoring tool of choice. • 1 stroke for any tool with any$\$ licensing cost.
• 1 stroke for every separate install process. No strokes for JVM and pre-installed OS tools.
• 1 stroke for tools/techniques specific to a particular Database vendor. Ex: Oracle AWR report. Even ‘EXPLAIN PLAN’ solutions are proprietary.

## Example One -- zero strokes :-D

This example does not use this github repo, but it will give you the general idea.

This solution to solving a high CPU problem would get lowest=best instrumentatin score: zero strokes. Only JVM and OS tools are used (thread dump and top -H). There are no tool license costs and a JVM restart was not required for the thread dump.

## Example Two -- 3 strokes :-(

This example also does not use this github repo, but it will give you the general idea of what we mean by the best troubleshooting with the least tooling/instrumentation.

A modern, commercial profiler (YourKit, JProfiler, etc...) would easily solve the high CPU problem in example 1. But look how many strokes (1+1+1=4!) are taken off with this approach: * 1 stroke because a JVM restart is required to hook up the tool * 1 stroke because there are licensing costs. * 1 stroke to install profiling the tool

• Answers in this site normally involve writing code, so this doesn't really appear to be on topic. – feersum Jun 16 '16 at 7:43
• Thanks for using the sandbox! I do however, see some problems with this challenge. For one, I think you would need to clarify a lot of the stroke criteria, as something like "rarely used" is pretty subjective. In addition, there doesn't seem to be a way to enforce a person to not use a high level tool, and then after figuring out the problem finding it again with a more basic tool. Even further, why couldn't someone look at another answer and then reuse their data to get a better score? cont... – FryAmTheEggman Jun 16 '16 at 13:22
• After all that, there doesn't seem to be an objective winning criterion, unless it is number of strokes. If number of strokes determines the winner, then won't there be many ties? I think you would need something more granular. – FryAmTheEggman Jun 16 '16 at 13:24
• Sounds like I need to work on the "rarely used" part mentioned by @FryAmTheEggMan. Regarding the same commenter's comments about the high-level tool and the basic tool. That is part of the natural progression of monitoring. We learn to do it one way, then we learn a better, less intrusive, less expensive way. As long as the user of the basic tool is "detailed enough so that others can reproduce your work", who cares how much refinement was involved? – Erik Ostermueller Jun 16 '16 at 22:45
• Regarding @FryAmTheEggman's question of "many ties". I look at auction sites like eBay as reasonable crowd-sourced arbiters of value of a given object for sale. I was hoping the voters would provide that kind of assessment, but I see where lack of objectivity could cause cronyism and perhaps other problems. Could someone point me to codegolf tolerance/lack of for ties? I'll try to work on that. – Erik Ostermueller Jun 16 '16 at 22:48
• @FryAmTheEggman, you mentioned that my "rarely used" criteria was pretty subjective. That's a good call, so just edited / removed that. – Erik Ostermueller Jun 18 '16 at 21:36
• @FryAmTheEggman, the "many ties" concern could also looked at from a different perspective -- that Performance Golf will provide a very useful "catalog" of answers. This "catalog" concept got 18 upvotes here. – Erik Ostermueller Jun 18 '16 at 21:43
• The catalogue concept is a failed experiment, and your mention of it is one of the reason why. "It's a catalogue question" should not be used to justify why a question should be closed even though it's off-topic and wouldn't have an effective scoring mechanism even if it were on-topic. – Peter Taylor Jun 19 '16 at 13:31

# Open the browser, polyglot edition. polyglotcode-challenge

Your job is to open a browser window of the default browser to https://codegolf.stackexchange.com in as many languages as possible.

Your code must open the browser itself, and cannot rely on an open one.

## Rules

• Versions of the same language are considered a single language
• Define "default browser" in the context of non-Windows OSes. – Peter Taylor Sep 25 '16 at 21:47
• @PeterTaylor Whatever browser the open command works with. There was a previous version of this challenge, it worked then. – noɥʇʎԀʎzɐɹƆ Sep 25 '16 at 22:24

Inspired by the paper calculator episode of Numberphile.

Your challenge in this puzzle is to take in two two-bit (0-3) numbers and output the sum of the two numbers... using ordinary household objects.

Some possibilities of how this can be done:
Dominoes
Paper
Marbles
music box (+ some helpers..)

## Input:

input must always be involving two sets of two-bit integers, which can be represented by anything you like, so long as the cardinality of the representations is the same.

## Output:

The output should be a single 3-bit integer which represents the addition of the two inputs.

## Rules:

• your device cannot have the capability to connect to the internet in any way (sorry, this also disqualifies carrier pigeons). Your device must also not be able to perform this function alone (eg a calculator).
• It must be somewhat original. put your own twist on it!
• Pictures are required for each entry to show how it works. videos would be better, but aren't required!
• The sole function of your machine does not have to be adding, it can do other things as well. This means that older projects that may serve a slightly different function are welcome, so long as they meet the rules stated above.
• Your device can be as simple or as complex as you like, so long as it doesn't get to a point where it's completely esoteric.

## Judging:

You will be judged based on ease of use, ease of understanding, as well as originality! This means that entries should be easily explained, used, and be unique in some way.

This is a , so the most upvotes wins! good luck!

• In my opinion, this is not a programming challenge. Once we start leaving the realm of a computer-based programming paradigm, a challenge becomes more difficult to test, replicate, and verify. Plus, something done with Dominoes, for example, may not "run" to completion 100% of the time, and in my opinion that makes it non-deterministic. – mbomb007 Sep 26 '16 at 18:43
• Related meta: meta.codegolf.stackexchange.com/a/10151/34718. TLDR, if you want to program with dominoes, find or create a domino simulator where programs can be scored in bytes. Instead of marbles, use Marbelous. – mbomb007 Sep 26 '16 at 18:52
• @mbomb007 what about papers, and counting dogs? This isn't a code golf, it's a popularity contest – user56309 Sep 26 '16 at 19:20
• Popcons still require the use of programming languages. meta.codegolf.stackexchange.com/q/2028/34718. See both linked meta questions. What you are trying to do is off-topic for this site. – mbomb007 Sep 26 '16 at 19:42
• @mbomb007 I'm not sure you linked the correct thing. I have found no reference of popularity contests in your recent link.. – user56309 Sep 26 '16 at 19:44
• Rules and meta consensus apply to all challenges, not just code-golf. – mbomb007 Sep 26 '16 at 20:21
• Popcons should be held to a higher standard than other questions, not a lower one as your comments imply. – Peter Taylor Sep 27 '16 at 7:33

I believe that each language has a score. The way you find the score of a language is shown in the ungolfed Python program below

def scorer(lang):

num = 0

for i in str(lang):
num += ord(i)

return num


Basically the score is the total of the unicode values of the language name.

Now this seemed like a fairly trivial challange, so I thought I'd make it a bit more difficult. You aren't allowed to use your language name (case-sensitive) in the code. So this code in C++ would be invalid as I've used C++ in the code.

#include <iostream>

int main() {

int total = 0;
std::string s("C++");

for (char & c : s) {
total = total + (int)c;
c = '*';
}

std::cout << total;

}


Although this does output the required number (153) it is still invalid.

# Rules

• You aren't allowed to use the language name but are allowed to use it in a different case. E.g. Java isn't allowed but java is.
• This is a code-golf so shortest answer in bytes wins
• You are allowed to use hex/octal codes in strings e.g \150 can be used instead of h
• Your program must take no input or function arguments
• You cannot simply output the score. Theoretically the program should work for any language name when changed.
• Languages where the only valid syntax is the name, such as Chicken are allowed to use said name.
• Version shouldn't be included so Python is always Python not Python 2 or 3
• The score is the value of the case-sensitive name

# Correct Scores

Language              Score

ArnoldC                675
brainfuck              949
C                       67
C++                    153
Java                   386
Lua                    290
Mornington Crescent   1922
Python                 642
TrumpScript           1165
Vim                    300


## Sandbox Questions

1) Why has this been downvoted?

2) I am thinking about putting a reputation limitation so that bosses like Dennis and Martin Büttner can't take answers from people who aren't as accomplished. Is this unfair? Should I not?

3) Is this a duplicate? I couldn't believe it wasn't already taken.

• Terms like "you cannot use your language name" and "it must be calculated by the program" are not only unclear but will likely not be able to be made rigorous. – Ad Hoc Garf Hunter Feb 5 '17 at 14:58
• Are you suggesting that I remove those rules? – user63571 Feb 5 '17 at 15:00
• I don't think that the challenge is very interesting without the rules, but I don't think it is clear with them. I would suggest reworking the rules in some manner but exactly how I do not know. – Ad Hoc Garf Hunter Feb 5 '17 at 15:01
• 1. I would guess that it's mainly because it fails some of the tests in Things to avoid when writing challenges (X without Y, asking for different things in different languages, unnecessary fluff, explicitly disadvantaging certain languages, arguably one or two more), although it might also in part be because some people oppose trivial "challenges", and in part because the problems WW mentioned can't be fixed. 2. Very bad idea. 3. It's a multi-dupe: it combines two trivial tasks, each of which independently would clearly be a duplicate. – Peter Taylor Feb 6 '17 at 9:15

# Goal

Write a program or function in a language of your choice that takes input and outputs that exact input.

# Specifications

• Your program/function should output the exact input in any reasonable way.
• Your program does not have to end after printing the input. It may end up in an infinite loop if you wish, as long as that loop doesn't output any extraneous characters.

# Winner

The winning answer will be the one that has the highest score. Voters should look for answers that use an unique way to print the input, have a special source code or use neat language features.

• Plain "do X in a creative way" popularity contests have fallen out of favour and will likely immediately get closed as being too broad or not having an objective winning criterion. – Martin Ender Apr 4 '17 at 18:33
• @MartinEnder: Yeah, I noticed. How do you think I should change the challenge so that it won't be closed? – Luke Apr 4 '17 at 18:35
• Can't really help you there. If I knew of a good way to make popularity contests work, I'd write some myself. ;) – Martin Ender Apr 4 '17 at 18:39
• Probably a duplicate of codegolf.stackexchange.com/q/62230/34718 – mbomb007 Apr 4 '17 at 18:43
• @mbomb007: No, this is not a code-golf challenge. – Luke Apr 4 '17 at 18:54

This is Code-Golf, Shortest answer wins.

Standard loopholes are forbidden.

• you can't say that answer doing something "would be good" if the shortest answer wins – Destructible Lemon Apr 18 '17 at 7:05
• underhanded challenges are off-topic. – Erik the Outgolfer Apr 18 '17 at 8:36
• It's not underhanded. – Feldspar15523 Apr 18 '17 at 14:15
• I'm sure this might be a dupe of an obfuscation challenge – Beta Decay Apr 18 '17 at 23:36

Of numbers of letters

there is something special the number 4. When spelled in English the word 'four' uses exactly 4 letters. I wonder whether there are further such numbers Your task is to identify whether there exist further such numbers and output them in any human readable format. To make this more of a challenge you can do the task in any regional Language of your choice (Say Russian or Portuguese or Spanish or Mandarin or Hindi etc.).

The Best entry will be selected by the most number of such numbers regardless of language used

Best of Luck

## No strings code bowling

I created this challenege idea with @redwolfprograms. In the challenge, you would create the longest program possible (code-bowling) it can do anything, but it cannot:

• Contain any strings, or quotation marks/apostrophes/backticks
• Contain the same alphanumeric byte more than twice
• Conatin the same non alphanumeric byte more than three times
• What is the task we have to solve? Is it really alphanumeric character but non alphanumeric byte? – Dennis Apr 17 '18 at 13:50
• Why do you mix characters and bytes? – user202729 Apr 17 '18 at 14:01
• I feel like there are a lot of languages that would score the maximum (768) by not (strictly speaking) having alphanumeric characters, and then just wrapping everything in a string: "[3x each other byte value]"". – Kamil Drakari Apr 17 '18 at 14:08
• I think you got bytes and characters mixed up. Both should be bytes, and make sure you specify the program can do anything. – Redwolf Programs Apr 17 '18 at 14:26
• People, the point of the sandbox is to add suggestions. This question has been downvoted several times. Why? – Redwolf Programs Apr 17 '18 at 22:39
• @RedwolfPrograms downvotes are a way for people to say that this challenge in the current state shouldn't be posted to main. If the challenge gets changed enough to make it viable and interesting the downvotes will be reverted (or upvotes from other people will outweigh them). – Leo Apr 18 '18 at 1:32
• Maybe this challenge should have a "No strings" rule? – Redwolf Programs Apr 18 '18 at 1:59
• Not being able to use e is not really that much of a big deal. Even in C you can get around it easily. (It would prevent you from returning values from functions, but you could just use pass by reference instead.) So that restriction wouldn't really add much to the challenge. – Nathaniel Apr 18 '18 at 8:35
• Now that strings are forbidden, one could just create a huge variable whose name is all the alphanumeric characters twice. This is the bane of any longes code that... challenge. Consider adding some more interesting restrictions. – Asone Tuhid Apr 18 '18 at 14:35

## Palindromic Programming

In English (And other languages), a palindrome is a word that is the same read backwards. This is your challenge: to build a program that is the same run backwards. For example:

var rav
f4x0 = 0x4f
/racecar/


But one potential problem would be a string, regex, or variable name that is very long. So here's the rule: no variable definitions, variable names, or constant can use more than 10 bytes of text. The program doesn't have to do anything, as long as it just doesn't error and is the same backwards. But here's the catch: It doesn't have to be the same backwards, it just has to run the same. Standard loopholes not allowed, and you're code bowling.

• I'm fairly certain that "Do two programs run the same" is impossible to verify, especially since the program isn't required to actually do anything visible. The stuff about "no variable definitions, variable names, or constant can use more than 10 bytes of text" is also not a very well defined constraint, nor does it forbid the most common type of padding: comments (which are at least as difficult to define). – Kamil Drakari Apr 18 '18 at 18:39
• In Japt, and many other golfing languages I'd assume, it's trivial to construct an endlessly long program that matches all of your current criteria. Altering, the a-s are method calls and constants, neither being longer than 10 bytes: ethproductions.github.io/japt/… – Nit Apr 18 '18 at 18:58
• I think the general challenge idea is interesting, that the program has to be a palindrome, but I think it would work better if there was a specific task the program had to achieve. – Nit Apr 18 '18 at 18:59
• Agreed. It's not enough to have a source-restriction; there needs to be a task to solve. Some direction needs to be given to us. Also, you didn't disallow comments. And even though a single constant is limited in size, it's trivial to add more constants. tio.run/##K6gsycjPM/r/39CaBvD/fwA – mbomb007 Apr 18 '18 at 19:47
• Okay. I'll disallow comments. What would be a good task to accomplish? – Redwolf Programs Apr 18 '18 at 23:51
• @RedwolfPrograms The problem is you are assuming language features. For every restriction you can come up with, I can find a programming language where those restrictions doesn't make sense (and thus make the program arbitrarily long) – user202729 Apr 19 '18 at 1:55
• @user202729 True. However, it could be possible to make the program required to do a certain task, and therefore any random palindromic text wouldn't work? – Redwolf Programs Apr 19 '18 at 2:18
• @RedwolfPrograms It's hard to write a successful code bowling problem (where it's hard for people to get arbitrarily large score) Just try it. – user202729 Apr 19 '18 at 2:32
• @user202729 Hopefully, I'll find something cool, like the "Pristine and Unique Code Bowling" challenge, but better. – Redwolf Programs Apr 19 '18 at 2:34
• Disallowing comments is impossible. Seriously. We've tried so many times. Beyond the fact that different languages have different meanings of "comment": Is a string a comment? A really big number? A really long variable name? All of these can be used as effectively as a comment, and are impossible to nail down. – Nathan Merrill Apr 19 '18 at 2:59
• Fundamentally, code-bowling doesn't work as the "core" of the challenge. What you really need is a challenge that is already about source layout/manipulation, and then fit code-bowling onto it. More of my thoughts – Nathan Merrill Apr 19 '18 at 3:03

[Posted, but reference kept]

Given a function with boolean inputs a1, ..., an and a boolean output, output an array of numbers 0 to n satisfying:

For each item in the truth value, if (from the array you output, we repeatedly remove two adjacent numbers x and y satisfying that, for each integer n between x+0.5 and y+0.5, an=1), we can get an empty result array iff the given function's output is 1. You can assume the result exist.

Sample input:

a[1] a[2] result
0    0    0
0    1    0
1    0    0
1    1    1


Sample output: 0 2

Sample input:

a[1] a[2] result
0    0    0
0    1    1
1    0    1
1    1    1


Sample output: 0 1 2 0 1 2

Sample input:

a[1] a[2] result
0    0    1
0    1    1
1    0    1
1    1    1


Sample output: (empty)

shortest code win, but optimizing running time and result length is encouraged(I won't accept but I may upvote)

• The spec makes absolutely no sense to me. What does it mean to remove a number from a truth table? – Peter Taylor Apr 25 '18 at 12:13
• Still makes no sense. Maybe if you give a detailed worked example I would be able to reverse engineer the spec and propose some changes to the wording. – Peter Taylor Apr 25 '18 at 14:59

Write a function that takes compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.

Static visualization of bubble sort and a gif explanation.

The steps go from left to right. At each stage, an exchange is made. The darkest color has the most value and finds its final place (bottom) first.

## The rules

• The function must take a list of integers that shall be sorted (less than 20 elements)

• The function must print each step of the sort.

• Yes, built-in Bubble sort algorithms are permitted.

• No, you can not assume only positive integers or unique integers.

• It's so the shortest code wins!

## Test cases

input list
5 4 3 1 2
1 2 3 5 4
11 4 2 1 5


## Optional

Add an interpreter so the submission can be tested. It is allowed to write this interpreter yourself for a previously unimplemented language.

Note

It's my first code-golf idea I'm fully open to improving it with more experienced users if I missed something.

This is not a duplicate of Bubble sorting in progress.

Thanks to @Erik the Outgolfer for encouraging me to post my idea in the sandbox.

• Can you add one walked-through example? I.e. show each pass. – Adám Jun 20 '18 at 13:04
• You note it isn't a duplicate of the in-progress bubble sort, but what distinguishes it from Golf me a bubble sort, which was closed as a dupe of that? – Geobits Jun 20 '18 at 13:10
• @Geobits This was not a dup but unclear. – DIDIx13 Jun 20 '18 at 13:12
• Here's my c# non-golfed solution : dotnetfiddle.net/ZFkl5y – DIDIx13 Jun 20 '18 at 14:01
• You claim it's not a duplicate of codegolf.stackexchange.com/q/92753 but you don't adduce any argument to support that claim, and I can't see any significant difference. (The upper limit is a trivial difference IMO). – Peter Taylor Jun 21 '18 at 6:14

Once, I thought of this. Rules:

1: You must make a fractal that looks like the specified thing.

2: One thing per round.

3: Algorithms are rated by two scores: Resemblance and Compactness. The one that gets the highest scores wins!

4: Only I can tell what thing must be made.

5: Only one entry per user. Do not plagiarize.

6: One may code in anything they wish.

7: Have fun!

• Erchh! OK OK Remove the PM stufs. didnt know – Ikura Jul 31 '18 at 0:12
• On this site, winning criteria has to be objectively defined. (by tradition, I have to admit... there is popularity-contest (read the tag info page for more details), but if you really want to make a pop-con, be careful) "Resemblance" is quite... subjective, unless you can define an objective formula. Also, what is a fractal exactly? – user202729 Jul 31 '18 at 4:05
• For example, how many points would I score if I just made the initial fractal look like the image and have it spiral inwards? What is the objective formula of Compactness/Resemblance – Jo King Jul 31 '18 at 6:04
• A fractal is a shape that recurses. It has copies of itself in it. Analyze the Mandelbrot set, you'll see mandelbrots in mandelbrots. What is a pop-con? Sounds like a soda convention. I'd love to go there! JK – Ikura Jul 31 '18 at 14:32
• @user202729, experts are unable to agree on the definition of a fractal. That aside, this looks more like a forum game than a good fit for this site. – Peter Taylor Jul 31 '18 at 14:46
• Oh, popularity? No. No voting. I will work on my formula, with a new parameter: Mandelbrottiness, which is more or less Goldilocks. – Ikura Jul 31 '18 at 14:54
• I attempted doing this on Encyclopedia Spongebobia, then went here. – Ikura Jul 31 '18 at 14:55
• Then maybe a Stack Exchange for off-topic? – Ikura Jul 31 '18 at 14:57
• @Ikura There are no such SE site, because it would generate low-quality content. Try Quora or Reddit... – user202729 Jul 31 '18 at 15:15
• Ergo! Goin' to the Kongregate Off-topic forum! – Ikura Jul 31 '18 at 18:48

This question is a simplified description of the requirement described at Permutations to the nines

Given input integer (minimum) where the first digit is always 1 and the adjacent digits are increasing in value, e.g.,

12

123

1234

12345

with the ability to handle up to the integer

123456789

where the maximum integer is always the input integer in reverse order, e.g.,

21

321

4321

54321

987654321

Return a list (array) of each number between the input minimum and maximum integer which satisfies three conditions

1. the resulting integer list item includes only the individual numbers comprising the input number
2. the resulting integer list item does not contain any duplicate individual digits
3. the resulting integer list item is greater than the preceding integer list item and not greater than a following integer in the list

## Test cases

Valid list items

12 -> [21] // done

123 -> [132,213,231,213,312,321] // done

Invalid list items

12345 -> 12344 // contains duplicate digits in whole number

123456789 -> 13256789 // not the next integer by increasing numeric value order

123456789 -> 987654322 // greater than maximum integer and duplicate digits

## Winning criteria

The algorithm which uses the least amount of operations to compute the complete resulting list of items.

Examples

123 -> 123+5+4=132 // two mathematical computations

123 -> 123+9=132 // one mathematical computation (winning criteria)

(@JoKing suggested fastest-algorithm tag; math and code-challenge tags are also applicable)

• @PeterTaylor Pared down version of the original question. – guest271314 Oct 8 '18 at 18:30
• Am not as yet well-versed in Big-O notation. If the phrase "the least amount of operations to compute the complete resulting list of items" can be translated into Big-O notation, kindly suggest and edit the language used in the question. We are not interested in code length (this is not a code-golf question), but rather, that the code produces the expected result in the fewest, or least amount of total computational operations. – guest271314 Oct 8 '18 at 18:35
• Ok, so if I understand the challenge, you give me a number N. I need to generate a list of numbers between N and M, where M = reverse(N). Each number in the list cannot have duplicate digits, can only consist of digits in N, and must be in strictly increasing order. Is this correct? – Nathan Merrill Oct 8 '18 at 18:52
• Assuming my above comment is correct: 1. Why is 123456789 -> 13256789 invalid, as the maximum is 987654321, which is bigger than 13256789? 2. You need a list of all possible operations. 3. Use the word digit when referring to the individual parts of a number. – Nathan Merrill Oct 8 '18 at 18:57
• @NathanMerrill Yes. Originally included using only the number 9 within the prerequisite criteria, though that inclusion appears to be challenging in itself to explain how the single number 9 can be employed to derive all list items. You are correct about 123456789 -> 13256789 being invalid. Was attempting to include invalid examples and to indicate that 13256789 should not be the next integer in the list following 123456789; the list should be in order from least to greatest integers. Ok, will use the term digit. – guest271314 Oct 8 '18 at 18:57
• Thinking about this more, there's a really simplified way to describe this: You want the all permutations of the digits of N in strictly increasing order. Permutation – Nathan Merrill Oct 8 '18 at 19:09
• @NathanMerrill Yes, that is one way to put it. From perspective here, we are trying to use a number - the indexes of the initial input as a whole number - to generate all lexicographic permutations by using only math and the initial number (the current number) to do so. No loops, swaps, recursion, etc. Which am able to achieve using the code at the linked question, though the approach used there adds 9 to the initial (current) number. The challenge is to reduce the mathematical operations necessary to achieve the result - is at all possible. – guest271314 Oct 8 '18 at 19:12
• I think describing it that way will make this challenge much clearer. Also, to be a fastest-algorithm, you really need to list all possible operations. – Nathan Merrill Oct 8 '18 at 19:13
• @NathanMerrill "I think describing it that way will make this challenge much clearer." Well, did that exhaustively in the linked question - with links to OEIS and previous inquiries which lead to here PPCG for context - which was closed due to "unclear what you are asking" votes codegolf.stackexchange.com/q/173145/31257, codegolf.meta.stackexchange.com/questions/16959. Posted this version of the question as users appear to not gather the original, more detailed question. Is this question codegolf.meta.stackexchange.com/a/16961/31257 clear to you? – guest271314 Oct 8 '18 at 19:15
• No. That question is much too long. I don't think it is the word "Permutation" killing you there, it's everything else. – Nathan Merrill Oct 8 '18 at 19:21
• @NathanMerrill Well, here we are back to square 1. "too long" is a subjective measurement, though have been advised that users actually do have some means to time the "read" of a question, which will more than likely never do, here. This question is the bare minimum, and yet you suggest including more details. Cannot glean every individual users' idea about what is "too long" or does not include enough details. Perhaps somewhere in the middle that am as yet unable to reach. If a user takes the time to read the original question without protesting the length thereof - the details are there. – guest271314 Oct 8 '18 at 19:25
• @NathanMerrill What edits to the original question or this question do you suggest? – guest271314 Oct 8 '18 at 19:26
• All of the close reasons are subjective: "Unclear" is subjective, "Off-topic" is subjective, etc. I can give a full analysis of the other post, but I'd rather focus on this one. My first suggestion is to get rid of most of the requirements in favor of all permutations of the digits of N in strictly increasing order. The second thing you need to do is define what "operation" means. – Nathan Merrill Oct 8 '18 at 19:28
• "The requirement is to add, subtract, divide, multiply, or use other mathematical procedure, the number 9 to the current number to generate the next number" is (a) not anywhere that I can see in the text of the requirements; and (b) an non-observable requirement, as described in the link I posted of things to avoid when asking questions. – Peter Taylor Oct 11 '18 at 7:16
• A requirement is only observable if you can verify it given a black box implementation, so I don't see how any code snippet can demonstrate that it is observable unless it's a test framework which verifies it by black-box testing. – Peter Taylor Oct 11 '18 at 7:30

## All numeric substrings

I like numbers. Really, really, like numbers. If you give me a string with numerals in it, I want to get all the numbers out of it that I can.

A string.

### Output:

Every numeric substring, in any order, but only one of each. Numeric here means anything with Unicode General Category Nd (because I'm no xenophobe).

### I/O

Any reasonable format. But languages that don't allow for multibyte-character I/O should use some numeric or other representation.

### Test cases

(input → one ordering of the correct output)

• 1212 → [1212, 121, 212, 12, 21, 1, 2]
• 123٤٥6 ‪→ [1, 2, 3, ٤,‪ ٥, 6, 12, 23, 3٤,‪ ٤٥,‪ ٥6,‪ 123, 23٤,‪ 3٤٥,‪ ٤٥6,‪ 123٤,‪ 23٤٥,‪ 3٤٥6,‪ 123٤٥,‪ 23٤٥6,‪ 123٤٥6]‪
• 12t45 → [1, 2, 4, 5, 12, 45]
• abc → []
• @JoKing, thanks, done. – msh210 Feb 27 '19 at 5:35
• I am not convinced by this challenge. To me, it essentially boils down to filtering a unicode string on a character-by-character level, followed by generating all substrings of non-split substrings of the original string. Is ‪٥6 supposed to have any semantic meaning or are those simply two unicode characters? – Jonathan Frech Mar 2 '19 at 4:36

# Fastest prime printer up to 500,000,000 with gapes

Write a program that takes no input and prints the first 26,355,867 prime numbers, from 2 to 499,999,993 inclusively. Or in other words, print all the prime numbers smaller the 500,000,000.

The fastest code wins!

Since it will take a long time to print all the numbers, print only every 26355 primes starting with 2 separated by a new line. So the output should look like this:

2
304417
648391
1007681
1376449
1752323
2133689
2520983
2910797
3304633
3702269


The output should not be hardcoded, or there is no fun in it.

The results will be tested on my machine, so please also output in the last line how long it took to run the program and give me some instructions about how to run it locally. I will then share the last line output with you that should contain the time it took to run.

Here is my machine system specs, note that it's Windows.

• Can be trivially hard coded. – user202729 Aug 4 at 2:06
• Also it's going to be nearly instantaneous, and might be duplicate of some existing (not sure about this part) – user202729 Aug 4 at 2:07
• tnx @user202729, I edited the question – Ilya Gazman Aug 4 at 2:17
• A [kolmogorov-complexity] challenge won't work as [fastest-code]. The fastest solution will be a huge puts in C or C++. "The output should not be hardcoded" is not objective (for example, what stops me from storing 2p for each prime in the output?). – my pronoun is monicareinstate Aug 4 at 2:46
• @mypronounismonicareinstate how about asking for the code size to be smaller than the output size? So such methods would not be possible? – Ilya Gazman Aug 4 at 2:54
• @IlyaGazman okay, then I can do something like that but with the numbers stored in binary, or computed at compilation time. – my pronoun is monicareinstate Aug 4 at 2:58
• Ok, how about that I ask your program or a library your program is using to have a code that checks for prime numbers? Something like: "You program can only print numbers that it tested to be primes" – Ilya Gazman Aug 4 at 3:15
• Okay, then my program can also run a primality test on them before printing. I also wonder if the sieve of Eratosthenes counts. This requirement is unobservable. – my pronoun is monicareinstate Aug 4 at 5:11
• Is the idea of doing every k'th prime that programs would otherwise be limited on time printing for all the primes rather than computing them? – xnor Aug 4 at 8:02
• @xnor printing 26 million primes take a ridiculously long time – Ilya Gazman Aug 4 at 10:36
• Another issue is that the run time is so fast (the C++ sieve answer (I think) takes only less than a second to run) that it's going to be hard to accurately measure the runtime. – user202729 Aug 4 at 13:37
• @user202729 that I would like to see! I bet you can't get it run below 2 seconds – Ilya Gazman Aug 4 at 17:50
• This is essentially a duplicate of your earlier challenge, with the rather trivial modification of introducing gaps. As for your sense of how long it takes to print 26 million primes, you are mistaken. My submission on your earlier challenge printed all 26 million of them in under a minute on my laptop. The (now-deleted) C++ answer was even faster. – Dingus Aug 5 at 1:28

Your task is to create a program that outputs a random pizza recipe following this one rule:

No random number choosers, you may have random text choosers. All standard code-golf rules apply. A sample output:

A simple PEPPARONI pizza sprinkled with fish and sausages. Your program must have the following items:

• Anchovies
• Fish
• An adjective for the pizza

The program written with the shortest code wins.

# Winner

The winner shall be picked on April 3rd, 12AM on the time zone GMT+3.

• I already had an answer to the question, albeit non-competing: Python3 print("Have a plain MARGHERITA without any",["fish.","anchovies."][len(input("What's your favourite pizza? "))%2]) – mIllIbyte Mar 31 '16 at 12:41
• Uh, this has a lot of problems with clarity. First, all "random text choosers" are implemented with "random number choosers" which makes this restriction feel a bit bizarre. Second, what counts as an adjective for pizza? And since this is code golf, people will always pick the shortest available. And third, what should an output look like? It's not clear from the spec. Also, sort of unrelated, but usually putting a time limit is unnecessary, even extremely popular challenges stop getting responses with any frequency after a month or so. – FryAmTheEggman Mar 31 '16 at 12:59
• Did you misspell it on purpose? – noɥʇʎԀʎzɐɹƆ Mar 31 '16 at 13:55