450
\$\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

2479 Answers 2479

-2
\$\begingroup\$

Calculate the number of consecutive 0's at the end of n!


Simply put, write a program or function that takes n and returns the number of consecutive 0's at the end of n!


Examples

Input: 12
Output: 2

Input: 12345
Output: 3082

Input: 100000
Output: 24999
\$\endgroup\$
  • \$\begingroup\$ I think this might be a dupe. \$\endgroup\$ – Rɪᴋᴇʀ Apr 2 '16 at 21:45
  • \$\begingroup\$ @EasterlyIrk Do you have a link to the duplicate problem? \$\endgroup\$ – Mr Public Apr 4 '16 at 11:38
  • \$\begingroup\$ This is extremely similar. \$\endgroup\$ – FryAmTheEggman Apr 4 '16 at 17:20
  • 2
    \$\begingroup\$ This proposal would be similar to finding the position of the last nonzero digit, but it's not similar to the linked challenge, which finds the value of the last nonzero digit \$\endgroup\$ – Luis Mendo Apr 6 '16 at 11:14
-2
\$\begingroup\$

Self-identification before golfing

Since golfed code is harder to read, answers often contain an less golfed version. There are a number of potential golfing transformations depending on the language, so you may be able to score more highly using a more traditional language. Some examples of golfing transformations:

  • Removal of spaces, tabs and/or newlines
  • Removal of disambiguating parentheses
  • Removal of braces around single controlled statements
  • Conversion from statements to comma operator
  • Removal of explicit return statements
  • Renaming identifiers

Your challenge is to write a program or function that can identify an ungolfed version of itself. Scoring is based on the number of golfing transformations that can be recognised. The submission must be capable of identifying all "original" code that is itself capable of self-identification (at least one such code must exist). Each supported transformation scores 1 point, but there are also bonus points available:

  • 1 bonus point if the transformation can be repeated multiple times
  • 1 bonus point of the program rejects at least one invalid transformation of itself (e.g. white space added inside a keyword)
  • 1 bonus point if the program only accepts valid transformations of itself
  • 1 bonus point if the transformation shortened the code (so if you only supported renaming a 1-letter variable to another letter, you would not qualify)
  • 1 bonus bonus point if in addition the transformed program recognises the original program as a transformation of itself

Example: A submission accepts the name of another program as a command-line parameter. It opens itself using its own name hard-coded into itself. It recognises the following transformations:

  • A change to the hard-coded file name (3 points, as there is only one file)
  • A change to the amount of space between words (5 points, as there are no invalid transformations to reject)
  • A change to the names of its variables (4 points, as it doesn't check whether the variables are renamed consistently or to keywords)

Total score: 12 points.

In the event of a tie on score, shortest code wins.

Tags: code-golf, quine

\$\endgroup\$
  • 4
    \$\begingroup\$ This is hopelessly subjective. \$\endgroup\$ – feersum Apr 5 '16 at 13:35
-2
\$\begingroup\$

Make a quine without using string literals

A quine is a computer program that prints out it's own source code to stdout. Your task is to make one that doesn't use string literals.

You cannot:

  • Have any empty program
  • Read your source code directly or indirectly (i.e. form a file)
  • Use error messages to print out the source code
  • Rely on language features to print out the source
  • Relying on a REPL environment

A string literal is a:

  • String type (obvious)
  • Number used to store the character (sorry BF!)
  • Other predefined constant

You are encouraged to compute your own source code.

\$\endgroup\$
  • 1
    \$\begingroup\$ This hits two of the "things to avoid when writing challenges": do X without Y and popcons. (I assume it's an attempt to finesse a third: generalised quines). It also has some fairly bad phrasing: what language can print anything without using "language features"? In what way does BF use literals? How many languages can compute anything without using at least one constant? \$\endgroup\$ – Peter Taylor Apr 12 '16 at 7:27
-2
\$\begingroup\$

Random Wikipedia Browsing

Here's a short one for you. Create a program or function prints or returns the title of a random Wikipedia page (similar to Alt + x functionality)

Rules:

  • Program or function will take no input
  • Program or function will print to STDOUT (or nearest equivalent) or return only the page name. I don't care about trailing spaces or newlines. Preceding spaces or new lines are disallowed
  • Program or function may not access a list of Wikipedia page names stored within a local file.
  • There is no requirement to use English language Wikipedia (en.wikipedia.org)
  • Page must be chosen (psuedo) randomly

For reference, here is a link to the Wikipedia API. Shortest program or function in bytes wins.

\$\endgroup\$
  • \$\begingroup\$ Bash: xdg-open http://bit.ly/19UDVJs (I think it's open). That Bitly link points to the Random Page link, which redirects to a random page. Wouldn't be hard to find a shorter URL, either. \$\endgroup\$ – Nic Hartley Apr 14 '16 at 17:10
  • \$\begingroup\$ Aww man, I had no idea that existed, guess it makes this pretty trivial \$\endgroup\$ – wnnmaw Apr 14 '16 at 17:11
  • \$\begingroup\$ Yep. Though if the language's builtins don't support automatic handling of redirects, it might be more challenging. \$\endgroup\$ – Nic Hartley Apr 14 '16 at 17:11
  • \$\begingroup\$ Could I disallow using that link? \$\endgroup\$ – wnnmaw Apr 14 '16 at 17:12
  • \$\begingroup\$ I dunno, to be honest. I'm not very good at writing challenges. \$\endgroup\$ – Nic Hartley Apr 14 '16 at 17:13
  • \$\begingroup\$ Relevant chat discussion, this challenge is trival \$\endgroup\$ – wnnmaw Apr 14 '16 at 17:21
  • \$\begingroup\$ @wnnmaw the Random Page is often used for wiki-racing. It's pretty fun. You can do either shortest distance (pages traversed), or fastest time. Maybe you could make this into a King of the Hill challenge to write a bot that wiki-races against other bots? \$\endgroup\$ – mbomb007 Apr 21 '16 at 18:15
-2
\$\begingroup\$

Golf a golf-scoring program!

Given a space delimited array of integers, find the smallest number. It's that simple.

[Meta] This may in fact be a duplicate. Please tell me if so.

\$\endgroup\$
  • 1
    \$\begingroup\$ This is basically a dupe of any regular sorting question, isn't it? Particularly something like Sign that word. \$\endgroup\$ – FryAmTheEggman Jun 9 '16 at 12:52
-2
\$\begingroup\$

Oh noes! A site redesign is eating my privileges!


PPCG is graduating and will soon receive a new design. Unfortunately for everbody except some people, the new design will also mean losing privileges due to higher reputation requirements.

Now, losing some privileges is a small sacrifice for the Magnificent Glorious Site Redesign®©™, but… How much do we stand do lose?

The challenge

Your program / function receives a reputation level (e.g. 535). Output the privileges that are currently available to it, but will not be available after the redesign.

Output

Output can be either an array or a string that's separated by a delimiter. The delimiter may not be any of A-Za-z<space>. Multi-character delimiters may end in a space, though.

If there are no matches, your program should output either an empty array or a falsy value.

Examples

Input
25000
Output
[]
Input
24999
Output
["access to site analytics"]
Input
2000
Output
["access to moderator tools","approve tag wiki edits","cast close and reopen votes","create tag synonyms"]
Input
535
Output
["cast close and reopen votes"]
Input
350
Output
["access review queues"]
Input
5
Output
[]
Input
4
Output
["participate in meta"]

Deliberately ignoring the facts in the last example.

Available privileges

For convenience, here is a JSON array with available privileges and the required reputation before / after:

[[5000,25000,"access to site analytics"],[4000,20000,"trusted user"],[3500,15000,"protect questions"],[2000,10000,"access to moderator tools"],[1500,5000,"approve tag wiki edits"],[500,3000,"cast close and reopen votes"],[1250,2500,"create tag synonyms"],[1000,2000,"edit questions and answers"],[750,1000,"established user"],[1000,1000,"create gallery chat rooms"],[350,500,"access review queues"],[150,300,"create tags"],[250,250,"view close votes"],[125,125,"vote down"],[100,100,"edit community wiki"],[100,100,"create chat rooms"],[75,75,"set bounties"],[50,50,"comment everywhere"],[20,20,"talk in chat"],[15,15,"flag posts"],[15,15,"vote up"],[10,10,"remove new user restrictions"],[10,10,"create wiki posts"],[1,5,"participate in meta"],[1,1,"create posts"]]

At index 0 is the reputation before, at index 1 is the reputation after. (The privilege reduce ads (200 reputation) is not available to beta sites and therefore not included in this list.)

Standard I/O and loophole rules apply.

\$\endgroup\$
  • \$\begingroup\$ Related. It's borderline whether this adds enough to not count as a duplicate: I would vote that it does, but I wouldn't cast my supervote. \$\endgroup\$ – Peter Taylor Jul 12 '16 at 16:21
  • \$\begingroup\$ @PeterTaylor I'm thinking of changing the challenge to allow submissions to download the privilege page. I guess that would make it distinct enough. \$\endgroup\$ – user2428118 Jul 13 '16 at 10:53
  • \$\begingroup\$ Turns it into a hybrid parse-HTML and merge data sources question. Yes, I think that's novel. You should make it very clear that the answers should keep working after the contents of the privilege page are updated to show the new rep levels; and possibly you should take a backup copy of the page in case of future addition of new privileges. \$\endgroup\$ – Peter Taylor Jul 13 '16 at 11:01
-2
\$\begingroup\$

Plot Partial Node Network

I have a 440*3 matrix that looks like:

1   144 Title1
1   152 Title2
1   135 Title3
2   3 Title4
2   12 Title5
2   107 Title6
2   31 Title7
3   4 Title8
3   147 Title9
3   0 Title10
4   end Title11
4   0 Title12
4   0 Title13
5   6 Title14
5   7 Title15
5   10 Title16
5   9 Title17

The left column are the starting points eg in the app all the 1's on the left would be on the same page. They lead to three choices, pages 144,152,135. These pages can each then lead to another page, and so on until the middle column says 'end'.

challenge Each number has an associated title in column three. I would like to have a function whereby if you input a given title it will plot all the possible starting points and their associated paths that will lead there. This should be a lot smaller and therefore graph friendly.

Example e.g.

44  234  tes
186  187  Frac
187  154  Low
154  end  Coll
99  101  adf
23   52   Med
52   11   Lip
11   42   AAA
42   154   BBB
154   end  Coll

EDIT - I added to the example. In the winning entry these new nodes will not be plotted as they do not lead to Coll.

I made this example to show how column 1 leads to a value in column 2 which then refers to a value in column 1 until you reach the end. Different starting points can ultimately lead to different length paths to same destination. so this would look sometigng like: All paths leads to Coll

So here, I wanted to see how you could go from all start points to 'Coll'

Input A data.frame like that illustrated (with not relevant rows included) and a given title

Rules -any language is fine as long as it will easy work with tab separated data laid out as shown

Output A graph like the one included for a given title

Win Criteria Shortest Runtime to make a png with graph

\$\endgroup\$
  • \$\begingroup\$ A question should have one challenge, not two. And a challenge should ideally have one goal, not two; and should certainly have a clear description not only of the input but also of the output. \$\endgroup\$ – Peter Taylor Jul 13 '16 at 16:14
  • \$\begingroup\$ Hi Peter, thanks for this. I've edited accordingly \$\endgroup\$ – cianius Jul 13 '16 at 16:16
  • \$\begingroup\$ Similar, also. \$\endgroup\$ – Peter Taylor Jul 13 '16 at 22:58
  • \$\begingroup\$ they're similar but not the same. they dont solve the problem of just plotting the rows that lead to Coll. \$\endgroup\$ – cianius Jul 14 '16 at 7:30
  • \$\begingroup\$ i edited example to clarify this Peter :) \$\endgroup\$ – cianius Jul 14 '16 at 7:45
  • \$\begingroup\$ I do like this question, but I currently do not support it as a question, due to it being unclear as to exactly what the png can and can not look like. I do support graphical output questions. \$\endgroup\$ – Rohan Jhunjhunwala Jul 15 '16 at 1:47
-2
\$\begingroup\$

The Library Problem

Bob has a very annoying problem. His boss told him to write a cat program that redirects the standard input to the standard output. But he recently installed a virus on his computer which deleted every libraries on it.

Now he really need to create this program without using any library (even the language standard library). It need to run at least on one operating system with one architecture.

Challenge

Write a program or that redirects the standard input to the standard output without using any library or external program/command to run to help Bob. You can use system calls and interrupts for example, but your program must not run in ring 0 mode (most operating systems like Microsoft Windows or GNU/Linux have kernels which prevent programs from doing anything, but MS-DOS for example let programs do everything).

  • Input: anything (text, binary)
  • Output: exactly the same as the input

This is , so shortest answer in bytes wins!

Example Input and Output

First:

  • Input: Hello, world!
  • Output: Hello, world!

Second:

  • Input: ...
  • Output: ...
\$\endgroup\$
  • \$\begingroup\$ That's just this challenge isn't it? \$\endgroup\$ – Martin Ender Jul 21 '16 at 15:26
  • \$\begingroup\$ @MartinEnder This challenge is about doing a cat program without using any library or external command/program even the standard library built with the language. \$\endgroup\$ – user54187 Jul 21 '16 at 15:30
  • \$\begingroup\$ So everything would need to be written in assembly or equivalent? \$\endgroup\$ – AdmBorkBork Jul 21 '16 at 15:34
  • \$\begingroup\$ @TimmyD Yes for example, but I think there are other lower-level languages which allow this. \$\endgroup\$ – user54187 Jul 21 '16 at 15:34
  • 3
    \$\begingroup\$ In that case it just seems like the same challenge limited to a small set of languages? In that case it would probably still be considered a duplicate and the usual course of action is to offer a bounty for the language you want to see a solution in. \$\endgroup\$ – Martin Ender Jul 21 '16 at 15:38
  • \$\begingroup\$ @MartinEnder You need a lower-level language but it doesn't mean that every program made using a lower-level language works with this challenge. See this answer for example which uses a function from the standard library codegolf.stackexchange.com/a/62309/54187. \$\endgroup\$ – user54187 Jul 21 '16 at 15:46
-2
\$\begingroup\$

Quine-ify PPCG Answers!

Write a program that, when executed, returns the markdown file to your answer.

So, something like this:

#Python: 123 bytes

`{insert code here}`

Required things:

  • Header must be one hash (#)
  • The "code part" must be indented with four spaces (or surrounded with backticks if it's a one-liner).
  • The code part must be the actual code used to run the program.
  • There must be a separation of a newline between the header and the code.
  • The program's display bytecount MUST equal the program's actual bytecount.

Meta:

  • Most importantly: is it even possible, at all?
  • Do I need more clarifications?
  • Has this been done already?
\$\endgroup\$
  • 4
    \$\begingroup\$ "Most importantly: is it even possible, at all?" Definitely possible and in most languages no more difficult than a standard quine. The points in this answer probably apply as well. Also the third-to-last paragraph in this answer since languages with longer names will have a disadvantage. And finally, there's this related challenge (same thing without the quine part). \$\endgroup\$ – Martin Ender Jul 27 '16 at 7:25
  • \$\begingroup\$ Actually, it's just too easy. Just use a normal quine with stuff before. \$\endgroup\$ – Erik the Outgolfer Aug 3 '16 at 17:50
-2
\$\begingroup\$

Alphabet Circle

This post got very negative feedback, so it's apparent that it needs tweaking in the sandbox before I attempt to repost it on PCG


With all the new alphabet xxx challenges, I've decided I'll give my own challenge.

Input

An Integer, (or your languages equivalent) r, such that 0 < r ≤ 26. (you don't need to validate this)

Output

An alphabet circle. Must meet the following criteria:

  • Smoothly interpolated from A at the center and Z at the edge.
  • Each point in the circle is the distance from the center offset so that 0 = A, 1 = B, 2 = C etc...
  • Be printed to STDOUT

Examples

r=26

enter image description here

r=15

enter image description here

Boilerplate

Anonymous classes and functions are fine. General Code Golf rules apply. Shortest code in bytes wins!Except Jelly

\$\endgroup\$
  • 8
    \$\begingroup\$ Please remove the Except Jelly part... \$\endgroup\$ – TuxCrafting Aug 3 '16 at 11:31
  • \$\begingroup\$ @TùxCräftîñg no \$\endgroup\$ – Shaun Wild Aug 3 '16 at 11:32
  • 4
    \$\begingroup\$ Disallowing language are a thing to avoid when writing challenges \$\endgroup\$ – TuxCrafting Aug 3 '16 at 11:35
  • \$\begingroup\$ It's triple super scripted, it's a joke. I'm not removing it. Get a sense of humour! \$\endgroup\$ – Shaun Wild Aug 3 '16 at 11:49
  • 4
    \$\begingroup\$ Since you mention negative feedback, my negative feedback would be that a glut of recent challenges on theme X (in this case alphabet layout) is a strong reason to avoid more challenges on theme X for a while, not to add to the pile. Variety is good. If I were you I'd hold this challenge for a month. Moving onto positive feedback, the spec needs to define the desired layout more clearly. I can't work out what the precise criterion is for which letter to place in each space. \$\endgroup\$ – Peter Taylor Aug 3 '16 at 14:51
  • \$\begingroup\$ If a position is not an integer distance from the centre, should the distance be truncated, rounded up/down or something else? \$\endgroup\$ – trichoplax Aug 6 '16 at 12:11
  • \$\begingroup\$ Could you specify whether leading/trailing spaces and newlines are permitted/required? Does the circle need to be framed in a square of matching size, or can it always be in a square of a fixed maximum size? \$\endgroup\$ – trichoplax Aug 6 '16 at 12:15
  • 1
    \$\begingroup\$ I think this would work best as a kolmogorov-complexity just for the size 26 pattern. That'd avoid any issues with defining how to interpolate the circles (or, indeed, defining the pattern generally, as it would be defined via stating the intended output). \$\endgroup\$ – user62131 Nov 24 '16 at 5:24
-2
\$\begingroup\$

Your task is to print the Champernowne constant (A033307) indefinitely.

There must be no spaces in your output and the solution with the fewest bytes wins!

\$\endgroup\$
  • 1
    \$\begingroup\$ 1. The Cham-whatever constant has infinitely many digits, making this challenge the same as this \$\endgroup\$ – Leaky Nun Aug 4 '16 at 18:23
  • 1
    \$\begingroup\$ 2. Duplicate. \$\endgroup\$ – Leaky Nun Aug 4 '16 at 18:25
  • \$\begingroup\$ @LeakyNun To prevent this being a duplicate could the challenge be "Print the Champernowne constant in base n", where the input is the base? \$\endgroup\$ – ASCIIThenANSI Aug 5 '16 at 14:35
  • \$\begingroup\$ Also, this question isn't self contained. If you were to post an acceptably modified version of this, please explain what this constant/sequence is within the question itself, even if there is a link \$\endgroup\$ – MildlyMilquetoast Jan 20 '17 at 1:03
-2
\$\begingroup\$

Nasty Nasty Bugs

Help the programmer provide detailed instructions to the team on how to deal with bug fixes.
The team's goto instructions for dealing with bugs goes like this.

For the twelfth bug of Christmas, my team leader said to me 

    Tell them it's a feature
    Say it's not supported
    Change the documentation
    Blame it on the hardware
    Find a way around it
    Say they need an upgrade
    Reinstall the software
    Ask for a dump
    Run with the debugger
    Try to reproduce it
    Ask them how they did it and
    See if they can do it again.

The indentation must comply with the teams coding standards, so it may either be tabs or four spaces (since the team's editors expand tabs to spaces anyway). The team lead doesn't mind a leading or trailing newline, but there is no tolerance for the dreaded standard loopholes. Also the office is a bit cramped so the code needs to be as small as possible. These lyrics are moderately adapted from http://www.manbottle.com/humor/twelve_bugs_of_christmas

\$\endgroup\$
  • \$\begingroup\$ What is the actual challenge? A kolmogorov-complexity to reproduce the quoted text verbatim? \$\endgroup\$ – Peter Taylor Aug 8 '16 at 21:41
  • \$\begingroup\$ whoops should have tagged it as such @PeterTaylor \$\endgroup\$ – Rohan Jhunjhunwala Aug 8 '16 at 21:42
  • 6
    \$\begingroup\$ There doesn't seem to be much of a pattern here. What does this add over other kgc questions? (And why isn't it a dupe of the Rickroll challenge?) \$\endgroup\$ – FryAmTheEggman Aug 9 '16 at 20:23
  • \$\begingroup\$ @FryAmTheEggman I could put all 12 verses of the 12 bugs of christmas in. But then it could be a dupe of the 12 days of christmas challenge \$\endgroup\$ – Rohan Jhunjhunwala Aug 9 '16 at 20:24
-2
\$\begingroup\$

Crab Canon

A crab canon is a piece of music where the same tune is played backwards and forwards at the same time, and it somehow sounds nice. The most famous example is this one by Bach. In Godel, Escher, Bach, Douglas Hofstadter wrote a crab canon in dialog form, in which the characters of Achilles and the Tortoise alternate lines, with one set of lines being the same as the other set except backwards. Somehow, it makes sense.

The challenge is to write a program inspired by this art form. The only requirement is that there has to be some sort of reversal of the source code involved. For example, you could make a program that:

  • Prints its own source code, but backwards
  • Does the same thing when reversed
  • Both of the above at the same time
  • Or make up something creative and wow the voters!

The reversal can happen on pretty much whatever level you want: lines of code, characters, characters within lines, or whatever makes sense for your language. The Hofstadter Crab Canon has some small changes between the two sets of lines for the sake of coherence, you can do something similar if you feel it is necessary.

This is a popularity contest, the answer with the most votes wins.

\$\endgroup\$
  • 7
    \$\begingroup\$ This is without a doubt too broad. See codegolf.stackexchange.com/tags/popularity-contest/info \$\endgroup\$ – Peter Taylor Aug 16 '16 at 7:10
  • \$\begingroup\$ @PeterTaylor FYI there's something wrong with that link's formatting \$\endgroup\$ – tbodt Aug 16 '16 at 18:07
  • \$\begingroup\$ There isn't any formatting. I just pasted the link directly. And it works for me. \$\endgroup\$ – Peter Taylor Aug 16 '16 at 19:11
  • \$\begingroup\$ @PeterTaylor hmm, seems to have fixed itself... \$\endgroup\$ – tbodt Aug 16 '16 at 19:12
-2
\$\begingroup\$

Left and Right

Given an input string, in ASCII, output ")|]" as many times as the case-insensitive word "right" appears in input, and output "(|[" as many times as the case-insensitive word "left" appears in input. The order is irrelevant. If and only if no occurences of these words are in input, output "X|X". Spacing between items is optional

This is , less bytes is best

Test cases:

input -> output
RightRightighteftleft -> (|[ )|] )|], or some other ordering
this doesn't contain either word -> X|X
LEfT, LeFT, leFT, righT -> (|[ (|[ (|[ )|]
(|[ -> X|X
\$\endgroup\$
-2
\$\begingroup\$

Petals around the Roses

Given 5 numbers from 1 to 6, calculate the number of Roses, Petals and Roots. Try guessing the formulas yourself by visiting http://jetpackshark.com/RPS before reading anybody's answers. (The dice-like display is significant.)

This is , so the shortest program wins.

\$\endgroup\$
  • 2
    \$\begingroup\$ If you're looking for a "solve-the-puzzle" challenge, the site for that is Puzzling. If you want it to be a code-golf, then please include a formula for how the roses, petals, and roots are calculated. \$\endgroup\$ – Nathan Merrill Aug 16 '16 at 13:06
  • 1
    \$\begingroup\$ Or at the very list a definition of roses, petals, and roots in this context. At present this question makes no more sense than the output of a Markov text generation process. \$\endgroup\$ – Peter Taylor Aug 16 '16 at 13:44
-2
\$\begingroup\$

Write a Brainfuck interpreter in Brainfuck

Since Brainfuck is known to be turing-complete, it is possible to write a Brainfuck interpreter in Brainfuck. This is what you're supposed to do.

You will get the input from the standard input and output to the standard output. This is a programming-puzzle, so the length is not top priority, however if there are multiple solutions, the shortest one wins!

\$\endgroup\$
  • \$\begingroup\$ BF interpreter (non language specific) challenge has already been done, and language exclusive challenges generally aren't good \$\endgroup\$ – Destructible Lemon Aug 19 '16 at 1:45
-2
\$\begingroup\$

Щoгкeгs of tиe щoгld, цпite!

Iпtгodцctioп

Iп tиe Iпteгпets, people sometimes liкe to stчlize tиeiг posts дs if tиeч щeгe щгitteп iп д diffeгeпt scгipt. Tидпкs to tиe пotoгietч of Soviet Яцssiд, tиe Cчгчlic scгipt seems to бe pдгticцlдгlч fдvoгed.

Бцt щидt cдп д пext-dooг tгoll do if tиeч'гe пot д pгogгдmmeг? Mдпцдllч гeplдciпg eдcи дпd eveгч letteг cдп бe qцite tedioцs...

Cидlleпge

Чoц дгe to щгite д pгogгдm tидt щill дccept дп дгбitгдгilч loпg iпpцt of Lдtiп cидгдcteгs дпd sцбstitцte some letteгs щitи similдгlч looкiпg Cчгчlics cидгдcteгs. Tиe oцtpцt sиoцld бe ideпticдl to tиe oцtpцt pгodцced бч tиe folloщiпg цпgolfed C# scгipt:

цsiпg Sчstem;
цsiпg Sчstem.Collectioпs.Geпeгic;
цsiпg Sчstem.Liпq;

pцбlic clдss Test
{
    pцбlic stдtic void Mдiп()
    {
        Dictioпдгч<cидг, cидг> tгдпs = пeщ Dictioпдгч<cидг, cидг>{
            {'A', 'д'},
            {'a', 'д'},
            {'B', 'Б'},
            {'b', 'б'},
            {'N', 'И'},
            {'b', 'и'},
            {'K', 'К'},
            {'k', 'к'},
            {'N', 'П'},
            {'n', 'п'},
            {'R', 'Я'},
            {'r', 'г'},
            {'U', 'Ц'},
            {'u', 'ц'},
            {'W', 'Щ'},
            {'w', 'щ'},
            {'Y', 'Ч'},
            {'y', 'ч'}
        };

        stгiпg s; щиile((s = Coпsole.ЯeдdLiпe()) != пцll) {
            Coпsole.ЩгiteLiпe(
                пeщ stгiпg(s.Select(c => tгдпs.CoпtдiпsКeч(c) ? tгдпs[c] : c).
                    Toдггдч()
                )
            );
        }
    }
}

Tиe sиoгtest code щiпs.

Exдmple Iпpцt дпd Oцtpцt

Iпpцt:

As we know, the goal of every struggle is victory. But if the proletariat is to achieve victory, all the workers, irrespective of nationality, must be united. Clearly, the demolition of national barriers and close unity between the Russian, Georgian, Armenian, Polish, Jewish and other proletarians is a necessary condition for the victory of the proletariat of all Russia.

We are for the withering away of the state, and at the same time we stand for the strengthening of the dictatorship of the proletariat, which represents the most powerful and mighty of all forms of the state which have existed up to the present day. The highest development of the power of the state, with the object of preparing the conditions of the withering away of the state: that is the Marxist formula. Is it "contradictory"? Yes, it is "contradictory." But this contradiction is a living thing and wholly reflects the Marxist dialectic.

Oцtpцt:

дs щe кпoщ, tиe goдl of eveгч stгцggle is victoгч. Бцt if tиe pгoletдгiдt is to дcиieve victoгч, дll tиe щoгкeгs, iггespective of пдtioпдlitч, mцst бe цпited. Cleдгlч, tиe demolitioп of пдtioпдl бдггieгs дпd close цпitч бetщeeп tиe Яцssiдп, Geoгgiдп, дгmeпiдп, Polisи, Jeщisи дпd otиeг pгoletдгiдпs is д пecessдгч coпditioп foг tиe victoгч of tиe pгoletдгiдt of дll Яцssiд.

Щe дгe foг tиe щitиeгiпg дщдч of tиe stдte, дпd дt tиe sдme time щe stдпd foг tиe stгeпgtиeпiпg of tиe dictдtoгsиip of tиe pгoletдгiдt, щиicи гepгeseпts tиe most poщeгfцl дпd migиtч of дll foгms of tиe stдte щиicи идve existed цp to tиe pгeseпt dдч. Tиe иigиest developmeпt of tиe poщeг of tиe stдte, щitи tиe oбject of pгepдгiпg tиe coпditioпs of tиe щitиeгiпg дщдч of tиe stдte: tидt is tиe Mдгxist foгmцlд. Is it "coпtгдdictoгч"? Чes, it is "coпtгдdictoгч." Бцt tиis coпtгдdictioп is д liviпg tиiпg дпd щиollч гeflects tиe Mдгxist diдlectic.

\$\endgroup\$
  • 2
    \$\begingroup\$ Welcome to PPCG and thanks for using the Sandbox! Unfortunately, this challenge is essentially the same as this question. Also, please don't write your specs in this "stylised" manner. It greatly hurts the searchability of your post. \$\endgroup\$ – FryAmTheEggman Aug 20 '16 at 22:03
  • \$\begingroup\$ Your code is also stylized. Does your code run properly? \$\endgroup\$ – Buffer Over Read Aug 20 '16 at 22:34
  • \$\begingroup\$ @ColdGolf And do you think I'd stylize my post by hand? \$\endgroup\$ – gaazkam Aug 21 '16 at 2:13
  • \$\begingroup\$ @FryAmTheEggman OK, thank you. I now see my challenge was pointless and won't post it to the main. \$\endgroup\$ – gaazkam Aug 21 '16 at 2:14
  • \$\begingroup\$ Nothing is pointless: now you you know more and can come up with a better challenge! :) \$\endgroup\$ – FryAmTheEggman Aug 21 '16 at 2:17
  • \$\begingroup\$ @ColdGolf OK you were right, I messed up the stylization. {'b', 'и'} - here is a bug. Sorry. \$\endgroup\$ – gaazkam Aug 21 '16 at 2:22
  • \$\begingroup\$ @gaazkam Does your code, with the stylized цsiпg Sчstem;, run properly? \$\endgroup\$ – Buffer Over Read Aug 21 '16 at 2:39
  • \$\begingroup\$ @ColdGolf I regard people of CodeGolf intelligent enough to find out they'd have to unstylize this code ^^ :) \$\endgroup\$ – gaazkam Aug 22 '16 at 7:11
  • \$\begingroup\$ @gaazkam I see. \$\endgroup\$ – Buffer Over Read Aug 22 '16 at 17:34
-2
\$\begingroup\$

Enterprise Quality Code!

Summary of this challenge

Print (to make it more fair when competing with another language changing the output method could be a trivial way to golf) the first N Prime numbers. Your score will be the sum of the byte counts of all entries which no one has been able to golf down (by removing one or more characters and rearrange the program). If you golf down someones program, post it as another submission.

You may not golf your own programs once submitted.


This is not a dupe because it significantly changes the scoring method. Writing code which allows a single byte to be golfed off will cost the whole of the score. Also as this is a challenge the winner is likely going to have high scores across a multitude of languages. It is likely that scores will be incredibly near 30k for each language. This limit allows a more interesting competition as it prevents submissions of exponentially large lengths.

Back-story and explanation

At Pretty Good consultants there is a focus on writing "quality" verbose code that is sufficiently engineered. Your boss has decided to test you on your skills.


Consider the set of all programming languages in existence before the posting of this challenge. For this challenge there will technically be one individual "winner" in each language, however the boss will give a promotion accepted tick mark to only one answer based on your score.
The goal of this challenge is to receive an integer N strictly smaller than 2^16-1 and print the first N prime numbers (in less than 24 hours) separated by your platforms choice of new line. OEIS sequence A000040 in as many bytes as possible in as many languages as possible. However, note that others vying for the promotion will try to "help" you by golfing down your score.

Sample output for an input 11

2
3
5
7
11
13
17
19
23
29
31

How to participate

Pick any language X, but please avoid selecting a language which is just another version or derivative of another answer. If there is no existing answer in language X than you will write a program (which must fit into a single post) that solves this challenge. The length in bytes of the source (in any reasonable preexisting textual encoding) will be added to your score. You must avoid using any unnecessary characters for reasons that will soon become apparent.

If language X already has been used to answer this question, then you must answer using any permutation of any proper subset of the characters used in the shortest answer (I.E take the shortest X answer and remove some (>=1) characters and optionally rearrange the resulting code). The previous holder of the shortest X answer will lose all of the bytes provided by his answer from his score, and the number of bytes of your submission will now be added to your score. The number of bytes golfed off gets "lost" forever.


Clarifications shamelessly lifted adapted from this challenge

Rules for Languages

Languages used should be distinctly different. A language is different iff:

  • It is not a different version of another language (Java 7, Java 8)
  • They must not be derived from another language (Branf*** versus Alphf***)
  • One language may not be a subset or superset or trivial of the other one (e.g. hq9+ versus hq9+b).

HQ9+ wouldnt be a language anyway, but please be judicious when selecting a language, if you have any clarifications on a language that may be significantly different from an existing answer please ping me and we can work it out.


\$\endgroup\$
  • \$\begingroup\$ If anyone knows how to make a scoreboard for this I will be much obliged \$\endgroup\$ – Rohan Jhunjhunwala Aug 20 '16 at 17:28
  • \$\begingroup\$ So the highest score wins, overall (from all your still-valid answers). And when you outgolf somebody, they lose their points, you gain your points, but do you get the points that they lost? \$\endgroup\$ – Rɪᴋᴇʀ Aug 20 '16 at 17:42
  • \$\begingroup\$ @EasterlyIrk the way I had it planned out is that the amount of bytes golfed off is forever lost. I don't know if thats fair but that essentially prevents people from "profiting" off of ridiculous answers that were not fortified against being golfed. \$\endgroup\$ – Rohan Jhunjhunwala Aug 20 '16 at 17:49
  • 2
    \$\begingroup\$ Yeah, that's what I figured. You might want to clarify that a bit though. I really like the idea. \$\endgroup\$ – Rɪᴋᴇʀ Aug 20 '16 at 17:52
  • \$\begingroup\$ @EasterlyIrk clarifications added, let me know if this is ready for main \$\endgroup\$ – Rohan Jhunjhunwala Aug 20 '16 at 17:59
  • 2
    \$\begingroup\$ It might be ready, but you should wait for somebody else to also give input. \$\endgroup\$ – Rɪᴋᴇʀ Aug 20 '16 at 18:01
  • \$\begingroup\$ All right sounds good \$\endgroup\$ – Rohan Jhunjhunwala Aug 20 '16 at 18:04
  • 2
    \$\begingroup\$ 1. So basically the accepted answer goes to the shortest answer in Unary? 2. The tags code-golf and code-bowling are mutually exclusive. This isn't really either. \$\endgroup\$ – Peter Taylor Aug 20 '16 at 19:49
  • \$\begingroup\$ @PeterTaylor please read the whole thing. The answer must fit within 30k \$\endgroup\$ – Rohan Jhunjhunwala Aug 20 '16 at 20:02
  • \$\begingroup\$ If someone can write a brainf*** program that is only about 6 chars long or so than they deserve the accept tick \$\endgroup\$ – Rohan Jhunjhunwala Aug 20 '16 at 20:03
  • \$\begingroup\$ @RohanJhunjhunwala Golunar wins \$\endgroup\$ – Rɪᴋᴇʀ Aug 20 '16 at 22:07
  • \$\begingroup\$ @EasterlyIrk lol thats actually just a compressed form of Brainf*** it probably wouldn't score that well \$\endgroup\$ – Rohan Jhunjhunwala Aug 20 '16 at 23:15
  • \$\begingroup\$ @PeterTaylor essentially I restrict answers to fit in one post which means the best score for a single language is slightly under 30 characters \$\endgroup\$ – Rohan Jhunjhunwala Aug 20 '16 at 23:15
  • 2
    \$\begingroup\$ I find the intro confusing. I didn't understand what the challenge is broadly about until reading to the end. Can you cleanly state the challenge at the beginning, and move the details later? \$\endgroup\$ – xnor Aug 21 '16 at 0:42
  • 1
    \$\begingroup\$ @trichoplax the overall winner with the highest score summed up over all of their answer posts will receive the tick on their highest scored post. It doesn't really matter which post in particular (as long as it is a post of the winner) receives the tick, but it makes sense to tick off the highest scoring post. \$\endgroup\$ – Rohan Jhunjhunwala Aug 21 '16 at 12:44
-2
\$\begingroup\$

Alphabet ripple

You must print out this exact text:

abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba
abcdefghijklmnopqrstuvwxyyyyxwvutsrqponmlkjihgfedcba
abcdefghijklmnopqrstuvwxxxxxxwvutsrqponmlkjihgfedcba
abcdefghijklmnopqrstuvwwwwwwwwvutsrqponmlkjihgfedcba
abcdefghijklmnopqrstuvvvvvvvvvvutsrqponmlkjihgfedcba
abcdefghijklmnopqrstuuuuuuuuuuuutsrqponmlkjihgfedcba
abcdefghijklmnopqrsttttttttttttttsrqponmlkjihgfedcba
abcdefghijklmnopqrssssssssssssssssrqponmlkjihgfedcba
abcdefghijklmnopqrrrrrrrrrrrrrrrrrrqponmlkjihgfedcba
abcdefghijklmnopqqqqqqqqqqqqqqqqqqqqponmlkjihgfedcba
abcdefghijklmnopppppppppppppppppppppponmlkjihgfedcba
abcdefghijklmnoooooooooooooooooooooooonmlkjihgfedcba
abcdefghijklmnnnnnnnnnnnnnnnnnnnnnnnnnnmlkjihgfedcba
abcdefghijklmmmmmmmmmmmmmmmmmmmmmmmmmmmmlkjihgfedcba
abcdefghijkllllllllllllllllllllllllllllllkjihgfedcba
abcdefghijkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkjihgfedcba
abcdefghijjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjihgfedcba
abcdefghiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiihgfedcba
abcdefghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhgfedcba
abcdefggggggggggggggggggggggggggggggggggggggggfedcba
abcdeffffffffffffffffffffffffffffffffffffffffffedcba
abcdeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeedcba
abcddddddddddddddddddddddddddddddddddddddddddddddcba
abccccccccccccccccccccccccccccccccccccccccccccccccba
abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbba
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Specs

  • You may do it in all-uppercase instead of all-lowercase.
  • A single leading and trailing newline are allowed
  • You may not output an array of strings - the delimiter must be a newline

Scoring

This is . Program with lowest byte-count wins.

\$\endgroup\$
  • \$\begingroup\$ Seriously, another alphabet challenge ._. \$\endgroup\$ – TuxCrafting Aug 21 '16 at 14:23
  • 2
    \$\begingroup\$ Duplicate, too lazy to find. \$\endgroup\$ – Leaky Nun Aug 21 '16 at 14:27
  • 3
    \$\begingroup\$ @LeakyNun you're too lazy to search through your own challenges...? \$\endgroup\$ – trichoplax Aug 21 '16 at 20:49
  • \$\begingroup\$ @trichoplax I don't feel like wasting my time to search for the duplicate. \$\endgroup\$ – Leaky Nun Aug 21 '16 at 20:57
  • 8
    \$\begingroup\$ @LeakyNun I knew what you meant - I was just making a poor joke that you would only need to search your own challenges since you wrote every alphabet challenge... \$\endgroup\$ – trichoplax Aug 21 '16 at 21:15
  • \$\begingroup\$ @LeakyNun, this Show tree rings age? \$\endgroup\$ – manatwork Aug 23 '16 at 10:50
  • \$\begingroup\$ @LeakyNun what exactly is the duplicate? I'd like to know. \$\endgroup\$ – Conor O'Brien Aug 27 '16 at 16:39
  • \$\begingroup\$ @ConorO'Brien this \$\endgroup\$ – Leaky Nun Aug 27 '16 at 16:46
-2
\$\begingroup\$

The Note-Takers Dream

Meta

This challenge requires more than most challenges. Is it to much?

The goal here is simple. Turn my notes into text. To this end, any tool or web service may be employed.

Specification

  • Input
    • An image of handwritten notes, stored an some data structure (this structure is flexible)
    • This image will be a direct, over-head shot of a single page of graph paper
  • Notes
    • The notes are taken on graph paper with one character per box
    • The characters will be printable ASCII
    • An empty box should be considered as a single Space character
    • There is an implicit New Line character between each row
  • Output
    • A string of the text represented in the image
    • This image should be trimmed of leading white space
    • Trailing white space is fine
  • Score
    • The score is the sum of the Levenshtein distances between required outputs and actual outputs
    • Lowest score wins

Test Cases

Coming soon. . .

\$\endgroup\$
  • 2
    \$\begingroup\$ Mathematica will win, and everyone else will weep \$\endgroup\$ – Rohan Jhunjhunwala Aug 30 '16 at 22:42
  • \$\begingroup\$ So basically codegolf.stackexchange.com/q/28207/194 with a larger character set and probably a smaller test set. It's effectively a dupe IMO. \$\endgroup\$ – Peter Taylor Aug 31 '16 at 7:52
  • \$\begingroup\$ Golfing in ABBYY FineReader Engine has never been so exciting. \$\endgroup\$ – Andreï Kostyrka Aug 31 '16 at 14:45
-2
\$\begingroup\$

Print the name of the language

The goal of this challenge, as implied in the title, is to print the name of the language with a program in said language, in as few bytes as possible.

But that would be too easy, right ?

So to add a litle bit of challenge, you are not allowed to use any characters included in the language's name.

Rules

  • Each submission must be a full program.

  • The program must take no input, and print the name of the language to STDOUT plus an optional trailing newline, and nothing else.

  • The program must not write anything to STDERR.

  • Usual loophole rules apply

  • Submissions are scored in bytes, in an appropriate encoding, usually (but not necessarily) UTF-8.

  • This is , so the shortest program (in bytes) wins.

Sandbox

After checking, I don't think this question is a dupe.
Are there any grammatical mistakes ? (English isn't my first language)
Are there any rules that should be added (like banning languages created after the challenge ?) Should I add any further specification ?

\$\endgroup\$
  • \$\begingroup\$ Do X without Y is discouraged. We're talking about your question in Code Golf Chat right now. (And now the conversation's moved on...) \$\endgroup\$ – wizzwizz4 Sep 1 '16 at 8:39
  • \$\begingroup\$ @wizzwizz4 Would removing the "not use characters in the program name" rule make it better ? I didn't want the challenge to become "who has the shortest printf command" \$\endgroup\$ – Lamedonyx Sep 1 '16 at 8:45
  • 3
    \$\begingroup\$ At the moment it's "who has the shortest program name". \$\endgroup\$ – wizzwizz4 Sep 1 '16 at 8:48
  • \$\begingroup\$ If the challenge is in danger of becoming "who has the shortest printf command" then rather than trying to fix it you should consider throwing it away and looking for an interesting challenge. \$\endgroup\$ – Peter Taylor Sep 1 '16 at 11:42
-2
\$\begingroup\$

Find all paths in a matrix maze.

A maze is represented as a two-dimensional array of 0s and 1s. Zero indicates a closed door and one indicates an open door. An example representation of maze is given below.

0100
0010
1101

to avoid loops input square matrix should not contain a square of once like

111      11
101  or  11
111

Write an application either in Java,C,C++,Python,C# or Javascript. It takes as input a maze(mxn array) and prints out all the possible ways out.

• No database should be used.

• Yes...Way out is any edge containing 1.

• Enter from any edges of the maze

• Exit from any edges of the maze

• Should not enter and exit from the same door

• Move can be one unit distance either top/bottom/left/right/diagonal

For the above maze, one possible way out is: [0,1] -> [1,2] -> [2,3] i.e you start at [0,1] and then move to [1,2] and then to [2,3]. There are other possible ways as you can see.

\$\endgroup\$
  • \$\begingroup\$ Probable dupes: One, Two \$\endgroup\$ – Emigna Sep 8 '16 at 15:10
  • 4
    \$\begingroup\$ Also, restricting challenges to specific languages are frowned upon. An objective winning criterion is also needed. \$\endgroup\$ – Emigna Sep 8 '16 at 15:10
  • \$\begingroup\$ @Emigna, No Actually, here we need to find all the paths not the shortest path or straight path and here we can also traverse diagonal in the matrix. \$\endgroup\$ – Ali786 Sep 8 '16 at 15:15
  • \$\begingroup\$ okay will add few more languages that I know so that I can evaluate ... \$\endgroup\$ – Ali786 Sep 8 '16 at 15:16
  • 1
    \$\begingroup\$ 1. "Handle error cases like a production application" is not a clear requirement. Different production applications have different standards for how to handle errors. 2. "prints out all the possible ways out" runs into trouble when there's an infinite number, and I don't see any guarantee that there won't be loops. 3. The example doesn't make the input format very clear. What's the non-rectangular border for? 4. Path-finding with a trivial input format is definitely a dupe of at least one previous question. \$\endgroup\$ – Peter Taylor Sep 8 '16 at 15:31
  • \$\begingroup\$ @PeterTaylor, I have modified my question, can you plz check once. \$\endgroup\$ – Ali786 Sep 8 '16 at 16:04
-2
\$\begingroup\$

Make a dummy C program

We all know the feeling. You have written a short, efficient and readable one-liner that's the perfect solution to the problem. Then your code-illiterate boss looks over your shoulder and is not very happy that you've spent an entire paid hour producing "nothing". You could politely explain the situation to your boss, complete with a demonstration that your code does what it should. Or, because talking to people is Hard Work™, you could fake it.

Your task is to write a program that takes a list of keywords as input, and outputs dummy C code that looks like it does something to do with those words. Sandbox note: not happy with the wording in final bit here.

For example, if the inputs were integral, formula, math, proof, fit and square, the output might be:

#include <math.h>
#include <setjmp.h>
double* squarefit(int integral, float* mathproof)
{
    char **integralb={{0}};
    double square[integral];
    int i=0;

    //integral math formula fit
    for(integralb[0][0]=(char)erff(*mathproof);isnan((double)++integral);i++) {
        return hypot(sqrt(square[integral]),integral)?square:square;
        printf(*integralb,integral,*mathproof);
    }
    setjmp((struct __jmp_buf_tag*)mathproof+(int)(abs(--integral)-expm1l(integral)));
    longjmp(0,0);
    return square;
}

Although it doesn't have to do anything, or even run successfully properly, the source code produced by your program must compile in gcc (no additional options) without fatal errors. You do not need to provide a main function; if you don't, expect the line int main(void){} to be appended to the output file before it is compiled.

This is a , so the best-liked answer will win. However, voters should keep these questions in mind when assessing the submissions:

  • Does the produced source code look like it does the expected task? Yes.
  • Does the produced source code look like it has taken a long time to produce? Yes.
  • Do different inputs result in the same program, just with different variable names? No.
  • Does the produced source code look like the same code repeated over and over? No.
  • Do your parents, grand-parents, co-workers or other "not computer people" think the produced source code was something to do with the input keywords (optional)? Yes.
  • Would you think the produced source code was written by a person with knowledge of the C language, if you did not know that it was just dummy code (optional)? Yes.
  • Does the code look readable (e.g. ungolfed)? Yes.

Not all of the standard loopholes apply for this challenge. For example, you mignt use external resources, such as library files or an indexable website. However, voters should use their discretion as to what is reasonable and what is not (such as expecting the "keywords" to be in a format that includes a high-quality, valid C program).

Sandbox note: how to finish challenge body?

\$\endgroup\$
  • \$\begingroup\$ Is this a language-specific challenge? \$\endgroup\$ – user56309 Sep 29 '16 at 17:05
  • \$\begingroup\$ @tuskiomi No, it's open to all languages. \$\endgroup\$ – wizzwizz4 Sep 29 '16 at 17:06
  • \$\begingroup\$ Generally it's a good Idea to separate your challenge into five sections: the intro, summary, input, output, and examples. I'd recommend you do so here as well. \$\endgroup\$ – user56309 Sep 29 '16 at 17:07
  • 1
    \$\begingroup\$ @tuskiomi Thanks, will do. Give me 6 to 8 weeks... \$\endgroup\$ – wizzwizz4 Sep 29 '16 at 17:11
  • 3
    \$\begingroup\$ @tuskiomi I disagree. There are plenty of ways to organize a challenge effectively. However, this challenge looks like it might suffer a bit from the "art contest" issue, so be wary wizz. \$\endgroup\$ – Calvin's Hobbies Sep 29 '16 at 17:31
  • \$\begingroup\$ @HelkaHomba I never said that it's the ONLY way to organize challenges to be effective, I said that generally it's a good idea to do that format. \$\endgroup\$ – user56309 Sep 29 '16 at 17:34
  • \$\begingroup\$ @HelkaHomba That's the format I often use, and I plan to split it into headings. What do you mean by "art contest issue"? \$\endgroup\$ – wizzwizz4 Sep 30 '16 at 6:28
  • 1
    \$\begingroup\$ I mean the judging is up to the whim of the voters own opinions and knowledge of how C code should look. We've had issues before with challenges like "draw the prettiest picture" which is plainly an art, not programming contest, and those kind of thing rarely go over well, often close voted as "primarily opinion based". This challenge (and all pop-cons really) suffer from similar issues. I'm not personally against this challenge or art contests, but it's just an issue you may need to face. \$\endgroup\$ – Calvin's Hobbies Sep 30 '16 at 6:35
  • \$\begingroup\$ @HelkaHomba Do you have suggestions as to which questions to change / remove / reword to stop it being bad subjective? \$\endgroup\$ – wizzwizz4 Sep 30 '16 at 6:45
  • \$\begingroup\$ I kind of like this, but I bet it would be closed as too broad. Anything from the program you provided to main(){integral+formula+square+proof+fit==math?return 0:return 1;} would be allowed. \$\endgroup\$ – MD XF May 26 '17 at 20:13
  • \$\begingroup\$ @MDXF That wouldn't be valid if the inputs foo, bar, baz, fizz, buzz, fred would result in main(){foo+bar+baz+fizz+buzz==fred?return 0:return 1;}. Also, gcc gets very cross that none of those names are defined, so it won't compile. So actually that wouldn't be allowed. Also note that that is a boring submission to a popularity-contest. \$\endgroup\$ – wizzwizz4 May 27 '17 at 8:06
-2
\$\begingroup\$

Quine tree

Inspired by that really weird quine challenge

For this challenge, you must construct a quine tree, which is a thing I made up, specifically an infinite binary tree.

How a quine tree works:

A quine tree has infinite nodes.

  • Each node is associated with a program

    • Let X, Y, Z, be the programming languages. This program is a polyglot in X and Y. In all but the root node, it is also a polyglot in Z. Note the

    • see below for more details

  • Each node has exactly two children

  • Every node but the root has a parent. Their parent has the node as a child (obviously).

Programs:

  • When a node's program is run in X, it produces the program of the first child of that node.
  • When run in Y, it produces the program of the second child of that node.
  • The programs produced must be different (node foo's program, cannot have the same output in X and Y. This output must also be different than the nodes program).
  • If not the root node, when run in Z, it produces the parent of the node.

Example

Imagine that we have the (fake) programming languages Hello, World, and Foobaz. Say the root node is $QQ$QQ$;:

  • when run in Hello, perhaps it produces $QQ$QQ$;;
    • When this is run with Hello again, perhaps produces $QQ$QQ$;;;
    • When this is run with World, perhaps produces $QQ$QQ$;;Q
    • Both these programs must produce, run in Foobaz, $QQ$QQ$;; (Output of root node run in Hello)
  • when run in World, perhaps it produces $QQ$QQ$;Q
    • When this is run with Hello, perhaps produces $QQ$QQ$;Q;
    • When this is run with World again, perhaps produces $QQ$QQ$;QQ
    • Both these programs must produce, run in Foobaz, $QQ$QQ$;Q (Output of root node run in World)
  • Both these programs, run in Foobaz, must produce $QQ$QQ$; (root program).
\$\endgroup\$
  • \$\begingroup\$ This seems like a really interesting challenge. I'm not sure how possible it is, though! Substitution languages like /// might be easiest to solve this in. \$\endgroup\$ – wizzwizz4 May 27 '17 at 8:20
-2
\$\begingroup\$

The only differences that matter

Cops' task

Write two programs (or functions) A and B in the same version of the same programming language. They also should be called in the same way, meaning you can't write one program and one function. Each should accept an integer n and output the term n of a different integer sequence on OEIS.

You should reveal a substring of each of A and B. Call them PA and PB. If one instance of PA is replaced by PB from A, it should become B. That means every byte except the reveal part in A and B should be exactly the same. You also reveal the lengths of A and B, and the two OEIS sequences. You don't reveal the programming language you use.

Your answer is cracked if a robber finds two programs A' and B' that also print the elements in the two integer sequences respectively, where A' is no longer than A, and A' with one instance of PA replaced by PB is also B'. They don't have to be the same with your original A and B. And they don't have to be in the same programming language as yours, as long as they are in the same programming language themselves.

If your answer isn't cracked 7 days after you post the answer, you can reveal your language and the original A and B and mark the answer safe, and it will be immune to future crack. Your answer can still be cracked if you don't do it.

Your score is max(len(A)+len(PA)*5, len(B)+len(PB)*5). The safe answer posted before a certain date with the minimum score wins.

For example, if your two programs are The first program and The second program, you can reveal first and second. Your score is 18 + 6*5 = 48. And a robber can crack your answer by <<first>> <<second>> if they work. But you can also reveal first pro and second pro to prevent this crack.

Please post your answer using this template:

# <length of PA> / <length of A> bytes, <length of PB> / <length of B> bytes, score <score>, <open / safe / cracked>

Part of program A (outputing [<OEIS number>](<OEIS link>)):

    <code of PA>

Part of program B (outputing [<OEIS number>](<OEIS link>)):

    <code of PB>

<any other explanations>

Robbers' task

(To do.)

\$\endgroup\$
  • \$\begingroup\$ Do robbers have to produce the same program, or any program? \$\endgroup\$ – Nathan Merrill Oct 28 '16 at 14:47
  • \$\begingroup\$ There are two tricky edge cases around character encodings which the question needs to address. 1. It talks about substrings of A and B, saying that every byte except the revealed ones must be the same. If A and B differ in one Unicode codepoint, such that in UTF-8 they differ in only one byte but it's part of a three-byte sequence, can I post just that one byte as PA/PB or must I post the three-byte sequence? (I.e. are the substrings operating on the bytes or on the codepoints?) \$\endgroup\$ – Peter Taylor Oct 28 '16 at 20:57
  • \$\begingroup\$ 2. If my program is in APL using an 8-bit encoding, do robbers answering in a language other than APL have to have the same bytes in the part of their file corresponding to PA/PB or the same Unicode codepoints? \$\endgroup\$ – Peter Taylor Oct 28 '16 at 20:57
  • \$\begingroup\$ @NathanMerrill Any program. \$\endgroup\$ – jimmy23013 Oct 28 '16 at 21:05
  • \$\begingroup\$ @PeterTaylor I'm considering requiring every program to be in printable ASCII (and tabs and newlines), as some special characters effectively banned many languages. But I'm not sure about newlines, which have the \r problem. \$\endgroup\$ – jimmy23013 Oct 28 '16 at 21:09
  • \$\begingroup\$ Maybe I'll just say \r\n is counted one byte in this challenge, and is interchangeable with \n. But the programs in one submission must use only \n or only \r\n. \$\endgroup\$ – jimmy23013 Oct 28 '16 at 21:13
  • \$\begingroup\$ An example would make this easier to understand, \$\endgroup\$ – xnor Oct 29 '16 at 6:08
  • 2
    \$\begingroup\$ I'm skeptical about having the programming language be a free variable. If a cop writes an answer using a verbose language, a robber can comment out all the visible parts and stuff a terse language answer into the cracks. \$\endgroup\$ – feersum Oct 29 '16 at 11:24
  • \$\begingroup\$ @feersum But that's the whole point of all the requirements. If you comment out all the visible parts, both your programs usually should output the same thing. But I realized it's easy to have some workarounds in languages such as Befunge. I may try to find a way to ban them, or just abandon this post. \$\endgroup\$ – jimmy23013 Oct 31 '16 at 0:59
-2
\$\begingroup\$

Translation Polyglot

Your task is to write a program which runs in two distinct programming languages to translate text. Input should be translated between each language i.e. running your code in Code Language A translates from language 1 to 2, while running your code in Code Language B translates from language 2 to 1.

Rules:

  • Code Languages must be distinct, two versions of the same language are disallowed
  • Your code may be a full program or function
  • Your code must take one string (or nearest equivalent) as input. Input may be user input, function arguments, or other reasonable form
  • Output may be a function return, output to STDOUT, or other reasonable form. I do not care about trailing newlines or spaces
  • Your code may translate from/to any language on the official language list on Wikipedia. List the languages in your answer
  • To accomplish your goal, you may use prebuilt language tanslation dictionaries such as the ones found here.
  • If you read your dictionary as an external file, only the code to read in the file (f = open("dictionary.txt", 'r') in Python) counts towards your byte count. If your dictionary is hardcoded in, only count the bytes required to make it syntatically valid code (s="word1_in_english word1_in_french ..." would be 4 (s="")). Essentially, do not include the dictionary as part of your submissions byte count.
  • The dictionary you use must have been created before this post (including sandbox time). You may not modifiy the dictionary in any way.
  • Any built-in translation tools are disallowed. Built-in dictionaries are ok, but whatever code used to import them into your code must be included in the byte count

This is code golf, so shortest answer in bytes wins.

\$\endgroup\$
  • \$\begingroup\$ wait... Are you actually asking for machine translation? Seems very difficult. Haven't you ever seen bad translator? If it actually is machine translation, this won't work, because of the different resolution of the languages (like converting a jpg to a png and expecting the same quality back) \$\endgroup\$ – Destructible Lemon Nov 1 '16 at 4:11
  • \$\begingroup\$ It's really just value lookup. I'm not asking people to to make their own dictionary, just use a pre-built and accept whatever it translates \$\endgroup\$ – wnnmaw Nov 1 '16 at 13:45
  • \$\begingroup\$ But that doesn't really satisfy Language A produces output O from input I, while running in Language B produces output I from input O. \$\endgroup\$ – Destructible Lemon Nov 1 '16 at 22:04
  • \$\begingroup\$ Ah, now I see the source of confusion. Updated text to require basic translation, not symmetric translation \$\endgroup\$ – wnnmaw Nov 2 '16 at 11:53
  • \$\begingroup\$ Also I don't think translation is objective enough for code golf... \$\endgroup\$ – Destructible Lemon Nov 3 '16 at 5:30
-2
\$\begingroup\$

Three-way meta-quine polyglot

Produce a program A such that running it in language A produces Program B, and running program A in language B produces program C.

Program B, when run in language B produces Program A, and running program B in language A produces program C.

Program C, when run in language A or language B, prints "Wrong language!".

Program | Language | Result
--------|----------|----------
A       | A        | Program B
B       | B        | Program A
A       | B        | Program C
B       | A        | Program C
C       | A        | "Wrong language!" 
C       | B        | "Wrong language!" 

Your answer should use this template:


Language A/Language B, {a bytes} + {b bytes} = {total bytes} bytes

Language A:

a code

Language B:

b code

Source:

# Language A/Language B, <a bytes> + <b bytes> = <total bytes> bytes

Language A:

    a code

Language B:

    b code

  • None of these programs should take input.
  • Different versions of the same language count DO NOT as different languages. - Languages A and B must be distinct.
  • You must not read your own source code from a file. Programs may not be empty
  • Standard loopholes apply.

This is , the smallest sum of the byte counts Program A and B wins.

\$\endgroup\$
  • \$\begingroup\$ Downvote reason? \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Nov 8 '16 at 20:23
  • \$\begingroup\$ It's probably not possible. I'll revert my downvote if you can find a solution within 24 hours of this comment. \$\endgroup\$ – MD XF Jun 7 '17 at 21:39
-2
\$\begingroup\$

Urinal Discomfort!

This question springboards off of Positional Bathroom Etiquette, while adding an extra twist.

Background

I'm going to take @Nick Frev 's formulae for the total discomfort of a urinal spot

dist(x,y) = linear distance between person x and person y in Urinal Units
discomfort(x) = sum(1/(dist(x,y)*dist(x,y))) for all persons y excluding person x
total_Discomfort = sum(discomfort(x)) for all x
short_urinal_discomfort = discomfort_from_surroundings + 1/9 (inherent_discomfort)

Your task is to put a person into the spot with the least total discomfort. However, now you have big and small urinals. The small ones, obviously, cause a little inherent discomfort, so we prefer to not use those if we have a choice.

The Challenge

Input/Output

Your program will take in a string of 1,0,i,o to represent the row of urinals. 1 represents a person in a tall urinal, 0 is an empty tall urinal, i is a full short urinal, and o is an empty short urinal.

Using the above formulae, build a program that will replace an empty urinal with the correct placement of the next person(0->1 or o->i).

  • The short urinals have an inherent discomfort of 1/9 which will be added onto the discomfort provided by the surroundings.
  • The door is to the right of the row, so the urinals fill up right to left, because you have to pee really bad and can't walk further than you have to.

Input Output 000 001 101 111 1000001 1001001 101010101 101010111 000o 001o 100o 100i oo0oooo oo1oooo 11000ii 11010ii

Any tips would be super helpful

More test cases maybe? Or more clarification?

\$\endgroup\$
-2
\$\begingroup\$

Stump the OEIS!

The OEIS is a wonderful database of integer sequences, but occasionally, there are code golf problems that generate integer sequences not found in the OEIS. Your challenge is to write some code that generates a sequence that meets all of the following criteria:

  1. Sequence must not exist in the OEIS. Prove this by providing a link to the search for your sequence showing 0 results, such as this: 1,2,6,81,35246. In the spirit of good faith, please do not generate a sequence that is merely an existing sequence offset or multiplied by some constant.
  2. The sequence must be non-repeating, non-oscillating, etc. Formally, there must not exist a subsequence S with finite length L, that begins at index I such that the subsequence from [I+kL] to [I+(k+1)L-1] for every k is identical to S. Such an invalid sequence would be 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, ... because the subsequence 1, 2, 3 beginning at index 1 with length 3 also exists as the subsequence from 4 to 6, from 7 to 9, from 10 to 12, etc.
  3. The sequence must contain a minimum of 3 distinct integers.
  4. The sequence must be deterministic, e.g. there must not be any element of randomness in the generation of your sequence. Every time your program is run, it must provide the same exact sequence.

Please write code that provides as many integers in your sequence as feasible. At least 20 is recommended, though sequences that grow incredibly fast can provide fewer, provided you also give a proof that your code would produce that number if given enough time.

This will be a problem, so the entry with the fewest number of bytes wins.

A bonus of -20% can be applied to your score if, in addition to your sequence, you can also provide some mathematical justification for your sequence being included in the OEIS in the future.

Standard loopholes are disallowed, as well as sequences that are simply "this sequence is just the handful of numbers I came up with to fit this problem."

\$\endgroup\$
  • \$\begingroup\$ You say "must contain an infinite number of entries not 0 or 1", then go on to talk about finite sequences, so I'm not sure what you're looking for here. \$\endgroup\$ – Geobits Nov 17 '16 at 17:44
  • \$\begingroup\$ Changed it to "The sequence, if infinite, must contain" blah blah blah \$\endgroup\$ – Gabriel Benamy Nov 17 '16 at 17:45
  • \$\begingroup\$ This is definitely going to be closed as "Too broad" - if it isn't closed first as "Unclear what you're asking" because of the impossibility of testing whether "this sequence is just the handful of numbers I came up with to fit this problem." \$\endgroup\$ – Peter Taylor Nov 17 '16 at 17:52
  • \$\begingroup\$ @PeterTaylor If I removed the possibility of finite sequences, then IMO that second possibility goes away. As for being closed for too broad, there have been problems that don't have a single goal that have done well, such as Does this code terminate? that inspired a lot of very creative answers. \$\endgroup\$ – Gabriel Benamy Nov 17 '16 at 17:59
  • \$\begingroup\$ Its pretty easy to fill most of the requirements you've listed here: all you need to do is combine two different OEIS sequences (multiply or add). Restriction 3 should be changed to "Your sequence must contain at least 3 distinct terms". I'd also definitely recommend disallowing finite sequences, as well as the 20% bonus (which is very ambiguous) \$\endgroup\$ – Nathan Merrill Nov 17 '16 at 18:33
  • \$\begingroup\$ @NathanMerrill That's a good idea for a change to #3, but as for being able to simply combine existing sequences, there's plenty of existing sequences like that are already in the OEIS even without necessarily being important. \$\endgroup\$ – Gabriel Benamy Nov 17 '16 at 18:44
  • \$\begingroup\$ @GabrielBenamy right, its not necessarily a bad thing, its just that most sequences generated aren't going to be that interesting. Also, what's to stop me from simply adding a random "9" number to the beginning of the sequence, or replacing the first term with "9"? \$\endgroup\$ – Nathan Merrill Nov 17 '16 at 18:45
  • 1
    \$\begingroup\$ Consider the family of sequences parameterised by x where S(x, n) = n >= x ? n+1 : n. Only a finite number of those sequences are either in OEIS or a linear transform of a sequence in OEIS. Are they caught by "just the handful of numbers I came up with to fit this problem"? IMO it's ambiguous. \$\endgroup\$ – Peter Taylor Nov 17 '16 at 19:22
  • \$\begingroup\$ That's a good point. Is there any way to salvage this concept? \$\endgroup\$ – Gabriel Benamy Nov 17 '16 at 19:24
  • \$\begingroup\$ This is similar to the question "print something with no results on google". It got closed for being a question about Google's database, not about code-golf, so this one will probably be closed too. \$\endgroup\$ – FlipTack Nov 19 '16 at 13:37
-2
\$\begingroup\$

Golf + Polyglot + Circle = ?

In the original challenge, we asked you to do this:

Program | Language | Result
--------|----------|----------
A       | A        | Program B
B       | B        | Program A
A       | B        | Program C
B       | A        | Program C
C       | A        | "Wrong language!" 
C       | B        | "Wrong language!" 

Now we're asking you to do this*:

Program | Language | Result
--------|----------|----------
1       | 1        | Program 2
2       | 2        | Program 3
3       | 3        | Program 4
        |    ...   |
X       | X        | Program 1
--------|----------|----------          
1       | Any but 1| Any member of Set %
2       | Any but 2| Any member of Set %
        |    ...   |
X       | Any but X| Any member of Set %
------------------------------
Set %   | Any lang | "Wrong language!"

(see original challenge for clarification)

Rules

  • Do not grab source off of internet, or read own code from file
  • Programs don't have to be distinct - you can make a polyglot quine
  • Don't take input for any of the programs
  • Different versions of the same language count do as different languages. (although this is discouraged because it leads to boring solutions)
  • Standard loopholes apply

Scoring

Score is byte_count_of_program_one/2.75**languages_supported, the submission with the lowest score wins.

Template

Because of its length, the answer template is here.


*not that I'm expecting X to be so large

\$\endgroup\$
  • \$\begingroup\$ +1 this comment if you think the title should be "Polyglot-Quine-Codegolf Returns!" \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Nov 23 '16 at 23:38
  • \$\begingroup\$ +1 this comment if you think the title should stay the same \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Nov 23 '16 at 23:38
  • \$\begingroup\$ Reply to this question if you have a better title \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Nov 23 '16 at 23:38
  • \$\begingroup\$ I personally think the title is way too descriptive, but "polyglot-quine-codegolf" isn't really descriptive enough. The problem is, I don't currently have a better idea... \$\endgroup\$ – ETHproductions Nov 24 '16 at 0:12

You must log in to answer this question.

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