468
\$\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 '19 at 7:51
  • \$\begingroup\$ @guest271314 You can use this markup to create a tag in a draft: [tag:code-golf] \$\endgroup\$ – James Aug 29 '19 at 15:19
  • \$\begingroup\$ Why no featured anymore? Can't we have it auto-added or something? \$\endgroup\$ – S.S. Anne Sep 26 '19 at 15:57
  • 3
    \$\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 '19 at 13:43

2739 Answers 2739

-3
\$\begingroup\$

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.
\$\endgroup\$
  • 1
    \$\begingroup\$ 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 \$\endgroup\$ – Unrelated String Aug 27 '19 at 7:48
  • 2
    \$\begingroup\$ A null program is compilable in most(if not all) languages. (Including specific compilers of C(in IOCCC).) \$\endgroup\$ – user85052 Aug 27 '19 at 10:15
  • \$\begingroup\$ @A_ I've added an additional rule. \$\endgroup\$ – user2190035 Aug 27 '19 at 10:58
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ – AdmBorkBork Aug 27 '19 at 14:25
  • \$\begingroup\$ Define "compile". \$\endgroup\$ – pppery Aug 28 '19 at 23:23
-3
\$\begingroup\$

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.

\$\endgroup\$
-3
\$\begingroup\$

But Is it Nice?

Given a single string consisting of printable ascii characters, determine whether or not it contains any nice numbers. The two nice numbers are 69 and 420. The numbers need to be unbroken: 69abc is nice while 6abc9 is not nice.

Rules

  • Input can be taken in any reasonable and convienient format
  • Output can be given in any reasonable and convienient
  • There can be anywhere from 0 to ∞ 69s and/or 420s in the string.
  • All standard loopholes are forbidden

Test Cases

"69" -> True
"420" -> True
"42069" -> True
"68" -> False
"4260" -> False
"6429" -> False
"Nice" -> False
"Hidden69lol" -> True
"420Quickscope" -> True
"4 2 0" -> False
"6 9" -> False

Feedback

Is this a dupe of any kind? Because I feel like it is, but I can't find anything that would match.

\$\endgroup\$
-4
\$\begingroup\$

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.

\$\endgroup\$
  • 2
    \$\begingroup\$ I don't see much of a challenge here. wc -l $0? \$\endgroup\$ – ugoren Feb 23 '14 at 17:15
  • 1
    \$\begingroup\$ It can be a nice question, but needs some work. Just add something like "it should not use any tool, macro, function, or similar device designed with the specific purpose of counting lines". \$\endgroup\$ – Victor Stafusa Feb 24 '14 at 2:10
  • \$\begingroup\$ @Victor Nice point, added. Thank you :) \$\endgroup\$ – Vereos Feb 24 '14 at 10:10
  • 4
    \$\begingroup\$ As long as you can read the program file, it's no challenge. E.g. print len(l for l in sys.argv[0]). But if you forbid reading the source, and forbid hard-coding the length, what's left? \$\endgroup\$ – ugoren Feb 24 '14 at 14:00
  • \$\begingroup\$ @ugoren I don't see where it says it can't read its source. \$\endgroup\$ – user10766 Feb 27 '14 at 22:13
  • 1
    \$\begingroup\$ @user2509848, It doesn't. This is why the question is easy and uninteresting. \$\endgroup\$ – ugoren Feb 28 '14 at 5:56
  • \$\begingroup\$ @ugoren If you can't though, how will you tell, hardcode it? \$\endgroup\$ – user10766 Feb 28 '14 at 5:57
  • 1
    \$\begingroup\$ @user2509848, Either way, not a good question. \$\endgroup\$ – ugoren Feb 28 '14 at 6:25
  • 2
    \$\begingroup\$ This is one byte in any golfing language with implicit output: 1 \$\endgroup\$ – Fund Monica's Lawsuit May 9 '16 at 20:11
-4
\$\begingroup\$

Here is my first attempt at a cops and robbers post (which is why I'm using the sandbox).


Cops - Golfed recursion

You must select a language that satisfies the following criteria:

  • Functions - It must be possible to create a function with any number of integer input values and a single integer output (or return) value. The function may also be a complete program in itself. (Your language may not call it a function, but that is ok)
  • Arithmetic operations - The integer operations +-*/% should all be possible, either in a simple or a complicated manner.
  • Data - You should be able to store one-byte or two-byte long integers (either signed or unsigned will do). You may do this also in an indirect manner.
  • Iteration - You must be able to create a loop that will keep running until a condition is satisfied. Therefore < > = <= >= ! & | should also be supported, either directly or indirectly.
  • Recursion - You should be able to call a function from within the function itself with a set of input values calculated by the main function.
  • Declaration - You should be able to declare new integer variables as needed from within the function.

Task

You need to create a recursive function. Code will be scored by the number of characters in it, the shorter the better. A solved code cannot win the challenge. A post with less than 5 up-votes cannot win the challenge. There will be no overall winner, but a separate winner for each language.

Robbers - Golfed recursion

Your objective is to pick up a cop's post, and write a function in the same language but it should not use any recursion (can use iteration). The function may create any number of variables, loops, etc. but should be able to achieve the exact same end result (atleast, in theory) as the cop's one.

Your score will be the same as the cop's post's score at the time it was solved. His/her post is now invalid, and you get his/her score

\$\endgroup\$
  • 2
    \$\begingroup\$ I don't understand how a cop can write an answer that isn't going to be cracked, unless the language of choice can only loop via recursion (which I think you're trying to rule out by requiring that "iteration" must be possible). Also, requiring 5 votes to be a winner is only encouraging tactical voting. Answers that are actually invalid will likely get downvoted and deleted anyway. \$\endgroup\$ – Martin Ender Feb 10 '16 at 12:36
  • \$\begingroup\$ @MartinBüttner Maybe in some languages it is possible by exploiting both closure and recursion, but I mainly agree with your point: recursion and iteration are two ways to do the same thing. \$\endgroup\$ – Katenkyo Feb 10 '16 at 12:41
-4
\$\begingroup\$

Stop the dance!

Your sister was at the hospital, but now she's fine, awfully, you lost a day of work, one of your most important days.

You work at your local television, and they have a contest, called "Stop the dance!", what is it about?: People is dancing, they have a big screen in the wall, while it says "Dance!", they have to dance, if it says "Stop!", they must stop, if you move, you lose.

You don't have internet at the studio, so you use some strange offline data sharing method. The day you weren't there, another programmer came, such a silly programmer! He made a "Reciever" program, basically, gets data, processes data and prints data in the Big Screen Wall.

The programmer was bored, so he made a way to get data, well, you don't know what way he choose! (Author comment: Let's assume he made all the possible ways. Cya.) Now you have to make a sender program, in any language, that sends data to that program using the protocol specified under this section.

You are an expert code golfer, so you decide that you must make the shortest code possible. (Another author comment: Any lang is allowed. Cya.)

How did I came out with this idea?

Having a shower, my friend...

Your task

You must make the shortest (and winner) code possible, that sends data to the reciever, using this protocol:

The reciever must recieve:

$displaytext:"<text here>";$instnm:<integer here>;

$displaytext corresponds to what it is going to be displayed on the Big Screen Wall.

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

\$\endgroup\$
  • 9
    \$\begingroup\$ I have no idea what you're asking me to do. \$\endgroup\$ – Peter Taylor Feb 3 '16 at 21:26
  • \$\begingroup\$ 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. \$\endgroup\$ – TheCrimulo Feb 3 '16 at 22:11
  • \$\begingroup\$ @TheCrimulo Example answer? \$\endgroup\$ – Akangka Feb 7 '16 at 7:06
  • \$\begingroup\$ 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. \$\endgroup\$ – TheCrimulo Feb 7 '16 at 15:54
-4
\$\begingroup\$

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.

\$\endgroup\$
  • 5
    \$\begingroup\$ Doesn't this boil down to which language has the biggest output stored in a predefined variable? \$\endgroup\$ – Denker Apr 3 '16 at 20:50
  • \$\begingroup\$ @DenkerAffe true. maybe i should make it 2 byte src code. that might allow some interesting stuff \$\endgroup\$ – Maltysen Apr 3 '16 at 20:52
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Denker Apr 3 '16 at 20:58
  • \$\begingroup\$ G for pyth wins :D :D \$\endgroup\$ – Leaky Nun Apr 4 '16 at 4:45
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ – Sp3000 Apr 4 '16 at 10:27
  • \$\begingroup\$ Actually, N in Seriously wins. 11752 bytes output. \$\endgroup\$ – Mego Apr 6 '16 at 4:06
  • \$\begingroup\$ @Mego Vitsy wins. 0 bytes, 11752 bytes of output. \$\endgroup\$ – Addison Crump Apr 7 '16 at 17:07
-4
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ Closed as a dupe. And/or unclear. \$\endgroup\$ – Rɪᴋᴇʀ May 19 '16 at 20:04
  • \$\begingroup\$ Paragraphs of text are boring for compression. Unless there's some particular structure in the text, the same techniques apply to all of them. \$\endgroup\$ – xnor May 19 '16 at 20:07
  • \$\begingroup\$ 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. \$\endgroup\$ – FryAmTheEggman May 19 '16 at 20:09
  • \$\begingroup\$ we want to give them a challenge, not a flashback.... \$\endgroup\$ – user56309 Aug 4 '16 at 19:42
  • \$\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:12
-4
\$\begingroup\$

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
\$\endgroup\$
  • 3
    \$\begingroup\$ 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?. \$\endgroup\$ – Geobits Jun 4 '16 at 19:06
  • \$\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:12
-4
\$\begingroup\$

"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

\$\endgroup\$
  • 2
    \$\begingroup\$ Answers in this site normally involve writing code, so this doesn't really appear to be on topic. \$\endgroup\$ – feersum Jun 16 '16 at 7:43
  • \$\begingroup\$ 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... \$\endgroup\$ – FryAmTheEggman Jun 16 '16 at 13:22
  • \$\begingroup\$ 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. \$\endgroup\$ – FryAmTheEggman Jun 16 '16 at 13:24
  • \$\begingroup\$ 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? \$\endgroup\$ – Erik Ostermueller Jun 16 '16 at 22:45
  • \$\begingroup\$ 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. \$\endgroup\$ – Erik Ostermueller Jun 16 '16 at 22:48
  • \$\begingroup\$ @FryAmTheEggman, you mentioned that my "rarely used" criteria was pretty subjective. That's a good call, so just edited / removed that. \$\endgroup\$ – Erik Ostermueller Jun 18 '16 at 21:36
  • \$\begingroup\$ @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. \$\endgroup\$ – Erik Ostermueller Jun 18 '16 at 21:43
  • 4
    \$\begingroup\$ 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. \$\endgroup\$ – Peter Taylor Jun 19 '16 at 13:31
-4
\$\begingroup\$

Open the browser, polyglot edition.

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
\$\endgroup\$
  • 1
    \$\begingroup\$ Define "default browser" in the context of non-Windows OSes. \$\endgroup\$ – Peter Taylor Sep 25 '16 at 21:47
  • 2
    \$\begingroup\$ @PeterTaylor Whatever browser the open command works with. There was a previous version of this challenge, it worked then. \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Sep 25 '16 at 22:24
-4
\$\begingroup\$

Score Your Language

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.

\$\endgroup\$
  • 4
    \$\begingroup\$ 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. \$\endgroup\$ – Ad Hoc Garf Hunter Feb 5 '17 at 14:58
  • \$\begingroup\$ Are you suggesting that I remove those rules? \$\endgroup\$ – user63571 Feb 5 '17 at 15:00
  • \$\begingroup\$ 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. \$\endgroup\$ – Ad Hoc Garf Hunter Feb 5 '17 at 15:01
  • \$\begingroup\$ 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. \$\endgroup\$ – Peter Taylor Feb 6 '17 at 9:15
-4
\$\begingroup\$

Popularly print the input

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.

\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Martin Ender Apr 4 '17 at 18:33
  • \$\begingroup\$ @MartinEnder: Yeah, I noticed. How do you think I should change the challenge so that it won't be closed? \$\endgroup\$ – Luke Apr 4 '17 at 18:35
  • 1
    \$\begingroup\$ Can't really help you there. If I knew of a good way to make popularity contests work, I'd write some myself. ;) \$\endgroup\$ – Martin Ender Apr 4 '17 at 18:39
  • \$\begingroup\$ Probably a duplicate of codegolf.stackexchange.com/q/62230/34718 \$\endgroup\$ – mbomb007 Apr 4 '17 at 18:43
  • \$\begingroup\$ @mbomb007: No, this is not a code-golf challenge. \$\endgroup\$ – Luke Apr 4 '17 at 18:54
  • \$\begingroup\$ But there's nothing separating the answers this might receive. Please read this: codegolf.stackexchange.com/tags/popularity-contest/info \$\endgroup\$ – mbomb007 Apr 4 '17 at 18:57
-4
\$\begingroup\$

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.

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

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

\$\endgroup\$
-4
\$\begingroup\$

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
\$\endgroup\$
  • 2
    \$\begingroup\$ What is the task we have to solve? Is it really alphanumeric character but non alphanumeric byte? \$\endgroup\$ – Dennis Apr 17 '18 at 13:50
  • \$\begingroup\$ Why do you mix characters and bytes? \$\endgroup\$ – user202729 Apr 17 '18 at 14:01
  • \$\begingroup\$ 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]"". \$\endgroup\$ – Kamil Drakari Apr 17 '18 at 14:08
  • \$\begingroup\$ I think you got bytes and characters mixed up. Both should be bytes, and make sure you specify the program can do anything. \$\endgroup\$ – Redwolf Programs Apr 17 '18 at 14:26
  • \$\begingroup\$ People, the point of the sandbox is to add suggestions. This question has been downvoted several times. Why? \$\endgroup\$ – Redwolf Programs Apr 17 '18 at 22:39
  • 3
    \$\begingroup\$ @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). \$\endgroup\$ – Leo Apr 18 '18 at 1:32
  • \$\begingroup\$ Maybe this challenge should have a "No strings" rule? \$\endgroup\$ – Redwolf Programs Apr 18 '18 at 1:59
  • \$\begingroup\$ 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. \$\endgroup\$ – Nathaniel Apr 18 '18 at 8:35
  • \$\begingroup\$ 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. \$\endgroup\$ – Asone Tuhid Apr 18 '18 at 14:35
-4
\$\begingroup\$

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.

\$\endgroup\$
  • 5
    \$\begingroup\$ 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). \$\endgroup\$ – Kamil Drakari Apr 18 '18 at 18:39
  • \$\begingroup\$ 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/… \$\endgroup\$ – Nit Apr 18 '18 at 18:58
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Nit Apr 18 '18 at 18:59
  • \$\begingroup\$ 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 \$\endgroup\$ – mbomb007 Apr 18 '18 at 19:47
  • \$\begingroup\$ Okay. I'll disallow comments. What would be a good task to accomplish? \$\endgroup\$ – Redwolf Programs Apr 18 '18 at 23:51
  • \$\begingroup\$ @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) \$\endgroup\$ – user202729 Apr 19 '18 at 1:55
  • \$\begingroup\$ @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? \$\endgroup\$ – Redwolf Programs Apr 19 '18 at 2:18
  • \$\begingroup\$ @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. \$\endgroup\$ – user202729 Apr 19 '18 at 2:32
  • \$\begingroup\$ @user202729 Hopefully, I'll find something cool, like the "Pristine and Unique Code Bowling" challenge, but better. \$\endgroup\$ – Redwolf Programs Apr 19 '18 at 2:34
  • 5
    \$\begingroup\$ 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. \$\endgroup\$ – Nathan Merrill Apr 19 '18 at 2:59
  • \$\begingroup\$ 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 \$\endgroup\$ – Nathan Merrill Apr 19 '18 at 3:03
-4
\$\begingroup\$

[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

\$\endgroup\$
  • 1
    \$\begingroup\$ The spec makes absolutely no sense to me. What does it mean to remove a number from a truth table? \$\endgroup\$ – Peter Taylor Apr 25 '18 at 12:13
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Peter Taylor Apr 25 '18 at 14:59
-4
\$\begingroup\$

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.

Bubble sort explanation Bubble sort gif

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.

\$\endgroup\$
  • 3
    \$\begingroup\$ Can you add one walked-through example? I.e. show each pass. \$\endgroup\$ – Adám Jun 20 '18 at 13:04
  • \$\begingroup\$ 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? \$\endgroup\$ – Geobits Jun 20 '18 at 13:10
  • \$\begingroup\$ @Geobits This was not a dup but unclear. \$\endgroup\$ – DIDIx13 Jun 20 '18 at 13:12
  • \$\begingroup\$ Here's my c# non-golfed solution : dotnetfiddle.net/ZFkl5y \$\endgroup\$ – DIDIx13 Jun 20 '18 at 14:01
  • 7
    \$\begingroup\$ 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). \$\endgroup\$ – Peter Taylor Jun 21 '18 at 6:14
-4
\$\begingroup\$

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!

\$\endgroup\$
  • \$\begingroup\$ Erchh! OK OK Remove the PM stufs. didnt know \$\endgroup\$ – Ikura Jul 31 '18 at 0:12
  • 2
    \$\begingroup\$ 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? \$\endgroup\$ – user202729 Jul 31 '18 at 4:05
  • \$\begingroup\$ 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 \$\endgroup\$ – Jo King Jul 31 '18 at 6:04
  • \$\begingroup\$ 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 \$\endgroup\$ – Ikura Jul 31 '18 at 14:32
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – Peter Taylor Jul 31 '18 at 14:46
  • \$\begingroup\$ Oh, popularity? No. No voting. I will work on my formula, with a new parameter: Mandelbrottiness, which is more or less Goldilocks. \$\endgroup\$ – Ikura Jul 31 '18 at 14:54
  • \$\begingroup\$ I attempted doing this on Encyclopedia Spongebobia, then went here. \$\endgroup\$ – Ikura Jul 31 '18 at 14:55
  • \$\begingroup\$ Then maybe a Stack Exchange for off-topic? \$\endgroup\$ – Ikura Jul 31 '18 at 14:57
  • \$\begingroup\$ @Ikura There are no such SE site, because it would generate low-quality content. Try Quora or Reddit... \$\endgroup\$ – user202729 Jul 31 '18 at 15:15
  • \$\begingroup\$ Ergo! Goin' to the Kongregate Off-topic forum! \$\endgroup\$ – Ikura Jul 31 '18 at 18:48
-4
\$\begingroup\$

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)

\$\endgroup\$
  • \$\begingroup\$ @PeterTaylor Pared down version of the original question. \$\endgroup\$ – guest271314 Oct 8 '18 at 18:30
  • \$\begingroup\$ 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. \$\endgroup\$ – guest271314 Oct 8 '18 at 18:35
  • \$\begingroup\$ 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? \$\endgroup\$ – Nathan Merrill Oct 8 '18 at 18:52
  • \$\begingroup\$ 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. \$\endgroup\$ – Nathan Merrill Oct 8 '18 at 18:57
  • \$\begingroup\$ @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. \$\endgroup\$ – guest271314 Oct 8 '18 at 18:57
  • \$\begingroup\$ 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 \$\endgroup\$ – Nathan Merrill Oct 8 '18 at 19:09
  • \$\begingroup\$ @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. \$\endgroup\$ – guest271314 Oct 8 '18 at 19:12
  • \$\begingroup\$ 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. \$\endgroup\$ – Nathan Merrill Oct 8 '18 at 19:13
  • \$\begingroup\$ @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? \$\endgroup\$ – guest271314 Oct 8 '18 at 19:15
  • \$\begingroup\$ No. That question is much too long. I don't think it is the word "Permutation" killing you there, it's everything else. \$\endgroup\$ – Nathan Merrill Oct 8 '18 at 19:21
  • \$\begingroup\$ @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. \$\endgroup\$ – guest271314 Oct 8 '18 at 19:25
  • \$\begingroup\$ @NathanMerrill What edits to the original question or this question do you suggest? \$\endgroup\$ – guest271314 Oct 8 '18 at 19:26
  • \$\begingroup\$ 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. \$\endgroup\$ – Nathan Merrill Oct 8 '18 at 19:28
  • 1
    \$\begingroup\$ "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. \$\endgroup\$ – Peter Taylor Oct 11 '18 at 7:16
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Peter Taylor Oct 11 '18 at 7:30
-4
\$\begingroup\$

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.

Input:

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 → []
\$\endgroup\$
  • \$\begingroup\$ @JoKing, thanks, done. \$\endgroup\$ – msh210 Feb 27 '19 at 5:35
  • \$\begingroup\$ 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? \$\endgroup\$ – Jonathan Frech Mar 2 '19 at 4:36
-4
\$\begingroup\$

Print the phrase “And she said, 'But that's his.'” without using the alphabet

This challenge is supposed to be the complementary to this challenge.

Your task is to print exactly the string And she said, 'But that's his.' but your source code cannot contain any of the following ASCII characters: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, i.e. ascii characters with code points in the ranges [65-90] and [97-122].

Input

Your program takes no input.

Output

The string And she said, 'But that's his.'

\$\endgroup\$
  • \$\begingroup\$ I've downvoted this because it is pretty clearly an X without Y challenge. \$\endgroup\$ – Ad Hoc Garf Hunter Mar 25 at 18:34
  • \$\begingroup\$ @AdHocGarfHunter thanks for your feedback, but couldn't we argue that all restricted-source challenges are some form of Do X without Y? \$\endgroup\$ – RGS Mar 25 at 18:39
  • 1
    \$\begingroup\$ @RGS Not really, consider your previous such question. That was do X by at least doing Y, which is generally much better (in my opinion, anyway). \$\endgroup\$ – FryAmTheEggman Mar 25 at 18:43
  • \$\begingroup\$ @FryAmTheEggman what previous question are you talking about? And so how would this challenge be salvageable? Would it make sense to impose, say, that the alphabetical characters make up for less than 1/3 of the whole source, for example? \$\endgroup\$ – RGS Mar 25 at 19:02
  • \$\begingroup\$ It might be worth reading the post, that coined the term Do X without Y. It is pretty clear that from that question that the main issue is that do X without Y challenges use overused or unclear restrictions. Maybe I should instead be saying that I think forbidding certain characters from appearing is an overused trope that was not really all that great to begin with. \$\endgroup\$ – Ad Hoc Garf Hunter Mar 25 at 19:14
  • \$\begingroup\$ The BUG challenge. Similarly, most of the other recent well received restricted source challenges are more of that form. I don't think the change you suggest will fix that. Perhaps something like "Print ... using exactly one alphabet" - submissions must contain at least one of each of the letters, but other characters are allowed. That makes it a bit of an interesting tradeoff between dumping characters in a comment vs using them in the code. The hard cap at 26 might not be good for golf languages though. Despite that, I still think it'd be better. \$\endgroup\$ – FryAmTheEggman Mar 25 at 19:14
  • \$\begingroup\$ We've had a number of challenges that have been basically "print a thing without using the thing in your code", and they've largely mined out the small volume of interesting ideas there. Mostly, people use ASCII codes or escape sequences. This specific version has the disadvantage that many languages like Python simply can't participate if they require any keywords to print. \$\endgroup\$ – xnor Mar 25 at 23:05
-5
\$\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
-5
\$\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
-5
\$\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
-5
\$\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
-5
\$\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
-5
\$\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
-5
\$\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\$ – James Apr 27 '18 at 20:19

You must log in to answer this question.

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