443
\$\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\$
  • 2
    \$\begingroup\$ Suggestion: instead of having a notice on the top answer ("note: if you are..."), you'd better just put a moderator notice below the question \$\endgroup\$ – nicael Mar 19 '18 at 19:35
  • 3
    \$\begingroup\$ @nicael We can only choose from three post notices: citation needed, current event, and insufficient explanation. \$\endgroup\$ – Dennis Apr 7 '18 at 14:43
  • \$\begingroup\$ If you remove a post but didn't post it you can replace the text body with [](lots of text here to reach the min chars) to make it much smaller when removed \$\endgroup\$ – Christopher Apr 13 '18 at 17:54
  • 5
    \$\begingroup\$ @Christopher Please don't do that for old proposals. It clutters the first page with an answer nobody cares about anymore, instead of staying hidden on page 10 where it will bother nobody. \$\endgroup\$ – Dennis Apr 13 '18 at 18:17
  • \$\begingroup\$ @Dennis ? what are you talking about. As if if you didn't post it like you just removed you own sandbox because dupe or something \$\endgroup\$ – Christopher Apr 13 '18 at 18:18
  • 4
    \$\begingroup\$ @Christopher If your proposal is still on the first few pages, you can replace the proposal with a stub to save vertical space on these pages. However, if your proposal is already on page 10, editing your proposal will bump it to page 1, where space is more precious than on page 10. \$\endgroup\$ – Dennis Apr 13 '18 at 18:21
  • \$\begingroup\$ @Dennis ohh that makes sense \$\endgroup\$ – Christopher Apr 13 '18 at 18:25
  • \$\begingroup\$ codegolf.meta.stackexchange.com/questions/12599/… \$\endgroup\$ – Redwolf Programs Apr 17 '18 at 17:38
  • 1
    \$\begingroup\$ Maybe it's time to consider cleaning some of this up a bit. There's just too much to go through and some of these proposals are years old and obviously not going anywhere (even some of the good ones). Perhaps cull anything that is two years old and has likewise been inactive for as long? \$\endgroup\$ – ouflak Aug 6 '18 at 9:07
  • 1
    \$\begingroup\$ @ouflak You can sort posts by "active". That seems to resolve all of the problems you describe. \$\endgroup\$ – FryAmTheEggman Sep 27 '18 at 19:04
  • \$\begingroup\$ I already posted this, but codegolf.stackexchange.com/questions/176599/… \$\endgroup\$ – 2br-2b Nov 27 '18 at 2:38
  • \$\begingroup\$ How are tags added to questions? \$\endgroup\$ – guest271314 Jan 9 at 7:51
  • \$\begingroup\$ It seems like there is a rollback war with moderators and the Community user to add and remove the featured tag. \$\endgroup\$ – smileycreations15 Mar 21 at 21:13
  • 3
    \$\begingroup\$ @smileycreations15 That's unfortunately unavoidable. Community is an automatic script, and, since most featured questions are only temporarily so, it assumes that we don't want this question to be featured forever. However, we do, so a mod has to edit the tag in every now and then. \$\endgroup\$ – Erik the Outgolfer Mar 24 at 15:22
  • 3
    \$\begingroup\$ @EriktheOutgolfer Yeah. Maybe they can create a special [featured-pin] tag which will both feature it and pin it from removal by the Community user. \$\endgroup\$ – smileycreations15 Mar 24 at 17:20

2450 Answers 2450

-3
\$\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
-3
\$\begingroup\$

99 selttob fo reeb no eht llaw

I teb ev'uoy lla draeh tuoba eht doog 'lo 99 selttob fo reeb no eht llaw. Llew ti os sneppah taht I emoc morf na evitanretla esrevinu - eht esrevinu erehw ew etirw gnihtyreve ni esrever! Ew peek eht snoitisop fo lanigiro hguoht. Siht osla snaem reporp noitazilatipac fo tsrif (ekil rettel ni siht txet). Ruoy egnellahc si ot etirw a margorp taht stuptuo eht lausu 99 selttob fo reeb no eht llaw, tub ni esrever (ni ruo egaugnal uoy dluow llac ti 99 bottles of beer on the wall). Siht si a ytiralupop tsetnoc, os teg evitaerc dna yrt ot sserpmi eht dworc. Doog kcul!

I bet you've all heard about the good ol' 99 bottles of beer on the wall. Well it so happens that I come from an alternative universe - the universe where we write everything in reverse! We keep the positions of original though. This also means proper capitalization of first letter(like in this text). Your challenge is to write a program that outputs the usual 99 bottles of beer on the wall, but in reverse (in our language you would call it 99 selttob fo reeb no eht llaw). This is a popularity contest, so get creative and try to impress the crowd. Good luck!

Elpmas fo derised tuptuo:

Sample of desired output:


99 selttob fo reeb no eht llaw, 99 selttob fo reeb. Ekat eno nwod dna ssap ti dnuora, 89 selttob fo reeb no eht llaw.

89 selttob fo reeb no eht llaw, 89 selttob fo reeb. Ekat eno nwod dna ssap ti dnuora, 79 selttob fo reeb no eht llaw.

...

1 elttob fo reeb no eht llaw, 1 elttob fo reeb. Ekat eno nwod dna ssap ti dnuora, on erom selttob fo reeb no eht llaw.

On erom selttob fo reeb no eht llaw, on erom selttob fo reeb. Og ot eht erots dna yub emos erom, 99 selttob fo reeb no eht llaw.

\$\endgroup\$
  • 3
    \$\begingroup\$ There's no need for the reversed text in the description - it distracts the viewer from the challenge at hand. \$\endgroup\$ – Qwerp-Derp Oct 21 '16 at 12:06
  • \$\begingroup\$ @Qwerp-Derp I wanted to make this a bit more "unique" and "immersing", so I thought about giving the reversed description(I like it). I also included original text(although in spoilers), but I was also wondering about distracting readers. Do you have some other idea on how to keep both versions without making it look obscure? \$\endgroup\$ – MatthewRock Oct 21 '16 at 12:10
  • 2
    \$\begingroup\$ 1. This should not be a popularity-contest. 2. It's fundamentally a duplicate of codegolf.stackexchange.com/q/64198/194 . 3. If you're going to muck around with the question text, write a program that mucks it around correctly. "elpmaS" doesn't follow the specified transformation rule. \$\endgroup\$ – Peter Taylor Oct 21 '16 at 12:34
  • \$\begingroup\$ @PeterTaylor 1. why not? 2. It's not. You can't simply reverse, and counting is a bit different. \$\endgroup\$ – MatthewRock Oct 21 '16 at 13:24
  • 2
    \$\begingroup\$ Do X creatively popularity contests have fallen out of scope. This will get closed if posted on main. \$\endgroup\$ – Dennis Oct 21 '16 at 13:46
  • \$\begingroup\$ @Dennis Damn, too bad. I guess I won't be posting it then, it's boring "shortest code". \$\endgroup\$ – MatthewRock Oct 21 '16 at 14:16
  • 2
    \$\begingroup\$ What does this add to the original '99 bottles of beer on the wall'? \$\endgroup\$ – 0WJYxW9FMN Oct 21 '16 at 20:54
  • \$\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:08
-3
\$\begingroup\$

Best n out of 2n - 1

Challenge:

This one should be relatively simple. Output this exact text:

Best [n] out of [2n - 1].

given n as an input.

Input:

Just the integer n, can be from stdin or as an argument. n will always be greater than 0.

Output:

The exact text above. Trailing spaces/newlines are allowed.

Rules:

This is , so shortest code in bytes wins. Standard loopholes are forbidden.

Meta:

Is this too simple? What other tags should be included, ?

\$\endgroup\$
  • 1
    \$\begingroup\$ Seems like a dupe of 2spooky4me, just with a different operator. \$\endgroup\$ – Geobits Nov 1 '16 at 17:52
  • 1
    \$\begingroup\$ Your wording specifies "this exact text" while I think your intent is "Best 5 out of 9." or the like. \$\endgroup\$ – AdmBorkBork Nov 1 '16 at 17:53
  • \$\begingroup\$ @Geobits Aha, I knew I remembered a similar challenge. Just forgot the exact name, so I thought maybe I was just imagining things after I tried to find it. My bad. \$\endgroup\$ – Yodle Nov 1 '16 at 17:55
-3
\$\begingroup\$

Google Home / Amazon Echo - Turing complete?

Your challenge is to try to make a turing machine based on Google Home and Amazon Echo, see this video.

You must describe how to set up the machine, and how to give it input.

You must also describe a program for integer addition. It should compute 1+1 to be 2, 200+55 = 255, 200+56 = 0, and so on for all other combinations of 2 8-bit integers.

\$\endgroup\$
  • \$\begingroup\$ It's basically not possible... \$\endgroup\$ – TuxCrafting Dec 2 '16 at 19:52
  • \$\begingroup\$ VTC as unclear and too broad. What are you even expecting as an answer? \$\endgroup\$ – Rɪᴋᴇʀ Dec 2 '16 at 19:52
  • \$\begingroup\$ @EasterlyIrk A set of commands that send the 2 computers into infinite loop, reading commands endlessly from a list of commands for the other to run, eventually processing a computer program and finally calculating the answer to the universe. \$\endgroup\$ – SoniEx2 Dec 2 '16 at 20:14
  • \$\begingroup\$ @TùxCräftîñg Why not? I mean other than that we have yet to prove their turing-completeness. \$\endgroup\$ – SoniEx2 Dec 2 '16 at 20:14
  • \$\begingroup\$ @SoniEx2 so only 1 of each computer? And what defines a command? \$\endgroup\$ – Rɪᴋᴇʀ Dec 2 '16 at 20:16
  • \$\begingroup\$ @EasterlyIrk A command is anything that starts with "Hey google" or "Alexa" and triggers a successful response on either of the computers. \$\endgroup\$ – SoniEx2 Dec 2 '16 at 20:19
  • \$\begingroup\$ Are we allowed to program the Echo and Google device? If so this is trivial. If we're supposed to construct a sentence that winds up having the devices compute using existing services like the calendar in the video, there are plenty of web sites that can process a variety of languages and read back the solution. Echo has basic math built in. \$\endgroup\$ – wyldstallyns Dec 2 '16 at 21:09
  • \$\begingroup\$ I really hope this can be tweaked into a challenge because the youtubes would be awesome. \$\endgroup\$ – wyldstallyns Dec 2 '16 at 21:12
  • \$\begingroup\$ @wyldstallyns tbh I have no idea what I'm doing... But yes, you're allowed to program both of them. \$\endgroup\$ – SoniEx2 Dec 2 '16 at 22:51
  • \$\begingroup\$ A question should ideally be self-contained. In this case the APIs for Google Home (whatever that is) and Amazon Echo (whatever that is) probably won't fit in the question, but an overview and links to the APIs would. \$\endgroup\$ – Peter Taylor Dec 2 '16 at 23:03
  • \$\begingroup\$ @PeterTaylor This isn't a matter of APIs. This is a matter of voice commands. \$\endgroup\$ – SoniEx2 Dec 3 '16 at 0:19
-3
\$\begingroup\$

Prelude:

Joke languages are allowed.
Submissions' scores will vary depending on whether they'll be made in a joke language, golfing language or a Turing complete language, don't worry if your score is high just because you chose a TC language.
That being said, let's get right into the challenge...

Challenge:

Make a program as close as possible to the language name and document what it does in the description.

Scoring/rules:

(will assume a simple language I made up, called Printr that has only a print() command that can take a argument to print but doesn't have to)

  • Submissions that contain more than a 1/2 of whole language name in a string (ex. print("Printr")) are banned.
  • Submissions must not throw any errors/exceptions/warnings (writing to an error stream is okay though).
  • +1 for every char away from language's name (ex. print("r") is 4 chars away, (""), +4 points)
  • Submissions need to contain (at least once) the language name "in a row" excluding nonalphanumeric characters and ignoring case (ex. print(" *@)!R") is okay, print("lolz R") is not okay)
  • Duplicates of the name will be counted as other characters (ex. print("r") print("r") is still 4+1 [space]+10=15).

By looking as close as the language I mean having the least score (since scoring is based on other characters than the language name itself.

Example:

Printr, score 4:

print("r")

This program prints "r" then quits.

\$\endgroup\$
  • \$\begingroup\$ is it allowed to throw an error? \$\endgroup\$ – FlipTack Dec 18 '16 at 14:00
  • \$\begingroup\$ @Flp.Tkc, good question, errors shouldn't be allowed (syntax error be like). \$\endgroup\$ – n4melyh4xor Dec 18 '16 at 14:07
  • \$\begingroup\$ What about a warning to STDERR? Stray error output is allowed by default on meta... \$\endgroup\$ – FlipTack Dec 18 '16 at 14:19
  • \$\begingroup\$ @Flp.Tkc, should be okay. \$\endgroup\$ – n4melyh4xor Dec 18 '16 at 14:24
  • \$\begingroup\$ ><>, in ><>, score 0, infinite loops. \$\endgroup\$ – redstarcoder Dec 18 '16 at 15:56
  • \$\begingroup\$ or actually if we're excluding non-alphanumeric characters, this could also be golfed down to > or empty depending on if outputting "something smells fishy..." is a valid program. \$\endgroup\$ – redstarcoder Dec 18 '16 at 16:00
  • \$\begingroup\$ in brainfuck you can just write brainfuck and it won't do anything... \$\endgroup\$ – FlipTack Dec 19 '16 at 17:31
-3
\$\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\$ – Sriotchilism O'Zaic 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\$ – Sriotchilism O'Zaic 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
-3
\$\begingroup\$

A simple challenge: Shortest program that takes the longest to compile.

\$\endgroup\$
  • \$\begingroup\$ What's the scoring requirement (i.e. how will programs be scored)? Who's machine will this be run on? \$\endgroup\$ – Qwerp-Derp Feb 11 '17 at 1:43
  • \$\begingroup\$ It's too broad of a challenge; are infinite loops allowed? To reiterate what Qwerp-Derp said, how will it be scored? Longest to compile -- what if it's an interpreted language? \$\endgroup\$ – user42649 Feb 11 '17 at 1:47
  • \$\begingroup\$ @AlexL.: languages without a compiler would be excluded. \$\endgroup\$ – jmoreno Feb 11 '17 at 1:57
  • \$\begingroup\$ I still believe this is not a good challenge because it is unclear what you are asking and it is too broad. \$\endgroup\$ – user42649 Feb 11 '17 at 2:01
-3
\$\begingroup\$

Make a Simple GUI application

I have made a simple glade layout. The chalenge is to remake it in as few bytes as possible.

The glade file:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <object class="GtkApplicationWindow">
    <property name="can_focus">False</property>
    <property name="title" translatable="yes">Remake me!</property>
    <child>
      <object class="GtkBox">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <child>
          <object class="GtkButton">
            <property name="label" translatable="yes">hello</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="receives_default">True</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">0</property>
          </packing>
        </child>
        <child>
          <object class="GtkLabel">
            <property name="visible">True</property>
            <property name="can_focus">False</property>
            <property name="label" translatable="yes">world</property>
          </object>
          <packing>
            <property name="expand">False</property>
            <property name="fill">True</property>
            <property name="position">1</property>
          </packing>
        </child>
      </object>
    </child>
    <child>
      <placeholder/>
    </child>
  </object>
</interface>

\$\endgroup\$
  • \$\begingroup\$ This probably doesn't break any rules, but it also doesn't seem that fun. It would be preferable if it was a more substantial task than simply golfing the code you already wrote. \$\endgroup\$ – Sriotchilism O'Zaic Feb 18 '17 at 2:09
-3
\$\begingroup\$

Rock Paper Scissors Lizard Spock

This game is from The Big Bang Theory, an extended version of the classic Rock Paper Scissors game.

Objective

To create a full program that I can run to play Rock Paper Scissors Lizard Spock against an "AI". The opponent ("AI") will pseudo-randomly choose their option after receiving user input.

The program must be run with user input of the following;

| Input     | Meaning   |
|-------    |---------- |
| R         | Rock      |
| P         | Paper     |
| S         | Scissors  |
| L         | Lizard    |
| SP        | Spock     |

The game is played with the following rules that Sheldon tells us;

Scissors cuts Paper

Paper covers Rock

Rock crushes Lizard

Lizard poisons Spock

Spock smashes Scissors

Scissors decapitates Lizard

Lizard eats Paper

Paper disproves Spock

Spock vaporises Rock

Rock crushes Scissors

enter image description here

Once you've taken user input, psuedo-randomly chosen the AIs option, you must output either "Player wins (<<user_input>> vs <<ai_input>>)" or "AI wins (<<user_input>> vs <<ai_input>>)". In the event of a tie (both the user and AI choose the same options), you must output "It's a tie"

Sample Runs

//Player chooses Scissors (S)
//AI chooses Paper (P)
$ php -f rpslsp.php S
Player wins (S vs P)

//Player chooses Spock (SP)
//AI chooses (R)
$ php -f rsplsp.php SP
Player wins (SP vs R)

//Player chooses Lizard (L)
//AI chooses Scissors (S)
$ php -f rsplsp.php L
AI wins (L vs S)

//Player chooses Lizard (L)
//AI chooses Lizard (L)
$ php -f rsplsp.php L
It's a tie

Rules

  • Standard loopholes apply.
  • The computer must choose an input at random (pseudo random) so that on each program run, the AI chooses (in a perfect world) a different input and that each input has the same percentage of being chosen.

This is code-golf so the shortest code in bytes wins.

\$\endgroup\$
  • \$\begingroup\$ "A full program" means that we're not allowed to return the result from a function? Must it be a full program?? \$\endgroup\$ – Mr. Xcoder Mar 13 '17 at 12:55
  • \$\begingroup\$ @Mr.Xcoder What I mean is we are able to run it in environments like TIO or REPL.it \$\endgroup\$ – ʰᵈˑ Mar 13 '17 at 13:01
  • \$\begingroup\$ 1. It's not true that the game is from BBT. BBT made a cultural reference to a preexisting game. 2. The output spec is incomplete because it doesn't say what to do in the case of ties. \$\endgroup\$ – Peter Taylor Mar 13 '17 at 14:32
  • \$\begingroup\$ @PeterTaylor Ah, I've only known the game exists because of TBBT, though the origin of the game doesn't really affect anything except maybe tread on the toes of some serious competitive RSPLSP players. Thanks for reminding me about it being a tie. \$\endgroup\$ – ʰᵈˑ Mar 13 '17 at 14:36
  • \$\begingroup\$ Closely related. Less closely related. \$\endgroup\$ – DLosc Mar 17 '17 at 19:42
-3
\$\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
-3
\$\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
-3
\$\begingroup\$

Fastest Compiling Fibonacci Sequence

Your task is to create a program which takes one numerical input and outputs all numbers in the Fibonacci sequence up to that point. However, you will not be scored on its bytecount or how many upvotes it gets. You will be scored on how quickly the compiler can compile it.


Rules

  • Of course, compiled languages are the only languages allowed.
  • All answers are tested on an Amazon EC2 instance with an Intel Xeon at 2.4GHz, about 1 GB of ram, and Amazon Linux installed. You can time your program on an equivalent machine, but I will compare results.
  • Your program is allowed to produce warnings when compiled, but it should work properly when run.
  • Compile time is tested with the time command, and "real" time is used for the final score.
  • If I need to comment the amount of time you took, you should add it to your answer.
  • Of course, standard loopholes are strictly disallowed.

This is , so may the cleverest optimization win and the best programmer prosper...

\$\endgroup\$
  • 1
    \$\begingroup\$ For a trivial challenge like this the compilation time is going to be dominated by noise: whether the compiler is in the disk cache is going to be more important than the code submitted. \$\endgroup\$ – Peter Taylor Aug 14 '17 at 8:05
  • \$\begingroup\$ To make compile times longer, you could require for the compiled program to work in O(1), or constant time. Then, the compiler will have to hardcode the entire sequence (up to a point specified by you, e.g. the largest 32- or 64-bit Fibonnaci number), which could make for interesting template-based programming optimization. \$\endgroup\$ – Sanchises Aug 14 '17 at 10:41
  • \$\begingroup\$ @Sanchises, not true. Binet's formula will do the job in O(1). \$\endgroup\$ – Peter Taylor Aug 14 '17 at 11:08
  • \$\begingroup\$ @PeterTaylor of course. So, another sequence which is proven not to have a direct formula could make this challenge possibly salveagable. \$\endgroup\$ – Sanchises Aug 14 '17 at 11:11
-3
\$\begingroup\$

Pascal's Particulars

Pascal is feeling very particular today. He wants to get an element from his famous triangle without going through the work of generating all the prior elements. He'll provide you with a row number and an entry number and you'll provide him with the element at that location.

Example:
Input row = 1, entry = 1, output 1. (row 1 is 1)
Input row = 3, entry = 2, output 2. (row 3 is 1-2-1)
Input row = 6, entry = 3, output 10. (row 6 is 1-5-10-10-5-1)

Rules

  • You will only be provided valid inputs (i.e. x will never be higher than n).
  • Your code should either print or return the output value, either works.
  • Standard golfing rules apply (lowest byte-count wins, etc.).

Happy golfing!

\$\endgroup\$
  • 2
    \$\begingroup\$ you know that you are just asking for binomial(n,k), don't you? this is trivial \$\endgroup\$ – J42161217 Aug 17 '17 at 17:33
  • \$\begingroup\$ Duplicate \$\endgroup\$ – Peter Taylor Aug 17 '17 at 17:39
-3
\$\begingroup\$

Break this block

Your challenge is to break this block. floating diamond

But of course that would be a pretty easy challenge, that's why this is a challenge.
The robber's challenge: Break the block. As breaking qualifies everything that has the result that no diamond block is at the coordinates 0 128 0 (even pushing it with a piston) and that follows the rules (see below).
The cop's challenge: Prevent the robbers from breaking the block. As preventing the breaking counts everything that guarantees that there is a diamond block at 0 128 0 in every future game tick despite the robber attempting his solution (and also if he doesn't). You are not in the world while the robber makes his attempt, so you have to prepare the world for him.

Rules

  • You may not use modded Minecraft or external tools that change the save file. Reading it with external tools is allowed.
  • You have to show a reproducible way to break/secure the block. Just uploading a world save without saying what you changed is invalid. You should offer a detailed explanation and preferably more (video, screenshots, structure file, etc.), if necessary.
  • This challenge starts with a normal world (default generation, Creative+cheats, random seed), where one diamond block was placed using the command
    /setblock 0 128 0 diamond_block
    The spawn chunks can include 0 0, but they don't have to. Since both sides have access to commands, that shouldn't matter anyway.

Sandbox questions

  • How should I restrict the version? Should it be "latest release", "any stable release", "only 1.12.1", "any snapshot, release or historical version" or something else? People could come up with interesting solutions using past versions (maybe even past snapshots that aren't selectable in the launcher anymore), but I have to somewhat restrict it. If a certain downgrade automatically breaks the block, it's of course boring, especially since they instantly win. And if they load the world in any of the 9 oldest versions in the launcher (called "Classic" and "pre-Classic), there isn't even a diamond block in the game, so it would be deleted.
  • Should I discourage people from instantly preventing every single breaking method with their first "cops" post? To have an interesting challenge, it should slowly become more difficult. If I should discourage it, how to "enforce" it?
  • What other rules do I need?
  • I'm planning to be very active myself on the "cops" side (I already have some nice ideas), possibly creating the majority of posts there. Is there a problem with that? If no, would it be considered unfair or boring to ask the others to wait up to a day with their solutions? Of course they don't have to do it, I just originally planned this to create programming challenges for myself.
  • If every answer on one side can have multiple answers on the other side, which itself could have answers on the first side and so on, that could lead to a tree-like structure. But such a structure would lead to many unanswered questions (if it doesn't keep growing exponentially, what I highly doubt). Is there a way to prevent that or should I even try it?
  • Apparently this is the first Minecraft-only programming challenge here. Should a tag be created for it?
\$\endgroup\$
  • 4
    \$\begingroup\$ This doesn't make sense. What are the submissions? Minecraft commands? A set of instructions? A program that reads a save file and outputs a new one? \$\endgroup\$ – DJMcMayhem Aug 22 '17 at 20:02
  • \$\begingroup\$ Submissions would mostly be Minecraft commands, but maybe in the first few rounds instructions. \$\endgroup\$ – Fabian Röling Aug 23 '17 at 5:39
-3
\$\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\$
-3
\$\begingroup\$

Be typically flexible efficiently

Write a short function that returns outputs of different types in a non-boring way. If L is the length of your code and T is the number of different types returned, your score is (T−1)/L. The highest score wins.

  • The function must take exactly one argument and be deterministic, i.e., the output depends only on the input.

  • Obviously your programming language must have an official notion of type, by which each object has a unique, clearly identified type. Typically this would manifest in a type or typeof function returning an object’s type. Also, it must obviously allow functions to have differently typed returns.
    If there are many separate typing systems in your language, you have to pick one (conforming with the above) and stick to it.

  • The function must not employ any conditional constructs or other language features whose primary purpose is to handle logic, such as if statements, loops, or logical conjunctions. (Obviously, employed predefined functions need not adhere to this.)

  • All inputs needed to produce the outputs used for scoring as well as any elements of container structures must adhere to the following:

    • They are all of the same type.
    • If they are functions or otherwise callable (and actually called in your program), they must consistently return objects of the same type.
    • They must not be classes, type identifiers, or similar.
    • If they are strings, they are treated (with respect to these rules) as any obvious interpretation of them as code, class names, or similar.
    • If they are containers themselves, their elements must adhere to these rules when taken together.

    So, e.g., in Python the following are invalid:

    a = lambda i: [ 0, 0., [], {}, (0), {0} ][i]
    b = lambda i: [ int, float, list, dict, tuple, set ][i]()
    c = lambda i: [ [0], [0.], [[]], [{}], [(0)], [{0}] ][i][0]
    d = eval   # using "0", "0.", "[]", "{}", … as input
    e = lambda i: eval( ["0","0.","[]","{}","(0)","{0}"][i] )
    

    This also applies to containers generated during by the function during its execution. (Obviously, this does not apply to such objects if used internally by employed predefined functions.)


Valid (ungolfed) example

Python:

def f(i):
    return sum([2.][0:i])

For this we have:

f(0) == 0
type(f(0)) == int
f(1) == 2.0
type(f(1)) == float

This makes use of the fact that the sum of an empty iterable (like [2.][0:0]) is 0.


Sandbox questions

  • I am pondering whether I should replace a portion of the rules with a catch-all like:

    If whatever trick you use to acquire n types of output can be used to obtain n+1 types of output, it is invalid. (If n+1 just doesn’t work because n is the total number of types in your language, this doesn’t count either.)

    Obviously, this would lessen the chance of any boring loopholes, but it would also be more likely to be subject to interpretation. Do you think this is a good idea?

  • Did I miss any obvious loopholes that would make this challenge boring?

  • This challenge was mainly done with Python in mind, but I seen no reason why it should not extend to other programming languages (with a suitable typing system). Are there any obvious pitfalls with other languages that I should consider?

  • Are there any other appropriate tags for the question?

\$\endgroup\$
  • 3
    \$\begingroup\$ This seems like an interesting challenge at its core, but there are a lot of gotchas. Is indexing into a tuple considered a logical construct? For example, in PowerShell, you can put a Boolean into the index and it will automatically cast to 0 or 1 to get a pseudo-ternary operation. Are languages like Java allowed to use reflection? Etc. \$\endgroup\$ – AdmBorkBork Oct 13 '17 at 20:34
  • 1
    \$\begingroup\$ Also in a language like R (my most familiar language), there are really only 7 types as given by typeof() but there are numerous classes which can be found by class(). That being said, every instance of an R class is really list when typeof() is called on it. see this, for example. Basically, you'll have to make a decision for every language submitted on "a suitable typing system" \$\endgroup\$ – Giuseppe Oct 13 '17 at 20:44
  • \$\begingroup\$ @AdmBorkBork: Is indexing into a tuple considered a logical construct? – No, handling logic is not the primary purpose of this feature. I also do not see this as a problem since a tuple is an iterable and thus its elements would have to be of the same type. (Such pseudo-choosing operations are exactly the reason why I imposed that rule.) — Are languages like Java allowed to use reflection? – I only briefly looked into this, but I don’t see a how this could pose a loophole. \$\endgroup\$ – Wrzlprmft Oct 13 '17 at 21:24
  • \$\begingroup\$ @Giuseppe: (T-1)/L rather than (T-1)/C – corrected, thanks. — Basically, you'll have to make a decision for every language submitted on "a suitable typing system" – I added a note that you can pick one and stick to it in that case. Would this pose any problems with your example (R)? \$\endgroup\$ – Wrzlprmft Oct 13 '17 at 21:34
  • \$\begingroup\$ 1. A PowerShell tuple is not an iterable. 2. Plenty of languages have duck typing. That's a clear notion of type, but it has the potential to trivialise this question in the same way that reflection does. E.g. in JavaScript function f(s){var o={};o[s]=f;return o} 3. The Java method you should be looking at is Class.forName. \$\endgroup\$ – Peter Taylor Oct 13 '17 at 22:59
  • \$\begingroup\$ @PeterTaylor: 1. Okay, let me generalise this to containers. 2. I am familiar with duck typing from Python but I don’t see how this provides a loophole. Your JavaScript example always returns something of type object IIUC. 3. From what I just learnt, that seems to be a special case of interpreting strings as code. \$\endgroup\$ – Wrzlprmft Oct 13 '17 at 23:28
  • \$\begingroup\$ 2. "If there are many separate typing systems in your language, you have to pick one and stick to it." I'm using duck typing: your objection is using prototype-based typing. 3. No, it takes a string which is the name of a type and instantiates an object of that type using its public 0-ary constructor. \$\endgroup\$ – Peter Taylor Oct 14 '17 at 6:27
  • \$\begingroup\$ Given that so many approaches are disallowed, can you add a simple example or two of a valid approach? \$\endgroup\$ – user2390246 Oct 14 '17 at 8:14
  • \$\begingroup\$ @PeterTaylor: 2. I get what you are going at now, but I would not consider duck typing a clear typing system in the sense that every object has a unique type (I edited to clarify) – if you so wish, it is the absence of such a system. 3. I gathered that, but how is that not interpreting a string as code? Anyway, I edited that criterion to be more inclusive. \$\endgroup\$ – Wrzlprmft Oct 14 '17 at 9:47
  • \$\begingroup\$ @user2390246: I added an example. \$\endgroup\$ – Wrzlprmft Oct 14 '17 at 9:48
  • 1
    \$\begingroup\$ I don't think the edits unambiguously resolve the issues. 2. I can write a typeof function in JavaScript which produces an array of the properties of an object. 3. It's more like a defaultdict lookup than eval. And I don't see how "these strings are subject to all rules" unambiguously prohibits reflection.The contents of the string are characters: the string is not a valid statement or expression, and its contents can't really be said to have a type. \$\endgroup\$ – Peter Taylor Oct 14 '17 at 10:53
  • \$\begingroup\$ @PeterTaylor: 2. I can write a typeof function in JavaScript which produces an array of the properties of an object. – Words fail me. Let’s stick to official type systems (I edited). — 3. unambiguously prohibits reflection – My goal isn’t to prohibit reflection (which is probably fuzzy anyway), but only exploits thereof that make this challenge boring. I restructured the rules and extended them in a way that I hope will clearly cover Class.forName and any other boring exploits. \$\endgroup\$ – Wrzlprmft Oct 15 '17 at 9:48
-3
\$\begingroup\$

Puzzle:

  • Make a program that draws the following figure line by line.

  • Your program should wait for one-second(it can be longer, just has to be a noticable difference) after drawing each line.

  • Your program can only draw line by line (you cannot jump to another point or re-draw over a line)

  • Given a positive integer n, produce an art image of the below drawing

  • The angle measures should always be the same (regardless of n's value)

  • However, each line's length should be 150*n pixels

  • You only need to account for when n = 1, n = 2, n = 3

example

Specifications:

if n=1:

  • length = 150 pixels

if n=2:

  • length = 300 pixels

if n=3

  • length = 450 pixels

.

.

Answering - Name the language you used followed by its bytes

Example:

Java (swing), 500 bytes

.

Scoring

Good luck!

\$\endgroup\$
  • 4
    \$\begingroup\$ You haven't solved the obvious issue "You can't have an equilateral triangle with angles of 45-45-90." (comment from deleted challenge) The sandbox is only helpful if you listen to people who suggest changes, really. \$\endgroup\$ – user202729 Oct 22 '17 at 8:00
  • \$\begingroup\$ I'm not sure what we're being asked to draw. Just the black figure? The black figure and the annotations? \$\endgroup\$ – Peter Taylor Oct 23 '17 at 7:07
-3
\$\begingroup\$

I have seen many a trivial answer in jelly, so i wish to propose:

Challenge: A non-trivial answer

  • Input two strings
  • If the two strings are integers and are equal, output a truthy value.
  • Otherwise, output a falsy value.

Clarifications

  • You may receive non-integer inputs.
  • You will never receive an integer that is outside the bounds [-2³¹, 2³¹). Rules

  • Standard loopholes are disallowed.

Scoring:

  • This is not your standard code-golf
  • the winner person who posts the longest program.
  • an entry is invalidated if someone posts a shorter program in the same language.
\$\endgroup\$
  • \$\begingroup\$ Note: i don't believe that this is code-bowling, as only the shortest program in any language is eligible; this is more about finding an obscure language in which the task is actually hard to do, rather than obscure languages where the task is too easy. \$\endgroup\$ – Andrew Hill Nov 2 '17 at 22:19
  • \$\begingroup\$ Easy win for Unary. \$\endgroup\$ – Dennis Nov 2 '17 at 22:26
  • \$\begingroup\$ what a horrible way of representing a program, yeah... any type of 'longest sensible program' task is not so helpful. \$\endgroup\$ – Andrew Hill Nov 3 '17 at 3:20
  • \$\begingroup\$ @Dennis do you think that restricting to languages that have won a standard code-golf challenge in 2017 would help? It does seem that if we have to start putting in language or other implementation restrictions, then this isn't worth posting. Oh well. guess this stays on the proposal board. \$\endgroup\$ – Andrew Hill Nov 3 '17 at 3:22
-3
\$\begingroup\$

Golf This Question

Your program should output to STDOUT the full text of this question as it appears on your screen, so no HTML. This includes the title and the body. Please do not edit this question whatsoever so-as to keep it the same for all programs.

No reading the text from a file or the internet

This is , so the shortest code wins!

Sandbox Is this a good question? Is there anything I should clarify?

\$\endgroup\$
  • \$\begingroup\$ similar but obviously different since it requires the markdown. \$\endgroup\$ – Giuseppe Nov 8 '17 at 16:17
  • 1
    \$\begingroup\$ You should add some rules and winning criteria (which would increase the length of the question, but oh well) \$\endgroup\$ – HyperNeutrino Nov 8 '17 at 17:28
  • 1
    \$\begingroup\$ I'm not sure what much this adds beyond the typical KC challenges, and thus it's likely to be closed as a dupe. \$\endgroup\$ – AdmBorkBork Nov 8 '17 at 17:36
  • 1
    \$\begingroup\$ @AdmBorkBork I guess OP means to allow access to the internet, in which case it's very different, but I'm not sure... If so, it's basically a challenge about parsing html, or get the result directly from the API (if that's possible). \$\endgroup\$ – Stewie Griffin Nov 8 '17 at 18:40
  • \$\begingroup\$ Include tag about Kolmogorov complexity. \$\endgroup\$ – Heimdall Nov 11 '17 at 8:43
  • \$\begingroup\$ Why the downvotes? \$\endgroup\$ – FantaC Nov 21 '17 at 23:24
-3
\$\begingroup\$

Find the min swaps for order one powerset for a List

The question it is write one powerset function and one sort function tha minimize the swaps for doing one order with this compare function on powerset of the List A

cmp(a,b) -- a and b are subset of the list A
    if sizeof a > sizeof b then (swap a and b; return)
    if sizeof a < sizeof b than return
    for i in 1..(sizeof a) repeat
         for j in 1..(sizeof A) repeat
               if a[i]==A[j] then return
               if b[i]==A[j] then (swap a and b; return)

the result of this compare function on the sets wuold be the follow:

(15) -> powSet([1,2,3])
   (15)  [[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]
                                                      Type: List List Any
(16) -> powSet([3,2,1])
   (16)  [[],[3],[2],[1],[3,2],[3,1],[2,1],[3,2,1]]
                                                      Type: List List Any

note that order depend not from the number element, but on the position on the start List A=[1,2,3]

(17) -> powSet([1,2,3,4,5,6])
   (17)
   [[], [1], [2], [3], [4], [5], [6], [1,2], [1,3], [1,4], [1,5], [1,6], [2,3],
    [2,4], [2,5], [2,6], [3,4], [3,5], [3,6], [4,5], [4,6], [5,6], [1,2,3],
    [1,2,4], [1,2,5], [1,2,6], [1,3,4], [1,3,5], [1,3,6], [1,4,5], [1,4,6],
    [1,5,6], [2,3,4], [2,3,5], [2,3,6], [2,4,5], [2,4,6], [2,5,6], [3,4,5],
    [3,4,6], [3,5,6], [4,5,6], [1,2,3,4], [1,2,3,5], [1,2,3,6], [1,2,4,5],
    [1,2,4,6], [1,2,5,6], [1,3,4,5], [1,3,4,6], [1,3,5,6], [1,4,5,6],
    [2,3,4,5], [2,3,4,6], [2,3,5,6], [2,4,5,6], [3,4,5,6], [1,2,3,4,5],
    [1,2,3,4,6], [1,2,3,5,6], [1,2,4,5,6], [1,3,4,5,6], [2,3,4,5,6],
    [1,2,3,4,5,6]]
                                                      Type: List List Any

Win the one that minimize the swaps for order the powerset of the follow list

[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5],[1,2,3,4,5,6]

Patterns match for composed expression

If we have one math expression B(x) [that mean in B appear x] [math expression is one expression where appear only symbols for function and operator of mathematics that are ok for type and compose ] Find the max lengt subexpression g(x) of B contain x such that

B(x)=f(g(x))

And f(y) and g(x) are both math expression.

Find Max for a function in one interval

R is the set of real numbers. Is given a function f:A->R from set A (⊆ R) to the R, continue and derivable in one close interval

 [a, b]⊆A

Write the shortest program for find

 max{f(x): x in [a,b]}

knowing the function f(x) derivable in the interval [a,b]. The solution has to be correct at last until the V digit after the float point, and for all functions f that has 10 value max in which f'(x)= 0 in [a, b]. codegolf tag

On Riemann Zeta function domain

If Zeta:C->C is the Riemann Zeta function, we give the set:

 W={b: 0<b<100 and Re(Zeta(0.5+i*b))=-Im(Zeta(0.5+i*b))}

Where Re() return the real part of its argument, and Im() return the imaginary part of its argument.

It is requested to calculate one approximation of each element of W; this means here all b in float numbers with b in 0..100 such way

  abs(Re(Zeta(0.5+i*b))+Im(Zeta(0.5+i*b)))<0.0001 

at last, to put all together in a array or list or set of float.

One can note that the below set of zeros for the Riemann function is a subset of above W set.

 {b: 0<b<100 and Zeta(0.5+i*b)=0}

Some test

Some numbers b approssimation to solution of equation

Re(Zeta(0.5+i*x))+Im(Zeta(0.5+i*x))=0 

the ones that are approssimation to solution of equation Zeta(0.5+i*x)=0 too

[14.134725, 21.022039, 30.424876, 32.935061, 37.58617815, 40.918719, 43.327073, 48.00515, 49.773832]

the ones not approssimation to solution of equation Zeta(0.5+i*x)=0 too

[12.458493623791109003, 24.351346882420215577, 28.716611773969890307]

The code more short in bytes that find all these approssimations of element of the set W wins...

Code golf tag

\$\endgroup\$
  • 2
    \$\begingroup\$ You're going to need to phrase this better and be more precise about what you're asking for. Currently, this sounds a little bit like a homework question. \$\endgroup\$ – numbermaniac Apr 22 '17 at 13:25
  • \$\begingroup\$ This is also formatted improperly. \$\endgroup\$ – Erik the Outgolfer Apr 22 '17 at 13:27
  • \$\begingroup\$ This appears to permit hard-coding the output, which is generally a sign of a bad question. Why not parameterise it? \$\endgroup\$ – Peter Taylor Apr 22 '17 at 15:09
  • \$\begingroup\$ I think now I ' m clear... What is not clear or ambiguous? \$\endgroup\$ – RosLuP Apr 22 '17 at 15:40
  • \$\begingroup\$ possibly a little too much difficult... there are numbers that seems solutions but if i increase digits they are just wrong.... \$\endgroup\$ – RosLuP Apr 23 '17 at 17:55
  • 1
    \$\begingroup\$ Also, it's "approximation". \$\endgroup\$ – Steve Bennett May 22 '17 at 6:40
  • 2
    \$\begingroup\$ Being (continuous and) differentiable is quite a weak constraint. There are e.g. nasty functions which are differentiable but whose derivative is not integrable. \$\endgroup\$ – Peter Taylor May 22 '17 at 11:47
  • \$\begingroup\$ One continue function in one close interval [a, b] has max and min \$\endgroup\$ – RosLuP May 22 '17 at 13:48
  • \$\begingroup\$ So for the order a PowerSet of one list is all clear... \$\endgroup\$ – RosLuP Nov 16 '17 at 13:30
-3
\$\begingroup\$

Shortest code to draw a png from stdin

Rules :

  • You’re free to use any image library you want as long as the image library is designed in the same language as your answer.
  • The image should be displayed in an Xorg or wayland window or a console framebuffer.
    If you’re displaying to a window, you don’t need to create any windows control (in that case the programs ends with CTRL+C).
  • The stdin stream doesn’t eof. so the only way to get the image size is to parse png data. Once the image had been displayed, /dev/stdin should be closed.
  • Your answer shouldn’t crash on random data.

The answer using the fewest bytes wins !

\$\endgroup\$
  • \$\begingroup\$ Way too easy for some languages and way too hard for others. And how would I do it if my language can't produce graphical output? What if I have neither STDIN nor STDOUT? \$\endgroup\$ – Stephen Leppik Nov 29 '17 at 16:21
  • \$\begingroup\$ @StephenLeppik : the point of my question is to suggest that language choice is restricted to languages that can run on Unix systems supportting screening. I don’t know too easy answers, but libpng16 along Xorg libraries should make it possible in a few line of code. \$\endgroup\$ – user2284570 Nov 29 '17 at 16:45
  • 2
    \$\begingroup\$ Restricting it to such a small list of languages is a good way of alienating half the site. \$\endgroup\$ – Stephen Leppik Nov 29 '17 at 16:52
  • \$\begingroup\$ @StephenLeppik : It just basically, restrict to all languages which can write a hello word. Writing to a framebuffer is just as easy as to write a raw image in device file which opens like a normal file so this doesn’t matter. I’d rather say the list of language that can print a Hello world on Linux or ʙꜱᴅ is huge but not small. \$\endgroup\$ – user2284570 Nov 30 '17 at 17:34
  • \$\begingroup\$ Believe it or not, displaying an image is not a capability that directly follows from being able to print text… \$\endgroup\$ – Unrelated String Mar 22 at 2:40
  • \$\begingroup\$ @UnrelatedString that’s because it’s not possible to do it from text I’m asking this. But this is defintely like writing to a file. \$\endgroup\$ – user2284570 Mar 22 at 19:31
-3
\$\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
-3
\$\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
-3
\$\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
-3
\$\begingroup\$

Not today


The challenge

Given a timestamp (date and time) output another timestamp that differs from the input at all positions, i.e. has different value for year, month, day, hour and minute.

Input and output

A timestamp in any reasonable format including, but not limited to:

  • timestamp type, if your language supports it,
  • string,
  • number (eg. number of seconds from specific fixed date),
  • array of numbers or strings.

You may assume valid date (AD) and time as input and must have valid date (AD) and time as output. You can follow simplified date regulations for the whole time since year 1 AD:

  • respective month lengths: 31, 28/29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31;
  • leap years are needed to be taken into account;
  • a day has 24 hours and an hour has 60 minutes - no need to account for leap seconds and other anomalies;
  • you can handle midnight any way you prefer (as 00:00 or 24:00).

If you choose, you can support seconds and milliseconds, but the difference condition doesn't apply.

Examples

2018-05-01 17:28 --> 2000-01-02 12:11
0001-01-01 00:01 --> 3000-12-31 23:59
3000-12-31 23:59 --> 0101-01-01 01:01
\$\endgroup\$
  • 2
    \$\begingroup\$ I'm afraid that this is too trivial. Just add 1 year, 32 days, 1 hour and 1 minute. (about 34390860 seconds) There may be better constants, but once a good constants had been figured out, people would just port that to other languages. Boring. \$\endgroup\$ – user202729 May 2 '18 at 8:59
  • \$\begingroup\$ @user202729 do you think removing the input/output as number will make it less trivial (without making it a chameleon challenge)? Also, maybe making an upper and lower limit for the date would add some difficulty? \$\endgroup\$ – pajonk May 2 '18 at 19:29
  • \$\begingroup\$ Javascript String->string s=>1+s \$\endgroup\$ – l4m2 May 3 '18 at 10:58
-3
\$\begingroup\$

Reverse Code Golf- Print out two by using variables a and b that both equal one and adding them without any extraneous lines.

Your task is very simple, display that 1+1=2, except you need as many commands and non extraneous lines as possible.

What counts as non-extraneous? If one cannot remove any kind of sequence or segment of commands, then the program is counted as non-extraneous. The variable names need to be only one byte each, without any kind of trailing zeroes or insignificant digits.

Input: nothing

Output: "2" or 2 or whatever, as long as the program runs 1+1.

Sample: Java- System.out.println( Integer.parseInt( "1" ) + Integer.parseInt( "1"));

\$\endgroup\$
-3
\$\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
-3
\$\begingroup\$

Send the pairs

Write two program A and B. A takes 1024 pairs of integers (a,b), where 0≤a<232, 0≤b<1024, and all as are different. Output a positive integer. B take the output of A and one a from the input pairs of A, and output its b.

Smallest output of A under a same random test data win.

\$\endgroup\$
  • \$\begingroup\$ To be a truly objective challenge, the test data should be included in the question; but then B could hard-code it and A could output 1 as a flag to invoke the hard-coded data. \$\endgroup\$ – Peter Taylor Jul 24 '18 at 20:03
  • 1
    \$\begingroup\$ @PeterTaylor I don't think hiding the test case make the challenge less objective. \$\endgroup\$ – user202729 Jul 25 '18 at 7:45
  • 2
    \$\begingroup\$ @user202729, codegolf.meta.stackexchange.com/a/1369/194 . If I can't tell whether a change to my answer makes it better or worse, it's not an objective challenge. If the only person who can tell is the OP, then the judging is a black box which from the outside is indistinguishable from a purely subjective judgement. \$\endgroup\$ – Peter Taylor Jul 25 '18 at 7:50
  • \$\begingroup\$ @PeterTaylor codegolf.meta.stackexchange.com/a/308 (+15 vote) \$\endgroup\$ – l4m2 Jul 25 '18 at 10:44
  • 1
    \$\begingroup\$ @l4m2, that agrees perfectly with the last sentence of my previous comment. \$\endgroup\$ – Peter Taylor Jul 25 '18 at 11:18
  • \$\begingroup\$ @PeterTaylor No if the test is public some days after \$\endgroup\$ – l4m2 Jul 25 '18 at 11:33
  • \$\begingroup\$ @l4m2, then you would lack a winning criterion until you post those tests publicly. \$\endgroup\$ – JungHwan Min Jul 29 '18 at 14:41
  • \$\begingroup\$ @JungHwanMin A recent meta post explicitly allowed that. \$\endgroup\$ – user202729 Aug 1 '18 at 2:52
-3
\$\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
-3
\$\begingroup\$

Write a program that takes a list of strings as input and creates trees of prefixes as such:

Hi_there_how_are_you?
Hi_there_would_you_mind?
Hi_the_weather_is_nice
Hills_are_green
Many_of_us
May_has_11_days
May_has_11_days_left
IWillLearnTheTrombone
IWillLearnTheSaxophone
IWillLearnThePiano

Which would output:

Hi Hi_there Hi_there_how_are_you?
            Hi_there_would_you_mind?
   Hi_the_weather_is_nice
   Hills_are_green
Ma Many_of_us
   May_has_11_days May_has_11_days
                   May_has_11_days_left
IWillLearnThe IWillLearnTheTrombone
              IWillLearnTheSaxophone
              IWillLearnThePiano

The input strings shall contain no spaces and the output shall be separated by at least one space, any number of extra line breaks or spaces are allowed. The output above is formatted to explain the challenge, the following formatting is also valid:

Hi Hi_there Hi_there_how_are_you? Hi_there_would_you_mind? Hi_the_weather_is_nice Hills_are_green Ma Many_of_us May_has_11_days May_has_11_days May_has_11_days_left IWillLearnThe IWillLearnTheTrombone IWillLearnTheSaxophone IWillLearnThePiano

This question is a kind of reverse of this Prefix Tree Traversal. This is code golf, shortest code in bytes win.

Note: I'm struggling with the output? What would be the most 'fun'/ have high potential for cleverness? The one I have now just looks like a mess. Can i have output as a list of lists(of lists)? Or do that hinder people?

\$\endgroup\$
  • 1
    \$\begingroup\$ Related (make an alphabeTrie). Very close, though I think it might depend on your output format on whether it is a dupe \$\endgroup\$ – Jo King Sep 23 '18 at 8:48
  • \$\begingroup\$ I would mark it as a duplicate to the one that Jo King linked. \$\endgroup\$ – AdmBorkBork Sep 27 '18 at 19:54

You must log in to answer this question.

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