# Sandbox for Proposed Challenges

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

Sandbox FAQ

## Posting

To post to the sandbox, scroll to the bottom of this page and click "Answer This Question". Click "OK" when it asks if you really want to add another answer.

Write your challenge just as you would when actually posting it, though you can optionally add a title at the top. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it.

When you think your challenge is ready for the public, go ahead and post it, and replace the post here with a link to the challenge and delete the sandbox post.

## Discussion

The purpose of the sandbox is to give and receive feedback on posts. If you want to, feel free to give feedback to any posts you see here. Important things to comment about can include:

• Parts of the challenge you found unclear
• Comments addressing specific points mentioned in the proposal
• Problems that could make the challenge uninteresting or unfit for the site

You don't need any qualifications to review sandbox posts. The target audience of most of these challenges is code golfers like you, so anything you find unclear will probably be unclear to others.

If you think one of your posts needs more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended!

It is recommended to leave your posts in the sandbox for at least several days, and until it receives upvotes and any feedback has been addressed.

## Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]. To search for posts with a certain tag, include the name in quotes: "king-of-the-hill".

Get the Sandbox Viewer to view the sandbox more easily!

# 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. 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. ;) Apr 4 '17 at 18:39
• Probably a duplicate of codegolf.stackexchange.com/q/62230/34718 Apr 4 '17 at 18:43
• @mbomb007: No, this is not a code-golf challenge.
– Luke
Apr 4 '17 at 18:54
• But there's nothing separating the answers this might receive. Please read this: codegolf.stackexchange.com/tags/popularity-contest/info Apr 4 '17 at 18:57

Make a Login Screen

Challenge: make code that asks the user to enter a username and password. The username and password should be hard coded, but they must not be visible: you cannot have the entire username or the entire password in plain text in the code. Both the username and the password must be 8 characters long. Upon the incorrect username or password, some error should be displayed. It would be good if there are multiple "accounts" that would display different text on login. The password field should not be visible (Only asterisks or something).

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 Apr 18 '17 at 7:05
• underhanded challenges are off-topic. Apr 18 '17 at 8:36
• It's not underhanded. Apr 18 '17 at 14:15
• I'm sure this might be a dupe of an obfuscation challenge 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? Apr 17 '18 at 13:50
• Why do you mix characters and bytes? 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]"". 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. Apr 17 '18 at 14:26
• People, the point of the sandbox is to add suggestions. This question has been downvoted several times. Why? 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? 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. 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. Apr 18 '18 at 14:35

[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)

You may check your answer here

• The spec makes absolutely no sense to me. What does it mean to remove a number from a truth table? 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. 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? Jun 20 '18 at 13:10
• @Geobits This was not a dup but unclear. Jun 20 '18 at 13:12
• Here's my c# non-golfed solution : dotnetfiddle.net/ZFkl5y 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). 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!

Round 1: Squidward's head!

• Erchh! OK OK Remove the PM stufs. didnt know 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? 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 Mod
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 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. 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. Jul 31 '18 at 14:54
• I attempted doing this on Encyclopedia Spongebobia, then went here. Jul 31 '18 at 14:55
• Then maybe a Stack Exchange for off-topic? Jul 31 '18 at 14:57
• @Ikura There are no such SE site, because it would generate low-quality content. Try Quora or Reddit... Jul 31 '18 at 15:15
• Ergo! Goin' to the Kongregate Off-topic forum! 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

## Task

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. 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. 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? 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. 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. 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 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. 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. 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? 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. 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. Oct 8 '18 at 19:25
• @NathanMerrill What edits to the original question or this question do you suggest? 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. 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. 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. 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. 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? 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. Aug 4 '20 at 2:06
• Also it's going to be nearly instantaneous, and might be duplicate of some existing (not sure about this part) Aug 4 '20 at 2:07
• tnx @user202729, I edited the question Aug 4 '20 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?). Aug 4 '20 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? Aug 4 '20 at 2:54
• @IlyaGazman okay, then I can do something like that but with the numbers stored in binary, or computed at compilation time. Aug 4 '20 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" Aug 4 '20 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. Aug 4 '20 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 '20 at 8:02
• @xnor printing 26 million primes take a ridiculously long time Aug 4 '20 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. Aug 4 '20 at 13:37
• @user202729 that I would like to see! I bet you can't get it run below 2 seconds Aug 4 '20 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. Aug 5 '20 at 1:28
• This is heavily downvoted and will require a great deal of work and specification to get to a point where it'd be considered on-topic on main. Furthermore, as other users have pointed out, this appears to be a duplicate of an existing challenge. If you don't intend to post this, would you mind editing this post down and deleting it in order to save space? Sep 25 '20 at 0:47

# Mystery Numbers Challenge math

Here are some sample inputs and outputs:

## IO

### Test 1

Input: 102
Output: 10404 1061208 14002414191924244276669361796022272

### Test 2

Input: 10
Output: 100 100000

### Test 3

Input: 50
Output: 2500 312500000 312500000

## BONUS

If there are two inputs, here are the corresponding inputs and outputs:

### Test B1

Input:

50
12


Output: 144 248832 248832

### Test B1

Input:

2310
9


Output: 81 729 59049 4782969 31381059609

## Notes

If you pass all bonuses too, feel free to third your score. Also add a * to the end.

• Maybe you should add kolmogorov-complexity, as if you don't explain how those outputs are generated you need to find the shortest way to generate these. Also how does the program need to preform on stuff not defined? Dec 31 '20 at 17:10
• This seems not to be a serious submission but if it is, 'I'm not outlining what the program should do' is problematic. How does one write any program without an outline of what it should do? Dec 31 '20 at 22:35
• @Dingus There are sample inputs and outputs. Jan 1 '21 at 20:09
• Questions involving hidden patterns and bonuses are discouraged here. If there's no hidden pattern and these are just random outputs, then the challenge is just compressing those output numbers and using the input as an index, which isn't very interesting. Jan 1 '21 at 20:49
• @Someone Yes, I can see that. What should the code do for inputs of 1, -123456.789, or abcdefg? Jan 1 '21 at 22:32
• Some kind of non-array-like output that indicates an error. I haven't thought of that. (Also, this is my first ever question, so it's likely garbage.) Jan 2 '21 at 18:44

Your challenge is to write a small compiler/interpreter to a small language. This language can be of any level. Example: brainf*ck or Turing.

Example submission:

languageName : “name”
GitHub : “https/GitHub.com/Lang”


a language is valid if it contains the folowing systems:

1: varibles of any type
2: a method of declaring and using functions
3: definable parameters
4: a update loop
5: loops
6: classes(optinal)


a compiler/interperater is valid if it can:

1: run/compile code
2: is fast (less than a minute to compile/initialize)
3: give error messages(optional)
4: written in java


The smallest compiler/interpreter wins

please tell me how i can fix this post if you intend on downvoting it in the comments

• Literally none of the requirements you've listed are observable or are formally specified. I would recommend reading through this thread.
– hyper-neutrino Mod
Jul 15 '21 at 2:50
• @2 - I would recommend you to specify the language in the challenge. Here, in code golf, we always have a criteria (like code-golf (shortest code)). If you don't specify the language, some small languages like HQ9+ will take less bytes to make, but other small languages like chicken will take more bytes to make. Take your time reading the existing challenges and good luck on your second idea! Jul 15 '21 at 8:05
• Welcome to Code Golf, and thanks for using the Sandbox! I'm going to be honest: I don't think you can fix this challenge idea. That's not a bad thing, some ideas just don't work well with our format. I'd be happy to elaborate more on the issues I see with this if you'd like me to, but overall, this is just far too broad to work. Many languages don't have any of the listed points (for example, brainfuck only has 5, and maybe 4), and the listed points seem very arbitrary Jul 15 '21 at 19:41

# Background

You are now the first employee of DuckDuckGoogle, a company founded by a Google employee and a DuckDuckGo employee! They have a new vision for search engine! But obviously, they need to make a search engine first! However, they are bad programmers (nobody knows how they were even hired at DuckDuckGo and Google!). So you are assigned the task of making a search engine.

Search engines

There are three parts to a search engine, a web crawler, an indexer, and a searcher.

The web crawler takes a link, and saves the page and stores the page data (the HTML code). It then looks for links in the page and visits those webpages and does the same. It will continue to do this until there are no more links left.

The web indexer will take the text from each page, take each word, and add it to a dictionary of words and the pages it is associated with. If the word is already in the dictionary, it adds the page as a value of that word that is found in the page. For example, lets say www.example.com/index.html contains the text "hello. thanks! goodbye." and the ww.example.com/index.html is linked to www.example.com/hello.html with the. text "hello. goodbye." The crawler would extract the text from the index.html, and find hello.html, and extract the text from hello.html. The indexer would make a dictionary like this:

dictionary ={"hello.": ["www.example.com/index.html","ww.example.com/hello.html"], "goodbye.":["www.example.com/index.html","ww.example.com/hello.html"], "thanks!": ["ww.example.com/index.html"]}


The simplest part of the search engine is the searcher, or retriever. It simply retrieves the value for the search term (i.e. the list of pages the search term is found in) and prints it. That is the final result of the program. So if the search term is "hello.", the program will print ["www.example.com/index.html","ww.example.com/hello.html"]

Now, here is the difficult part. You must take into account punctuation. So "hello" returns the same as "hello." Also the search engine should be case-insensitive. So "Hello" is the same as "hello", which, as we said, is the same as "hello." which was ["www.example.com/index.html","ww.example.com/hello.html"]

# Challenge

The challenge is to write a search engine in the least number of bytes as possible. Why? Because your bosses have decided to use 90% of the one hard drive they have (budget problems!) for the Holy Grail part of their project and you only get 10%.

# Rules

1. The input is the "seed", a url at which the crawler should start at, and also the search term.
2. The output is a list of webpage urls where the search term is found.
3. The program cannot use builtins for a search engine or even a crawler (or related, like a scraper or spider library).
4. No need to worry about Javascript at all. Assume that the pages will not have Javascript.
5. The webpages are assumed to have HTML 4.0.1 Strict.

# Testing

I am pretty sure people know how search engines work. So I will only include two testcases. You can use the websites in the testcases for testing purposes as well.

> "https://www.udacity.com/cs101x/index.html" "crawl"
["https://www.udacity.com/cs101x/index.html","https://www.udacity.com/cs101x/crawling.html"]

> "https://www.udacity.com/cs101x/urank/index.html" "hummus"
["https://www.udacity.com/cs101x/urank/index.html","https://www.udacity.com/cs101x/urank/hummus.html","https://www.udacity.com/cs101x/urank/arsenic.html","https://www.udacity.com/cs101x/urank/kathleen.html","https://www.udacity.com/cs101x/urank/nickel.html","https://www.udacity.com/cs101x/urank/zinc.html"]

• The first bonus doesn't make sense, as the terms localhost and @PHASE COME BACK WE ARE YOUR FRIEEEEENDS, just themselves, are 49 bytes. The language would need to do string-delimiter/comparison/output all in one character. ... Separately, how many iterations does the search need to travel? Meaning, if index1.html has a link to index2.html which has a link to index3.html which ... has a link to indexN.html, what's the limit on N? Jan 13 '16 at 13:59
• 1. I don't even understand what the second bonus is trying to say. 2. What syntax should we assume? Do we need to handle tag soup, or can we refuse to index pages which aren't valid XHTML? Do we need to support JS execution which affects the page content, web components, etc.? Jan 13 '16 at 14:30
• What counts as "visible text"? If there is white text on a white background, is that considered invisible? If there is another element stacked on top of the text, is that invisible? What if it is only visible on odd days of the month (because of some JavaScript)? If I have to scroll inside of a scroll pane in order to see it, is that considered visible? Jan 13 '16 at 14:39
• Can we assume that all links on the page will be valid links? If not, how should we handle errors like HTTP 404 (Not Found)? Jan 13 '16 at 14:44
• @Rainbolt all links are assumed to be valid. Jan 13 '16 at 20:12
• @TimmyD I didn't take "localhost" into account and now the bonus will be -75 bytes. Also, do you really think a limit on N is needed? Jan 13 '16 at 20:15
• @PeterTaylor syntax will be regular HTML.No need to handle JS. What I am saying in thr second bonus is that you would need to build a search engine that only puts text within the paragraph element (i.e. no tags will be counted as words) in the index. Also, other tags like <b> cannot be counted as words although it is part of the paragraph element. Jan 13 '16 at 20:17
• @Rainbolt visible text, for the sake of simplicity will be anything in the paragraph element. Jan 13 '16 at 20:18
• So only text in <p> elements should be counted? Text in titles etc should be ignored? (And what is "regular" HTML?) Jan 13 '16 at 20:24
• @PeterTaylor HTML 4 will be "regular" HTML (since HTML5 has to still work dominating the world!) although thst reslly wouldn't affect the crawling that much. The paragraph, preformatted text, and header will be counted as visible text. Jan 13 '16 at 20:32
• "HTML 4" still isn't very precise. Can answers require input to be conforming HTML 4.01 Strict? Jan 13 '16 at 23:31
• @PeterTaylor ok. Jan 13 '16 at 23:31
• 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.
– user58826
Jun 9 '17 at 14:13

# Calculate Hello World!

Your goal is to calculate the simple string "hello world" or any other variant.

## Rules

• You may not use the characters in this set (inside your code): hHeElLoOwW rRdD!, in any form (character codes, hex codes, etc. not allowed) [only applies for direct use].
• Your program may not take any input from any source.
• Your program may only print hello world or any other variant to standard output (for your language). Again, it may not print anything else.
• Standard loopholes apply (to clarify, they are not forbidden).
• This challenge is underhanded.
• Your program may not use any built-in string of printable characters (for example, string.printable in Python).
• I recommend you be creative.

Remember, this is ! Have fun!

• This is a trivial variant on stuff which has been done to death. It's also a Do X without Y question with obvious loopholes. Jun 12 '16 at 21:50
• @Peter, I wrote this for creativity. I wanted to see the community's creative answers.
– user36215
Jun 12 '16 at 21:56
• This is not creative even remotely. I would even go as far as saying this is a duplicate of antoher challenge Jun 12 '16 at 22:03
• Underhanded contests are off topic by community consensus. Jun 14 '16 at 3:19

Letter Grade Challenge

Create a program that allows the user to input an int between 1 and 100, then grades that number based on standard US letter grades, printing the grade character as a result. Please use Java for this challenge, and like usual code golf challenges, the smallest answer (bytes) wins. For example, if input is 90, then you display A.

• Welcome to PPCG and thank you for sandboxing. Please include the exact cut-off points. Is the input an integer or a floating point? Are the extremes included or excluded. We generally frown on language-specific challenges. Do you have any particular reason for restricting answers to Java?
– Adám
Feb 28 '18 at 23:11
• Don't restrict which languages you can use. All it does is keep people who don't know Java from answering your past. Also, you should include the definition of the letter grade scale in your challenge, rather than along readers to look it up. Feb 28 '18 at 23:11
• You don't need to include the clause about multiple files. At PPCG, we include all necessary code in the byte-count.
– Adám
Feb 28 '18 at 23:13
• What are "standard US letter grades"? Feb 28 '18 at 23:25
• 90-100: A; 89-80: B; 79-70: C; 69-60: D; 59-0: F Mar 1 '18 at 0:02
• @Pavel Sorry about that. I saw a few people posting python only challenges a while back, so I assumed specific languages are the norm. Mar 1 '18 at 0:03
• @OCDkirby >_> Because people did that more often "A while back" doesn't mean it's still the norm, just look at the questions on the main page Mar 1 '18 at 0:28
• That's several years back. What was on-topic several years back can be off-topic now. Remember to see the timestamp. /// Stack Overflow has the same problem: see this (first revision). Now the title is not valid. Mar 1 '18 at 3:51
• Please edit necessary information into the post. / Some example I/O please? Mar 1 '18 at 3:51
• Probable dupe
– Jo King Mod
Mar 1 '18 at 5:21
• @JoKing They use different letter grades. There is no 'E' in this grading system, and the number value requirements are different. Mar 1 '18 at 16:05
• @OCDkirby But still, if the algorthm on the other question can be adapted for this question with small modification, it's considered a dupe. Mar 2 '18 at 7:22
• @user202729 Is editing every condition in an if statement and removing one condition considered a "small modification"? Mar 2 '18 at 14:37

# Shortest Possible 240 Sided Die Program: Using No Constant Greater than 6

Have you ever played Yahtzee with a 240-sided die? No, probably not. Anyway, I came up with the idea of a 240-sided die program, but to make it hard, you cannot use a constant with an absolute value greater than 6. For example, randInt(1,240) wouldn't work. The chances of any number 1-240 must be completely equal, and using expressions that represent numbers with an absolute value larger than 240 is not allowed. For example, randInt(1,4*6*2*5) is against the rules, since 4*6*2*5 evaluates to 240. Standard loopholes prohibited, and you're code golfing.

• Comments are not for extended discussion; this conversation has been moved to chat. Apr 27 '18 at 20:19

I recently made a language called bit, and your challenge is to create a valid program that takes 2 numbers from STDIN, and outputs the sum of them. You may assume the numbers are no more than 5 digits, and your output doesn't need to be more than 5 digits long

# Bit Specification

You can find the specification and an interpreter at the GitHub repo

• Do you have a reference interpreter or compiler? How can we test a solution?
– qwr
Sep 7 '18 at 20:57
• @qwr I do, in Java, should I add it to the question? Sep 7 '18 at 21:01
• Yes it's very helpful
– qwr
Sep 7 '18 at 22:06
• @qwr Actually how am I going to do that, the file isn't online anywhere Sep 7 '18 at 22:11
• You may just paste the java code in your question, or even better link a TIO script (tio.run/#java-openjdk) so people can run it online
– qwr
Sep 9 '18 at 5:32
• @qwr It's much more than 1k lines of code, and multiple classes, however I have a GitHub now, added to question Sep 9 '18 at 15:31
• Ok that suggests to me the problem may be too long. Others may feel differently
– qwr
Sep 9 '18 at 19:18
• @qwr Not really, Java code tends to be long, there's no problem in that Sep 10 '18 at 18:19
• Well the meta here is for challenges that don't feel arbitrary, and to me this is leaning towards an arbitrary list of commands for your own personal language.
– qwr
Sep 10 '18 at 20:57
• @qwr So you think the idea is bad? Sep 10 '18 at 21:49
• I wouldn't call it bad, which is a pretty broad term, but challenges that are easy to understand and conceptualize are generally better received and get more responses (if that is what you want)
– qwr
Sep 11 '18 at 20:09
• Unrelated: Github is generally for hosting source code and packages/binaries like .jar (these can be included in releases)
– qwr
Sep 11 '18 at 20:11
• If you posted this it would likely get closed as a dupe of Add two numbers. Instead of posting this, I'd recommend just submitting solutions in Bit yourself and seeing if anyone else is interested
– Jo King Mod
Sep 13 '18 at 8:02

# Count up to N without math or inbuilds

### Idea:

The challenge is the following: count from 0 up to N without using mathematical operations or other (counting, list or whatever) inbuilds. You handle the incoming number N as a string on which you can't apply mathematical operations like addition or substraction for example. Also don't use list things like print [0..N] or something other inbuilt of your language. Counting inside arrays, for example at index x+1 or something like that to get position after another is allowed. But you must not apply any (mathematical) operations on the numbers between 0 and N itself.

Think that you are like a small child and don't know anything about maths. You only know: after 0 comes 1, after 1 comes 2 ... after 8 comes 9 and after 9 comes 0 and you have to "increment" the number in front of it.

### Examples:

• So after the number 9 (with leading, but not outwritten zero) comes, you write zero and place the number 1 in front of it for 10.
• For 19 you write 0 and "increment" the number in front to the next one, making it 20.
• For 399 you do: last 9 goes to zero, 9 in front goes to 0 too and the 3 goes to 4, making it 400.

### Task:

Write a function or program which takes N via the way you want to as its input.
Output the numbers from 0 up to N (element after element or once as a list)
Important: use a seperator as 01234567891011 will become unreadable with larger numbers

### Test Case:

Taking a string of seperated numbers and your seperator, you can check your answer here.

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

I hope this challenge has never been here, I did not found it while searching trough the already asked challenges (maybe I did not found it because I did not knew the correct english words to search for because english is not my first language). Thank you already in advance for helping to improve this challenge.

### Tags:

counting, code-golf

• Thank you for putting your first challenge into the Sandbox! Know that do-X-without-Y [are difficult to get right], and generally discouraged for those that do not have a lot of challenge writing experience. If all built-in language features are prohibited, then the challenge is obviously impossible, and if not, how will you decide what is and what isn't allowed for all languages. Please do not make assumptions about language features — there are odd languages out there.
– Adám
Jul 24 '19 at 6:29
• @Adám I see what you mean with built ins, but dont know how to specify it in other terms. i mean things like inbuild methods that automatically output from [0..N] wihtout doing anything as a programmer. What I want to see, is the numbers from 0 to N, each seen as a string with no mathematical operations on it. The counting should happen in a way of the "algorithm" of how small children (with no knowledge about mathematics) count, pattern matching stlye. A child sees the 1, takes the next known value 2 and that it is.,Is it understandable what I mean? Jul 24 '19 at 7:00
• Sure it is clear what you want, but challenges must be unambiguous, and it must be possible to objectively judge if an answer is allowed or not.
– Adám
Jul 24 '19 at 7:43
• Maybe instead you rephrase the challenge as: Given a list of digits, increment the number that they represent in base-10. This way, you can require that solutions handle inputs that are way too wide for normal integer representations. Of course, some languages have "infinite-precision" integers, but such solutions then just don't deserve upvotes for cleverness.
– Adám
Jul 24 '19 at 7:48
• @Adám - or is it possible to write it like: "'count' from 0 to N, but not by interpreting 0 to N as numbers, they are strings. you are a small child, you know nothing about arithmetics and you only know the word representations of numbers and what number comes after another by following rules. [...]". or does this still opens the possibility to use the numbers as integers for example? Jul 25 '19 at 5:45
• That doesn't help, we'll just evaluate the string, find the range, then stringify the numbers. Also, if you prohibit arithmetic, how are we to add digits? With a lookup table?
– Adám
Jul 25 '19 at 6:47
• Yeah that is what I want to achieve. The one solving the task needs to lookup what number comes after the one he is looking at (without doing calculus on the number itself). something like having a string all="01234567890" and with that you search for s in all and look at the next symbol (next symbol can be fetched with +1, this is allowed, but you are not allowed to add +1 to s directly). e.g. you have the number 5, you lookup the next number in all, which is 6, and so on. the "next" operation is something the child does intuitive, without knowing that this is an mathematical operation. Jul 25 '19 at 7:38
• on top of that, there is one special case when going from most significant position of the number beeing a 9 to a 0 and adding a new 1 as most significant position. (9->10, 99->100, 999->1000 and so on ...). is that too simple? guess it can be interesting what kind of solution people come up on the lookup thing and special case optimization - @Adám Jul 25 '19 at 7:50
• – Adám
Jul 25 '19 at 8:41

# Write an interpreter for the language used in the previous answer that will run the code in that answer

Your task is to interpret the previous answer. I'll post the answer first.

To prevent from Unusable Programming Language, you need to do the 10 tasks:

# Tasks:

1. "Hello, World!"

2. Print the last character of the input

3. Is this even or odd?

4. Golf you a quine for great good!

5. Shortest code to produce infinite output

6. Shortest infinite loop producing no output

7. Print every argument separated by newlines

8. Read file of the first argument

9. Convert The Number of input to ASCII char

10. Alphabet Diamond

this is so the last answer older than 10 days will be winner.

• Suggestions?

# Smallest code to import in G++

Given some head files that need to import, return the shortest code to do so.

1. You are allowed to access include/
2. You should consider both #include <xxx> and #include "xxx"(used in e.g. backward/hash_set #include "backward_warning.h"), but not #import (std don't use #import)

Sample input ['string']

Sample output #import<map>

Related

1. What more assumption necessary? (#if don't effect imported heads?)
2. Time limit necessary?
• I don't understand what is the challenge. Apr 21 '18 at 16:32
• I don't think tips questions have to go through the sandbox
– Jo King Mod
Apr 24 '18 at 2:22
• @user202729 I do. C++ header files may include other header files. It's mostly implementation-specific. This person's <map> header happens to include <string> so if you want <string> it's shorter to include <map> instead. Aug 24 '20 at 17:48
• @user253751 ... that comment was made two years ago. I don't remember what it's about now. Aug 25 '20 at 7:25

Merge two code in two languages into a polyglot.

E.g. If you choose C & Python 3, you can merge

main(){puts("a");}


and

print(6)


into

#define print(x) main(){puts("a");}
print(6)


(for it's hard to have a score on language difficulty, optimizy, etc.)

• This is way too broad as it is currently written. "Do X Creatively" is out of scope, even for popularity-contests. May 17 '18 at 18:04
• @AdmBorkBork It seems not a creatively challenge? though I don't vote it that high either
– l4m2
May 17 '18 at 18:20

# Delete or a file disapear as fast as possible!

Requirements to participate:

• have a HDD hard drive, witch you will use to compete
• Use Windows (version 7 or more recent) for this challenge.

Assume that you already know the file path. no input needed.

You can use any language you want for this challenge, but you will need to explain the logic in your code.

You will delete a 2GB file.

## How do you win?

You win this challenge by creating a piece of code that can delete a file in the OS as fast as possible, the winner is the one with less time to delete a file.

• This is a) too wide open to interpretation; b) far more dependent on the hardware than on the software. May 23 '17 at 13:41
• so what? I say in the begining what the requirements to participate are, only the ones that match the requirements can participate, else the results will be so diferent i cant even evaluate @PeterTaylor May 23 '17 at 13:51
• And what do you mean "wide open to interpretation?" @PeterTaylor May 23 '17 at 13:52
• What does it mean to "make a file disappear"? If I unmount the disk, does that count? How about if I format the index block? Change the permissions so that I can no longer see it? Rename it? Toggle the disk header so that it seems to be a different filesystem and won't mount? Is rm acceptable, or do I need to shred? Can I insist on a filesystem of my choice (probably FAT)? May 23 '17 at 14:40

# Worst language Ever

Let's find out the worst language.

Make a program that does anything that is shortest.

The worst language would be the longest of all.

I'll go with C first.

# C (gcc), 15 bytes

f(){puts("1");}


Try it online!

It prints 1.

It does print something and it is the shortest code.

# Swift 4, 8 bytes

print(2)


Try it online!

It prints 2. It does print something that is shortest.

• How would you define "does anything"? Jan 9 '18 at 4:05
• Also it's nontrivial to verify whether a program is the shortest possible, unless you tried all programs shorter than that. Jan 9 '18 at 4:06
• Print anything except nothing. You can have an input Jan 9 '18 at 4:06
• So this is a code-golf challenge which ask users to output anything? Isn't this too broad? I will let others to judge... Jan 9 '18 at 4:09
• Doing all of that, we can find the worst language. Jan 9 '18 at 4:13

# Write the worst Hello World program you can [popularity-contest] [super rough]

Who needs conventions? Write the most terrible Hello World program you can think of. Inefficiency, spaghetti code, you name it. Add a few gotos here and there to spice it up. Write code that has gone against everything you've ever been taught.

Be creative. This isn't about obfuscation: it's about bad code quality. Try making up your own ways of writing inefficient or unadaptable code. Have fun!

• VTC because of no winning criterion, objective or not. Needs some work. Feb 28 '16 at 2:11
• I suggest a code-bowling criterion, but this is still way too broad. Feb 28 '16 at 2:13
• As I said, it's super rough and needs a lot of work. Feb 28 '16 at 2:13
• This is essentially code trolling, which was deemed off topic a few years ago. Mar 9 '16 at 1:13

# Divisibility by 4

Your job is to write a program that checks divisibility of an integer by 4.

Restrictions:

You can't use:

• modulo
• binary shift/rotates
• Divisions

You must instead do it like a HUMAN DOES by checking the last 2 digits and output a truthy value when is divisible and a falsey when not.

Non-printable characters; golfing-dedicated, whitespace and esoteric languages are forbidden.

The winner will be the code that has less characters, where white space doesn't count (tabs, spaces and newlines).

• – user61451
Jan 9 '17 at 0:35
• People never like when they can't use their favorite language for a challenge. I would seriously recommend removing the language restriction as it not only is it next to impossible to reliably enforce (you have been already linked several meta discussions so I'll leave that out) but it is most importantly not very fun for the people involved.
– Wheat Wizard Mod
Jan 9 '17 at 0:35
• @LearnHowToBeTransparent There are a number of problems here, which it is useful to point out, but I think "I hate this challenge" is unnecessary. Jan 9 '17 at 0:36
• Can I forbid only whitespace languages, as they would automatically win by my measures? Jan 9 '17 at 0:39
• Are we allowed to check / use the other digits, too or just the last two digits? Does looping through all digits to reach the last two digits count as "checking / looking at / using"?
– nimi
Jan 9 '17 at 0:39
• I think that you could because it is objective. But the much better alternative would be to simply count whitespace. Why do you want to not count whitespace.
– Wheat Wizard Mod
Jan 9 '17 at 0:41
• @nimi: One more time I tell you that is absolutely not necessary. You can, but that will for sure increase your non-whitespace char count! Jan 9 '17 at 0:42
• @WheatWizard: I want to measure it in terms of "Visual Overload". Whitepace does not have any visual load and when exists even alleviates the "visual overload" of characters that have it! Jan 9 '17 at 0:43
• Since the discussion has already grown quite long I have created a room here: chat.stackexchange.com/rooms/51421/…
– Wheat Wizard Mod
Jan 9 '17 at 0:43
• Implements question using whitespace. Jan 9 '17 at 15:11