535
\$\begingroup\$

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

Sandbox FAQ

Posting

To post to the sandbox, scroll to the bottom of this page 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, though you can optionally add a title at the top. 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, and replace the post here with a link to the challenge and delete the sandbox post.

Discussion

The purpose of the sandbox is to give and receive feedback on posts. If you want to, feel free to give feedback to any posts you see here. Important things to comment about can include:

  • Parts of the challenge you found unclear
  • Comments addressing specific points mentioned in the proposal
  • Problems that could make the challenge uninteresting or unfit for the site

You don't need any qualifications to review sandbox posts. The target audience of most of these challenges is code golfers like you, so anything you find unclear will probably be unclear to others.

If you think one of your posts needs more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended!

It is recommended to leave your posts in the sandbox for at least several days, and until it receives upvotes and any feedback has been addressed.

Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]. To search for posts with a certain tag, include the name in quotes: "king-of-the-hill".

Get the Sandbox Viewer to view the sandbox more easily!

\$\endgroup\$
0

3502 Answers 3502

-3
\$\begingroup\$

Output Infinity (updated v2)

Challenge

Output the following infinity symbol:

         ∞∞infinity                         ∞infinity                   
     infinity∞∞infinity                 infinity∞∞infinity              
   infinity∞∞∞∞∞∞∞infinity           infinity∞∞∞∞∞∞∞infinity            
  infinity        ∞∞infinity      ∞∞∞∞∞infinity        ∞∞∞∞∞∞∞          
 ∞∞∞∞∞                 ∞∞∞∞∞∞∞  ∞∞∞infinity               ∞∞∞∞∞         
 ∞∞∞                      ∞∞∞∞∞∞∞infinity                   ∞∞∞         
∞∞∞                         ∞∞infinity                       ∞∞∞        
∞∞∞                       ∞∞infinity                         ∞∞∞        
 ∞∞∞                    ∞∞∞∞∞∞infinity                      ∞∞∞         
 ∞∞∞∞∞               ∞∞∞infinity  ∞∞∞∞∞∞∞                 ∞∞∞∞∞         
  infinity       ∞∞∞∞∞infinity     ∞∞∞infinity        infinity          
    infinity∞∞∞∞∞∞∞infinity           infinity∞∞∞∞∞∞∞infinity           
      infinity∞∞infinity                infinity∞∞∞infinity             
           ∞infinity                        ∞∞∞infinity                 

Rules

  • No input.
  • Output can be given in any convenient format.
  • Any number of trailing spaces at the end of each line is allowed.
  • Any number of trailing new lines at the end of the shape is permitted.
  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
  • If possible, please include a link to an on-line testing environment so other people can try out your code!
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.
\$\endgroup\$
12
  • \$\begingroup\$ need some comments for down-vote... \$\endgroup\$
    – mdahmoune
    Apr 20 '18 at 19:01
  • 1
    \$\begingroup\$ If the challenge's goal is -- as I understand it -- to output one of the five objects, in most languages that would result in an optimal submission of something along the lines of print("∞"). A rather boring but valid submission to a challenge that effectively asks to print a single unicode character. \$\endgroup\$ Apr 20 '18 at 19:34
  • 1
    \$\begingroup\$ The downvotes are probably because you're allowing multiple outputs, some of which are interesting (4-5), some of which are trivial (1-3). As @JonathanFrech suggests, for a code-golf challenge, everyone is going to chose a trivial output for shortness. Alternate ideas: Input an integer 1-5, output the corresponding form of infinity. Or perhaps narrow to just output option #4 (or an even larger, fancier ASCII infinity), and make it a kolmogorov-complexity question. \$\endgroup\$
    – BradC
    Apr 20 '18 at 20:59
  • 1
    \$\begingroup\$ I would even say that this challenge in its current form should be tagged kolmogorov-complexity. If you decide to go in the direction @BradC suggested, you could maybe also consider to incorporate the challenge's theme into your challenge rather than posting yet another Kolmogorov complexity challenge. Something along the lines of infinitely outputting the ASCII art or taking two numbers as input, dividing them and producing the infinity symbol when the second one is zero. \$\endgroup\$ Apr 20 '18 at 22:01
  • \$\begingroup\$ I don't think this is anyhow related to math. Only "inspired by math", maybe. \$\endgroup\$
    – DELETE_ME
    Apr 21 '18 at 10:54
  • \$\begingroup\$ Now -- is there any exploitable pattern in the output such that it should not be closed as a dupe of "We're no stranger to code golf, you know the rules, and so do I"? \$\endgroup\$
    – DELETE_ME
    Apr 21 '18 at 10:55
  • \$\begingroup\$ @user202729 No, there is no predefined specific pattern, I prepared this MANUALLY. How could I specify that in the challenge? \$\endgroup\$
    – mdahmoune
    Apr 21 '18 at 11:00
  • \$\begingroup\$ I believe it's customary to specify if trailing spaces / new lines are permitted and if so, how many \$\endgroup\$ Apr 21 '18 at 19:30
  • \$\begingroup\$ @AsoneTuhid for spaces I think it is ok because it does not deform the shape, but I do not think so for new lines, what do you think? \$\endgroup\$
    – mdahmoune
    Apr 21 '18 at 19:54
  • \$\begingroup\$ Not between the lines, of course. I mean new lines after the whole drawing. Some people put restrictions (none, one, whatever). Nice art btw \$\endgroup\$ Apr 21 '18 at 19:57
  • \$\begingroup\$ @AsoneTuhid yes of-course, thanks a lot for this remarks. \$\endgroup\$
    – mdahmoune
    Apr 21 '18 at 20:06
  • \$\begingroup\$ Can you write a reference implementation which beats bzip2 and gzip, preferably by a few percent? \$\endgroup\$ Apr 25 '18 at 12:05
-3
\$\begingroup\$

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

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

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

Input: nothing

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

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

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

Send the pairs

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

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

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

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

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

Which would output:

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

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

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

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

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

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

I'm glad the sandbox exists because I have a few issues coming up with the right wording for this.

Background

Theoretically, any numeric pattern should exist somewhere in the decimal places of pi.

Challenge

Given any numeric input, find the index (location?) of the first occurrence of that input in the decimal place of pi

Example cases:

  • 1 = 1
  • 14 = 1
  • 41 = 2
  • 897 = 11

Rules:

any numeric input, can't see why it should be limited by any number of characters. I am not sure about limitations, but this could get computationally intense if it's a large sequence of numbers that occur very deep into pi. Do I need to add any restrictions to cater for computational complexity?

\$\endgroup\$
2
  • 5
    \$\begingroup\$ We'be had this challenge before. That one only requires the first few digits, but I think we've had enough challenges about pi that this won't add anything \$\endgroup\$
    – H.PWiz
    Sep 25 '18 at 7:36
  • 2
    \$\begingroup\$ "Theoretically, any numeric pattern should exist somewhere in the decimal places of pi." - how do you know that? \$\endgroup\$
    – ngn
    Sep 25 '18 at 10:00
-3
\$\begingroup\$

Tags:

Code-Bowling

Name: Two is an error, One runs fine!

The challenge is simple.

When one character is removed from the given program, it should not error, but when two are removed, it should error.

PENALTIES:

If you repeat one Unicode character in the program, then your score will be the number of bytes subtracted by the Unicode value of the character (0 for NUL, 10 for newline, 64 for A, etcetera).

Else, your score is the number of bytes.

As always, since this is code bowling, most bytes win!

\$\endgroup\$
8
  • 2
    \$\begingroup\$ What if I repeat two characters in the program? \$\endgroup\$
    – DELETE_ME
    Dec 1 '18 at 3:29
  • 4
    \$\begingroup\$ What if I just have a really large amount of NUL bytes? \$\endgroup\$
    – Jo King Mod
    Dec 1 '18 at 3:33
  • \$\begingroup\$ Is it ok if the program itself error/not error? \$\endgroup\$
    – DELETE_ME
    Dec 1 '18 at 3:35
  • \$\begingroup\$ What about infinite loop? \$\endgroup\$
    – DELETE_ME
    Dec 1 '18 at 3:35
  • 1
    \$\begingroup\$ This question needs major work: in its current state I would definitely vote to close it, and the only question would be whether to close as Too Broad or to close as Unclear. It's too broad because there's no specification for what the program must do. It's unclear because it's not specific enough on the quantifiers around the character removal: if it should be robust against the removal of any character, be explicit. See radiation-hardening for existing questions in this area, both for examples of how to word them and to ensure that it's different enough to be new and interesting. \$\endgroup\$ Dec 1 '18 at 10:42
  • \$\begingroup\$ @PeterTaylor Although the program can do anything, it should not be too broad if the challenge is sufficiently hard. \$\endgroup\$
    – DELETE_ME
    Dec 4 '18 at 10:30
  • \$\begingroup\$ About the removal of any character: I guess that the score is \$len-\sum_{c}{c\times \max(0,n(c)-1)}\$ for \$len\$ = program length in bytes and \$n(c)\$ = number of occurences of character c in program, but I'm not sure. \$\endgroup\$
    – DELETE_ME
    Dec 4 '18 at 10:32
  • \$\begingroup\$ LENGUAGE win!!! \$\endgroup\$
    – l4m2
    Dec 4 '18 at 11:32
-3
\$\begingroup\$

Output a number \$n\$ such that:

  1. \$n\text{mod}10=5\$
  2. \$n^2\text{mod}10^{10000}=n\$

Shortest code win. You should be able to try it rather than purely know it work.

Sandbox mainly to check duplication

\$\endgroup\$
8
  • 1
    \$\begingroup\$ Wouldn't this be easy to just hardcode the number? \$\endgroup\$
    – Jo King Mod
    Dec 13 '18 at 13:22
  • \$\begingroup\$ @JoKing We must have \$n^2\ge 10^{10000}\$, so \$n\ge 10^{5000}\$ which if naively hardcoded takes \$5000 \log_2{10}\$ bits. \$\endgroup\$
    – DELETE_ME
    Dec 13 '18 at 14:24
  • \$\begingroup\$ However, we already have modular multiplicative inverse challenge, I expect most answers to be very similar. \$\endgroup\$
    – DELETE_ME
    Dec 13 '18 at 14:42
  • \$\begingroup\$ @user202729 It's likely that you'll get 1 in that way or be too slow so I need time requirement \$\endgroup\$
    – l4m2
    Dec 13 '18 at 15:00
  • \$\begingroup\$ @l4m2 Most solutions there use extended Euclid algorithm so they will not be too slow... \$\endgroup\$
    – DELETE_ME
    Dec 13 '18 at 15:06
  • \$\begingroup\$ @user202729 So they'll get 1 \$\endgroup\$
    – l4m2
    Dec 13 '18 at 15:22
  • \$\begingroup\$ Get 1 what? The correct answer is 810...90625. \$\endgroup\$
    – DELETE_ME
    Dec 13 '18 at 15:31
  • \$\begingroup\$ Will how many languages use this? \$\endgroup\$
    – l4m2
    Dec 13 '18 at 15:57
-3
\$\begingroup\$

Integer or decimal to array and array to decimal or integer

Task

Write two functions

1) Convert an integer or decimal to array of integers that potentially includes a single decimal

2) Convert array including integers and potentially a single decimal to integer or decimal

Input

Integer or decimal to array

  • An integer or decimal

Array to integer or decimal

  • An array

Output

Integer or decimal to array

  • An array containing each digit of the input at an individual index with the first decimal portion of input containing the decimal character.

Array to integer or decimal

  • An integer or decimal equal to input

Specification

When the first digit of a decimal is a 0 , and a digit follows, that value includes all 0's up to and including the last digit of that decimal, else the decimal portion is spread or expanded to the remainder of the decimal portion for the remainder of indexes of the array, that is: -0.01 <-> [-0.01], 100.01 <-> [1,0,0,0.01], 100.0001 <-> [1,0,0,0.0001]

Test cases

Input <----------> Output

-123               [-1,-2,-3]
4.4                [4,0.4]
44.44              [4,4,0.4,4]
-0.01              [-0.01]
123                [1,2,3]
200                [2,0,0]
2.718281828459     [2,0.7,1,8,2,8,1,8,2,8,4,5,8,9]
321.7000000001     [3,2,1,0.7,0,0,0,0,0,0,0,0,1]
809.56             [8,0,9,0.5,6]
1.61803398874989   [1,0.6,1,8,0,3,3,9,8,8,7,4,9,8,9]
1.999              [1,0.9,9,9]
100.01             [1,0,0,0.01]
545454.45          [5,4,5,4,5,4,0.4,5]
-7                 [-7]
-83.782            [-8,-3,-0.7,-8,-2]
1.5                [1,0.5]
100.0001           [1,0,0,0.0001]

Winning criteria

Least amount of total (each of function or programs 1 and 2) bytes used.

code-golf

\$\endgroup\$
39
  • \$\begingroup\$ 1) What should output be for test cases 0, 200, and 1.0015? 2) I would suggest a more descriptive title. 3) Bonuses are generally discouraged in code golf, so make sure they add something to this challenge. \$\endgroup\$
    – lirtosiast
    Dec 18 '18 at 23:43
  • 1
    \$\begingroup\$ The string method thing is very iffy. Won't a print function in any language be converting a number/list of numbers to a string? \$\endgroup\$
    – Jo King Mod
    Dec 19 '18 at 0:16
  • \$\begingroup\$ @lirtosiast [0], [200], [1,0.001,5]. What title do you suggest? Not using string methods does add something to the challenge. \$\endgroup\$ Dec 19 '18 at 0:47
  • \$\begingroup\$ @JoKing Not sure what you mean by a print function converting a number or list to a string? If JavaScript is used it means not using ``, '', String, template literal, RegExp.prototype.match(), etc. to create or convert the input to output or add, subtract, divide, multiply, manipulate arrays are what is meant, not print(output) or console.log(output). A user is not obligated to try for the bonus in their answer. \$\endgroup\$ Dec 19 '18 at 0:49
  • 1
    \$\begingroup\$ @guest271314 The challenge is not clear to me: why is 200 [200] but 100.01 [1,0,0,.01]? Maybe a worked-through example in the question as well as a reference implementation would help. For a title "Modified decimal expansion of a number" is a start. \$\endgroup\$
    – lirtosiast
    Dec 19 '18 at 0:57
  • \$\begingroup\$ @guest271314 Some languages have builtins for the digits of an integer or float e.g. Mathematica RealDigits[3.14159] = [{3,1,4,1,5,9},1] . Do those count as string methods? \$\endgroup\$
    – lirtosiast
    Dec 19 '18 at 0:59
  • \$\begingroup\$ @lirtosiast 200 does not contain a decimal, 100.01 contains a decimal. The reference implementation is at the question. Created the requirement from scratch while attempting to solve another inquiry. Does Mathematica have a method to check if a value is a string, integer or decimal? \$\endgroup\$ Dec 19 '18 at 1:03
  • \$\begingroup\$ I don't see any reference implementation. It might be better if you explicitly listed the rules behind the transformation \$\endgroup\$
    – Jo King Mod
    Dec 19 '18 at 1:05
  • \$\begingroup\$ @JoKing See "Test cases". That goes back to whether to post the question here or at Software Engineering. The question does not ask users to write an entire specification (frequently edited; maintained; an entire process in and of itself). Observing the test cases: when the first digit of a decimal is a 0 , and a digit follows, that value includes all 0's up to and including the last digit of that decimal, else the decimal portion is spread or expanded to the remainder of the decimal portion for the remainder of indexes of the array, that is: [-0.01], [1,0,0,0.01], [1,0,0,0.0001]. \$\endgroup\$ Dec 19 '18 at 1:09
  • 1
    \$\begingroup\$ Right, you should include those rules in the question, along with what happens when the input is an integer and/or ends in zero. I'm not sure what you'd achieve by posting on Software Engineering because I doubt any form of this question would be on-topic. \$\endgroup\$
    – Jo King Mod
    Dec 19 '18 at 1:22
  • 1
    \$\begingroup\$ Also, the specification should be given as a specification, not as a set of test cases to reverse-engineer. \$\endgroup\$ Dec 19 '18 at 9:42
  • 1
    \$\begingroup\$ "The specification ... is WIP." That's fine: that's what the sandbox is for. I'm trying to identify things which need addressing before the question leaves the sandbox. "A users' answer could redefine the specification, in a good way" This is completely against the ethos of this site. All users should implement the same specification, because otherwise it's not a fair contest. \$\endgroup\$ Dec 19 '18 at 14:56
  • 1
    \$\begingroup\$ I'm guessing he means move the specification from below the test cases to the task section and remove the Observing the test cases part. And perhaps make it a bit clearer, for example giving us the inputs that led to [-0.01], [1,0,0,0.01], [1,0,0,0.0001] rather than having them in isolation. \$\endgroup\$
    – Jo King Mod
    Dec 20 '18 at 5:36
  • 2
    \$\begingroup\$ Specifically? Nothing is clear to me. Try reading through the spec yourself without the test cases and forgetting that you already know in your head how everything should work - is it clear to you? As for a solution to making it clearer: start by having a look through the specs of recent, well-received challenges and note the detail they go into about what is expected of solutions and what is & isn't allowed. Then rewrite your own spec in a similar manner so there's no (or very little) room for doubt or confusion. (1/2) \$\endgroup\$
    – Shaggy
    Dec 20 '18 at 19:11
  • 1
    \$\begingroup\$ Ah, I didn't realise you'd deleted the bounty post. I think you misunderstood what I meant when I commented. I was just clarifying that if an answer were to be posted, the 500 rep would come from me, though you could add some rep if you wanted. There was no censorship of your post and I'm not sure why you deleted it. Typically on PPCG, we post the bounties after a valid answer has been posted, in order to make sure the rep doesn't go to waste, especially if the task is very hard or possibly impossible \$\endgroup\$
    – Jo King Mod
    Feb 19 '19 at 10:37
-3
\$\begingroup\$

Introduction

The original creator of this meme has gone blind, lost his internet and accidentally deleted all his memes. Except this one. He has this one last meme on his desktop, and since he can't see, he wants to know what this meme is.

By hearing it.

Challenge

Your challenge is to write the shortest program that will produce a playable audio file that the meme creator will play to hear the text in this meme.

  • The input is the meme below
  • The output will be a audio file that reads the output text in English and has a slight pause after a colon or a new line. But don't read out 'colon'

Answer the following questions for your readers.

  • You can use any programming language
  • You can use any existing library
  • Output audio must be playable by vlc
  • Networking is not allowed, you cannot connect to any internet services
  • Shortest answer wins

Input and Output

Input:

surprised pikachu eyesight

Output:

Me: spends 8 hours per day on the internet

Eyesight: gets worse

me:

\$\endgroup\$
2
  • 7
    \$\begingroup\$ The output would always be hardcoded, so there's no point in the input \$\endgroup\$
    – Jo King Mod
    Mar 8 '19 at 9:43
  • 1
    \$\begingroup\$ This challenge would be nice with different memes as test cases. Otherwise it would be hardcoded as said previously. \$\endgroup\$
    – Belhenix
    Mar 20 '19 at 19:35
-3
\$\begingroup\$

Compress briefly

Compress and decompress the first chapter of Worm, beginning with the opening words "Class ended" and ending with the closing words "my best friend." (including the period). You do not need to include any of the formatting (copy and paste as plain text).

Rules

  • You may not use any built-in or imported compression functions or procedures. You must implement the compression yourself.

  • You may either write one program to compress and another to decompress, or one program that does both. If you wish, the second option can be a polyglot, where compiling as one language compresses and compiling as the other decompresses.

  • Your program must be no more than 2000 bytes long. You may, at your option, compress your program with bzip2 or gzip before measuring its size for the purpose of meeting this limit.

  • Your program does not need to work for any other text.

  • Standard loopholes apply.

  • Standard I/O rules apply.

Scoring

  • The score is the sum of the total number of bytes of your program(s) and the total number of bytes in the compressed text.

  • If you use a single program to compress and decompress, then you may have to pay a penalty. Specifically, you must pay a number of bytes equal to the Levenshtein distance between the shell command needed to (compile and) run your compression program and the one needed to run your decompression program. You can calculate this online. A special exception: if you choose to write a polyglot, then you can leave out the paths to the compilers/interpreters when you calculate the penalty.

Tags: code-challenge, compression

\$\endgroup\$
9
  • \$\begingroup\$ Related \$\endgroup\$
    – Beefster
    Mar 19 '19 at 22:31
  • \$\begingroup\$ @Beefster, a bit, but I think there are enough differences to make competitive answers largely incompatible. \$\endgroup\$
    – dfeuer
    Mar 19 '19 at 22:36
  • 2
    \$\begingroup\$ I don't think any answers are going to outperform gzip/bzip/whatever. There's no obvious patterns to exploit in the text. \$\endgroup\$
    – Beefster
    Mar 19 '19 at 22:37
  • 2
    \$\begingroup\$ Also: how is this different from kolmogorov-complexity? \$\endgroup\$
    – Beefster
    Mar 19 '19 at 22:38
  • \$\begingroup\$ @Beefster, it's different because I don't allow the code to be big enough to have much chance of encoding the text in it. It doesn't have to outperform industrial-strength algorithms. That mention had to do with the source code size limit, intended to give extremely verbose languages the opportunity to participate. \$\endgroup\$
    – dfeuer
    Mar 20 '19 at 0:28
  • \$\begingroup\$ Every answer will be some variant of import gzip; gzip.compress(story) \$\endgroup\$
    – Beefster
    Mar 20 '19 at 16:21
  • \$\begingroup\$ @Beefster, is my explicit prohibition of that insufficient? My first rule is that you can't use a built-in or imported compression function. \$\endgroup\$
    – dfeuer
    Mar 20 '19 at 16:42
  • \$\begingroup\$ That sounds a lot more interesting than it actually is. There's a reason "do X without Y" questions have fallen out of favor. Compression challenges are hard to write. At the very least, you need some exploitable pattern common to a class of strings. This simply isn't the case in the linked text. \$\endgroup\$
    – Beefster
    Mar 20 '19 at 19:29
  • \$\begingroup\$ Even without using built-ins the best answer will use some variant of Huffman coding that fits in 2000 bytes. LZ77 is also pretty easy to implement and works well on text. \$\endgroup\$
    – Beefster
    Mar 20 '19 at 19:44
-3
\$\begingroup\$

Output an alphabet suite

A successor to the ŋarâþ crîþ alphabet challenge.

Outputting the alphabet song with as few letters as possible was too easy, but what about outputting many of them?

Your challenge is to write as many programs as you can, with no two programs sharing any Unicode codepoints, and each program outputting the names of the letters of the alphabet (or the glyphs of some other kind of phonetic script) used by a different language. For instance, one program can output

a bee cee dee e eff gee aitch i jay kay el em en o pee cue ar ess tee u vee double-u ex wye zed

and another program can output

a be ce de e efe ge hache i jota ka ele eme ene eñe o pe cu erre ese te u uve uve doble equis ye zeta

Notes:

  • For a given language, there will probably be some leeway in what you can output.
  • Unlike in the previous challenge, you don't need to worry about any particular punctuation. You should at least separate each letter name with whitespace.
  • You must output the names of the letters, not the letters themselves (so A B C... is invalid), unless the letters are literally pronounced so in the language in question.
  • If a language uses both capital and lowercase letters, then you may output the letter names in either case. If it uses only one of them, then you must output the alphabet in that case.
  • You must use a different language's alphabet for each program, but you are allowed to use the same script in the context of different languages.
  • Constructed languages are allowed, as long as they predate the challenge.
  • You may use different programming languages for each program. Or the same.
  • Standard loopholes are forbidden.

TODO:

  • is the requirement against sharing any codepoints too strict?
\$\endgroup\$
1
  • 2
    \$\begingroup\$ I haven't downvoted you, but suspect that the major reason that you're getting downvoted is that it's totally unclear what outputs are valid or not, and skimming the edges of that is where most of the byte savings are going to come from in a code-golf. That said, I don't think this is code golf, despite having the tag. You'll probably find that, when any golfing aspect is removed, the strings to print are more or less irrelevant, so you might as well use a fixed, objective set of strings instead of the ones you have. \$\endgroup\$ May 13 '19 at 16:24
-3
\$\begingroup\$

add two numbers in string representation

Idea:

Given two strings representing non-negative integers in base 10, return the string corresponding to their sum - without any explicit arithmetic operations. This means you have to implement incrementing (probably with a lookup and indexing) and carrying (probably with iteration or recursion) on your own. Comparisons and boolean operations are allowed.

Examples:

"1" + "1" = "2"
"5" + "6" = "11"
"0" + "8" = "8"

I/O:

Write a function or program which takes the two strings in a way you want to.
Output, print or return the solution in whatever way you want.

Ah, and also don't forget that this is code-golf, so shortest answer in bytes will win. Also, all standard loophole rules and so on apply (you should know from all the other challenges!)


Sandbox

This challenge changed, evolved and got compressed during discussion with Adám starting from here (feel free to review the edits and chat of this post on how we got here)

Tags for cgcc post:

\$\endgroup\$
5
  • 9
    \$\begingroup\$ This is still "Do X without Y", and Y is not always clear-cut. What counts as an "explicit arithmetic operation" in lambda calculus? \$\endgroup\$ Jul 25 '19 at 15:22
  • \$\begingroup\$ @PeterTaylor my english is not the best in the world and also i am not a pro in thins like loopholes or coding terminus around maths. you have any idea how to propose this or what kind of operations to prohibit? I would just come up with explicite "+" "-" "*" and "/" operations directly on the string representations (also to exklude languages which can handle interpreting strings as numbers). But are there furter operations I forget? \$\endgroup\$
    – pixma140
    Jul 26 '19 at 5:43
  • 7
    \$\begingroup\$ I don't think it can be fixed. \$\endgroup\$ Jul 26 '19 at 5:53
  • \$\begingroup\$ I agree this can't be defined objectively. The only way I can see this working is if the output was required to include the steps of calculation so that it's no longer an non-observable requirement. That would probably involve specifying a particular approach to implement though. I can't guess whether such a restriction would make the challenge interesting, but I suspect it would not. \$\endgroup\$
    – trichoplax
    Jul 28 '19 at 18:58
  • \$\begingroup\$ Guess then I will better not post this question outside of the sandbox.. But thanks to you all so far! :) \$\endgroup\$
    – pixma140
    Jul 29 '19 at 5:41
-3
\$\begingroup\$

The goal is to make a program that is compilable in as many languages as possible.

  • The program must be compilable with a specific compiler version and compiler parameters without any errors.
  • The program may result in an error when run.
  • The source code must not be empty or whitespace.
\$\endgroup\$
5
  • 1
    \$\begingroup\$ This is somewhat similar in spirit but not the same. This probably is a duplicate of something, strictly or less so, but that's the first thing that came to mind \$\endgroup\$ Aug 27 '19 at 7:48
  • 2
    \$\begingroup\$ A null program is compilable in most(if not all) languages. (Including specific compilers of C(in IOCCC).) \$\endgroup\$
    – user85052
    Aug 27 '19 at 10:15
  • \$\begingroup\$ @A_ I've added an additional rule. \$\endgroup\$
    – user11909
    Aug 27 '19 at 10:58
  • 3
    \$\begingroup\$ As-is, this will be closed as Too Broad, since there's no "thing" for the program to do. Have a look at the polyglot tag and see what others have done. \$\endgroup\$ Aug 27 '19 at 14:25
  • \$\begingroup\$ Define "compile". \$\endgroup\$ Aug 28 '19 at 23:23
-3
\$\begingroup\$

Writing a WebCrawler

Challenge

Design a web crawler that recursively extracts all the hyperlinks from the HTML of the web page and does the same for every hyperlinked page it finds. The webcrawler must store the hyperlinks in a separate file

How The WebCrawler Works

First the webcrawler should download the HTML file of the URL the user inputted.

Second the webcrawler will copy every single hyperlink embedded in the hyperlink and paste it into an output text file. The best general way to do this based on my experience is to have the webcrawler iteratively search through the HTML file for an "a href" tag. Be careful about what kind of hyperlinks are embedded in those tags. Sometimes only the subdomain directories of a complete hyperlink are embedded in this

For example: https://en.wikipedia.org/wiki/Toyota may simply have an a href tag in the HTML file of a webpage as: "/wiki/Toyota"

After extracting all the hyperlinks of the first webpage, visit all the hyperlinks found on the base webpage starting from the the first hyperlink found and repeat all the steps above. The only exception to doing this is obviously if the hyperlink fails to lead to an HTML page.

Input

The program must accept only one URL as input.

Output

A text file that lists every hyperlink that it finds. Note:

Your webcrawler must avoid revisiting webpages it has already crawled. This can cause the crawler get trapped in a "circular link loop" where it continously visits the same pages endlessly.

Note:

Special consideration will be given to submissions that prove they are capable of crawling deep web websites, including those with the .onion sites.

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

Create a "Transpiler"

for the purpose of this challenge, a transpiler is any program that takes valid source code from one language as input and produces a program valid in another language that performs the same actions. Calling the original languages interpreter is not banned.

Posts should start with "SRCLANG to DSTLANG in LANG; X bytes" as a heading.

Here's an example post:

Shell to Ruby in Ruby; 41 bytes

puts'`bash #{Data}`
__END__
'+STDIN.read

Here we use the somewhat obscure Data constant to embed arbitrary data in the program. this has the advantage of never having to escape anything.

Each "triple" of source, destination, and working language represents its own category, as this challenge varies greatly in difficulty depending on the languages used.

\$\endgroup\$
5
  • \$\begingroup\$ What is the winning criterion? Are there requirements for the languages used? \$\endgroup\$ Nov 6 '20 at 23:09
  • \$\begingroup\$ @RedwolfPrograms lowest byte count, as usual. I guess no strict subsets as well, so you can't say cat is a sh to bash transpiler \$\endgroup\$
    – binarycat
    Nov 6 '20 at 23:24
  • \$\begingroup\$ How would this be consistently graded? I don't get how this is fair to all answers. \$\endgroup\$
    – Razetime
    Nov 7 '20 at 3:35
  • \$\begingroup\$ Is g++ a C++ to x86 assembly transpiler? "this challenge varies greatly in difficulty depending on the languages used" I'd say it varies in difficulty way too much. \$\endgroup\$ Nov 7 '20 at 7:08
  • \$\begingroup\$ @thedefault. Yes, but it's far from trivial. As for variation, like I said, each "triple" of languages forms it's own category. If it's necessary to have 1 winner, I guess it could be popularity-contest. \$\endgroup\$
    – binarycat
    Nov 8 '20 at 21:35
-3
\$\begingroup\$

I have the following code. Help me make it code shorter.

new Promise(r=>r(URL.createObjectURL(new Blob(['<h1>Example</h1>'],{type:'text/html'})))).then(u=>open(u)&&setTimeout(t=>URL.revokeObjectURL(u),2e3))

The Catch:

  • This has to be in JavaScript
  • It cannot contain semicolons
  • It must be a "one-liner"
  • It must have the same steps as the code above:
    1. Create a blob URL from a blob
    2. Open a browser window of the blob URL
    3. Revoke the blob URL

Extras

  • The winner will be decided by the shortest amount of bytes
  • If you try this in another language, you will still get an upvote
\$\endgroup\$
-3
\$\begingroup\$

Most digits of Pi in a hundred bytes

\$\endgroup\$
3
  • 4
    \$\begingroup\$ It's likely possible to output infinitely many. \$\endgroup\$ Jan 19 at 3:09
  • \$\begingroup\$ @thedefault. how? \$\endgroup\$
    – someone
    Jan 20 at 0:46
  • 2
    \$\begingroup\$ By using one of the many known formulas for pi. And if you do not use a formula for pi, you're compressing random digits (it's possible to store around 240 digits like this). codegolf.stackexchange.com/q/47808 has multiple answers below 100 bytes. \$\endgroup\$ Jan 20 at 1:52
-3
\$\begingroup\$

Reinvent math

The task is simple. Define the basic operators (+, -, *, /) without using them directly.

Also banned:

  • any add-assign (+=) and its equivalents
  • basically anything intended to be used as a basic arithmetic operation

Program should consist of at least 4 binary functions, one for each operation. they may call other functions defined in your program, including each other. The types of the arguments to the function may be any types that the basic arithmetic operators work on, except for types that are less than 3 bits in size.

Shortest code wins

\$\endgroup\$
17
  • \$\begingroup\$ Thank you for using the sandbox. Have you considered stating the required argument domain? And how should one answer? Using for functions/programs with the total length being the score? Can the four share code? \$\endgroup\$
    – Adám
    Feb 8 at 19:35
  • \$\begingroup\$ Also, what does "using them directly" mean? Does that mean we can't use those four symbols or their equivalents in whatever language we use? And do we implement them for integers or floating-point numbers? \$\endgroup\$
    – user
    Feb 8 at 19:43
  • 1
    \$\begingroup\$ If our language allows e.g. using _plus_ instead of +, is that allowed? \$\endgroup\$
    – Adám
    Feb 8 at 19:45
  • \$\begingroup\$ @user I feel like it it's fairly clear what "using them directly" means. I can't really think of an alternative interpretation. Any numeric type which the basic operators work on will do. For most c-derived languages, this will be floats and ints. \$\endgroup\$
    – binarycat
    Feb 8 at 19:54
  • \$\begingroup\$ @binarycat It's not clear to me - I can't tell if you're talking about those four specific symbols or the equivalent operators in the answer's language (if there is an equivalent operator). Also, could you add to the draft that any numeric type will do? \$\endgroup\$
    – user
    Feb 8 at 19:57
  • 1
    \$\begingroup\$ Are we allowed to use the basic operators in each others' definitions, e.g. plus(x,y)=x--y? \$\endgroup\$
    – Adám
    Feb 8 at 20:15
  • \$\begingroup\$ @Adám Ideally, the operator will behave the same as the builtin, but if that's not possible due to restrictions in the language, that's ok. Also, no _plus_ wouln't be allowed. That is still using the basic operator of addition. \$\endgroup\$
    – binarycat
    Feb 8 at 20:19
  • \$\begingroup\$ @binarycat OK, that's useful information (i.e. it should be included in the challenge specification). \$\endgroup\$
    – Adám
    Feb 8 at 20:29
  • \$\begingroup\$ Are we allowed to use the corresponding operations in a different language than the one we're answering in, i.e. to call out? \$\endgroup\$
    – Adám
    Feb 8 at 20:31
  • \$\begingroup\$ Pro-tip: I note that you have never posted any challenges. restricted-source challenges are notoriously difficult to get right. I'm not saying this is a bad challenge, not at all, but I highly recommend posting a few well-received standard code-golf challenges before attempting a restricted-source one. \$\endgroup\$
    – Adám
    Feb 8 at 20:33
  • \$\begingroup\$ @Adám the post has been updated to reflect the fact that the answer is no \$\endgroup\$
    – binarycat
    Feb 8 at 20:34
  • \$\begingroup\$ @Adám It's really not restricted source, just the "no using a builtin that does exactly what the challange says" loophole. \$\endgroup\$
    – binarycat
    Feb 8 at 20:36
  • 5
    \$\begingroup\$ This is a textbook example of a "do X without Y" challenge and simply isn't considered interesting on this site. \$\endgroup\$
    – Beefster
    Feb 8 at 20:48
  • 2
    \$\begingroup\$ @binarycat You seem very convinced that this isn't do-X-without-Y. I'd be very interested in hearing why you think so, especially considering that your text literally says "Define [=do] the basic operators (+, -, *, /) [=X] without using them directly [=Y]." \$\endgroup\$
    – Adám
    Feb 8 at 21:47
  • 1
    \$\begingroup\$ Essentially a duplicate of Add without addition, as the same techniques can be used to define all four operators. \$\endgroup\$
    – Bubbler
    Feb 8 at 22:54
-3
\$\begingroup\$

Google search

Challenge is very simple, you have to get a string as input and then launch the default web browser, and search for that string in Google.

Input string will have only characters a-zA-Z

Google search URL is google.com/search?q=querystring

Standard loopholes apply, Internet connection allowed, but only to google.com domain

Tags: ,


Author note: challenge title sucks, please improve it!

\$\endgroup\$
7
  • 1
    \$\begingroup\$ I suspect on many (older) systems the notion of a default browser does not exist. In addition, I think there are many other escape characters. Of course, you could allow the answers to fail - but without the encoding requirements this is probably a dupe of some old basic internet challenge. \$\endgroup\$ Feb 20 at 18:08
  • 1
    \$\begingroup\$ Also, %20 is not the right escape sequence for a + \$\endgroup\$
    – pxeger
    Feb 20 at 19:00
  • \$\begingroup\$ @FryAmTheEggman The first one is not really an issue, if the programming language doesn't have the thing then it can't have an answer. \$\endgroup\$
    – DELETE_ME
    Feb 24 at 3:55
  • \$\begingroup\$ For the challenge: it's best to specify which characters might appear in the input. \$\endgroup\$
    – DELETE_ME
    Feb 24 at 3:56
  • \$\begingroup\$ @FryAmTheEggman,user202729 edited, now input will only have a-zA-Z \$\endgroup\$
    – wasif
    Feb 24 at 17:30
  • \$\begingroup\$ Most languages can't launch a browser. Also, there are dozens like this already, \$\endgroup\$
    – emanresu A
    Feb 25 at 4:04
  • \$\begingroup\$ Sorry, I missed your edit earlier. I think if you want to go ahead with this you need to define what the "default browser" is, and what to do if it isn't present. Depending on how you define it, this may not be a dupe, but I imagine you will have some trouble with different systems defining it differently. \$\endgroup\$ Mar 3 at 19:03
-3
\$\begingroup\$

Reverse error quine

,

Based on this

Write a quine that prints it own source code in reverse, but to STDERR.

Penalties

  • +200 using other files I.E. reverse.txt
  • +150 internet usage
  • +100 reading own source code

Rules

  • Minimum length of source is 2 bytes

  • Standard loopholes apply

, shortest code wins

\$\endgroup\$
6
  • 3
    \$\begingroup\$ As a reverse error quine, it will probably just be basically the same as a plain error quine, but with the creative solutions using syntax errors not valid. The things with penalties should probablly just be disallowed or someone will just do sh, 6 bytes + 20 penalty, tac $0. You can also add [tag:quine] \$\endgroup\$
    – Wezl
    Feb 24 at 17:45
  • 4
    \$\begingroup\$ But thanks for using the sandbox! \$\endgroup\$
    – Wezl
    Feb 24 at 17:46
  • \$\begingroup\$ Why the rule No palindromes? Aside from Stack Cats, there are pretty much no languages that print a palindromic error. \$\endgroup\$
    – emanresu A
    Feb 25 at 4:07
  • \$\begingroup\$ Changed the rules: 1) Increased penalty (None will not now dare to read own source code) 2) Palindromes allowed 3) Added the tag quine \$\endgroup\$
    – user101036
    Feb 25 at 7:45
  • \$\begingroup\$ Penalty in code golf is discouraged by itself, just like bonuses. Accessing the internet/other files/the source file itself to get the desired output is already considered a standard loophole, so you should just say they're not allowed, and remove the penalties altogether. \$\endgroup\$
    – Bubbler
    Feb 25 at 8:06
  • \$\begingroup\$ Also, another thing to avoid: using old challenges as a model. \$\endgroup\$
    – Bubbler
    Feb 25 at 8:11
-3
\$\begingroup\$

“Simple” Programming Homework


Your friend has been caught sleeping in class again! As punishment, his computer science teacher has assigned him homework, knowing that he will not be able to solve it due to not having paid any attention.

The assignment seems deceiving simple at first; all that is required is to output the string:

John Doe

Unfortunately, the teacher is intent on making the simple assignment much more difficult. Since your friend was not listening when the teacher explained the concept of strings and numbers, the teacher forbids him from using any number character (0-9) or the quotes (", ', `).

Can you help your friend solve this problem with the shortest code possible, and save his computer science grade in the process?

Try to find the shortest code in each language!

Note: it is encouraged to try to solve this problem in languages where string/character literals exist but cannot be used due to the restrictions (most mainstream languages are like this, e.g. C++).

\$\endgroup\$
5
  • \$\begingroup\$ Better leaving it here for a while (and ask in chat often) to see if people mostly agree that what "literal" means is obvious. (see, bash have echo John Doe and BF has +++something+++., and most languages doesn't have a formal specification to define English names for the components of the language) \$\endgroup\$
    – DELETE_ME
    Feb 27 at 12:18
  • \$\begingroup\$ Other than that (huge) point it is clear enough. [please review other sandbox posts] \$\endgroup\$
    – DELETE_ME
    Feb 27 at 12:19
  • \$\begingroup\$ @user202729 Ask which chat? \$\endgroup\$
    – user101295
    Feb 27 at 22:14
  • \$\begingroup\$ @user202729 I thought this would be interesting for most languages that do use quotes for string and character literals like C, but I do see how it might be too easy in some languages. \$\endgroup\$
    – user101295
    Feb 27 at 22:54
  • 1
    \$\begingroup\$ chat.stackexchange.com/rooms/240/the-nineteenth-byte \$\endgroup\$
    – DELETE_ME
    Feb 28 at 6:13
-4
\$\begingroup\$

Output the number of lines of your code

Your task is to write a program that counts the number of its lines of code and outputs them.

Specs:

  • The number mustn't be hardcoded into the program, nor in any other external resource;

  • Internet access is forbidden;

  • Your program's output must be the number of lines only;

  • Your program should not use any tool, macro, function, or similar device designed with the specific purpose of counting lines.

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

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


Cops - Golfed recursion

You must select a language that satisfies the following criteria:

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

Task

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

Robbers - Golfed recursion

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

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

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

Your task is to create a program that outputs a random pizza recipe following this one rule:

No random number choosers, you may have random text choosers. All standard code-golf rules apply. A sample output:

A simple PEPPARONI pizza sprinkled with fish and sausages. Your program must have the following items:

  • Anchovies
  • Fish
  • An adjective for the pizza

The program written with the shortest code wins.

Winner

The winner shall be picked on April 3rd, 12AM on the time zone GMT+3.

\$\endgroup\$
3
  • \$\begingroup\$ I already had an answer to the question, albeit non-competing: Python3 print("Have a plain MARGHERITA without any",["fish.","anchovies."][len(input("What's your favourite pizza? "))%2]) \$\endgroup\$
    – mIllIbyte
    Mar 31 '16 at 12:41
  • 5
    \$\begingroup\$ Uh, this has a lot of problems with clarity. First, all "random text choosers" are implemented with "random number choosers" which makes this restriction feel a bit bizarre. Second, what counts as an adjective for pizza? And since this is code golf, people will always pick the shortest available. And third, what should an output look like? It's not clear from the spec. Also, sort of unrelated, but usually putting a time limit is unnecessary, even extremely popular challenges stop getting responses with any frequency after a month or so. \$\endgroup\$ Mar 31 '16 at 12:59
  • \$\begingroup\$ Did you misspell it on purpose? \$\endgroup\$ Mar 31 '16 at 13:55
-4
\$\begingroup\$

What about one question on numeric solve?

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

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

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

Beep. Boop. Maggot?

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

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

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

Hints

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

Score Your Language

I believe that each language has a score. The way you find the score of a language is shown in the ungolfed Python program below

def scorer(lang):

    num = 0

    for i in str(lang):
        num += ord(i)

    return num

Basically the score is the total of the unicode values of the language name.

Now this seemed like a fairly trivial challange, so I thought I'd make it a bit more difficult. You aren't allowed to use your language name (case-sensitive) in the code. So this code in C++ would be invalid as I've used C++ in the code.

#include <iostream>

int main() {

    int total = 0;
    std::string s("C++");

    for (char & c : s) {
        total = total + (int)c;
        c = '*';
    }

    std::cout << total;

}

Although this does output the required number (153) it is still invalid.

Rules

  • You aren't allowed to use the language name but are allowed to use it in a different case. E.g. Java isn't allowed but java is.
  • This is a code-golf so shortest answer in bytes wins
  • You are allowed to use hex/octal codes in strings e.g \150 can be used instead of h
  • Your program must take no input or function arguments
  • You cannot simply output the score. Theoretically the program should work for any language name when changed.
  • Languages where the only valid syntax is the name, such as Chicken are allowed to use said name.
  • Version shouldn't be included so Python is always Python not Python 2 or 3
  • The score is the value of the case-sensitive name

Correct Scores

Language              Score

ArnoldC                675
brainfuck              949
C                       67
C++                    153
Java                   386
Lua                    290
Mornington Crescent   1922
Python                 642
TrumpScript           1165
Vim                    300

Sandbox Questions

1) Why has this been downvoted?

2) I am thinking about putting a reputation limitation so that bosses like Dennis and Martin Büttner can't take answers from people who aren't as accomplished. Is this unfair? Should I not?

3) Is this a duplicate? I couldn't believe it wasn't already taken.

\$\endgroup\$
4
  • 4
    \$\begingroup\$ Terms like "you cannot use your language name" and "it must be calculated by the program" are not only unclear but will likely not be able to be made rigorous. \$\endgroup\$
    – Wheat Witch Mod
    Feb 5 '17 at 14:58
  • \$\begingroup\$ Are you suggesting that I remove those rules? \$\endgroup\$
    – user63571
    Feb 5 '17 at 15:00
  • \$\begingroup\$ I don't think that the challenge is very interesting without the rules, but I don't think it is clear with them. I would suggest reworking the rules in some manner but exactly how I do not know. \$\endgroup\$
    – Wheat Witch Mod
    Feb 5 '17 at 15:01
  • \$\begingroup\$ 1. I would guess that it's mainly because it fails some of the tests in Things to avoid when writing challenges (X without Y, asking for different things in different languages, unnecessary fluff, explicitly disadvantaging certain languages, arguably one or two more), although it might also in part be because some people oppose trivial "challenges", and in part because the problems WW mentioned can't be fixed. 2. Very bad idea. 3. It's a multi-dupe: it combines two trivial tasks, each of which independently would clearly be a duplicate. \$\endgroup\$ Feb 6 '17 at 9:15
-4
\$\begingroup\$

Popularly print the input

Goal

Write a program or function in a language of your choice that takes input and outputs that exact input.

Specifications

  • Your program/function should output the exact input in any reasonable way.
  • Your program does not have to end after printing the input. It may end up in an infinite loop if you wish, as long as that loop doesn't output any extraneous characters.

Winner

The winning answer will be the one that has the highest score. Voters should look for answers that use an unique way to print the input, have a special source code or use neat language features.

\$\endgroup\$
6
  • \$\begingroup\$ Plain "do X in a creative way" popularity contests have fallen out of favour and will likely immediately get closed as being too broad or not having an objective winning criterion. \$\endgroup\$ Apr 4 '17 at 18:33
  • \$\begingroup\$ @MartinEnder: Yeah, I noticed. How do you think I should change the challenge so that it won't be closed? \$\endgroup\$
    – Luke
    Apr 4 '17 at 18:35
  • 1
    \$\begingroup\$ Can't really help you there. If I knew of a good way to make popularity contests work, I'd write some myself. ;) \$\endgroup\$ Apr 4 '17 at 18:39
  • \$\begingroup\$ Probably a duplicate of codegolf.stackexchange.com/q/62230/34718 \$\endgroup\$
    – mbomb007
    Apr 4 '17 at 18:43
  • \$\begingroup\$ @mbomb007: No, this is not a code-golf challenge. \$\endgroup\$
    – Luke
    Apr 4 '17 at 18:54
  • \$\begingroup\$ But there's nothing separating the answers this might receive. Please read this: codegolf.stackexchange.com/tags/popularity-contest/info \$\endgroup\$
    – mbomb007
    Apr 4 '17 at 18:57
-4
\$\begingroup\$

Make a Login Screen

Challenge: make code that asks the user to enter a username and password. The username and password should be hard coded, but they must not be visible: you cannot have the entire username or the entire password in plain text in the code. Both the username and the password must be 8 characters long. Upon the incorrect username or password, some error should be displayed. It would be good if there are multiple "accounts" that would display different text on login. The password field should not be visible (Only asterisks or something).

This is Code-Golf, Shortest answer wins.

Standard loopholes are forbidden.

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

Of numbers of letters

there is something special the number 4. When spelled in English the word 'four' uses exactly 4 letters. I wonder whether there are further such numbers Your task is to identify whether there exist further such numbers and output them in any human readable format. To make this more of a challenge you can do the task in any regional Language of your choice (Say Russian or Portuguese or Spanish or Mandarin or Hindi etc.).

The Best entry will be selected by the most number of such numbers regardless of language used

Best of Luck

\$\endgroup\$
2

You must log in to answer this question.

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