571
\$\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 requires more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended! Be patient and try not to nag people though, you might have to ask multiple times.

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

\$\endgroup\$
2
  • \$\begingroup\$ What if I posted on the sandbox a long time ago and get no response? \$\endgroup\$
    – None1
    Commented May 15 at 14:05
  • \$\begingroup\$ @None1 If you don't get feedback for a while you can ask in the nineteenth byte \$\endgroup\$
    – mousetail
    Commented May 29 at 13:27

4705 Answers 4705

1
148 149
150
151 152
157
-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\$
9
  • \$\begingroup\$ Regarding loopholes, you can link to this: Loopholes that are forbidden by default \$\endgroup\$
    – Emigna
    Commented Feb 22, 2017 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
    Commented Feb 22, 2017 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
    Commented Feb 22, 2017 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
    Commented Feb 22, 2017 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
    Commented Feb 22, 2017 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
    Commented Feb 22, 2017 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
    Commented Feb 22, 2017 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
    Commented Feb 22, 2017 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\$ Commented Feb 27, 2017 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\$
7
  • \$\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
    Commented Mar 2, 2017 at 15:55
  • \$\begingroup\$ Logout is shutdown with option l. The shutdown challenge was shutdown with option s \$\endgroup\$ Commented Mar 2, 2017 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\$ Commented Mar 2, 2017 at 16:12
  • 1
    \$\begingroup\$ If you made it prevent me from logging in to PPCG my overall productivity would skyrocket \$\endgroup\$
    – user63187
    Commented Mar 2, 2017 at 16:17
  • \$\begingroup\$ That's just a browser extension. Just close any PPCG tabs. \$\endgroup\$ Commented Mar 4, 2017 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
    Commented Mar 14, 2017 at 5:07
  • \$\begingroup\$ bash + utilities, 14 bytes: pkill -u $USER \$\endgroup\$
    – anna328p
    Commented Apr 7, 2017 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\$
4
  • \$\begingroup\$ There is not always a short summary. \$\endgroup\$ Commented Mar 10, 2017 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\$ Commented Mar 10, 2017 at 18:50
  • 1
    \$\begingroup\$ You should include more test cases, especially large ones if you want to score by fastest code. \$\endgroup\$
    – Laikoni
    Commented Mar 12, 2017 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
    Commented Oct 7, 2017 at 11:22
-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\$
10
  • \$\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\$ Commented Mar 13, 2017 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
    Commented Mar 13, 2017 at 1:59
  • \$\begingroup\$ @DJMcMayhem Good point that I have not thought about. \$\endgroup\$
    – arodebaugh
    Commented Mar 13, 2017 at 10:33
  • \$\begingroup\$ Making edits to it \$\endgroup\$
    – arodebaugh
    Commented Mar 13, 2017 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
    Commented Mar 13, 2017 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
    Commented Mar 13, 2017 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
    Commented Mar 13, 2017 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\$ Commented Mar 13, 2017 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
    Commented Mar 13, 2017 at 14:09
  • \$\begingroup\$ @Laikoni Well this makes an equation so it does not have to do with that. \$\endgroup\$
    – arodebaugh
    Commented Mar 13, 2017 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\$
6
  • \$\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\$ Commented Mar 13, 2017 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\$ Commented Mar 13, 2017 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\$ Commented Mar 13, 2017 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
    Commented Mar 14, 2017 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\$ Commented Mar 14, 2017 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\$ Commented Mar 14, 2017 at 6:22
-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\$
12
  • \$\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\$
    – user45941
    Commented Mar 19, 2017 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\$
    – anna328p
    Commented Mar 19, 2017 at 4:47
  • \$\begingroup\$ I'm confused by this "prevents hardcoding" as hard-coding a string is exactly the problem statement. \$\endgroup\$
    – feersum
    Commented Mar 19, 2017 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
    Commented Mar 19, 2017 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
    Commented Mar 19, 2017 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
    Commented Mar 19, 2017 at 16:49
  • \$\begingroup\$ That doesn't make sense. \$\endgroup\$
    – feersum
    Commented Mar 19, 2017 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
    Commented Mar 19, 2017 at 18:54
  • \$\begingroup\$ What does "hardcoding" mean to you? Please give a definition. \$\endgroup\$
    – feersum
    Commented Mar 19, 2017 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
    Commented Mar 19, 2017 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
    Commented Mar 19, 2017 at 19:05
  • \$\begingroup\$ Let us continue this discussion in chat. \$\endgroup\$
    – user42649
    Commented Mar 19, 2017 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\$
7
  • \$\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\$ Commented Mar 20, 2017 at 9:19
  • \$\begingroup\$ @JanDvorak challenge is now changed to displaying it instead. i think it's hard enough now. \$\endgroup\$
    – user55673
    Commented Mar 20, 2017 at 9:27
  • \$\begingroup\$ Same difference - most environments display the program output rather than ... doing anything else to it. \$\endgroup\$ Commented Mar 20, 2017 at 9:28
  • \$\begingroup\$ @JanDvorak but AFAIK most environment won't display it correctly. do they? \$\endgroup\$
    – user55673
    Commented Mar 20, 2017 at 9:30
  • \$\begingroup\$ TIO.run displays it just fine... \$\endgroup\$ Commented Mar 20, 2017 at 9:32
  • \$\begingroup\$ @JanDvorak But it's not right alignment and it's aligned to left \$\endgroup\$
    – user55673
    Commented Mar 20, 2017 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\$ Commented Mar 20, 2017 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\$
9
  • \$\begingroup\$ First cops and robbers challenge, pleas help me writing it nice. \$\endgroup\$
    – marcosm
    Commented Apr 4, 2017 at 14:58
  • \$\begingroup\$ Just to be clear, is the goal of the robbers to crack the encryption algorithm that the cops create? \$\endgroup\$ Commented Apr 4, 2017 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
    Commented Apr 4, 2017 at 15:05
  • \$\begingroup\$ You might want to read this, which specifically mentions certain types of encryption/decryption \$\endgroup\$ Commented Apr 4, 2017 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
    Commented Apr 4, 2017 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\$ Commented Apr 4, 2017 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\$ Commented Apr 5, 2017 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\$ Commented Apr 5, 2017 at 11:25
  • \$\begingroup\$ ok, i've learned something, thanks for your comments. \$\endgroup\$
    – marcosm
    Commented Apr 5, 2017 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\$
6
  • 1
    \$\begingroup\$ Hmm, why not xfs/zfs? Also, I don't really think this is a programming problem \$\endgroup\$
    – ASCII-only
    Commented Apr 4, 2017 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\$ Commented Apr 4, 2017 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\$ Commented Apr 5, 2017 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\$ Commented Apr 5, 2017 at 12:32
  • \$\begingroup\$ How are you drawing a distinction between programming challenges and code challenges? To me they're the same thing. \$\endgroup\$ Commented Apr 5, 2017 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\$ Commented Apr 5, 2017 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\$
10
  • \$\begingroup\$ All answers from here apply to this challenge. I'd say this would be a duplicate. \$\endgroup\$
    – user42649
    Commented Apr 9, 2017 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
    Commented Apr 9, 2017 at 22:05
  • \$\begingroup\$ @ais523 How can I add variation and distinguish my challenge? \$\endgroup\$
    – ckjbgames
    Commented Apr 9, 2017 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
    Commented Apr 9, 2017 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
    Commented Apr 10, 2017 at 1:54
  • \$\begingroup\$ I should make the requirements less strict. \$\endgroup\$
    – ckjbgames
    Commented Apr 10, 2017 at 12:58
  • \$\begingroup\$ Done! Requirements less strict. \$\endgroup\$
    – ckjbgames
    Commented Apr 10, 2017 at 12:59
  • \$\begingroup\$ "3. Language Y should preferably have unusual comment behavior" very subjective thing, isn't it? \$\endgroup\$
    – 0xffcourse
    Commented Apr 10, 2017 at 13:36
  • \$\begingroup\$ @officialaimm How to make it less subjective? \$\endgroup\$
    – ckjbgames
    Commented Apr 10, 2017 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\$
    – user58826
    Commented Jun 9, 2017 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\$
5
  • 3
    \$\begingroup\$ Forbidding hardcoding is not considered an observable requirement. \$\endgroup\$
    – Wheat Wizard Mod
    Commented Apr 16, 2017 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 Mod
    Commented Apr 16, 2017 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 Mod
    Commented Apr 16, 2017 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 Mod
    Commented Apr 16, 2017 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
    Commented Apr 17, 2017 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\$
6
  • \$\begingroup\$ codegolf.stackexchange.com/q/47870/194 \$\endgroup\$ Commented Apr 27, 2017 at 10:19
  • \$\begingroup\$ @PeterTaylor but that involves decimal input. This question is for binary input. \$\endgroup\$ Commented Apr 27, 2017 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\$ Commented Apr 27, 2017 at 11:20
  • \$\begingroup\$ Easy solution: add up all the numbers in the input. Many answers will have one-character answers. \$\endgroup\$
    – sporkl
    Commented Apr 27, 2017 at 13:48
  • \$\begingroup\$ O - 05AB1E and 2SABLE polygot 1 byte. \$\endgroup\$ Commented Apr 28, 2017 at 15:38
  • \$\begingroup\$ @MagicOctopusUrn c'mon 05AB1E and 2sable are practically the same thing I wouldn't call that polyglot :I \$\endgroup\$
    – hyper-neutrino Mod
    Commented Sep 10, 2017 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\$
5
  • \$\begingroup\$ You have to define what a math function is. Are we allowed bitwise operations? \$\endgroup\$
    – Beta Decay
    Commented May 14, 2017 at 22:54
  • \$\begingroup\$ @BetaDecay Fixed it. \$\endgroup\$
    – arodebaugh
    Commented May 15, 2017 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
    Commented May 15, 2017 at 3:43
  • 2
    \$\begingroup\$ "Do X without math" has no chance of not being closed, just so you know. \$\endgroup\$
    – feersum
    Commented May 15, 2017 at 4:04
  • \$\begingroup\$ Probable dup \$\endgroup\$ Commented May 16, 2017 at 23:20
-2
\$\begingroup\$

Prove the Undecideability of the Halting Problem

More information on the halting problem.

Either:

Create a program that, when given an input, no single program (which receives your source and your input) can determine if your program terminates, or

Create a function that, when given an input, no single program (which receives your source and your input) can determine if your function returns.

Your score is the byte count of your program plus the byte count of your input (or of the shortest input in the set of input that solves this problem).

Lowest score wins.

//I would love some input on my wording.

\$\endgroup\$
12
  • \$\begingroup\$ Can I make a request to an external URL until I get a 404? \$\endgroup\$
    – user58826
    Commented May 17, 2017 at 18:21
  • \$\begingroup\$ @programmer5000 can an external program determine whether your program will halt? For example, by pinging that URL themselves? \$\endgroup\$
    – Stephen
    Commented May 17, 2017 at 18:24
  • \$\begingroup\$ Oh. Could I make a program that stops when it finds 5 points that prove the Happy Ending Problem wrong? \$\endgroup\$
    – user58826
    Commented May 17, 2017 at 18:29
  • \$\begingroup\$ @programmer5000 if your program stops with a given input, and another program can predict that it will stop with that input, your program does not match specs. No input is accepted input, but it is very unlikely that an undecidable program can come from no input AFAIK. \$\endgroup\$
    – Stephen
    Commented May 17, 2017 at 18:32
  • \$\begingroup\$ @programmer5000 from the Wikipedia page it seems like that problem is already solved, so that program will terminate, so another program could predict that. Could be wrong though. \$\endgroup\$
    – Stephen
    Commented May 17, 2017 at 18:33
  • \$\begingroup\$ Um. eval. It's one byte long in GolfScript. \$\endgroup\$ Commented May 17, 2017 at 21:35
  • \$\begingroup\$ @PeterTaylor you need to provide an input that is undecidable, and that counts towards your score. \$\endgroup\$
    – Stephen
    Commented May 17, 2017 at 21:38
  • 3
    \$\begingroup\$ I don't think this is how the halting problem works... \$\endgroup\$ Commented May 17, 2017 at 23:50
  • \$\begingroup\$ @DestructibleLemon You may be right; Wikipedia says a general algorithm to solve the halting problem for all possible program-input pairs cannot exist. Do I need to require two inputs? This answer seems to contradict Wikipedia though. \$\endgroup\$
    – Stephen
    Commented May 18, 2017 at 0:10
  • \$\begingroup\$ hmmm, you definitely could do this (make it an interpreter) but I'm not sure how much you have to do to make this work... as in what the simplest program would be \$\endgroup\$ Commented May 18, 2017 at 0:17
  • 1
    \$\begingroup\$ @StephenS It doesn't require 2 inputs, it requires a pair (program, input). \$\endgroup\$ Commented May 18, 2017 at 1:07
  • 2
    \$\begingroup\$ It's the problem which is undecidable, not the instances. If you want to ask for a program which cannot be proven to halt or not halt, you have to specify the axiom system which can be used for the proof. See e.g. codegolf.stackexchange.com/q/79470/194 , codegolf.stackexchange.com/q/79620/194 \$\endgroup\$ Commented May 18, 2017 at 6:19
-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\$
8
  • 6
    \$\begingroup\$ "looks like" isn't a tight enough specification for a challenge. \$\endgroup\$
    – user45941
    Commented May 29, 2017 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\$ Commented May 30, 2017 at 0:22
  • 2
    \$\begingroup\$ So the answer could replicate it at the 0th generation? \$\endgroup\$ Commented May 30, 2017 at 10:48
  • \$\begingroup\$ @PeterTaylor Good point \$\endgroup\$
    – arodebaugh
    Commented May 30, 2017 at 13:14
  • \$\begingroup\$ @FryAmTheEggman Popularity contest? \$\endgroup\$
    – arodebaugh
    Commented May 30, 2017 at 13:14
  • \$\begingroup\$ @Mego Also good point \$\endgroup\$
    – arodebaugh
    Commented May 30, 2017 at 13:15
  • \$\begingroup\$ OK I updated stuff maybe it will make this challenge better \$\endgroup\$
    – arodebaugh
    Commented May 30, 2017 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\$ Commented May 30, 2017 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\$
11
  • \$\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\$ Commented May 29, 2017 at 16:43
  • \$\begingroup\$ @FryAmTheEggman "Typing restrictions"? (Added proper instructions) \$\endgroup\$ Commented May 29, 2017 at 16:45
  • 1
    \$\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\$ Commented May 29, 2017 at 16:48
  • 7
    \$\begingroup\$ In answer to "Because why not": because it will be closed as a dupe. \$\endgroup\$ Commented May 29, 2017 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\$ Commented May 30, 2017 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\$ Commented May 31, 2017 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
    Commented May 31, 2017 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
    Commented Jun 1, 2017 at 20:35
  • 1
    \$\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\$ Commented Jun 2, 2017 at 9:07
  • \$\begingroup\$ #PHP 8.3 256char echo exp(bindec("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")); \$\endgroup\$
    – Willtech
    Commented Dec 28, 2023 at 5:13
  • \$\begingroup\$ @PeterTaylor That question is closed but I would like credit for my answer. \$\endgroup\$
    – Willtech
    Commented Dec 28, 2023 at 5:18
-2
\$\begingroup\$

Draw an XBox

Here's an X:

\  /
 \/
 /\
/  \

And here's a Box:

+----+
|    |
|    |
|    |
|    |
+----+

So, for an XBox, just draw an X in a Box:

+----+
|\  /|
| \/ |
| /\ |
|/  \|
+----+

Your input will be a number (in any standard way) that will represent the size of the box. To output the above box, this could be the number of -/|\s (4), or the number of lines/columns (6), or even the intercept of the second diagonal (5) would be acceptable. (Don't ask me to accept the base256 encoding of the output though, as that's one of the many banned standard loopholes.)

Your program or function should then output (in any standard way) the XBox of the given size. If the \/s cross in the same character, place an X (as per Draw a big slash X). For example, here's an XBox three sizes larger than the one above:

+-------+
|\     /|
| \   / |
|  \ /  |
|   X   |
|  / \  |
| /   \ |
|/     \|
+-------+

This is , so the shortest program wins!

\$\endgroup\$
12
  • \$\begingroup\$ in some obvious way unclear/subjective \$\endgroup\$
    – MD XF
    Commented Jun 9, 2017 at 16:35
  • \$\begingroup\$ @MDXF 4 examples weren't sufficient? \$\endgroup\$
    – Neil
    Commented Jun 9, 2017 at 17:04
  • \$\begingroup\$ I'm just warning you that it could get closed for being too broad due to that statement. \$\endgroup\$
    – MD XF
    Commented Jun 9, 2017 at 17:05
  • \$\begingroup\$ I agree with @MDXF \$\endgroup\$
    – Beta Decay
    Commented Jun 9, 2017 at 18:03
  • \$\begingroup\$ @BetaDecay That's all very well, but I'm unclear as to what you want. \$\endgroup\$
    – Neil
    Commented Jun 9, 2017 at 19:15
  • \$\begingroup\$ Just a basic explanation of how scaling works. Some examples would suffice \$\endgroup\$
    – Beta Decay
    Commented Jun 9, 2017 at 21:32
  • \$\begingroup\$ I've added an example. \$\endgroup\$
    – Neil
    Commented Jun 10, 2017 at 0:42
  • \$\begingroup\$ @MDXF Here's my problem. I just tried implementing this in Charcoal, and came up with Try it online!. As it turns out, to produce those example XBoxes I actually need sizes of 7 and 10, but I didn't want to penalise that choice of input just because I hadn't predicted that particular scaling. \$\endgroup\$
    – Neil
    Commented Jun 10, 2017 at 13:42
  • \$\begingroup\$ @BetaDecay If you still have any further input it would be appreciated. \$\endgroup\$
    – Neil
    Commented Jun 12, 2017 at 12:06
  • \$\begingroup\$ Related \$\endgroup\$ Commented Jun 15, 2017 at 11:57
  • \$\begingroup\$ @KevinCruijssen Ugh, I even have an answer on that question... I guess the use of specific characters doesn't really sufficiently distinguish this one. \$\endgroup\$
    – Neil
    Commented Jun 15, 2017 at 12:42
  • \$\begingroup\$ @Neil Well, using /+x\ instead of just * does make it a bit trickier, but it's indeed a bit too similar imho. \$\endgroup\$ Commented Jun 15, 2017 at 13:11
-2
\$\begingroup\$

Print a Variable's Memory Address

Similar to this puzzle I posted earlier, with a difference that should make this challenge easier.

Create a function (not a full program) that prints or returns the memory address of the parameter passed in. Literal values should return a falsey value.

Examples:

var foo = 4901
var bar = "foobarbaz"
var baz = true

getMemoryAddress(from: foo) // 0x00000000004030f0
getMemoryAddress(from: bar) // 0x00000000004030f8
getMemoryAddress(from: baz) // 0x0000000000403110
getMemoryAddress(from: "Bad Value") // false

Note that you probably won't get the same exact result as show above.

\$\endgroup\$
2
  • \$\begingroup\$ Example(s) please. \$\endgroup\$
    – Shaggy
    Commented Jun 15, 2017 at 15:15
  • \$\begingroup\$ @Shaggy Updated. \$\endgroup\$ Commented Jun 15, 2017 at 15:38
-2
\$\begingroup\$

Migrate questions to and from the Sandbox!

Challenge

Write user scripts that will migrate challenges to and from the Sandbox.

Criteria

These are my suggestions for criteria that will create the most beautiful user scripts. Feel free to suggest your own!

Migrating to the Sandbox

The script should...

  • only act on a question that has been closed for "unclear what you're asking"
  • answer the Sandbox as the original author of the question
  • make the title and tags the first line of the answer as a H1-sized header
  • link the original question to the Sandbox post, and then delete it

Migrating from the Sandbox

The script should...

  • use the first line to determine the title and tags for the post, and eliminate it from the post body
    • error handling here would be a good idea
  • create the question as the author of the Sandbox answer
  • comment on the question with a link to the Sandbox answer
  • replace the Sandbox answer with just the title and link to the question, then delete the Sandbox answer

Scoring

This is a , so the answer with the highest net of votes will win.

Sandbox

  • Is what I'm asking for even possible? I've never written a user script before. Maybe it should be a question?
  • Should this be a Community effort rather than a challenge? Does it even belong on main?
\$\endgroup\$
2
  • \$\begingroup\$ This is not within the capabilities of a userscript. Also, automating this wouldn't really help at all, since the sandbox only does anything if the poster wants to use it. Anyway, if you disagree with me and still want to pursue this, it should be a question on meta, asking if people want a sandbox migration bot. \$\endgroup\$ Commented Jun 20, 2017 at 4:15
  • \$\begingroup\$ @FryAmTheEggman Thanks for your feedback! I've asked on meta as you suggested. \$\endgroup\$ Commented Jun 20, 2017 at 4:45
-2
\$\begingroup\$

Grep for math in a pdf document

This challenge is likely to need the use of libraries. You may use any free library of your choice as well as any library.

The challenge is simply to write a tool that can grep for "2^n" in a pdf document. That is the math that represents 2 to the power n. You may assume that the pdf was produced from LaTeX which contains $2^n$ and that the pdfr was made using the command line tool pdflatex.

What should the code do?

The code should take a pdf file as input either by reading a file or from standard in. It should output if the file contains "2^n" or not.

Scoring

I will provide a number of pdf files as test examples. Your score will just be how many your code gets right.

Requests for help

I could provide sample pdf documents that do or do not contain 2^n in them.

Does it always appear as an image in the pdf as Mego suggests? If so, this image will depend on the font and font size and this is an image processing task.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ 1. How are you going to score this? Code golf? Popularity contest? 2. PDFs can vary wildly in how something is displayed. If you're specifying that it's produced from a specific program in a specific way, then it's likely just a search for a static string of bytes, which is IMO a boring challenge. 3. What exactly is the output? Is it a simple yes/no, or is it supposed to be location within the file? \$\endgroup\$
    – Shelvacu
    Commented Jul 1, 2017 at 19:37
  • \$\begingroup\$ @Shelvacu I was going to score by how often the code gives the right answer. I would ideally like the code to output the first page number it finds 2^n on but I don't know if that is too hard. If it is then the output is just yes/no. \$\endgroup\$
    – user9206
    Commented Jul 2, 2017 at 17:38
  • \$\begingroup\$ So test-battery. \$\endgroup\$
    – DELETE_ME
    Commented Mar 23, 2018 at 14:35
-2
\$\begingroup\$

Is it cat-urday?

Caturday is one of the oldest memes out there. For this challenge you need to write a program that outputs the input, but only on Saturday.

The catch:

You can acquire the date via UNIX timestamp, or as a formatted date string (local or UTC). However, you can not:

  • use day of the week information in a date string
  • directly acquire the day of the week of a date by some other means
  • use Date or Calendar functions, beyond one to simply give you the current date
  • use any external resources (files, Internet)

Don't forget leap years!


Does this question work as is? Should I make anything clearer?

\$\endgroup\$
1
  • 5
    \$\begingroup\$ This is a "do X without Y" challenges, and those have been done to death. \$\endgroup\$ Commented Jul 22, 2017 at 20:28
-2
\$\begingroup\$

Output the infinite sequence of middle positions of odd square numbers

As everyone knows, every odd square number has an element at its central position — I represent those central elements as an *:

n=1 => 1
*

n=9 => 5
###
#*#
###

n=25 => 13
#####
#####
##*##
#####
#####

n=49 => 25
#######
#######
#######
###*###
#######
#######
#######

The challenge consists on output the sequence 1, 5, 13, 25, ... uninterruptedly. The separator does not need to be a comma, but use the same separator always.

There will not be any accepted answer, except if I see some very creative answer. There will be a winner for each language (I will steal Leader board code somewhere)

\$\endgroup\$
4
  • \$\begingroup\$ Is this equivalent to "output (N+1)/2 for every odd square number N"? \$\endgroup\$ Commented Aug 3, 2017 at 17:15
  • \$\begingroup\$ @trichoplax: Yes. \$\endgroup\$
    – sergiol
    Commented Aug 3, 2017 at 17:40
  • 1
    \$\begingroup\$ There will not be any accepted answer, except if I see some very creative answer The whole point of code-golf is the shortest answer wins. Why output constantly and not return the Nth or first N terms? \$\endgroup\$ Commented Aug 4, 2017 at 10:08
  • 2
    \$\begingroup\$ Also surely this boils down to for(i=1;;i+=2)Output((i**2+1)/2+",") which isn't that exciting. \$\endgroup\$ Commented Aug 4, 2017 at 10:09
-2
\$\begingroup\$

Hello, Quine!

Your task is to write a program which, if given an input of "Hello," will output "Hello, world!", if given any other input, it will output its source code.


Rules

  • Input does not have to be case-sensitive.
  • Your program may not contain the string "Hello, world!" or any variation with different cases of letters (i.e "hELLO, WORLD!", "HeLlO, WoRlD!", and "hello, world!").
  • No "cheating quines."
  • Standard loopholes are strictly forbidden.

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

\$\endgroup\$
4
  • 4
    \$\begingroup\$ This is combining two different challenges into one, and I don't see a good reason to do so. (Output your source, and output Hello, World! without it in your source). Also, restricted-source. \$\endgroup\$
    – Stephen
    Commented Aug 3, 2017 at 17:36
  • \$\begingroup\$ @StepHen How could I distinguish it somewhat? \$\endgroup\$
    – ckjbgames
    Commented Aug 3, 2017 at 17:40
  • \$\begingroup\$ Distinguish it from what? It's just combing two already used challenges - Hello, World! without important characters, and quining, into one. \$\endgroup\$
    – Stephen
    Commented Aug 3, 2017 at 17:43
  • \$\begingroup\$ @StepHen Definitely true. \$\endgroup\$
    – ckjbgames
    Commented Aug 3, 2017 at 17:46
-2
\$\begingroup\$

Complicating Simple Maths

We do know what 1 + 1 is, or 2 - 1. How about we turn those and other really simple operations into complex numbers?

Goal:

As stated in the intro, taking an operation that can be done within the range of the following operators ( +, -, /, *, ^ and () ), print out a complex number operation that is pretty much a transformed version, and when done using the order of operations, results in the same answer as the inputted operation.

Examples:

Input: 5 - 1
Output: 5 + 2i

Input: 4 * (7 ^ 2)
Output: (4 * 4i) * (7 ^ 2) 

Rules:

  • It is recommended you print out the sector(s) that holds your complex number(s) as a + bi, e.g. (a + bi) - (ci * (di ^ f)). (NOTE: If you are doing non-communicative operations, such as ^, /, or -, the recommendation doesn't apply to the sub-operation).

  • No standard loopholes.

  • If you want to, feel free to use operations/functions other than the set mentioned in the Goal, but your input operation must have at least one of them.

  • You can format your operators in any way, e.g. x or • instead of *, ÷ instead of /, etc.

  • Input and output is allowed in any format as long as it fits within the standard I/O rules.

  • Input must also be flexible (as in to return any input from a simple operation to a complex number operation.

  • This is , so shortest answer wins.

Sandbox use only:

Is there any way I can improve this challenge? Are there any other loopholes to be covered in the rules?

\$\endgroup\$
5
  • \$\begingroup\$ Can you relax output to standard IO too? At the moment it seems you can only print the result. Also isn't this essentially calculate the result of the inputted expression then work out a complex expression that gives the same answer seeing as you don't need to keep anything in the input the same. \$\endgroup\$ Commented Aug 7, 2017 at 10:32
  • 3
    \$\begingroup\$ And if that is the case isn't this challenge just return input + (1 + i^2)? \$\endgroup\$ Commented Aug 7, 2017 at 10:33
  • \$\begingroup\$ No, the challenge is to transform parts of the input into complex numbers and output that. \$\endgroup\$ Commented Aug 7, 2017 at 13:13
  • 1
    \$\begingroup\$ But 5 - 1 becomes 5 + 2i You are removing two stages - and 1 and adding 2 + and 2i. It's not entirely clear how much you can remove and how much you can add. \$\endgroup\$ Commented Aug 7, 2017 at 13:15
  • \$\begingroup\$ At least one sub-operation should be transformed from simple to complex (which could take two steps). \$\endgroup\$ Commented Aug 7, 2017 at 13:16
-2
\$\begingroup\$

The Self-Referential Algorithm

Most people are familiar with Tupper's self-referential formula. When the formula is graphed on a calculator it magically graphs itself. Wouldn't it be interesting if we could do something similar with a programming language?

Your task

Write a small program that will be able to output exactly itself when ran.

This is a question so answers will be scored in bytes, with the fewest bytes winning.

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

Pascal's Particulars

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

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

Rules

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

Happy golfing!

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

Break this block

Your challenge is to break this block. floating diamond

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

Rules

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

Sandbox questions

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

The Compressor

You are given this list of 100 positive integers that are at between 7 and 18 digits long:

[list to come]

You need to generate 100 snippets that will produce these numbers in some language (either as a numeric or string). Your score is the total length of the snippets. Lowest score overall wins, but you should also try to get the lowest score in whichever language your snippets are in. Please include both your snippets and any code you used to generate them in your submission. Note: the generating code isn't actually scored.

Rules

  • The snippets must all be in one language, however it does not need to be the same language as the generating program(s).
  • You may assume that any pre-existing libraries you use are already imported.
  • You don't need to include the line terminator (i.e ';' in Java and others) for snippets that fit on one line. For multi-line snippets, you don't need to put a terminator on the last line.

Examples

  • 1357000 => 1357e3 (many languages)
  • 1234567 => 1234567 (most languages)
  • 307422089600 => S6*99b (CJam, returns value of [32,32,32,32,32,32] in base 99)
  • 12582912 => 12<<20 (JS + others)

Alternative:

I generated this 100 digit random number with random.org:

7160708104901559695507628057638725214364226867212714872539720713967912042100814603497742352846014272

Write the shortest possible program that outputs this number.


Related: No strings (or numbers) attached

Questions? Clarifications?

\$\endgroup\$
6
  • \$\begingroup\$ I would say that rather than having the input be a list of 100 numbers, have the input be a single number and just have score be the sum of output lengths when applied to each of the 100 numbers. I think that this will avoid confusion over valid output formats, without altering the interesting part of the problem. \$\endgroup\$ Commented Sep 7, 2017 at 21:14
  • \$\begingroup\$ I would also say that this could be dangerously close to a duplicate, since answers to that challenge seem likely to score well in this one with relatively minor modifications. \$\endgroup\$ Commented Sep 7, 2017 at 21:15
  • \$\begingroup\$ @KamilDrakari I'm trying to understand your suggestion. Currently the score is lowest sum of output lengths. \$\endgroup\$
    – geokavel
    Commented Sep 7, 2017 at 22:15
  • \$\begingroup\$ currently the challenge is for a program which takes a list of numbers and outputs 100 snippets. I think the challenge would be better if the program takes 1 number and outputs 1 snippet, and gets run 100 times to score it. \$\endgroup\$ Commented Sep 8, 2017 at 13:04
  • \$\begingroup\$ @KamilDrakari You're allowed to make a program that takes 1 snippet at a time, because you are score on the snippets, not the program. The program is a meta-program. \$\endgroup\$
    – geokavel
    Commented Sep 8, 2017 at 14:46
  • \$\begingroup\$ I think having both options should be more clearly stated then. One other suggestion: you mention "Lowest score in a particular language", which I think should be explicitly clarified whether answers compete based on the language of their snippets or their generating program. \$\endgroup\$ Commented Sep 8, 2017 at 14:59
-2
\$\begingroup\$

Ulam spiral 2

Like Ulam, I had a boring moment and began drawing a spiral like him's. But his version is utterly incorrect, as the \ diagonal distorts the equation n^2.

The following picture illustrates an wrong Ulam spiral at left and a correct at right:

enter image description here

I challenge you to output a numbered Ulam spiral, the right version, where it is mandatory to highlight the primes. The input is n, meaning the point where the spiral ends. For the image example I gave n was 100. It will always begin at 1

I don't care what highlight style you use (different color, font weight, circle around number, etc), given it makes the primes easily distinguishable form the rest.

There will be no accepted answer; just did it for fun.

\$\endgroup\$
7
  • \$\begingroup\$ This isn't [arithmetic]. \$\endgroup\$
    – Riker
    Commented Sep 19, 2017 at 19:06
  • \$\begingroup\$ Also, can you provide an actual explanation of how you got the second one? \$\endgroup\$
    – Riker
    Commented Sep 19, 2017 at 19:07
  • \$\begingroup\$ You can only have a maximum of 5 tags per question. \$\endgroup\$ Commented Sep 19, 2017 at 19:36
  • \$\begingroup\$ @Riker there is a pattern. Interpreting it is part of the challenge. \$\endgroup\$
    – sergiol
    Commented Sep 19, 2017 at 19:50
  • 3
    \$\begingroup\$ @sergiol -1, that's no fun at all. The first person can figure it out, and the rest can and will copy the pattern. PPCG doesn't work well with the "find the pattern and decode it" style. \$\endgroup\$
    – Riker
    Commented Sep 19, 2017 at 21:40
  • \$\begingroup\$ wrong Ulam spiral at left; I thought the spiral on the left was the Ulam spiral? \$\endgroup\$ Commented Sep 20, 2017 at 2:20
  • \$\begingroup\$ @JonathanFrech: Yes. \$\endgroup\$
    – sergiol
    Commented Sep 20, 2017 at 9:21
-2
\$\begingroup\$

Looking for some help to make this code golf/question better.

Proposal:

Now that twitter has increased it's character limit from 140 to 280, there's a joke of almost enough to write Hello World! in Java. But what actual programs could you write in 280 characters, fizz buzz? Sure you could write many in 140 or less, but maximum points if you get a good program in the full 280.

\$\endgroup\$
4
  • 3
    \$\begingroup\$ Hello! Your programming challenge needs an actual task... Think of an idea first, then come here again! \$\endgroup\$
    – hyper-neutrino Mod
    Commented Sep 27, 2017 at 14:01
  • \$\begingroup\$ So "do something in exactly 280 bytes"? Yeah, you're going to need a much better spec than that. As well as a winning criterion. \$\endgroup\$
    – Shaggy
    Commented Sep 27, 2017 at 14:25
  • \$\begingroup\$ There is some precedent for a similar challenge, but that was more narrow, more clearly defined, and it was still closed for being "too broad" (though it did have some interesting answers). I don't think this would really offer any improvements over that existing challenge. \$\endgroup\$ Commented Sep 27, 2017 at 14:40
  • \$\begingroup\$ codegolf.stackexchange.com/questions/35569/… is basically what you're describing except the limit is 280 rather than 140 characters \$\endgroup\$
    – Beta Decay
    Commented Sep 28, 2017 at 21:40
1
148 149
150
151 152
157

You must log in to answer this question.

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