459
\$\begingroup\$

What is the Sandbox?

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

To post to the Sandbox, scroll to the bottom of this page or click on the "Add Proposal" link below, and click "Answer This Question". Click "OK" when it asks if you really want to add another answer. Write your challenge just as you would when actually posting it. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it. When you think your challenge is ready for the public, go ahead and post it, replace the post here with a link to the challenge and delete it.

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

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

Add Proposal

Search the Sandbox

Browse your pending proposals

Get the Sandbox Viewer to view the sandbox more easily

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

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

2569 Answers 2569

-2
\$\begingroup\$

I want to post the question here to make sure it is suitable.

Question: Word Equations

Given a word equation, the solution must output the answer.

My definition of a 'word equation' is an equation where the operators are words.


The operators will be spelt as

add minus times divide


The solution must take one input

The solution must give one output

Examples:

Input: 7 add 8 Output: 15

Input: 9 times -2 Output: -18

Input: 24 divide 2 Output: 12

Input: 4 minus 5 Ouput: -1


You are not required to deal with divide by zero errors.

Fewest characters will win

Feedback is welcomed

\$\endgroup\$
  • \$\begingroup\$ What is the winning criterion? \$\endgroup\$ – acrolith Dec 2 '16 at 22:14
  • \$\begingroup\$ @daHugLenny fewest characters, should have known to include that \$\endgroup\$ – george Dec 2 '16 at 22:59
  • \$\begingroup\$ Be aware that you will receive many answers in the form: substitute words with corresponding char (+-*/), then evaluate the string you got. Non necessarily a bad thing, just pointing this out in case you expect people to build a calculator from scratch. \$\endgroup\$ – Leo Dec 3 '16 at 18:41
  • \$\begingroup\$ @Leo the way I expected to solve it was by char substituting. However building a calculator from scratch only using + and - could be an interesting challenge \$\endgroup\$ – george Dec 3 '16 at 18:55
-2
\$\begingroup\$

GoL flooding

Considering a 1000x1000 grid (no wrapping, borders dead), your task is to grow the maximum "stable" population from the fewer individuals.

For the purpose of this challenge, the definition of stable is a configuration who repeat with a period of less than hundred(100) generations.

Scoring

Your score is lowest number of live cells in your stable population divided by the number of initialy live cells, highest score win

meta post about on topicness

\$\endgroup\$
  • \$\begingroup\$ How many generations does the simulation run before the score is tabulated? \$\endgroup\$ – AdmBorkBork Dec 8 '16 at 13:48
  • \$\begingroup\$ @TimmyD I would say 10.000 but feel free to suggest a better number if you think it could improve \$\endgroup\$ – Sefa Dec 8 '16 at 14:07
-2
\$\begingroup\$

Convenient Palindromic quine golf, Cops

This is the cops thread, the robber's thread is here.

Cop's Challenge

A program is conveniently palindromic if

it is equal to the string derived when its reverse has all its parentheses (()), brackets ([]), and braces ({}) flipped. No other characters are special and require flipping. (<> are sometimes paired but often not so they are left out.)

copied from this challenge.

Write a conveniently palindromic program that prints its own source. This is the robber's goal:

  • Remove byte(s) from the cop's program so that the resulting program:
    • prints the original source, or
    • prints the new modified source
  • Resulting program need not be a convenient palindrome

A counterexample

JavaScript

(function $(){console.log('('+$+'())')}())//((){('(()'+$+')')gol.elosnoc}()$ niotcnuf)

is easily cracked because the robber can remove all the characters past the comment and it will still print its own source.

Rules

  • Program must be longer than one character
  • No reading from a file or grabbing from an external resource
  • Submissions that aren't cracked for 7 days are marked as "safe", and cannot be cracked anymore
  • Cop's submissions after XX/XX/XX are non-competing (can be pushed back depending on popularity), so there are still robbers around to crack it
  • The shortest safe solution in bytes wins.
  • Robbers won't have a chosen winner

\$\endgroup\$
  • \$\begingroup\$ This is basically just a "comment-free palindromic quine" challenge, right? When those challenges have been run elsewhere, the comment-freedom has been verified via brute forcing rather than via a robber, and I suspect that the robbers might not have much to do here. (That said, some languages are slow enough that brute-forcing their correctness would be difficult.) In other news, you should probably require proper quine rules, even if we can't quite define them; under your current rules, 1 is a valid palindromic quine in PHP. \$\endgroup\$ – user62131 Dec 9 '16 at 22:41
  • \$\begingroup\$ I would possibly change the palindrome restriction to convenient palindromes, as these are way easier to implement in most common languages such as JS and Python. \$\endgroup\$ – ETHproductions Dec 9 '16 at 23:01
  • \$\begingroup\$ @ais523 1. Yas. That was my aim! 2. It's difficult to implement a brute-force solution for a longer submission, how would that work? 3. Program must be longer than one character 4. Thanks. \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Dec 10 '16 at 14:27
  • \$\begingroup\$ 11 then :-P. Also, in a way I think this might be more interesting with true palindromes, as it forces you to hide the backwards string somehow, but I agree that it would disqualify a lot of languages. \$\endgroup\$ – user62131 Dec 10 '16 at 14:40
  • \$\begingroup\$ @ais523 I'll do a true palindrome one then a convenient palindrome one later, perhaps? (also 11 then means ?) \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Dec 10 '16 at 14:44
  • \$\begingroup\$ @ais523 When those challenges have been run elsewhere, they have? \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Dec 10 '16 at 14:51
  • \$\begingroup\$ Neither this challenge nor this challenge has the same task as yours, but they both disallowed comments in much the same way as this one (i.e. by ensuring that deleting from the program breaks it). \$\endgroup\$ – user62131 Dec 10 '16 at 15:27
-2
\$\begingroup\$

Print number of possible values of X if:

  • Code 1: X is dividable by 3, X contains the number 3 and input() < X < 10000
  • Code 2: X is dividable by 7, X contains the number 2, X doesn't contain the number 3 and input() < X < 5000

Sub-Challenge:

Do the same but instead of printing the number, print the values


Disclaimer: This is my first code golf challenge, and it's very simple, but could bring up some really short answers and cool languages

\$\endgroup\$
  • \$\begingroup\$ First thing: Sub-challenges are not a good idea. People will write the shortest code they can and just disregard the sub-challenge. \$\endgroup\$ – Stewie Griffin Jan 16 '17 at 19:49
  • \$\begingroup\$ Should you output the sum of the numbers from both two bullet points, in one? I don't think it benefits the challenge to have two different upper limits. I can see why you want it there, but I personally don't think it's a good thing. This needs some good test cases. \$\endgroup\$ – Stewie Griffin Jan 16 '17 at 19:52
  • \$\begingroup\$ Those were actually different puzzles, sorry! \$\endgroup\$ – endriklos977 Jan 17 '17 at 12:10
  • \$\begingroup\$ Two different independent puzzles in one challenge is not a very good idea either I'm afraid. I think it would be better to use the same upper limit and require the numbers from both 1 and 2 together, I.e. the union of the two sets. \$\endgroup\$ – Stewie Griffin Jan 17 '17 at 12:23
-2
\$\begingroup\$

[please suggest a name]

Mark got an idea of making a path finding algorithm for auto driving vehicles.

Unfortunately, Mark doesn't yet know about programming, so he decided to get help from the code golfers.


How should it work?

First, we input how many 'nodes' there are. we call it 'N', and its an integer up to 16 bit values.

Second, we input what nodes are connected to each nodes, and the length of the connection. for example, if the diagram is

(1)-5-(2)-2-(3)

the input should be

2 5  //node 1 is connected to node 2, and the length is 5
1 5 3 2 //node 2 is connected to node 1 and the length is 5. and its also connected to node 3, and its length is 2.
2 2  //node 3 is connected to node 2, and the length is 2.

then, finally, the starting node, and the final node. they are inputted as node numbers.

Your code should output the path of the shortest way to go from the start to the final node.

Examples

Input:

3
2 5
1 5 3 2
2 2
1 3

Output:

1->2->3

Explanation:

(1)-5-(2)-2-(3) starts from 1, and ends in 3. there is only one path, and it is the answer.


Specs

Standard rules apply.

\$\endgroup\$
  • \$\begingroup\$ Possible duplicate. And another related question. Suggested tags for this challenge: graph-theory and path-finding \$\endgroup\$ – user2428118 Jan 17 '17 at 9:35
  • \$\begingroup\$ Not a duplicate. Though related, clearly not a duplicate. \$\endgroup\$ – Matthew Roh Jan 17 '17 at 10:32
  • 2
    \$\begingroup\$ By the standards of this site, it is a duplicate. \$\endgroup\$ – Peter Taylor Jan 18 '17 at 11:48
  • \$\begingroup\$ Proof of duplicate? \$\endgroup\$ – Matthew Roh Jan 18 '17 at 11:50
  • 2
    \$\begingroup\$ Currently the only differences are that not all nodes are necessarily connected and the specified input format. However both input formats are tight and string based, so I'd like to see this challenge with a loosened input format, e.g. allow all reasonable input formats for a weighted graph. \$\endgroup\$ – Laikoni Jan 18 '17 at 11:53
  • \$\begingroup\$ Okay, thanks for the suggestion. @Laikoni \$\endgroup\$ – Matthew Roh Jan 18 '17 at 11:55
  • \$\begingroup\$ The way we identify duplicates on this site is to ask "Can answers from one question be copied over to the other with little or no modification and still be competitive?" \$\endgroup\$ – trichoplax Jan 19 '17 at 7:09
  • \$\begingroup\$ @trich Seems legit, but those two question have quite of a difference, and second, I have came up to this idea all by myself, and being tagged as dupe, seems a tad unfair. \$\endgroup\$ – Matthew Roh Jan 19 '17 at 12:12
  • 2
    \$\begingroup\$ Being marked as duplicate doesn't mean "This is a bad challenge", it just means "This challenge has already been posted". This is a good challenge idea, but we only host each challenge once, so that all the answers are in one place. \$\endgroup\$ – trichoplax Jan 19 '17 at 13:42
-2
\$\begingroup\$

Generate "N" random numbers which their sum is exactly "N"

Your goal is to generate N pseudo-random numbers R, then sum or subtract all the R togheter and obtain as result N.

Rules:

  • You get N from standard input as integer number, such as N <= 1000.
  • You can't perform operations like sum 100 times 1, 50 times 2, or similar...
  • R shall be generated in any reasonable non-deterministic way
  • R shall be integer such as 0 <= R <= N.
  • R can't have a constant value each time you generate it. For example you can't generate R with methods like R = rand(1,2) with the result that 1 <= R < 2 (R is constantly always =1), and then sum R 100 times.
  • You can perform only sums or subtractions of the generated R's.
  • You have to sum or subtract the newly generated R to the total of R's.
  • Standard loopholes are forbidden.
  • This is so the shortest code wins.

Example 1:

  1. Get N=100 from standard input.
  2. Generate 100 pseudo-random integer numbers R such as 0 <= R <= 100.
  3. Sum or subtract all the R and obtain 100(N) as result.

Example 2:

  1. Get N=20 from standard input.
  2. Generate 20 pseudo-random integer numbers R such as 0 <= R <= 20.
  3. Sum or subtract all the R and obtain 20(N) as result.

Not-so-smart-but-working example in C#:

using System;           
public class Program {
    public static void Main() {
        int S = 0, N, R = 1, X;
        int INPUT = Int32.Parse(Console.ReadLine());
        Random rnd = new Random();
        for (int I = 1; I < (INPUT+1); I++) {
            X = (INPUT+1) - I;
            if (I == INPUT && S == INPUT) {
                R = 0;
            }
            N = rnd.Next(R, X);
            if (S <= INPUT) {
                S = S + N;
            } else {
                S = S - N;
            }
            Console.WriteLine("I = {0}      N = {1}     S = {2}", I, N, S);
        }
    }
}

Test online

Tags:

\$\endgroup\$
  • \$\begingroup\$ I don't understand what the goal is. If my program accepts the number 20, I have to generate 20 random numbers that sum to 20? So I generate random real numbers? Integers? Positive integers? Positive-or-zero integers? \$\endgroup\$ – Gabriel Benamy Jan 19 '17 at 15:27
  • \$\begingroup\$ "You get N from standard input as integer" and "N shall be generated in any reasonable non-deterministic way" seem incompatible. If these are referring to two different things, then it would be clearer to not call them both N. \$\endgroup\$ – trichoplax Jan 19 '17 at 15:42
  • 1
    \$\begingroup\$ It's not clear to me what your working definition of "random number" is, especially given that the system to be implemented has fewer degrees of freedom than "random" numbers. For a question about random numbers to be well specified it should state the distributions to be followed (modulo limitations of PRNGs). \$\endgroup\$ – Peter Taylor Jan 19 '17 at 21:17
  • \$\begingroup\$ @GabrielBenamy Yes you understood correctly the challenge. I changed it adding more specs and more details. If you have further doubts please let me know. \$\endgroup\$ – Mario Jan 20 '17 at 8:03
  • \$\begingroup\$ @trichoplax Thanks for your comment. I edited the question to make it more clear with more details and specifications. Please let me know if I can improve it in a better way. \$\endgroup\$ – Mario Jan 20 '17 at 8:04
  • \$\begingroup\$ @PeterTaylor I am not sure I get what you mean, probably they are too advanced concepts for me :) Anyway I largely edited the question to make as more clear as possible. If you think it needs to be improved please give me your suggestions on how to make it a more clear and better challenge. \$\endgroup\$ – Mario Jan 20 '17 at 8:07
  • \$\begingroup\$ What about cases where it is impossible to sum/subtract to R? For example: N=5, R=[0,1,1,1,1]. \$\endgroup\$ – Emigna Jan 20 '17 at 9:46
  • \$\begingroup\$ @Emigna if you try my C# example it works for N=5. \$\endgroup\$ – Mario Jan 20 '17 at 11:22
  • 2
    \$\begingroup\$ If random distributions are too advanced a concept for you then I think you should abandon the idea of trying to post a question about sums of random variables. \$\endgroup\$ – Peter Taylor Jan 20 '17 at 11:23
  • \$\begingroup\$ The explanation is still unclear, and needs work in itself. Separately from that, I recommend example inputs and outputs (literal output rather than explanation). The specification should be unambiguous before seeing the examples, and then the examples should come afterwards to confirm correct understanding of the spec. At present I believe the intention is to output an expression containing N integers, each added or subtracted, each in the range [0, N], evaluating to N, and for the integers to be randomly distributed amongst those that meet these criteria. \$\endgroup\$ – trichoplax Jan 20 '17 at 11:55
  • \$\begingroup\$ @trichoplax thanks for your comments and explanations, although the challenge seems clear to me it's obvious that I am missing something that goes beyond my knowledges. I think I will delete the post maybe reviewing it. \$\endgroup\$ – Mario Jan 20 '17 at 12:24
  • \$\begingroup\$ @PeterTaylor I got an idea and I posted it here to have feedbacks about it and maybe help or suggestions for improvement, but as I said obviously I am missing something that I haven't studied. I'll delete the challenge. \$\endgroup\$ – Mario Jan 20 '17 at 12:28
  • \$\begingroup\$ A post always seems clear to the person who wrote it, because they already knew what they meant. That's why the sandbox is so useful - I can't tell if my challenge is really clear until I show it to other people. Being unclear doesn't make it a bad challenge. It just means it needs rewording before it will be ready. Here in the sandbox you don't need to delete. You can simply keep making adjustments and getting feedback until it's ready. \$\endgroup\$ – trichoplax Jan 20 '17 at 13:17
-2
\$\begingroup\$

Make the Shape

This is a wider version of this question, so it may not get posted.

Given a single character e.g. H or ! and a sequence of letters e.g. abcdefghijklmnopqrstuvwxyz you must output the character drawn using the letters in the sequence. If you need more letters, just loop through the sequence again.

Input

A single character, c. You can assume that it will always be one character.

A sequence of charaters s. All characters must be printable ASCII letters.

Output

c made up of the letters in s

Examples

Let's say c = "H" and s = "abcdefghijklmnopqrstuvwxyz". The correct output would be

ab   cd
ef   gh
ij   kl
mnopqrs
tuvwxyz
ab   cd
ef   gh
ij   kl

c = "!" and s = "hello, world" outputs

he
ll
o,
 w
or

ld

Rules

  • Shortest code (in bytes) wins
  • Any correct output may be outputted i.e. either one of the example
  • c must be one character
  • Leading/trailing newline is acceptable
  • Standard golfing loopholes apply
  • Lines must be 2 characters thick
  • You must use every letter in s at least once to make c
  • Either a full program or a function, NO snippets
\$\endgroup\$
  • \$\begingroup\$ You need definitive rules about the shape and size of each letter or else this will probably be closed as unclear. \$\endgroup\$ – FlipTack Jan 22 '17 at 17:35
  • \$\begingroup\$ This is similar to another question, that I can't find at the moment. It's about making words from other words, nested n times. \$\endgroup\$ – wizzwizz4 Jan 22 '17 at 18:42
  • \$\begingroup\$ "Both inputs must be surrounded by "" - um, why? This isn't a parsing challenge. Input should be allowed to be taken in any reasonable format, as is the code-golf standard. You should only break the IO defaults if it is of paramount importance to your challenge, whereas it just looks like a trivial pointless rule here. \$\endgroup\$ – FlipTack Jan 22 '17 at 18:49
  • \$\begingroup\$ It was to clarify for languages that need " at input. I'll change it. \$\endgroup\$ – user63571 Jan 22 '17 at 19:06
  • \$\begingroup\$ Also whoever downvoted can you tell me why? I might be able to improve the question \$\endgroup\$ – user63571 Jan 22 '17 at 23:26
  • \$\begingroup\$ If you want to limit it to alphabetical characters, you may use my list of ASCII art: codegolf.stackexchange.com/questions/99913/5-favorite-letters \$\endgroup\$ – Magic Octopus Urn Jan 23 '17 at 19:36
  • \$\begingroup\$ Also, Jack, they're probably downvoting because of how open-ended it is. You haven't defined the layout of any of the characters beyond H!. \$\endgroup\$ – Magic Octopus Urn Jan 23 '17 at 19:52
  • \$\begingroup\$ Thanks for the help \$\endgroup\$ – user63571 Jan 23 '17 at 20:24
  • \$\begingroup\$ If you want to reply to someone, tag them - @JackBates \$\endgroup\$ – FlipTack Jan 23 '17 at 22:49
-2
\$\begingroup\$

Why is it buff...........ering?

As the Internet isn't perfect, occasionally the videos we watch start buffering. When this happens, I get very annoyed. As the wait gets longer, I get even more annoyed.

Your task is to write a function or program that waits a random amount of time and then outputs an angry message with the level of anger increasing the longer it waits

Input

None

Output

An angry message and the length of the wait

Examples

Time waited: 5 seconds

Angry message: Never mind!

Time waited: 30 seconds

Message: I hate YouTube!

Time waited: 1 minute

Message: Die computer, die!!!

This code is an example in Python, obviously ungolfed.

import time
import random
messages = ["Never mind!","Getting annoyed","I hate YouTube!","Die computer, die!"]
slept = random.randint(5,60)
msg_num = slept//len(messages)
time.sleep(slept)
print("Time waited:",slept)
print(messages[msg_num])

Rules

  • Messages are up to you
  • The time to wait ranges from 5 seconds to 1 minute
  • Standard code-golf rules apply
  • Standard code-golf loopholes are disallowed
\$\endgroup\$
  • 1
    \$\begingroup\$ This won't work as code-golf because it'd mostly be about golfing the angry messages in question, and golfing English is always highly subjective; how angry does the message have to be before it qualifies as "angry"?. I don't really see it working with another victory condition, either. \$\endgroup\$ – user62131 Jan 25 '17 at 19:14
-2
\$\begingroup\$

Don't know what to call this

Some people here may be familiar with Euler's identity. If not click the link

Now you know what the equation is, what if we change it slightly? No-one like to imagine numbers so instead we're going to use an unknown number x.

So first we get rid of i and replace it with x. Now we all know that i*i is -1. But with i gone, so must -1. Let's change it to x^2 instead. However this means there is only one solution. So instead let's make it x^random_integer(0,x) to spice it up

If we change the equation from e^(i*π) - 1 = 0 to e^π / (x^random_integer(0,x)) = 0 we now have something we can work with.

Given an integer or float as input, x, calculate if it satisfies the above equation. Your code should result in True or False or the closest equivalent.

Input

A single number between -(2^32-1) or what ever your language can handle and 2^32-1 or whatever it can handle called x

Output

A Boolean that says whether the number satisfies the above equation and the random number that is picked

Rules

• The code must calculate if x fits this equation rather than take it from an outside source

• Results in True if within -0.1 and 0.1

• This is code-golf so shortest code (bytes) wins

• Builtins that postdate this challenge are allowed unless they are specifically designed for the sole purpose of winning this challenge

• Standard code-golf loopholes apply

Examples

x = 5
e^π / 5 ^ rand(0,5) = 0
rand(0,5) = 2
results False (0.92)

x = 6
e^π / 6 ^ rand(0,6) = 0
rand(0,6) = 4
results True (0.01)
\$\endgroup\$
  • 2
    \$\begingroup\$ Most languages don't have accurate enough floats to be able to compare the two sides as equal. As such, they could just arbitrarily return false. You might want to add a precision level. (Also, I assume there are only finitely many solutions anyway…) \$\endgroup\$ – user62131 Jan 25 '17 at 20:19
  • \$\begingroup\$ Sorry I'm a bit all over the place. I'm not perfect with the maths and keep changing it so it might work :/ \$\endgroup\$ – user63571 Jan 25 '17 at 20:30
  • \$\begingroup\$ I found something that works! :) \$\endgroup\$ – user63571 Jan 25 '17 at 20:44
  • \$\begingroup\$ Check rules number 2 and the examples \$\endgroup\$ – user63571 Jan 25 '17 at 20:55
  • \$\begingroup\$ According to your equation the rule number two has both of those as false, 0.92 and 0.64 are not 0.1 away from 0. Random numbers are also usually considered a bad thing to be using in the challenges. \$\endgroup\$ – fəˈnɛtɪk Jan 25 '17 at 20:56
  • \$\begingroup\$ Sorry got the example wrong, fixing now. I thought it was to 1 while I did the first one :/ \$\endgroup\$ – user63571 Jan 25 '17 at 20:57
  • \$\begingroup\$ e^π / (x^random_integer(0,x)) = 0 requires e^π = 0 (false) or x^random_integer(0,x) to be infinite (in which case it's not strictly true, but it is in the limit). The only way it's going to be infinite with real x and non-negative random_integer(0, x) is if x is infinite. Therefore the explanation of the task effectively states that the task is to return False. It's very confusing that the rules then contradict this. \$\endgroup\$ – Peter Taylor Jan 25 '17 at 23:06
  • \$\begingroup\$ @PeterTaylor If you look at rule 2, it explains how to beat this. Also check the example true one \$\endgroup\$ – user63571 Jan 25 '17 at 23:09
  • \$\begingroup\$ My point is precisely that rule 2 and the second example contradict the problem statement, which therefore needs fixing. \$\endgroup\$ – Peter Taylor Jan 25 '17 at 23:26
  • \$\begingroup\$ I'm not sure if I understand you correctly. The problem is to find if x satisfies the equation e^pi / x^rand(0,x) = 0 plus-minus 0.1. Rule 2 and the examples both follow this problem and output the correct result. \$\endgroup\$ – user63571 Jan 25 '17 at 23:32
  • \$\begingroup\$ The problem statement clearly says "Given an integer or float as input, x, calculate if it satisfies the above equation" where the above equation is e^π / (x^random_integer(0,x)) = 0. Then half a screen later the rules say, in effect, "Actually, what I said earlier was a lie." That's not the way to write a clear specification. One way to fix it would be to change the problem statement to say "If we change the equation from e^(i\*π) - 1 = 0 to e^π / (x^random_integer(0,x)) = 0 we now have no solutions, so let's make it an inequality: abs(e^π / (x^random_integer(0,x))) <= 0.1". \$\endgroup\$ – Peter Taylor Jan 26 '17 at 8:34
  • \$\begingroup\$ What rules make it say "What I said earlier was a lie"? \$\endgroup\$ – user63571 Jan 26 '17 at 15:34
  • \$\begingroup\$ Loophole found: Consider a/(x^b): For a non-zero a, this fraction gets closer to 0 as x^b gets closer to infinity, where higher values for b result in outcomes closer to 0. As such, if you want to check if the fraction is smaller than some other value c if b goes from 0 to x, you only have to check if a/(x^x) < c, because if that's false, there will be no value for b smaller than x for which it is true. \$\endgroup\$ – Luke Jan 26 '17 at 19:03
  • \$\begingroup\$ What's your point? Are you suggesting I change it in some way? \$\endgroup\$ – user63571 Jan 26 '17 at 19:28
  • \$\begingroup\$ You should at least remove the word "random" from the question, since this has nothing to do with randomness. The question is stated a lot more complicated than it actually is. \$\endgroup\$ – Luke Jan 26 '17 at 20:07
-2
\$\begingroup\$

Count My Change

Your task is to sort an array containing the strings "quarter", "dime", "nickel", and "penny" any number of times in no specific order and sort them so that they are in this order: quarter dime nickel penny (in other words, greatest to least monetary value).


Rules

  1. Your program must take an array as input containing the names of U.S coins and sort them from greatest to least by monetary value.
    • For those who are not from the U.S or don't use change, the values of U.S coins, from greatest to least, are:
      • Quarter: 25 cents
      • Dime: 10 cents
      • Nickel: 5 cents
      • Penny: 1 cent
  2. You may sort this array in any way you wish, as long as the output is ordered by the monetary values shown above.
  3. Input can be taken in any way, be it command-line arguments or STDIN.
  4. An input array would be all lowercase strings, something like this:
    • quarter dime nickel nickel quarter dime penny penny
  5. If there is a value in input that is not a quarter, dime, nickel, or penny, your program should output 0 .

Test Cases

  • penny nickel dime quarter should become: quarter dime nickel penny
  • nickel penny penny quarter quarter quarter dime dime dime dime
  • quarter dime nickel nickel quarter dime penny penny
  • euro quarter nickel dime would output 0 because a euro is not U.S currency.
  • esac (not a test case, I just like bash a lot)

This is , so standard rules & loopholes apply.

\$\endgroup\$
  • \$\begingroup\$ Test cases please? \$\endgroup\$ – MildlyMilquetoast Feb 3 '17 at 16:01
  • \$\begingroup\$ @MistahFiggins On it \$\endgroup\$ – ckjbgames Feb 3 '17 at 16:26
-2
\$\begingroup\$

What in the heck just happened?

I want you to write a program that will bleep out the H-word, regardless of where it occurs, whether it is inside of another word or a stand-alone word, whether capitalized or not.

Input and Output

The inputs and outputs of your program may be any of the following: an array of characters, a string, or any other standard data structure which does the job. However, the output must match the case of the input.

Samples:

In the format of Input: Output
A Shell gas station : A Sheck gas station
Hell is a very bad place to be. : Heck is a very bad place to be.
Ella fell and Nelly dug a well. : Ella fell and Nelly dug a well.
Chellsea Thell bought shells. : Checksea Theck bought shecks.

Standard loopholes apply, and the entry submitted by [insert date here] with the lowest number of bytes as defined by the Meta will win.

\$\endgroup\$
  • 1
    \$\begingroup\$ I can't say for sure, as I don't have an exact reference, but I'm pretty sure a simple find and replace challenge has been done before. \$\endgroup\$ – ATaco Feb 13 '17 at 0:19
  • 1
    \$\begingroup\$ "Hell" and "heck" are both "H-words", so you need to be clearer. Also, I feel like this is a duplicate. Though these are milder swear words, I think someone did one with swear words in general and it got deleted. If you're going to make a find/replace challenge, it's simple enough to make it about something else. \$\endgroup\$ – mbomb007 Feb 13 '17 at 0:19
  • \$\begingroup\$ Ah, I see. So, are you saying I should change what's being replaced or what my idea is? \$\endgroup\$ – Drew Christensen Feb 14 '17 at 0:50
-2
\$\begingroup\$

Digitless digits

Introduction

What we have feared for so long has finally happened, the robots have gained counsciousness and have risen. There has been a war, a global and violent one, and humans have been defeated.

Calcubot, the fearless and tyrannic robot leader, has established a new world order, and its first decree as Supreme World Leader has been to forbid all non-AI entities from using numbers.

But, as it's always been the case in oppressive regimes, the Resistance has begun to form. Their first act of rebellion is to print leaflets with numbers on them. However, as the secret robot police is everywhere and can see everything, especially computer programs, these leaflets have to be inconspicuous and must not use numbers within their construction.

Challenge

The goal of the challenge is to print all digits from 0 to 9 without using them in the source code.

Example Input and Output

Input:

There is no input required

Output:

0123456789

Restrictions

The source code must not use one of the following characters : 0123456789.

Also, as this is a challenge, your code must be inventive, i.e. please refrain from using prebuilt classes with all the digits or other standard loopholes. You might still try to make your source code the shortest possible, but not at the expense of inventivity.

The answer with the most upvotes after 7 days will be declared the winner, the time of submission will be used as a tie-breaker.

For example, this is what I had in mind for a PHP solution :

$i = (int)false;
foreach(str_split('abcdefghij') as $k) {
    echo $i++;
}

Meta questions

  • Has this challenge already been done ? I feel like it's not a revolutionary idea and am afraid someone has thought about it before.
  • Could you give me examples of "forbidden loopholes", as I don't really now all the esoteric programmation languages you guys are using.
  • Finally, do you think it's a good challenge ? And if not, what could be done to improve it ? That's my first proposed challenge, so I'm aware there might be blatant errors or misses.
\$\endgroup\$
  • \$\begingroup\$ Regarding loopholes, you can link to this: Loopholes that are forbidden by default \$\endgroup\$ – Emigna Feb 22 '17 at 10:38
  • 1
    \$\begingroup\$ If you intend to ban "boring" answers, like predefined character classes you need to be very careful as writing a Do X without Y challenge can be very hard to get right. \$\endgroup\$ – Emigna Feb 22 '17 at 10:39
  • 1
    \$\begingroup\$ Code-challenge doesn't provide an objective winning criteria by default so you need to explicitly specify one. \$\endgroup\$ – Emigna Feb 22 '17 at 10:40
  • \$\begingroup\$ Thank you for your input @Emigna. I think most upvotes could be the winning criterion, since I don't want it to be a code-golf challenge. I'll edit and add the loopholes link. \$\endgroup\$ – roberto06 Feb 22 '17 at 10:45
  • 1
    \$\begingroup\$ Related: Print all ASCII alphanumeric characters without using them, Print every printable ASCII character without using it. This challenge is in between those two, and I'm not sure if there's space for a third (because many answers are likely to end up similar to answer to one of those). \$\endgroup\$ – user62131 Feb 22 '17 at 10:47
  • \$\begingroup\$ @ais523 I don't think the second example you're giving could be considered as a dupe, since only one character is forbidden for each execution. As for the first one, I see two major differences with my propose challenge : letters are allowed here, which would make it easier for submitters to create a "real" function, and this is not a code-golf challenge, which might reduce the numbers of answers written in esoteric languages such as Brainf**k. I hear what you're saying, but IMO, this challenge could find its space, as I'm really looking for readable and inventive solutions. \$\endgroup\$ – roberto06 Feb 22 '17 at 10:57
  • \$\begingroup\$ Oh, I missed the victory condition. A "most upvotes" victory condition uses the popularity-contest tag, not code-challenge. Popularity contests historically tend not to do that well here, as a notable proportion of the site's userbase dislikes them (although many other users are fine with them). \$\endgroup\$ – user62131 Feb 22 '17 at 10:59
  • \$\begingroup\$ The winning criterion could be something else, I set it to "most upvotes" because I supposed "The winner is whosever solution I find the most interesting" wouldn't have been a good criterion. I'm open to ideas though, what do you think could be an accurate and impartial victory condition (still, I'd rather not use "shortest code" as the criterion) ? \$\endgroup\$ – roberto06 Feb 22 '17 at 11:04
  • \$\begingroup\$ "Inventivity" is not objective. The obvious way to do this in CJam neither uses prebuilt classes with all the digits nor any other standard loophole, is two characters long, and by virtue of being obvious is probably not "inventive". If you feel the need to try to forbid non-inventive answers, that suggests to me that you already know that the answer to "Is it a good challenge?" is "No, it's not". \$\endgroup\$ – Peter Taylor Feb 27 '17 at 14:38
-2
\$\begingroup\$

You should log out


In the programming language of your choice, log off the currently logged in user.

Rules and clarifications:

  • After running the program the user should be taken to the login screen of the appropriate operating system, where they can re-login
  • You can assume that no programs are running that would block the logout process with popups
  • Solutions that just restart the computer to get to the login page are not allowed
  • Always specify which OS / architecture / environment your code runs on
  • Standard loopholes are forbidden

This is code-golf, so the lowest amount of bytes wins


Sandbox questions:

  • I'm unsure how to discourage answers where logout is achieved by expecting the code to be called from bash using "exec", or other solutions where logout is not actually initiated by the program, but by the caller process
  • Do we have a tag for architecture dependent questions?
\$\endgroup\$
  • \$\begingroup\$ @LliwTelracs: "After running the program the user should be taken to the login screen of the appropriate operating system", no shutdown will not take you there. Also "Solutions that just restart the computer to get to the login page are not allowed" \$\endgroup\$ – SztupY Mar 2 '17 at 15:55
  • \$\begingroup\$ Logout is shutdown with option l. The shutdown challenge was shutdown with option s \$\endgroup\$ – fəˈnɛtɪk Mar 2 '17 at 16:06
  • 2
    \$\begingroup\$ The only difference for linux systems is that the command used will change. All the programs will access the OS commands the same way, which means that all the answers will be portable by changing one piece. \$\endgroup\$ – fəˈnɛtɪk Mar 2 '17 at 16:12
  • 1
    \$\begingroup\$ If you made it prevent me from logging in to PPCG my overall productivity would skyrocket \$\endgroup\$ – Christopher Mar 2 '17 at 16:17
  • \$\begingroup\$ That's just a browser extension. Just close any PPCG tabs. \$\endgroup\$ – CalculatorFeline Mar 4 '17 at 16:11
  • \$\begingroup\$ @fəˈnɛtɪk: There may be a shorter solution on Linux by killing/crashing X (which with some graphical desktop environments, is how logging out is implemented in the first place). I don't think that's enough to make the question substantially different, though. \$\endgroup\$ – user62131 Mar 14 '17 at 5:07
  • \$\begingroup\$ bash + utilities, 14 bytes: pkill -u $USER \$\endgroup\$ – dkudriavtsev Apr 7 '17 at 2:33
-2
\$\begingroup\$

Google search result short summary

Intro

When you search in google, it always shows you a result with a sample text from the found webpage.

For example if you search for "Madonna greatest vinyl", google will show you one line link, and below a short excerpt from that found webpage:

Madonna Greatest Hits Records, LPs, Vinyl and CDs
Madonna - Greatest Hits Volume 2, Madonna, Greatest Hits ... vinyl Is Fully Restored To As Near New Condition As Possible. Shipping & Multiple Order D..

Task

Imagine yourself you work for google and you have to write a program/function which takes in:

  • a string containing many words (the webpage content)
  • list of searched words (at least 3)

and returns the shortest excerpt of given string (webpage) containing all searched words.

Example

Given this webpage content:

This document describes Session Initiation Protocol (SIP), an application-layer
 control (signaling) protocol for creating, modifying, and terminating
 sessions with one or more participants. These sessions include 
 Internet telephone calls, multimedia distribution, and multimedia conferences.

and these searched words:

calls, sessions, internet

the program should return:

sessions include Internet telephone calls
, as this is the shortest substring containing all 3 searched words. Note that one more substring contains these 3 words, it is "sessions with one or more participants. These sessions include Internet telephone calls", but it is longer, so it was discarded.

Rules

  • If the string is empty, return empty string
  • If all searched words are not found in given string, return empty string
  • Search is ignoring letters case
  • At least 3 words need to be specified for searching
  • The returned string may contain the searched words in different order than specified

Challenge

Write the fastest code. It's for google, right? Remember that repeatable strings comparison is very expensive.

\$\endgroup\$
  • \$\begingroup\$ There is not always a short summary. \$\endgroup\$ – fəˈnɛtɪk Mar 10 '17 at 18:19
  • 1
    \$\begingroup\$ Fastest code is going to be tough to measure on this, as even pretty large chunks of text will still result in very small amounts of time. \$\endgroup\$ – AdmBorkBork Mar 10 '17 at 18:50
  • 1
    \$\begingroup\$ You should include more test cases, especially large ones if you want to score by fastest code. \$\endgroup\$ – Laikoni Mar 12 '17 at 19:04
  • \$\begingroup\$ @fəˈnɛtɪk There is, if all searched words are found in the given string. (For some definitions of short...) \$\endgroup\$ – wizzwizz4 Oct 7 '17 at 11:22
-2
\$\begingroup\$

Make me look like a real programmer

There are some great programmers who can write code without taking any breaks or looking up documentation. I am not one of those people, but I've come up with a clever solution. Instead of spending time learning languages, I'll get you guys to write a program that makes it look like I'm programming! The challenge is to write a program that writes "programs" in the same language as your program to standard output.

Guidelines:

The "programs" your program outputs should follow these guidelines. While you won't be eliminated by breaking these guidelines, and it's okay to slip up a little bit, you should try to obey them. Intentionally breaking them will be heavily frowned upon.

Syntax

The "programs" you output should be syntactically valid. Although it doesn't have to be perfect, avoid misplaced or unmatched punctuation and incomplete programs.

Repeats

The "programs" you output shouldn't repeat themselves.

Cut and paste programs

Don't just output a bunch of slightly different programs to bypass the "no repeats" rule.

Examples:

Brain****:

+[>++[------>+<]>.>++++++++++.]

This prints out an infinite number of Brain**** programs, but all of those programs are "+", which violates the "Repeats" guideline.

Python 3

a = "print()"
    while True:
    print(a)
    a = "print("+a+")"

Violates the "Cut and paste programs" guideline. It just prints nested "print" layers.

Javascript

function rint() {
 return Math.floor(Math.random() * 10) + 1;
}
function makeString(l)
{
    var t = "";
    var p = "abcdefghijklmnopqrstuvwxyz0123456789(){};";

    for( var i=0; i < l; i++ )
        t += p.charAt(Math.floor(Math.random() * p.length));

    return t;
}
var v;
var s;
while (true) {
    console.log("\n"+makeString(rint()));
}

Although this does print distinct programs, none of them or syntactically correct, violating the "Syntax"

As you can see, my (halfhearted) attempts haven't been very successful, so good luck! This is a popularity contest, so the most popular answer wins. This is my first PCCG challenge, so if I messed something up, please tell me.

\$\endgroup\$
  • \$\begingroup\$ This likely was downvoted for the reasons I mentioned before, that it is essentially too broad. What do you think about making the scoring mechanism the length of the code divided by the number of valid programs the program will output? That way all the programs will be valid and it is clear what the goal is, but I think it still keeps the spirit of what you were going for? \$\endgroup\$ – FryAmTheEggman Mar 14 '17 at 0:21
  • \$\begingroup\$ So instead of trying to program an infinite number of programs it would print out a finite number? \$\endgroup\$ – Madison Silver Mar 14 '17 at 18:23
  • \$\begingroup\$ Yes, although this may cause a problem now that I've thought about it a bit more :( If someone managed an infinite amount, which wouldn't be too difficult essentially by just concatenating simple stuff, so it may not be so simple to fix. \$\endgroup\$ – FryAmTheEggman Mar 14 '17 at 23:27
  • \$\begingroup\$ I could try something like "shortest program that prints another valid program," but that seems kinda easy. If HQ9+ has a two-character solution ("QQ"), that can't be a good thing. Someone could also just do their language's equivalent of print("a=1") \$\endgroup\$ – Madison Silver Mar 14 '17 at 23:34
-2
\$\begingroup\$

It's 42!

This challenge is to code golf a program that proves that the next number in a pattern is 42 based on the website Actually it's 42.

In your program, the user inputs a pattern of numbers and it has to output the equation that proves that the next number is 42.

For example, the user inputs the pattern 1, 2, 3, 4, 5 the output is something like:

f(n)=9/2(n^2)−17(n)+29/2

Because f(6) = 42

Your program can output any form of an equation that makes the next value in the equation 42.

Your outputted equation must be able to also output the numbers in the original input also in the form of a variable. For example, in this equation, if you put 1 as the number input you get the number 1.

Your program cannot make any HTTP requests to APIs, in other words, all the calculations must be done in the program.

Good Luck!

\$\endgroup\$
  • \$\begingroup\$ You might want to make your question a bit clearer. Explain input format is first n terms of a sequence. Seems like an interesting idea though \$\endgroup\$ – fəˈnɛtɪk Mar 13 '17 at 1:38
  • 1
    \$\begingroup\$ It seems to me like this challenge is two disjointed parts. 1) is recognizing the pattern of numbers and determining the next, and 2) is turning an arbitrary n into 42. For 1, you should be clearer about which patterns must be recognized (arithmetic sequences? Geometric sequences? More?), and for 2 you probably need more restriction. For example, what's stopping me from outputting n - n + 42 regardless of input? \$\endgroup\$ – DJMcMayhem Mar 13 '17 at 1:59
  • \$\begingroup\$ @DJMcMayhem Good point that I have not thought about. \$\endgroup\$ – arodebaugh Mar 13 '17 at 10:33
  • \$\begingroup\$ Making edits to it \$\endgroup\$ – arodebaugh Mar 13 '17 at 10:34
  • \$\begingroup\$ @DJMcMayhem You can't always output n - n + 42 because it won't fit the previous numbers in the sequence. That is if OP wants the challenge to be to implement the functionality of the linked site. \$\endgroup\$ – Laikoni Mar 13 '17 at 13:07
  • \$\begingroup\$ However the algorithm used by the site is (according to the why page) is to solve a system of linear equations, and this has been done before: codegolf.stackexchange.com/questions/22573/… \$\endgroup\$ – Laikoni Mar 13 '17 at 13:10
  • \$\begingroup\$ @laikoni Oh, I thought the sequence was the list of inputs, not the list of outputs. I completely misunderstood the challenge. \$\endgroup\$ – DJMcMayhem Mar 13 '17 at 13:17
  • \$\begingroup\$ Looking at the sole example in the question, the challenge seems to be to output a random function independently of the input. Is this correct? If so, ditch the input. If not, it's a dupe \$\endgroup\$ – Peter Taylor Mar 13 '17 at 13:50
  • \$\begingroup\$ @PeterTaylor the input is required to be taken part in the equation. Hense the rule. You have to output the equation DJMcMayhem \$\endgroup\$ – arodebaugh Mar 13 '17 at 14:09
  • \$\begingroup\$ @Laikoni Well this makes an equation so it does not have to do with that. \$\endgroup\$ – arodebaugh Mar 13 '17 at 14:10
-2
\$\begingroup\$

The Mnemonic Major System

People frequently need to memorize long strings of digits, such as telephone numbers. Fortunately, the mnemonic major system, which uses sounds to represent digits, and words to represent strings of digits, can help.

  • /s/ and /z/ represent the digit 0
  • /t/, /d/, /θ/ and /ð/ all represent 1
  • /n/ represents 2
  • /m/ represents 3
  • /r/ represents 4
  • /l/ represents 5
  • /tʃ/, /dʒ/, /ʃ/ and /ʒ/ all represent 6
  • /k/ and /ɡ/ represent 7
  • /f/ and /v/ represent 8
  • and /p/ and /b/ represent the digit 9
  • For the purpose of this challenge, the sound /ŋ/, generally written as ng, counts as 27.

All other sounds can be used to create words, but do not represent any digits. Thus, the words Code Golf represent the digits 71 758. Since the mnemonic major system is a phonetic system, silent letters do not represent any digits. Thus, the word knight represents the number 21, not 7271. The letter x is pronounced /ks/, and thus represents the digits 70. On the other hand, most double consonants are not actually pronounced separately (e.g. mummy, chicken), and represent only one digit.

Challenge

Your task is to write a program or function that takes a string of digits in any convenient format as input and returns a mnemonic representation of those digits as output. The following rules must be observed:

  1. You must use real English words. Acronyms and abbreviations are not allowed. If in doubt, refer to an authoritative dictionary.

  2. Whenever possible, two or more digits must be represented by a single word. If the number of digits is odd, you may choose which digit, if any, stands alone (see examples). All two-digit numbers can be represented by English words.

You may use a built-in or external dictionary to search for suitable words.

This is code golf, so the shortest solution wins.

Example Input and Output

758
golf, kale fee, key leaf

0142710
strengths, suitor nugget saw, seat run key tease

2362185
unimaginatively, gnome gin devil, enmesh native lie
\$\endgroup\$
  • \$\begingroup\$ Getting the sounds from a word is not a task that computers can do properly due to the English language not actually following the rules it supposedly has. \$\endgroup\$ – fəˈnɛtɪk Mar 13 '17 at 16:51
  • \$\begingroup\$ The supplied link to M-W.com is pretty useless. To make a reasonable question you should provide a link to a single file which includes a word list with phonetic representation in easily parseable form. That would also allow verification that the requested task is possible, which at present I doubt: are all 1000 possible three-digit groups really representable? E.g. 333 seems like a tough one to represent. \$\endgroup\$ – Peter Taylor Mar 13 '17 at 16:58
  • 2
    \$\begingroup\$ On a separate issue, the calculation of pi has been done to death, so the interesting part of the question is the mapping from a sequence of digits to a sequence of words. On that basis I would recommend removing pi from the question and instead taking a sequence of digits as input, putting the focus squarely on the interesting part. \$\endgroup\$ – Peter Taylor Mar 13 '17 at 16:59
  • 1
    \$\begingroup\$ On the dictionary issue, just make the program take the dictionary as an input (and let people use whatever dictionaries they want to test their program, given that you could get the answer you want by substituting your own). It's not like hardcoding the dictionary is possibly going to save bytes here, given that even languages with dictionaries built in would have a different dictionary to the one you wanted. \$\endgroup\$ – user62131 Mar 14 '17 at 4:44
  • \$\begingroup\$ @PeterTaylor Thanks for your input. Whether all three-digit groups are representable is irrelevant for the question as is, since only three three-digit groups need to be represented. However, I think your proposed changes would improve the question. I will do some research on the problem of representing arbitrary three-digit numbers. \$\endgroup\$ – Michael Vehrs Mar 14 '17 at 6:19
  • \$\begingroup\$ @fəˈnɛtɪk Well, English spelling was pretty consistent when it was introduced around 1400. However, written language is generally more conservative than spoken language. While it is difficult to determine how a given word is pronounced, it is not so difficult to construct a word to match a given pronunciation. \$\endgroup\$ – Michael Vehrs Mar 14 '17 at 6:22
-2
\$\begingroup\$

Golf that for me, please.

I have my favourite language (or two) (or three), and I'm not into "golfing languages" (yet?), so it could happen that I do my best to find a clever solution for a particular problem in Ruby, or in C, then cut my variable names, wrap some string, abuse some features of the preprocessor, and finally post, very proud of my 74-bytes answer.

But then, it inevitably happens: somebody finds a combination of 4-5 obscure symbols and posts it, calling it a solution. Unfair!

So, I decided: I will post some "code" which covers the basic test cases, and get away with it. Who runs tests anyway?

Task:

Given input and expected output, write a program which writes a program which seems to solve the problem in a golfy way. It does not matter if the code actually does random things and just spits out the right result for the particular test case, but it must work consistently (in a repeatable fashion). The generator program and the generated programs can be in different languages.

Input:

Input to the generated program and expected output, in any appropriate format (string, array of strings, array of arrays, dictionary).

Output:

A sequence of chars representing a program in a particular language, which given the input as above specified, generates the expected output.

Scoring:

This is : the shortest (generator) program wins.

Test cases:

The program must be able to solve (at least) these 5 problems:

  • Given a number in input, if it is a Fibonacci number, output the next Fibonacci number. If not, output whatever. This must work for the first 10 numbers of the sequence (for example, 8 -> 13 or 55 -> 89). When given 1 in input, you decide if the output should be 1 or 2.
  • Given 2 Magic The Gathering card colors, determine if they are allied or enemies, as in this challenge . Example WU -> True, WB -> False.
  • Same as above, but using the german color names (W, R, and G are the same, but use "B" for blue and "S" for black). So in this case WB would be True.
  • Determine the outcome of a Rock Paper Scissor game round (input and output in any format, for example RP -> 2 means "Rock Paper -> second player wins"), you decide which symbol to use for a tie (0, X, nil, Cippirimerlo, -1...).
  • Given a Tic-Tac-Toe board (valid or not), output the number of crosses on the board. For example "XOX XX XO " -> 5

Of course, the generator program could use the same loophole and only work for the test cases. This would be unfair, but life is unfair, you know.

\$\endgroup\$
  • \$\begingroup\$ So basically just output a program that outputs the correct result for the single test case? (The second and third challenges are missing their test-cases, by the way) \$\endgroup\$ – ETHproductions Mar 17 '17 at 18:54
  • \$\begingroup\$ Yes, actually I am thinking about changing something. Dropping the bonus and just golfing the generator, to keep it simple. The test cases are the same as the linked challenge, but I will specify better. \$\endgroup\$ – G B Mar 17 '17 at 19:33
-2
\$\begingroup\$

Print the Previous Program

Specifications:

You must print the exact text of the previous answer without ever having a sequence of more than 5 letters in a row in your program that also show up in the previous answer (prevents hardcoding). Your program must only use UTF-8 characters.

You may repeat a language; however, you may not post twice in a row and no two of your consecutive answers may be from the same language class (different versions are treated as the same language).

The first language is to print the exact text "Hello, World!"

0-byte submissions are not allowed.

By the way, this is just a draft, it might be a dupe or really closely related, and probably has more holes in it than Swiss cheese so please give me any suggestions you have. Thanks.

Also, my drafted scoring system is something like bytes / answer_num where answer_num is which answer yours is (on a time scale).

\$\endgroup\$
  • \$\begingroup\$ "letters" isn't clear, because there are a bunch of Unicode characters that aren't letters. Requiring that no sequence of 5 Unicode characters can be repeated would be better. Additionally, it's traditional in answer chaining challenges for the first program to be provided in the challenge. \$\endgroup\$ – Mego Mar 19 '17 at 4:44
  • \$\begingroup\$ I don't like the 5 letters in a row thing, I think there should be more finegrained restrictions on hardcoding. Additionaly, someone could just do a couple of transformations on program text. \$\endgroup\$ – dkudriavtsev Mar 19 '17 at 4:47
  • \$\begingroup\$ I'm confused by this "prevents hardcoding" as hard-coding a string is exactly the problem statement. \$\endgroup\$ – feersum Mar 19 '17 at 5:13
  • \$\begingroup\$ @Mego Right, I meant characters. And also, if that's the case, I'll make a program to start off with then. Thanks! \$\endgroup\$ – user42649 Mar 19 '17 at 16:47
  • \$\begingroup\$ @Mendeleev That is true. Do you have any suggestions? I'll keep thinking of better ways to restrict that. \$\endgroup\$ – user42649 Mar 19 '17 at 16:48
  • \$\begingroup\$ @feersum Not quite, the problem statement is to print out the code of the previous answer without hardcoding it. \$\endgroup\$ – user42649 Mar 19 '17 at 16:49
  • \$\begingroup\$ That doesn't make sense. \$\endgroup\$ – feersum Mar 19 '17 at 18:52
  • \$\begingroup\$ @feersum How so? The general idea is to generate the previous answer without hardcoding it (because that would be trivial), so it's kinda like a kolmogorov challenge in some sense... \$\endgroup\$ – user42649 Mar 19 '17 at 18:54
  • \$\begingroup\$ What does "hardcoding" mean to you? Please give a definition. \$\endgroup\$ – feersum Mar 19 '17 at 18:57
  • \$\begingroup\$ @feersum In my definition, "hardcoding" means that you just put "print" and then the exact text you want printed. \$\endgroup\$ – user42649 Mar 19 '17 at 18:59
  • \$\begingroup\$ We usually use "hardcoding" to refer to an answer that exploits a limited input range to avoid performaing an expected algorithm, e.g. for a Fibonacci question where the input is at most 20, writing a list of 20 Fibonacci numbers in the code. Here the task is not associated with any calculation at all. \$\endgroup\$ – feersum Mar 19 '17 at 19:05
  • \$\begingroup\$ Let us continue this discussion in chat. \$\endgroup\$ – user42649 Mar 19 '17 at 19:06
-2
\$\begingroup\$

Display Haftseen table items - in Persian/Arabic characters

Theme : Jalali New Year 1397

Main Goal : Displaying non-ASCII characters correctly

Introduction

A typical Haftseen table consists 7 items which their names start with س (pronounced like S) and some additional items. It is set few days before the new year's day and it's kept till end of new year's holiday.

Challenge

Your program/function should display exactly 7 items from the list below :

سبزه
سرکه
سکه
سیب
سنبل
سمنو
سماق
سیر
سنجد

with right alignment, right to left typing, in an Arabic-compatible font, with each word displayed correctly, and a non-alphabetical character (,.- =+~?,newline etc) between each 2 words. The list must be displayed in a window, in terminal or similar.

\$\endgroup\$
  • \$\begingroup\$ I would be surprised if people didn't just output the string directly or with a built-in compression scheme. Say, in Bubblegum. \$\endgroup\$ – John Dvorak Mar 20 '17 at 9:19
  • \$\begingroup\$ @JanDvorak challenge is now changed to displaying it instead. i think it's hard enough now. \$\endgroup\$ – user55673 Mar 20 '17 at 9:27
  • \$\begingroup\$ Same difference - most environments display the program output rather than ... doing anything else to it. \$\endgroup\$ – John Dvorak Mar 20 '17 at 9:28
  • \$\begingroup\$ @JanDvorak but AFAIK most environment won't display it correctly. do they? \$\endgroup\$ – user55673 Mar 20 '17 at 9:30
  • \$\begingroup\$ TIO.run displays it just fine... \$\endgroup\$ – John Dvorak Mar 20 '17 at 9:32
  • \$\begingroup\$ @JanDvorak But it's not right alignment and it's aligned to left \$\endgroup\$ – user55673 Mar 20 '17 at 9:35
  • 1
    \$\begingroup\$ If that's necessary, my language of choice would most likely be HTML+CSS. I thought you wanted the challenge to be about string compression, though, not choosing the right environment. \$\endgroup\$ – John Dvorak Mar 20 '17 at 9:38
-2
\$\begingroup\$

Code - Decode

Cops:

Your task is to write a program or functon wich otuputs encrypted alphabetic input. The same program or function has to be used to encrypt and decrypt messages as the case of ROT13

You have to post in your answer:

  1. Languaje and length of your program
  2. The encrypted output of the input "CODE GOLF"
  3. Two more examples of crypted - unencrypted strings

Example:

Bash, 30 chars

  1. "CODE GOLF" <=> "PBQR TBYS"
  2. "SHA" <=> "FUN"
  3. "Why did the chicken cross the road? Gb trg gb gur bgure fvqr!" <=> "Jul qvq gur puvpxra pebff gur ebnq? To get to the other side!"

You may post your program code an decpription of your crypting algorithm once is considered safe. Shortest uncracked answer wins.

Example:

tr '[A-Za-z]' '[N-ZA-Mn-za-m]'

This bash command crypts and decrypts messages shifting each letter 13 positions in the alphabet.

Robbers:

Your task is to write a program or function wich otuputs encrypted alphabetic input. The same program or function has to be used to encrypt and decrypt messages as the case of ROT13

Your code has to pass test cases posted on one of the COPS post. The user who cracks most wins.

Extra bonus if your code cracks more than one answer.

\$\endgroup\$
  • \$\begingroup\$ First cops and robbers challenge, pleas help me writing it nice. \$\endgroup\$ – marcosm Apr 4 '17 at 14:58
  • \$\begingroup\$ Just to be clear, is the goal of the robbers to crack the encryption algorithm that the cops create? \$\endgroup\$ – AdmBorkBork Apr 4 '17 at 15:02
  • \$\begingroup\$ Folowing the example if one cop posts an answer wich uses ROT13 and a robber implements ROT13 the answer is cracked. \$\endgroup\$ – marcosm Apr 4 '17 at 15:05
  • \$\begingroup\$ You might want to read this, which specifically mentions certain types of encryption/decryption \$\endgroup\$ – fəˈnɛtɪk Apr 4 '17 at 15:18
  • \$\begingroup\$ Certanly I'm not an cryptography expert, wouldn't the constrait of being the same function that crypts-decrypts avoid such cases of random crypt? How can I change robber thread to avoud brute force? \$\endgroup\$ – marcosm Apr 4 '17 at 15:25
  • \$\begingroup\$ The problem with this is that real encryption is really hard to crack. All they need to do is add a random salt, and the robbers have to blindly guess what the salt is. \$\endgroup\$ – Nathan Merrill Apr 4 '17 at 17:27
  • \$\begingroup\$ I'm not sure what the proposed constraint is. An encryption function takes two arguments (plaintext and key) and produces one output (ciphertext). Are you saying that for any plaintext and key, encrypt(encrypt(plaintext, key), key) == plaintext? If so, I think that's essentially a restriction to stream ciphers, and you might as well ditch the whole plaintext processing and ask for a function which takes the key and the length of the plaintext and generates a deterministic output of that length. \$\endgroup\$ – Peter Taylor Apr 5 '17 at 11:22
  • 1
    \$\begingroup\$ And it has the same cryptographic flaw that many cops-and-robbers do. It's not even really necessary to use good crypto: something like for(i='secret';n--;putch(i[0]))i=md5(i); would require heavy-duty cracking even if you hinted that that's the structure. \$\endgroup\$ – Peter Taylor Apr 5 '17 at 11:25
  • \$\begingroup\$ ok, i've learned something, thanks for your comments. \$\endgroup\$ – marcosm Apr 5 '17 at 13:24
-2
\$\begingroup\$

Shortest “Hello World” for common journaled file systems.

Create a valid file system image as small as possible containing a file or a folder labeled “Hello World” with the following constraint:

  • If the hello world is a regular file, it needs to not be empty.
  • The file system needs to one of the following: ntfs3.1 ext3/ext4 zfs btrfs hfsplus

Please note you won’t be able to create the smallest file system with normal fomatting tool.
I mean they don’t allows to create the smallest theoriticall size.

Winner

The answer with the smallest file system

\$\endgroup\$
  • 1
    \$\begingroup\$ Hmm, why not xfs/zfs? Also, I don't really think this is a programming problem \$\endgroup\$ – ASCII-only Apr 4 '17 at 23:04
  • \$\begingroup\$ @ASCII-only the challenge seems to easy with xfs. Otherwise I didn’t got an answer to this question chat.stackexchange.com/transcript/message/36478963#36478963 . Though if it can be made on topic for a code challenge, please explain how. Although it is not a code problem, the special case of journaled filesystem require create a program behind the hood due to the huge number of data structure, so I think it’s still a programming problem, even it’s for being able to only write a unique file. \$\endgroup\$ – user2284570 Apr 4 '17 at 23:10
  • \$\begingroup\$ You can make it a code problem by changing it to verifying that a byte sequence is a valid ext3 image. \$\endgroup\$ – Peter Taylor Apr 5 '17 at 10:15
  • \$\begingroup\$ @PeterTaylor hemmm, by turning it in a code challenge, I still want something that can lead to create very small journaled filesystems. But does programming cahllenges needs also to be code challenges in order to be on topic? \$\endgroup\$ – user2284570 Apr 5 '17 at 12:32
  • \$\begingroup\$ How are you drawing a distinction between programming challenges and code challenges? To me they're the same thing. \$\endgroup\$ – Peter Taylor Apr 5 '17 at 15:54
  • \$\begingroup\$ @PeterTaylor I mean by handling or creating algorithms you don’t necessarily write code. But anyway this challenge need to be converted into a code challenge while still generating small filesystems. Any ideas? \$\endgroup\$ – user2284570 Apr 5 '17 at 20:39
-2
\$\begingroup\$

Real Programmers Don't Comment Their Code

(Disclaimer: I do think programmers should comment their code.)
Your task is to write code in one language that removes comments from code in another language. Both single-line and multi-line comments should be removed from your program. You may write code in one language to remove comments from the same language. Input and output may be in any format. Finally, before answering, read the rules, please.


Rules

  1. Your program in language X must take a program in language Y as input and output the code with all comments removed. Language X may be the same as Language Y.
  2. You may not use language Y if:
    • Language Y has no comments whatsoever.
    • Language Y does not have 2 or more types of comment.
  3. Language Y should preferably have unusual comment behavior. (Ex.: older programming languages or Haskell)
  4. You may not ignore line continuations (usually \ at the end of the line).
  5. Your code may not remove anything inside a string literal.
  6. Standard loopholes are disallowed.
  7. I strongly encourage you, ironically, to provide an explanation if it is unclear how your code works.

This is , so may the best programmer with the shortest code win...

\$\endgroup\$
  • \$\begingroup\$ All answers from here apply to this challenge. I'd say this would be a duplicate. \$\endgroup\$ – user42649 Apr 9 '17 at 21:23
  • \$\begingroup\$ If this isn't a duplicate, it's mostly about selecting a language Y which makes the question as easy as possible. (There are comment markers that are terser to parse than //…\n and /*…*/, so good answers won't be exactly the same, but they'll still be pretty similar.) \$\endgroup\$ – user62131 Apr 9 '17 at 22:05
  • \$\begingroup\$ @ais523 How can I add variation and distinguish my challenge? \$\endgroup\$ – ckjbgames Apr 9 '17 at 23:14
  • \$\begingroup\$ Try requiring a specific Y whose comment behaviour is unusual. A good start would be to pick a language where comments nest, for example, although that might not be enough by itself. \$\endgroup\$ – user62131 Apr 9 '17 at 23:17
  • \$\begingroup\$ But Pascal as given in the example only have 1 comment type (start with (* or {, and end with *) or }, not in string, and not (*)) \$\endgroup\$ – tsh Apr 10 '17 at 1:54
  • \$\begingroup\$ I should make the requirements less strict. \$\endgroup\$ – ckjbgames Apr 10 '17 at 12:58
  • \$\begingroup\$ Done! Requirements less strict. \$\endgroup\$ – ckjbgames Apr 10 '17 at 12:59
  • \$\begingroup\$ "3. Language Y should preferably have unusual comment behavior" very subjective thing, isn't it? \$\endgroup\$ – officialaimm Apr 10 '17 at 13:36
  • \$\begingroup\$ @officialaimm How to make it less subjective? \$\endgroup\$ – ckjbgames Apr 10 '17 at 14:44
  • \$\begingroup\$ This sandbox post has had little activity in a while and little positive reception from the community. Please improve / edit it or delete it to help us clean up the sandbox. \$\endgroup\$ – programmer5000 Jun 9 '17 at 14:12
-2
\$\begingroup\$

You've been Thunderstruck!

Background

A "fun" drinking game is based on the classical hard rock song by AC/CD: Thunderstruck. The Thunderstruck drinking game starts when the song starts. When the word "thunder" is heard, the first person starts drinking, not stopping until the word "thunder" is said again. At that point, the next person begins to drink. This continues around the circle until the song ends.

The "twist" is that in the middle of the song, there is an entire verse where thunder is not uttered once. The person who gets this part -- and thus has to drink for the longest period of time -- is said to have been thunderstruck.

Challenge

Input: An Integer number of players.

Output: Which player got thunderstruck

Example

Input:  1
Output: 1

Input:  2
Output: 1

Input:  3
Output: 3

Rules

Here are the rules:

  • Assume that the number of players always is a positive integer.
  • Output should always give a positive integer.
  • You are not allowed to hardcode the number of times before the "solo" / long verse. Meaning your code has to find the longest part without the word thunderstruck, on its own.
  • Use the following lyrics for thunderstruck
  • Shortest code wins.
\$\endgroup\$
  • 3
    \$\begingroup\$ Forbidding hardcoding is not considered an observable requirement. \$\endgroup\$ – Wheat Wizard Apr 16 '17 at 17:47
  • \$\begingroup\$ You should also state exactly which verse is the one without the thunder (it seems like it is the one after the 16th thunder) \$\endgroup\$ – Wheat Wizard Apr 16 '17 at 17:48
  • \$\begingroup\$ And I think your 3rd test case is wrong here is a solution I made in python you can compare it to. \$\endgroup\$ – Wheat Wizard Apr 16 '17 at 17:54
  • 3
    \$\begingroup\$ I think this challenge could be made more fun if you also take a song as input and have to find the longest part without a thunder. This would solve your hardcoding problem and make the challenge a little more fun. \$\endgroup\$ – Wheat Wizard Apr 16 '17 at 17:56
  • 2
    \$\begingroup\$ Just seconding this; this challenge badly needs to take the song as input. If it doesn't, then the problem is that (even banning hardcoding) it becomes mostly about kolmogorov-complexity of the song (with the actual finding of the long gap becoming almost irrelevant by comparison), which is both a chameleon challenge and a duplicate; and because it's about kolmogorov complexity, thus compression, it'd be quite easy to choose a compressed representation in which the challenge was easier than you think. (Note that even taking input, the challenge is very easy anyway.) \$\endgroup\$ – user62131 Apr 17 '17 at 9:34
-2
\$\begingroup\$

Description

Find the number of '1's in a binary number of any length. (Variable name up to you)

Output

You should output or print an integer/number/string which reflects the number of '1's that were counted.

Example

10101100 should return 4

Sandbox

I'm new here, so I don't know if this has been asked before. I searched but I could only find one other similar question, however that required the answer to be in binary, and was somewhat different in terms of the inputs.

My question seems very short and lacking details, but I don't know how to expand further on such a simple challenge.

Any other ways I could improve on my first post in this Stack Exchange?

\$\endgroup\$
  • \$\begingroup\$ codegolf.stackexchange.com/q/47870/194 \$\endgroup\$ – Peter Taylor Apr 27 '17 at 10:19
  • \$\begingroup\$ @PeterTaylor but that involves decimal input. This question is for binary input. \$\endgroup\$ – Joel Damien Apr 27 '17 at 11:09
  • \$\begingroup\$ I'm not sure what you mean. Are you saying that the input will be a string, and the answer has to count the number of times the character '1' appears in it? \$\endgroup\$ – Peter Taylor Apr 27 '17 at 11:20
  • \$\begingroup\$ Easy solution: add up all the numbers in the input. Many answers will have one-character answers. \$\endgroup\$ – Comrade SparklePony Apr 27 '17 at 13:48
  • \$\begingroup\$ O - 05AB1E and 2SABLE polygot 1 byte. \$\endgroup\$ – Magic Octopus Urn Apr 28 '17 at 15:38
  • \$\begingroup\$ @MagicOctopusUrn c'mon 05AB1E and 2sable are practically the same thing I wouldn't call that polyglot :I \$\endgroup\$ – HyperNeutrino Sep 10 '17 at 1:45
-2
\$\begingroup\$

Add numbers without math functions.

In this challenge, you must take an input that can take at least 10 numbers separated by commas and add them together without addition, subtraction, multiplication, and division symbols. Least bytes win. Normal code golf rules apply.

Examples:

Input:

1,2,3,4,5,6,7,8,9,10

Output:

55

Input:

1,1

Output:

2
\$\endgroup\$
  • \$\begingroup\$ You have to define what a math function is. Are we allowed bitwise operations? \$\endgroup\$ – Beta Decay May 14 '17 at 22:54
  • \$\begingroup\$ @BetaDecay Fixed it. \$\endgroup\$ – arodebaugh May 15 '17 at 0:50
  • \$\begingroup\$ I'm assuming summation counts as addition because that's just common sense. Does string or list repetition count as multiplication? \$\endgroup\$ – user42649 May 15 '17 at 3:43
  • 2
    \$\begingroup\$ "Do X without math" has no chance of not being closed, just so you know. \$\endgroup\$ – feersum May 15 '17 at 4:04
  • \$\begingroup\$ Probable dup \$\endgroup\$ – Digital Trauma May 16 '17 at 23:20
-2
\$\begingroup\$

Bike saddle drawn through a fractal

Based on the Mandelbrot image in every language, and on the observation the 3rd layer (0 indexed) always looks like a bike saddle, I had a little bit different challenge:

  • Language must be capable of graphical output or drawing charts (saving files disallowed)
  • Render a window or control that is resizable by mouse action. As example, it can be a typical GUI Window with the typical frame that allows resizing
  • After resizing the GUI element, the fractal should be updated according to the new pixel space
  • The fractal coordinates range from approximately -2-2i to 2+2i
  • The pixels outside of the 3rd layer (0 indexed) of Mandelbrot set should have one color; the ones inside 3rd and inner layers should have another. The only two colors used should be clearly distinguishable
  • At least 99 iterations
  • ASCII art not allowed

Winning conditions:
Shortest version (size in bytes) for each language will get a mention in this post, ordered by size.
No answer will ever be 'accepted' with the button.

\$\endgroup\$
  • \$\begingroup\$ @Mark Jeronimus: credits to you. \$\endgroup\$ – sergiol May 27 '17 at 8:48
-2
\$\begingroup\$

Google Logo in Conway's Game of Life

Conway's Game of Life base challenges are always fun so here is a new one.

This is Google's Logo (if you have not somehow seen it): Google Logo

The font is called Product Sans. Your job is to replicate this logo (no color of course) in 800x439px just like the image (just the letters).

Have fun! This is a popularity contest so the most votes wins. :D Good luck. Of course, this may not be possible but, you never know until you try.

Usual rules apply.

Inspired by this.

\$\endgroup\$
  • 6
    \$\begingroup\$ "looks like" isn't a tight enough specification for a challenge. \$\endgroup\$ – Mego May 29 '17 at 21:20
  • 1
    \$\begingroup\$ Also consider some method besides first-past-the-post, that winning criteria doesn't really work well with this site. \$\endgroup\$ – FryAmTheEggman May 30 '17 at 0:22
  • 1
    \$\begingroup\$ So the answer could replicate it at the 0th generation? \$\endgroup\$ – Peter Taylor May 30 '17 at 10:48
  • \$\begingroup\$ @PeterTaylor Good point \$\endgroup\$ – arodebaugh May 30 '17 at 13:14
  • \$\begingroup\$ @FryAmTheEggman Popularity contest? \$\endgroup\$ – arodebaugh May 30 '17 at 13:14
  • \$\begingroup\$ @Mego Also good point \$\endgroup\$ – arodebaugh May 30 '17 at 13:15
  • \$\begingroup\$ OK I updated stuff maybe it will make this challenge better \$\endgroup\$ – arodebaugh May 30 '17 at 13:16
  • 3
    \$\begingroup\$ 1. I don't see how the change you've made addresses my previous point. 2. Pop-con is barely any better than fastest-gun-in-the-west. 3. It's possible to test whether this is possible or not (I highly doubt it) by running the CA backwards. \$\endgroup\$ – Peter Taylor May 30 '17 at 16:09
-2
\$\begingroup\$

The 2017 Loader contest

Here's a thing: Let's do the bignum bakeoff again.

Because why not.

What to do

Write a program in less than 256 characters that outputs the biggest number you can.
Yep, that's it. Biggest return value wins.

We'll run the program on a VM with infinite memory. (How do we do this?)

Rules

  • 256 chars max, excluding whitespace
  • Different leagues for each language
  • Output however you want
    • No explicitly printing numbers until your loop runs out. Print the number you generate directly. {1}
  • Program must terminate
  • No implementation-dependent shenanigans.
  • Implementation-independent shenanigans is encouraged.
  • ints are infinite.
  • Program must return the same number every time
  • Submission must include the approximate return value in any suitable googological notation.
  • Whitespace is space, tab, newline, formfeed, and return
    • BrainF***: Whitespace is all non-[]+-<> characters

{1} Allowed ways to return: printf("%d", num); return num;, etc.
Banned ways to return: for(;num>0;num--)printf("99999");, etc.


This is not a dupe of...

This because you can put any characters you want, not just non-digits; because we're hard-limiting the characters.


Suggested rules

  • No floats: float double long double, etc
  • No strings or chars
  • No bitfeilds
  • No looking at Command-line args

Next year's contest will be named after this year's winner, for no particular reason.

http://djm.cc/bignum-rules-posted.txt


Sandbox

  • How do you even test these programs?
  • What other rules should we have?
\$\endgroup\$
  • \$\begingroup\$ You don't actually explain the rules of the challenge, we would have to go to that link to find out what we are supposed to do. Aside from that, I think this has a lot of problems with your typing restrictions if these are not limited to C, but limiting it to C wouldn't really fit the spirit of the site. I think you may want to rethink how you want to approach this question. \$\endgroup\$ – FryAmTheEggman May 29 '17 at 16:43
  • \$\begingroup\$ @FryAmTheEggman "Typing restrictions"? (Added proper instructions) \$\endgroup\$ – SIGSTACKFAULT May 29 '17 at 16:45
  • \$\begingroup\$ Your post doesn't describe how people win. Is it by the largest possible number? Anyway, the problems are things like not counting whitespace, which can easily result in degenerate answers, as well as things like I/O streams and whatnot. All of your extra rules seem entirely based around C with no regard for other languages, which will not go well. \$\endgroup\$ – FryAmTheEggman May 29 '17 at 16:48
  • 4
    \$\begingroup\$ In answer to "Because why not": because it will be closed as a dupe. \$\endgroup\$ – Peter Taylor May 29 '17 at 17:59
  • \$\begingroup\$ Here's a couple of rules I would consider. 1. Program must generate the same result every time (e.g. not based on timer, probability, or the like). 2. Submissions should include, if not the exact resulting number, at least a best estimate, in scientific notation if need be. \$\endgroup\$ – Computronium May 30 '17 at 18:32
  • \$\begingroup\$ Scientific notation? People will post answers that far, far exceed that. In fact, Mathematica, 22: Fold[Power,2~Range~9999] It's 2^3^4^...^9999. That's not being represented anytime soon. \$\endgroup\$ – CalculatorFeline May 31 '17 at 3:31
  • 1
    \$\begingroup\$ This is a duplicate, and is also going to come down a lot to whether or not you allow programs that exceed the computational capacity of any existing computer. (If you require programs to work on a physical computer, the best they can possibly do is to use the entirety of memory as a counter and print out 9s over and over again. If you don't, the answers can easily be large enough that you need to use notation invented specifically for describing the number, because all other notations are not enough.) \$\endgroup\$ – user62131 May 31 '17 at 22:40
  • \$\begingroup\$ If your code can simulate a Turing machine, it becomes hard to judge who the winner is, and whether an answer is valid at all. \$\endgroup\$ – anatolyg Jun 1 '17 at 20:35
  • \$\begingroup\$ Re your latest edit: you're wrong. The question it's a dupe of also has a hard limit to the number of characters; in fact it's a harder one, but the best answers could be copied with slight tweaking to take advantage of the extra space. And the digit restriction turned out not to be a serious problem: the winning answer would gain extremely little from being able to use digits. \$\endgroup\$ – Peter Taylor Jun 2 '17 at 9:07
-2
\$\begingroup\$

Buzzfeed's Ultimate Coder Challenge

Buzzfeed recently published a coding test which the guys over in TNB have determined is the world's hardest coding test [citation-needed].

In the language of your choice, given no input, output 8 separate snippets of code in your language. The snippets should do the following, in order:

1 - Print "Hello, world!"
2 - Print 200
3 - Read input from STDIN then print "Hello "[input]
4 - Print 10
5 - Print 25
6 - Terminate silently (do nothing)
7 - Print "a is 1", "a is 2"... all the way to "a is 10"
8 - Print "a is 5", "a is 6", "a is 7", "a is 8"

For challenges 7 and 8, the outputted source should output each output newline separated

Scoring

This is so fewest bytes in each language wins!

Meta

  • What needs clarifying?
  • What other tags could this use?
  • Would this perform better as a ?
  • Is it even worth posting this challenge at all?
\$\endgroup\$
  • \$\begingroup\$ citation \$\endgroup\$ – Adám Jun 7 '17 at 12:10
  • 3
    \$\begingroup\$ Generally, bunching a lot of unrelated tasks is frowned upon. \$\endgroup\$ – Adám Jun 7 '17 at 12:11
  • \$\begingroup\$ Also, several of these tasks will have almost identical answers (2, 4, and 5 being the worst offenders I think). I don't feel this fits very well for any tag on this site. \$\endgroup\$ – FryAmTheEggman Jun 7 '17 at 18:26
  • \$\begingroup\$ 2, 4, and 5 are actually radically different in golfing languages (a builtin for 200 would be very unusual, and it's just large enough to make for an interesting competition between compressed representations, whereas most have a builtin for 10 and some have a builtin for 25). However, that doesn't change the facts that a) they're nonetheless far too easy, and b) asking people to solve a number of unrelated tasks is inferior to splitting them all up into separate questions (which in this case, is inferior to posting them at all). \$\endgroup\$ – user62131 Jun 8 '17 at 0:11

You must log in to answer this question.

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