459
\$\begingroup\$

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.

To post to the Sandbox, scroll to the bottom of this page or click on the "Add Proposal" link below, 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. 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, replace the post here with a link to the challenge and delete it.

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

The Sandbox works best if you sort posts by "active".

Add Proposal

Search the Sandbox

Browse your pending proposals

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]

\$\endgroup\$
  • \$\begingroup\$ How are tags added to questions? \$\endgroup\$ – guest271314 Jan 9 at 7:51
  • \$\begingroup\$ @guest271314 You can use this markup to create a tag in a draft: [tag:code-golf] \$\endgroup\$ – DJMcMayhem Aug 29 at 15:19
  • \$\begingroup\$ Why no featured anymore? Can't we have it auto-added or something? \$\endgroup\$ – JL2210 Sep 26 at 15:57
  • 1
    \$\begingroup\$ @JL2210 We now have a permanent info box that links to the Sandbox, so the featured tag isn't necessary \$\endgroup\$ – caird coinheringaahing Sep 29 at 13:43
  • \$\begingroup\$ I think the sentence 'replace the post here with a link to the challenge and delete it' may specify that the deletion should be done immediately . \$\endgroup\$ – AZTECCO Oct 5 at 19:39

2566 Answers 2566

-4
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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]) \$\endgroup\$ – mIllIbyte Mar 31 '16 at 12:41
  • 4
    \$\begingroup\$ 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. \$\endgroup\$ – FryAmTheEggman Mar 31 '16 at 12:59
  • \$\begingroup\$ Did you misspell it on purpose? \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Mar 31 '16 at 13:55
-4
\$\begingroup\$

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!

\$\endgroup\$
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ – Peter Taylor Jun 12 '16 at 21:50
  • \$\begingroup\$ @Peter, I wrote this for creativity. I wanted to see the community's creative answers. \$\endgroup\$ – user36215 Jun 12 '16 at 21:56
  • \$\begingroup\$ This is not creative even remotely. I would even go as far as saying this is a duplicate of antoher challenge \$\endgroup\$ – Bálint Jun 12 '16 at 22:03
  • \$\begingroup\$ Underhanded contests are off topic by community consensus. \$\endgroup\$ – Dennis Jun 14 '16 at 3:19
-4
\$\begingroup\$

Mad lads!

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!
  • though, your entry can be alive (does your dog add??), so long as your entry is not in discomfort.
  • 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!

\$\endgroup\$
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – mbomb007 Sep 26 '16 at 18:43
  • \$\begingroup\$ 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. \$\endgroup\$ – mbomb007 Sep 26 '16 at 18:52
  • \$\begingroup\$ @mbomb007 what about papers, and counting dogs? This isn't a code golf, it's a popularity contest \$\endgroup\$ – user56309 Sep 26 '16 at 19:20
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – mbomb007 Sep 26 '16 at 19:42
  • \$\begingroup\$ @mbomb007 I'm not sure you linked the correct thing. I have found no reference of popularity contests in your recent link.. \$\endgroup\$ – user56309 Sep 26 '16 at 19:44
  • \$\begingroup\$ Rules and meta consensus apply to all challenges, not just code-golf. \$\endgroup\$ – mbomb007 Sep 26 '16 at 20:21
  • \$\begingroup\$ Popcons should be held to a higher standard than other questions, not a lower one as your comments imply. \$\endgroup\$ – Peter Taylor Sep 27 '16 at 7:33
-4
\$\begingroup\$

What about one question on numeric solve?

Write one function that gets as one argument one function f(x), and one interval a..b and return the list of all element v such f(v)=0 in the interval a..b. In the interval a..b the f must be definite and can not be f(r) = +oo for r in a..b.

Win the one write the function with biggest set of right results. If two have the same set, win the one has less characters. You can not use solve() or nsolve() or fsolve() or one already written function that your sys offer that finds numerical x in f(x)=0

\$\endgroup\$
  • 2
    \$\begingroup\$ Finding all zeros of an arbitrary function is impossible unless the domain is restricted. \$\endgroup\$ – Mego Nov 29 '16 at 8:59
  • \$\begingroup\$ Ok you are right \$\endgroup\$ – RosLuP Nov 30 '16 at 10:04
  • 3
    \$\begingroup\$ The edit doesn't do anything to fix the problem. \$\endgroup\$ – Peter Taylor Nov 30 '16 at 14:48
  • 3
    \$\begingroup\$ The bigger problem is that this post is incomprehensible. \$\endgroup\$ – Mego Dec 2 '16 at 8:54
-4
\$\begingroup\$

Beep. Boop. Maggot?

  1. Read input from STDIN until enter is pressed.
  2. If the input is "Beep", continue.
  3. Otherwise, print "Wrong!" and exit.
  4. Repeat steps one to three with "Boop" instead.
  5. Execute step one.
  6. If the input is "Maggot", output "Done".
    • Otherwise, output "Wrong.".

Remove punctuation (?.!'"), ignore capitalization (a-zA-Z only), and strip whitespace (\t and )

Notes: You must print the text word-for-word, character-for-character. Step 3 is Wrong!, while Step 6 is Wrong.

Hints

  • Notice how boop is just beep with the o's turned into e's.
  • There is lots of repetition here, but with many caveats.
\$\endgroup\$
  • \$\begingroup\$ Technically speaking, step 4 should repeat steps 1-3, shouldn't it? Anyway, apart from that, I don't see anything technically wrong with the challenge, but I'm not sure it's a very good challenge. \$\endgroup\$ – user62131 Jan 1 '17 at 0:07
-4
\$\begingroup\$

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.

\$\endgroup\$
  • 6
    \$\begingroup\$ 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? \$\endgroup\$ – Adám Feb 28 '18 at 23:11
  • \$\begingroup\$ 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. \$\endgroup\$ – Pavel Feb 28 '18 at 23:11
  • \$\begingroup\$ You don't need to include the clause about multiple files. At PPCG, we include all necessary code in the byte-count. \$\endgroup\$ – Adám Feb 28 '18 at 23:13
  • 2
    \$\begingroup\$ What are "standard US letter grades"? \$\endgroup\$ – Shaggy Feb 28 '18 at 23:25
  • \$\begingroup\$ 90-100: A; 89-80: B; 79-70: C; 69-60: D; 59-0: F \$\endgroup\$ – OCDkirby Mar 1 '18 at 0:02
  • \$\begingroup\$ @Pavel Sorry about that. I saw a few people posting python only challenges a while back, so I assumed specific languages are the norm. \$\endgroup\$ – OCDkirby Mar 1 '18 at 0:03
  • 1
    \$\begingroup\$ @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 \$\endgroup\$ – ASCII-only Mar 1 '18 at 0:28
  • \$\begingroup\$ 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. \$\endgroup\$ – user202729 Mar 1 '18 at 3:51
  • \$\begingroup\$ Please edit necessary information into the post. / Some example I/O please? \$\endgroup\$ – user202729 Mar 1 '18 at 3:51
  • 1
    \$\begingroup\$ Probable dupe \$\endgroup\$ – Jo King Mar 1 '18 at 5:21
  • \$\begingroup\$ @JoKing They use different letter grades. There is no 'E' in this grading system, and the number value requirements are different. \$\endgroup\$ – OCDkirby Mar 1 '18 at 16:05
  • \$\begingroup\$ @OCDkirby But still, if the algorthm on the other question can be adapted for this question with small modification, it's considered a dupe. \$\endgroup\$ – user202729 Mar 2 '18 at 7:22
  • \$\begingroup\$ @user202729 Is editing every condition in an if statement and removing one condition considered a "small modification"? \$\endgroup\$ – OCDkirby Mar 2 '18 at 14:37
-4
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. \$\endgroup\$ – DJMcMayhem Apr 27 '18 at 20:19
-4
\$\begingroup\$

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

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

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

\$\endgroup\$
  • \$\begingroup\$ Do you have a reference interpreter or compiler? How can we test a solution? \$\endgroup\$ – qwr Sep 7 '18 at 20:57
  • \$\begingroup\$ @qwr I do, in Java, should I add it to the question? \$\endgroup\$ – FireCubez Sep 7 '18 at 21:01
  • \$\begingroup\$ Yes it's very helpful \$\endgroup\$ – qwr Sep 7 '18 at 22:06
  • \$\begingroup\$ @qwr Actually how am I going to do that, the file isn't online anywhere \$\endgroup\$ – FireCubez Sep 7 '18 at 22:11
  • \$\begingroup\$ 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 \$\endgroup\$ – qwr Sep 9 '18 at 5:32
  • \$\begingroup\$ @qwr It's much more than 1k lines of code, and multiple classes, however I have a GitHub now, added to question \$\endgroup\$ – FireCubez Sep 9 '18 at 15:31
  • \$\begingroup\$ Ok that suggests to me the problem may be too long. Others may feel differently \$\endgroup\$ – qwr Sep 9 '18 at 19:18
  • \$\begingroup\$ @qwr Not really, Java code tends to be long, there's no problem in that \$\endgroup\$ – FireCubez Sep 10 '18 at 18:19
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – qwr Sep 10 '18 at 20:57
  • \$\begingroup\$ @qwr So you think the idea is bad? \$\endgroup\$ – FireCubez Sep 10 '18 at 21:49
  • \$\begingroup\$ 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) \$\endgroup\$ – qwr Sep 11 '18 at 20:09
  • \$\begingroup\$ Unrelated: Github is generally for hosting source code and packages/binaries like .jar (these can be included in releases) \$\endgroup\$ – qwr Sep 11 '18 at 20:11
  • 2
    \$\begingroup\$ 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 \$\endgroup\$ – Jo King Sep 13 '18 at 8:02
-5
\$\begingroup\$

Make a search engine!

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"]
\$\endgroup\$
  • 3
    \$\begingroup\$ 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? \$\endgroup\$ – AdmBorkBork Jan 13 '16 at 13:59
  • 2
    \$\begingroup\$ 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.? \$\endgroup\$ – Peter Taylor Jan 13 '16 at 14:30
  • \$\begingroup\$ 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? \$\endgroup\$ – Rainbolt Jan 13 '16 at 14:39
  • \$\begingroup\$ 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)? \$\endgroup\$ – Rainbolt Jan 13 '16 at 14:44
  • \$\begingroup\$ @Rainbolt all links are assumed to be valid. \$\endgroup\$ – TanMath Jan 13 '16 at 20:12
  • \$\begingroup\$ @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? \$\endgroup\$ – TanMath Jan 13 '16 at 20:15
  • \$\begingroup\$ @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. \$\endgroup\$ – TanMath Jan 13 '16 at 20:17
  • \$\begingroup\$ @Rainbolt visible text, for the sake of simplicity will be anything in the paragraph element. \$\endgroup\$ – TanMath Jan 13 '16 at 20:18
  • \$\begingroup\$ So only text in <p> elements should be counted? Text in titles etc should be ignored? (And what is "regular" HTML?) \$\endgroup\$ – Peter Taylor Jan 13 '16 at 20:24
  • \$\begingroup\$ @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. \$\endgroup\$ – TanMath Jan 13 '16 at 20:32
  • \$\begingroup\$ "HTML 4" still isn't very precise. Can answers require input to be conforming HTML 4.01 Strict? \$\endgroup\$ – Peter Taylor Jan 13 '16 at 23:31
  • \$\begingroup\$ @PeterTaylor ok. \$\endgroup\$ – TanMath Jan 13 '16 at 23:31
  • \$\begingroup\$ 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. \$\endgroup\$ – programmer5000 Jun 9 '17 at 14:13
-5
\$\begingroup\$

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?

\$\endgroup\$
  • 10
    \$\begingroup\$ I don't understand what is the challenge. \$\endgroup\$ – user202729 Apr 21 '18 at 16:32
  • \$\begingroup\$ I don't think tips questions have to go through the sandbox \$\endgroup\$ – Jo King Apr 24 '18 at 2:22
-5
\$\begingroup\$

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

\$\endgroup\$
  • 7
    \$\begingroup\$ 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. \$\endgroup\$ – Adám Jul 24 at 6:29
  • \$\begingroup\$ @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? \$\endgroup\$ – pixma140 Jul 24 at 7:00
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Adám Jul 24 at 7:43
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Adám Jul 24 at 7:48
  • \$\begingroup\$ @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? \$\endgroup\$ – pixma140 Jul 25 at 5:45
  • \$\begingroup\$ 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? \$\endgroup\$ – Adám Jul 25 at 6:47
  • \$\begingroup\$ 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. \$\endgroup\$ – pixma140 Jul 25 at 7:38
  • \$\begingroup\$ 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 \$\endgroup\$ – pixma140 Jul 25 at 7:50
  • \$\begingroup\$ Let us continue this discussion in chat. \$\endgroup\$ – Adám Jul 25 at 8:41
-8
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ This is a) too wide open to interpretation; b) far more dependent on the hardware than on the software. \$\endgroup\$ – Peter Taylor May 23 '17 at 13:41
  • \$\begingroup\$ 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 \$\endgroup\$ – jeyejow May 23 '17 at 13:51
  • \$\begingroup\$ And what do you mean "wide open to interpretation?" @PeterTaylor \$\endgroup\$ – jeyejow May 23 '17 at 13:52
  • \$\begingroup\$ 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)? \$\endgroup\$ – Peter Taylor May 23 '17 at 14:40
  • \$\begingroup\$ I flat-out hate Windows. No. \$\endgroup\$ – JL2210 Sep 24 at 11:32
-8
\$\begingroup\$

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.

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

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!

\$\endgroup\$
  • 6
    \$\begingroup\$ VTC because of no winning criterion, objective or not. Needs some work. \$\endgroup\$ – Rɪᴋᴇʀ Feb 28 '16 at 2:11
  • 1
    \$\begingroup\$ I suggest a code-bowling criterion, but this is still way too broad. \$\endgroup\$ – Addison Crump Feb 28 '16 at 2:13
  • 1
    \$\begingroup\$ As I said, it's super rough and needs a lot of work. \$\endgroup\$ – TheInitializer Feb 28 '16 at 2:13
  • 4
    \$\begingroup\$ This is essentially code trolling, which was deemed off topic a few years ago. \$\endgroup\$ – Dennis Mar 9 '16 at 1:13
-11
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Sriotchilism O'Zaic Jan 9 '17 at 0:35
  • 6
    \$\begingroup\$ @LearnHowToBeTransparent There are a number of problems here, which it is useful to point out, but I think "I hate this challenge" is unnecessary. \$\endgroup\$ – trichoplax Jan 9 '17 at 0:36
  • \$\begingroup\$ Can I forbid only whitespace languages, as they would automatically win by my measures? \$\endgroup\$ – sergiol Jan 9 '17 at 0:39
  • \$\begingroup\$ 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"? \$\endgroup\$ – nimi Jan 9 '17 at 0:39
  • \$\begingroup\$ 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. \$\endgroup\$ – Sriotchilism O'Zaic Jan 9 '17 at 0:41
  • \$\begingroup\$ @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! \$\endgroup\$ – sergiol Jan 9 '17 at 0:42
  • \$\begingroup\$ @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! \$\endgroup\$ – sergiol Jan 9 '17 at 0:43
  • \$\begingroup\$ Since the discussion has already grown quite long I have created a room here: chat.stackexchange.com/rooms/51421/… \$\endgroup\$ – Sriotchilism O'Zaic Jan 9 '17 at 0:43
  • \$\begingroup\$ Implements question using whitespace. \$\endgroup\$ – Magic Octopus Urn Jan 9 '17 at 15:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .