435
\$\begingroup\$

What is the Sandbox?

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

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

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

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

Add Proposal

Search the Sandbox

Browse your pending proposals

Get the Sandbox Viewer to view the sandbox more easily

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

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

2384 Answers 2384

-2
\$\begingroup\$

Bees?

Inspired by SCP-3045

Write a program that takes the input, extracts all of the words, and looks for the word bee; then:

  • If bee is not detected, pick sections of the text at random and delete them.
  • If bee is detected, add instances of the word bee to the input such that it has significantly more bytes than the original input.

The program should then output these modifications.

\$\endgroup\$
  • 1
    \$\begingroup\$ How much is significantly more? Why is it popularity-contest? \$\endgroup\$ – Laikoni Mar 18 '18 at 14:00
  • 1
    \$\begingroup\$ Do X creatively pop cons have fallen out of scope. This will get closed instantly if posted on main. \$\endgroup\$ – Dennis Mar 19 '18 at 12:51
-2
\$\begingroup\$

Move a window around the screen

Your code should open a new window that is at least 100 by 100 pixels in size. Once the window is open you should be able to move the window around the screen using the keyboard. The window should move smoothly but it doesn't matter how fast it moves.

\$\endgroup\$
  • 2
    \$\begingroup\$ Is there anything else that could make this challenge a bit more interesting? Maybe a scoring method? \$\endgroup\$ – RamenChef Mar 26 '18 at 14:01
  • \$\begingroup\$ @RamenChef I suppose the scoring method was meant to be by the code-golf rules. I could make the challenge more interesting maybe by insisting that you can type into the window? \$\endgroup\$ – user9206 Mar 26 '18 at 14:05
  • 1
    \$\begingroup\$ What counts as a "window"? I think this might be quite hard to define objectively in a way which is OS-agnostic. \$\endgroup\$ – Peter Taylor Mar 26 '18 at 15:38
-2
\$\begingroup\$

Output a Random Bit

Your task is simple: print either 1 or 0.

Chosen uniformly randomly every time.

No, not your silly pseudorandom nonsense. No system calls. No reading /dev/urandom. The randomness has to be unpredictable (i.e. reliant on chaotic, impossible-to-reasonably-model natural phenomena, and not on some configuration of bits in your computer).

Specifications

  • It is OK to query a site such as random.org for your bit.
  • Your program only needs to be runnable once per day (i.e. you can assume there is a 24 hour gap between executions). This is to work around the fact that sites like random.org often have rate-limits.
\$\endgroup\$
  • \$\begingroup\$ If it only has to be run once a day, wouldn't millis() % 2 be truly random? \$\endgroup\$ – geokavel Apr 2 '18 at 3:22
  • 1
    \$\begingroup\$ @geokavel No, because you can't assume that the calling actions will be random (e.g. I could always invoke the program at 25-hour intervals, meaning that millis() % 2 would always be a consistent value. \$\endgroup\$ – Esolanging Fruit Apr 2 '18 at 4:11
  • \$\begingroup\$ Is a time cost of maybe read a file in nanoseconds allowed? \$\endgroup\$ – l4m2 Apr 2 '18 at 4:42
  • 1
    \$\begingroup\$ In its current form, it appears to be impossible to define the validity criteria objectively. Temporary -1. \$\endgroup\$ – user202729 Apr 2 '18 at 6:39
  • \$\begingroup\$ @user202729 If it were up to you, how would you define them? \$\endgroup\$ – Esolanging Fruit Apr 2 '18 at 6:45
  • \$\begingroup\$ /dev/random seems to be really random. Is it allowed? \$\endgroup\$ – someone Apr 2 '18 at 7:30
  • \$\begingroup\$ @someone Wikipedia says it's a PRNG, and I've heard that system randomness tends to draw entropy from sources like startup times and user actions, so that wouldn't count. \$\endgroup\$ – Esolanging Fruit Apr 2 '18 at 7:42
  • \$\begingroup\$ Would a HRNG such as RdRand work? \$\endgroup\$ – someone Apr 2 '18 at 8:24
  • \$\begingroup\$ ... I admit that my downvote/comment is not constructive, but I found absolutely no way to objectively define the challenge. \$\endgroup\$ – user202729 Apr 2 '18 at 14:02
  • \$\begingroup\$ Maybe define "real random" as "not only based on xxx"(currently last state, calling current) \$\endgroup\$ – l4m2 Apr 2 '18 at 15:38
  • \$\begingroup\$ @l4m2 That was what I was trying to imply by saying it shouldn't be pseudorandom. \$\endgroup\$ – Esolanging Fruit Apr 2 '18 at 18:47
  • \$\begingroup\$ @EsolangingFruit but you need to define what's pseudo \$\endgroup\$ – l4m2 Apr 2 '18 at 18:52
-2
\$\begingroup\$

Let's play the too high too - low game!

TL:DR : write a code that plays the too high - too low game


Given this pseudo code function for the too high - too low game, write it in your language of choice. This is just to make the challenge work better across all languages. This code won't count in the final score. You may also change the function's name and any of its variable's name too.

function isRight(number, guess):  # where the number is the correct answer and the guess is your code's guess

    if guess < number:            # if the guess is too low
        return 0                  # return 0

    else if guess > number:       # if the guess is too high
        return 2                  # return 2

    else if guess == number:      # if the guess is right
        return 1                  # return 1

    else:                         # if there is an error
        return -1                 # return -1

The challenge

Write a code, function, script, etc. that guesses the right number. The range of the "random" number will be between 0 inclusively and 100 exclusively. For the sake of this challenge, the "random" numbers will be the test cases. Note that hard-coding the test cases is banned.


Scoring

This is how the score will be counted:

bytes = number of bytes in your code
tries = the sum of all the tries used to guess all the test cases

score = bytes + tries

Rules

  • Hard-coding the test cases if forbidden.

Test cases

[0,2,4,13,19,21,26,33,38,42,48,50,51,56,66,69,74,75,80,89,98,99]
\$\endgroup\$
  • \$\begingroup\$ For one, i'd say the randomness is unfair. If you manipulate the seed python is given, you can just have it output a known sequence. Alongside that, can't you just hardcode the testcase? EDIT: Hardcoding the test case is the only way to get a good score. \$\endgroup\$ – moonheart08 Mar 29 '18 at 16:38
  • \$\begingroup\$ @moonheart08 would banning hardcoding the test cases help? \$\endgroup\$ – Dat Mar 29 '18 at 17:57
  • 1
    \$\begingroup\$ "the sum of all the tries used to guess all the test cases" Won't this be the same for all answers (with the only difference being floor vs ceil when taking halve the previous guess (as in 75 & higher could result in a next guess of either 87 or 88).First guess will always be 50. Is it lower, guess 25; is it higher, guess 75. etc. etc. Btw, there are already a few Guess the number challenges: Here is one; and here is another one. \$\endgroup\$ – Kevin Cruijssen Apr 3 '18 at 12:54
-2
\$\begingroup\$

I see a window and I want it painted black

Yes, I know this is a popular mishearing of the lyrics. But instead of a red door, I really do want an (application) window painted black.

Your standalone program should launch an application window at least 400x400 and fill it entirely with black. It doesn't need to be borderless, and it doesn't need to exit gracefully.

Running in a browser is insufficient because there are still elements of the window such as the address-bar and tab-bar that aren't painted black. You must paint the whole window black except for borders added by your window manager.

This is code golf. Standard loopholes apply. Additional challenge is to listen to The Rolling Stones while making your submission.

Here is an un-golfed Java solution:

#compile: javac BlackWindow.java
#run: java BlackWindow
import java.awt.Color;
import java.awt.Frame;

public class BlackWindow{
  public static void main(String[] args){
    Frame frame = new Frame("no colors anymore");
    frame.setsize(400, 400);
    frame.setLocationRelativeTo(null);
    frame.setBackground(Color.Black);
    frame.setvisible(true);
  }
}
\$\endgroup\$
  • \$\begingroup\$ What if my platform doesn't support windows that large? \$\endgroup\$ – Stephen Leppik Apr 20 '18 at 23:17
  • \$\begingroup\$ What is the 400x400 measured in? Pixels? Does it qualify if I somehow emulate a screen with larger resolution? \$\endgroup\$ – user202729 Apr 21 '18 at 9:23
  • \$\begingroup\$ Does making the whole screen black count? \$\endgroup\$ – user202729 Apr 21 '18 at 9:24
  • \$\begingroup\$ Stephen then make the whole screen black? What kind of system doesn't support that? \$\endgroup\$ – Jared K Apr 22 '18 at 0:16
  • \$\begingroup\$ user202729 i was thinking pixels \$\endgroup\$ – Jared K Apr 22 '18 at 0:16
  • \$\begingroup\$ What if I am listening to The Feelies cover of the song? Do I get the bonus point? +1 from me for an unusual challenge. \$\endgroup\$ – JayCe Jun 11 '18 at 3:34
-2
\$\begingroup\$

Shorter coding in non-golfing language

Copper write a requirement, a sample program in a golfing language, and a required non-golfing language. Rob hack it with the required language, with fewer bytes of code.

I guess it'd be cuz it's sometimes hard to define which is "golfing language". Also is it a duplicate?

\$\endgroup\$
  • \$\begingroup\$ If it's a cops-and-robbers, then it can't be a popularity-contest. I personally don't think this challenge would work out; first of all, it's virtually impossible to outgolf a golfing language using a non-golfing languages because most golfing languages can complete most reasonable tasks in fewer bytes than it takes a non-golfing language to even print Hello World. Also like you said, golfing/non-golfing is extremely difficult to define. I also don't think this challenge would be particularly interesting because you'd likely end up with a bunch of miscellaneous cops posts with all \$\endgroup\$ – HyperNeutrino May 2 '18 at 13:09
  • \$\begingroup\$ sorts of random requirements, which is basically just going to be a bunch of questions that either exist on PPCG already or could be posted to PPCG main as its own challenge, without any robber posts because it would be basically impossible. \$\endgroup\$ – HyperNeutrino May 2 '18 at 13:09
  • 3
    \$\begingroup\$ IMO this is well past the threshold of "Too Broad", so I would vote to close for that reason. \$\endgroup\$ – Peter Taylor May 2 '18 at 15:23
-2
\$\begingroup\$

(Now I don't know what the name should be)

Intention

I want to create a challenge based on dependent typing, feature that exists in Idris, Coq, Agda and the similiar.

Text

You should create a function in dependently typed language (Idris, Coq, Agda, etc) so that:

  1. The function will receive a string that denotes format.
  2. The format string will have s or n, s means it will receive a string, n means it will receive a number. You can assume that there is no other thing in the string
  3. Arguments is received in order. If there is type mismatch, the error must be reported on compile-time.
  4. After all arguments is received, the function will return a string, that is list of all passed argument

For example

formatf "sn" "goods" 25
> "goods 25"
formatf "sn" "goods" "bad"
> Type error in compile time
formatf "ak" "Akangka" 25
> You can do anything.
formatf "nnn" 24 25
> Either type error or return a function expecting a number and return string (currying is almost universal in these languages)
formatf "ss" "Akangka" "Martin Ender" "Adám"
> Type error on compile time

This challenge is similiar to printf-style string formatting, the difference that the function in this challenge has to be type safe.

Note that you cannot use build-in function or macro to do this

Discussion

  1. What should be the name of this challenge?
\$\endgroup\$
  • \$\begingroup\$ Any reason why full programs are not allowed? \$\endgroup\$ – user202729 May 2 '18 at 9:29
  • \$\begingroup\$ What happens if the language is not compiled? \$\endgroup\$ – user202729 May 2 '18 at 9:32
  • 1
    \$\begingroup\$ (if you didn't realize, it's not just some languages can't solve it, but in some languages your requirements don't make any sense. There are languages without functions, language with only monadic functions, languages without integers, language without macros, language where macros have different meaning than C #define, language without string (C), etc.) \$\endgroup\$ – user202729 May 2 '18 at 9:59
  • \$\begingroup\$ If the string is possibly not known at compile time, how can it produce a type error at compile time? \$\endgroup\$ – Angs May 2 '18 at 10:04
  • \$\begingroup\$ Personally I think it's a bit too similar to the challenge you linked.. The only difference is validating the input-type with the format.. In which case it would be better to have a challenge dedicated to that, as in: Given this format and a variable amount of other objects, check if the format and types of these objects match. In which case "%s: %i%%", "Percentage", 25 would be truthy, and "%s: %i%%", 123.45, 25 would be falsey. In addition, most languages are type independent, which can change during run-time based on their use.. 10.0 could be all three types in some languages.. \$\endgroup\$ – Kevin Cruijssen May 2 '18 at 10:07
  • \$\begingroup\$ Suggested re-working of the problem: Given a pattern using only %s and %n (for number), slot in the given list of strings and numbers in the given order, but return a distinct value or throw an error if the given list doesn't fit right. \$\endgroup\$ – Adám May 2 '18 at 10:08
  • \$\begingroup\$ @Angs dependent typing. In fact, this challenge is about dependent typing. \$\endgroup\$ – Akangka May 2 '18 at 10:17
  • \$\begingroup\$ @user202729 well, by compile-time, I mean about typechecking time. I specifically disallow dynamic typing, as one of the point of the challenge is to make the program fail to typecheck if %s format is supplied by integer, etc. \$\endgroup\$ – Akangka May 2 '18 at 10:21
  • \$\begingroup\$ @KevinCruijssen Indeed, not all language can do this challenge. After all the intention is on the dependent typing, which most programming language (but not Idris, Coq, etc) lack. \$\endgroup\$ – Akangka May 2 '18 at 10:26
  • \$\begingroup\$ @Adám nice suggestion. But the type-safe feature (i.e. all error is on type-checking time) is integral part of the challenge \$\endgroup\$ – Akangka May 2 '18 at 10:28
  • \$\begingroup\$ @Akangka I don't understand why my suggestion doesn't satisfy that. You get a list of strings and numbers and need to check against each tag in the format that you've been given the right tag. \$\endgroup\$ – Adám May 2 '18 at 12:12
  • \$\begingroup\$ I think you should limit to some languages (perhaps extend the language list if needed), as the challenge does not make sense in other languages anyway. \$\endgroup\$ – user202729 May 3 '18 at 1:26
  • \$\begingroup\$ @Adám I actually implement your suggestion, except the throw an error part. I make the challenge require the result is type error \$\endgroup\$ – Akangka May 3 '18 at 2:03
  • \$\begingroup\$ @Akangka I don't understand why you insist on language specific features like "type errors" and "compile time". Your examples do not show how to format ss, ns, and nn. You mention float dots, but floats are not part of the examples any more. \$\endgroup\$ – Adám May 3 '18 at 5:46
  • \$\begingroup\$ @Adám thanks about float dots. About language specific features, I just want to create a challenge about dependent typing. \$\endgroup\$ – Akangka May 3 '18 at 6:50
-2
\$\begingroup\$

Quecho, a quine-like implementation of echo.

Challenge:

Your challenge is to write a quine-like program that takes a string from stdin and gives two outputs: Output A is the input string. Output B is your source code.

Output Formats:

You can send your outputs to stdout, stderr, and/or files. If A and B go to the same output, they must be separated by a newline. Having a newline at the beginning of your source doesn't count. You'd need to print that newline from your source and then another newline to separate A and B.

Examples:

source: print($stdin+"\n"+codeThatGeneratesSource)

input: Hello, World!

Both outputs on stdout:

Hello, World!
print($stdin+"\n"+codeThatGeneratesSource)

Separate Outputs:

stdout: Hello, World!

stderr: print($stdin+"\n"+codeThatGeneratesSource)

Standard loopholes are forbidden.

Submissions should be proper quines except that they produce the additional specified output.

\$\endgroup\$
  • \$\begingroup\$ Related: codegolf.stackexchange.com/questions/66276/quat-quine-cat \$\endgroup\$ – Beefster Jun 1 '18 at 16:27
  • \$\begingroup\$ Good find. Not a dupe because that calls for either printing the source or printing the input, not both. Also it requires testing length of input, where this does not. \$\endgroup\$ – Jared K Jun 1 '18 at 16:38
  • 2
    \$\begingroup\$ How is this any different from that, though? The concept of printing the source and printing the output is the same, and I can't see how only a small tweak wouldn't be able to port an answer between the challenges. \$\endgroup\$ – LyricLy Jun 3 '18 at 5:32
-2
\$\begingroup\$
  • This is in sandbox to check whether or not to repost the BrainF**k interpreter challenge. The links have been given in credits.
  • Should comment handling be required.
  • Also any other improvements are welcome

BrainF**k:

BrainF**k is an esoteric programming language designed in the 90s. The reason for its fame is that understanding a program longer than 10 characters in the language is quite hard.

Example program :

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

Guess what this does.


Commands:

Brainf**k operates on an array of memory cells, also referred to as the tape, each initially set to zero. There is a pointer, initially pointing to the first memory cell.

There are a total of eight commands in BF and these are as follows:

Command       |                              Purpose
  >           |      increment the data pointer (to point to the next cell to the right).
  <           |      decrement the data pointer (to point to the next cell to the left).
  +           |      increment (increase by one) the byte at the data pointer. 
  -           |      decrement (decrease by one) the byte at the data pointer.
  .           |      output the byte at the data pointer
  ,           |      one byte of input, storing its value in the byte at the data pointer.
  [           |      if the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command.
  ]           |      if the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.

Note :

+ and - operators increment and decrement the bytes at the at the data pointer, note that if the value reaches 255 then upon a + it would become 0.

255 + 1 = 0

Similarly if the value reaches 0 then upon the next - it would become 255.

0 - 1 = 255

Input:

You will be given two strings as input:

  • The actual BrainF**k code that you are supposed to interpret.
  • the program input (that will eventually be emptied) to be interpreted as an array of bytes using each character's ASCII code and will be consumed by the , instruction

Example:

Program : +[,>,]<.
stdin   : 11111 

Output:

  • the output of the interpreted code, if any was produced by the . instruction.

Example:

For the above mentioned program, the output should be:

output: 1

Notes:

  • Both program and stdin will be given as strings.
  • The output should be a string showing the result after operations.
  • Given input will always be valid, with a valid BrainF**k program.
  • In order to avoid confusion, note that you do not need to output the word output as well

e.g :

 output : 1

in this your output should only be 1. (asked by @Picard)

Credits:

The question was (more or less) already asked here. This has been reposted since that was 7 years old and was outdated as well.

Meta posts on that:


Examples:

Program: +[>>>>+++++[-<++>]<[-<++++++++++>]<[-<<->>]<<-[>-<[-]]>+<,]>[>>+>+<<<-]>>>[<<<+>>>-]<<+>[<->[>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]++++++++[<++++++>-]>[<<+>>-]>[<<+>>-]<<]>]<[->>++++++++[<++++++>-]]<[.[-]<]<
stdin: Hello, World. This is a program for checking eeeeeeee. Well I have plenty of e
output: 14

Program: ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
stdin: 
output: Hello, World

Winning-criteria:

This is , so the shortest code in bytes for each language wins.

\$\endgroup\$
  • \$\begingroup\$ @AdmBorkBork : So i should put nothing ? \$\endgroup\$ – Muhammad Salman Jun 1 '18 at 14:59
  • \$\begingroup\$ @AdmBorkBork : Thanks, done. \$\endgroup\$ – Muhammad Salman Jun 1 '18 at 15:01
  • \$\begingroup\$ I think some of your notes are too ambiguous to be useful. In particular, "You can have numbers as output where numbers are expected" and "The input will be what it should be" seem to just be... "You are allowed to output numbers if you're allowed to output numbers" and "You can assume that the input is the input" \$\endgroup\$ – Kamil Drakari Jun 1 '18 at 15:07
  • \$\begingroup\$ Also, it would be good to clarify whether the BF commands are the only characters that will be in the program string, or if we are required to handle other characters as comments. \$\endgroup\$ – Kamil Drakari Jun 1 '18 at 15:09
  • \$\begingroup\$ @KamilDrakari : Changed. Hopefully better \$\endgroup\$ – Muhammad Salman Jun 1 '18 at 15:09
  • \$\begingroup\$ @KamilDrakari : I think I will put that as something I would like to know (reasons why this is sandboxed)\ \$\endgroup\$ – Muhammad Salman Jun 1 '18 at 15:09
  • \$\begingroup\$ I don't believe comment handling would be interesting, so I would rather leave it as "you may assume the program input contains no characters other than ><+-.,[]" \$\endgroup\$ – Kamil Drakari Jun 1 '18 at 15:32
  • \$\begingroup\$ @KamilDrakari : Okay \$\endgroup\$ – Muhammad Salman Jun 1 '18 at 15:34
  • \$\begingroup\$ What happens if you move left of the starting position on the tape? Is it undefined behaviour or does it have to work? \$\endgroup\$ – wastl Jun 1 '18 at 18:58
  • \$\begingroup\$ @wastl : undefined behaviour is ok. \$\endgroup\$ – Muhammad Salman Jun 1 '18 at 19:00
  • 1
    \$\begingroup\$ 3 things: 1, you need to explain how the memory tape works. You hvaen't really explained that. 2, you should clarify that the output doesn't need to say literally output: 1, you should really allow just 1. 3, don't really bother with comments, it's basically just ignoring other characters. \$\endgroup\$ – Rɪᴋᴇʀ Jun 1 '18 at 22:37
  • \$\begingroup\$ 1. Hopefully done, 2. done, 3. Ok, 2 votes for not having comments. \$\endgroup\$ – Muhammad Salman Jun 2 '18 at 9:26
  • \$\begingroup\$ What if our language has only one input stream? Can we also accept input as the program and input separated by a ! (or some other character)? \$\endgroup\$ – Jo King Jun 4 '18 at 2:11
  • \$\begingroup\$ @JoKing : yes, you can \$\endgroup\$ – Muhammad Salman Jun 4 '18 at 7:42
-2
\$\begingroup\$

Longest reference

Write two code A and B, where len(A)<=1024, running A returns B and running B returns A. Longest B win.

Proper quine rule and no rubbish rule(for code-bowling) apply.

Un-used Code

All code must be used. Meaning the program must fail to always properly complete the task if any individual character (or varying set(s) of characters) is/are removed. Naturally, a subset of the program should not be able complete the task on its own without the rest of the program.

Sandbox notes

  • The "1024" may change
\$\endgroup\$
  • 1
    \$\begingroup\$ Actually we have no standard rule for code-bowling to prevent unused code. \$\endgroup\$ – user202729 Jul 5 '18 at 9:52
  • \$\begingroup\$ (although for this particular challenge, it's not possible to make program arbitrarily long) \$\endgroup\$ – user202729 Jul 5 '18 at 9:53
  • 3
    \$\begingroup\$ It's pretty easy to abuse this one. Program A prints program C n times, where program C prints program A and then comments out any further copies of C. Make n as large as you can and it's easy. Good code-bowling challenges usually have more restrictions \$\endgroup\$ – Jo King Jul 5 '18 at 10:34
  • \$\begingroup\$ @JoKing Your solution seems to break the "no rubbish rule" \$\endgroup\$ – l4m2 Jul 6 '18 at 1:10
  • 1
    \$\begingroup\$ As user202729 says, there is no standard "rubbish rule". And if there was, there would be many ways of getting around it. \$\endgroup\$ – Jo King Jul 6 '18 at 1:25
  • 1
    \$\begingroup\$ Suggestion: Why not have the challenge be to minimise the length of A while maximising the length of B? I'm not sure what the scoring system would be though... \$\endgroup\$ – Jo King Jul 7 '18 at 3:25
  • 2
    \$\begingroup\$ @JoKing I really like that idea but I don't think it would solve the problem. The issue is that B can still contain "rubbish", so it becomes a kind of busy-beaver problem for A to print the largest amount of nonfunctional code in B. \$\endgroup\$ – Nathaniel Jul 7 '18 at 4:28
  • 3
    \$\begingroup\$ The "unused code" test is unlikely to be practical for programs longer than about 100 characters. \$\endgroup\$ – Peter Taylor Jul 7 '18 at 12:04
-2
\$\begingroup\$

Sort on an infinite-dimension cube

Given a unit cube in the \$n\$-dimensional space. Assume that the vertices of the cube has coordinate \$(x_0, x_1, x_2, \dots, x_n)\$ where \$x_i \in \{0,1\} \forall i\in \mathbb N, 0\le i<n\$.

It's possible to number all vertices with non-negative integers less than \$2^n\$. In this challenge, the vertex with coordinate \$(x_0, x_1, x_2, \dots, x_n)\$ will be assigned with number \$2^0\times x_0+2^1\times x_1+\dots+2^n\times x_n\$.

Each vertex can hold an integer.

In this challenge, you can assume \$n\$ contains a very large (practically infinite) value.


Given \$4096\$ items placing in vertex 0 - vertex 4095, you're to sort them. Other vertices contain undefined values, and may be modified by the program.

However, the program cannot directly access the values held by the vertices. You can only control a memory pointer M, which always lie at a vertex of the cube (call this vertex V). Initially M is at the coordinate \$(0,0,0,\dots)\$. This memory pointer can store exactly 1 integer value.

The following operations on the memory pointer M are alllowed:

  • Store the value held by V into memory of M.
  • Write the value stored by M into V.
  • Compare value stored by M and value held by V. This operation should report to the program 3 different values based on whether the comparison is \$<\$, \$=\$ or \$>\$.
  • Move along an edge (in the direction specified by the program) of the cube. This corresponds to changing exactly 1 coordinate of M from 0 to 1, or vice versa.

Your score is the distance traveled by the memory pointer.


A psuedo-code sample interaction library may be:

obj[Infinity] = {[4096 values]}
ptr = 0, cry = undefined
function move(i): ptr = ptr xor (1 shl i)
function carry(): cry = obj[ptr]
function place(): obj[ptr] = cry
function compare(): return sgn(obj[ptr] - cry)

You can write functions, use IO, or anyway to interact. Lowest move callings win.

\$\endgroup\$
  • \$\begingroup\$ Actually I think there are just 12 dimensions. \$\endgroup\$ – user202729 Jul 12 '18 at 14:55
  • \$\begingroup\$ @user202729 More dimensions exist and you can use them, but they are initally empty \$\endgroup\$ – l4m2 Jul 12 '18 at 14:59
  • 5
    \$\begingroup\$ What does it mean to sort an infinite-dimension cube? Currently this very unclear. \$\endgroup\$ – Laikoni Jul 13 '18 at 12:46
  • \$\begingroup\$ @Laikoni I'd say code shows enough to understand, so it's not ready to post but not unclear \$\endgroup\$ – l4m2 Jul 13 '18 at 14:25
  • 2
    \$\begingroup\$ No, sorry, it's not so clear to the rest of us. I have no idea what the input is, what the output is, even what obj we're working with and how it relates to an "infinite dimension cube". Many of your questions here (including this one) seem to contain something interesting in them, but they'd be much better received if you post them on the chat room first and explained what you had in mind, and got some help with the question text, at least to the level that they can be meaningfully discussed on. That way your challenges will reach more people too. \$\endgroup\$ – sundar Jul 15 '18 at 10:41
  • 5
    \$\begingroup\$ @sundar I think the sandbox is exactly the place for improving challenges. I'm not sure if using the chat room is necessary. \$\endgroup\$ – user202729 Jul 19 '18 at 14:35
  • \$\begingroup\$ @Laikoni Better now? \$\endgroup\$ – user202729 Jul 19 '18 at 15:10
-2
\$\begingroup\$

Golf a regex that matches syntactically valid programs in the language of your choice.

1: Pick a programming language, P, that meets these requirements:

  • P is known to be Turing-Complete.
  • P has a freely available and working compiler or interpreter.

2: Create a regular expression, R, such that:

  • R matches any string that is a syntactically valid program of P.
  • R rejects any string that is a syntactically invalid program of P

3: Golf R. Shortest regex wins.

\$\endgroup\$
  • 1
    \$\begingroup\$ For a lot of Esolangs it would just be .*, I think you'd need to restrict the languages to something that doesn't allow any string ALPHABET* or ALPHABET+. Also you'd need to specify a regex flavour. \$\endgroup\$ – ბიმო Jul 27 '18 at 20:49
  • \$\begingroup\$ Warning: Most low-level languages are not known to be TC. For example C (which is only recently proved TC, AFAIK. Ref) \$\endgroup\$ – user202729 Jul 28 '18 at 9:21
  • \$\begingroup\$ Hm. int main(){int x=__builtin_popcount(1);} is not syntactically valid C (undefined identifier), but it compiles in GCC. Also, most compilers don't allow too long identifiers. What do you think? \$\endgroup\$ – user202729 Jul 28 '18 at 9:23
  • 3
    \$\begingroup\$ @user202729: I doubt that you'll find a regex for C (or pretty much any non-esoteric, high-level language) anyways since most of the time you need to check if () are balanced. \$\endgroup\$ – ბიმო Jul 28 '18 at 15:21
  • \$\begingroup\$ @OMᗺ Just saying...... // For the first comment, typically the answerer just specify the regex flavor in the answer. \$\endgroup\$ – user202729 Jul 28 '18 at 15:23
  • \$\begingroup\$ Because only those high-level languages have a proper definition of what is a syntax error. The low-level languages are often just "what the interpreter complains about", and there are still different forms of error -- assertion error, runtime, return 1, .... \$\endgroup\$ – user202729 Aug 1 '18 at 2:49
-2
\$\begingroup\$

Largest and Smallest Numbers Printable

Related: Largest Number Printable

Your goal is to write code that produces a large number. However, when your code is reversed, you must output a small number.

Rules

  • No constants over 10 (like the other challenge)
  • No numeric literals
  • No infinite numbers
  • Each program can only output one number
  • You must have at least two bytes in your program.
  • Your small number must be less than your large number.

Scoring:

Your score is: \$\frac{code~length}{N_{large} - N_{small}}\$. Smallest score wins.

\$\endgroup\$
  • \$\begingroup\$ Ban numeric literals. having the code of n 9's and n 0's in a golving language with auto output results in having a score of \$\frac{2n}{(10^n-1)^2}\$ which will go to 0 for arbitrary large n \$\endgroup\$ – Kroppeb Aug 25 '18 at 11:26
  • \$\begingroup\$ Even with "no constant over 10" the strategy above will still works in languages such as cat. \$\endgroup\$ – user202729 Aug 25 '18 at 14:16
  • \$\begingroup\$ @kroppeb that's interesting, thanks. \$\endgroup\$ – NoOneIsHere Aug 25 '18 at 14:49
  • \$\begingroup\$ Like the other challenge I'd suggest a maximum code length and putting a higher penalty on code length. Also, are we allowed to print negative numbers? \$\endgroup\$ – Jo King Aug 28 '18 at 6:14
-2
\$\begingroup\$

The Tiniest Generic Evolutionary AI



Introduction

The smallest program you can make (measured in bytes) that builds evolving AIs that parses unknown text string A into unknown text string B that still evolves.

All languages are options. Internet connectivity is allowed (but not providing any specific links). The AI must have a choice of commands (allowing variables) from a Turing Complete instruction set.


Scoring

Scoring is two fold: N = Number of bytes of program (ignoring size of AIs generated)

T = The average generations (generations of 200 AIs or less) before your program can evolve an AI that can do the 5 test cases.

Score = 1000/(N*T)


Challenge

Rules: Using the fewest bytes possible, create a generic evolutionary AI that will evolve to parse one supplied but previously unknown string into another supplied but previously unknown string.

What qualifies as an evolutionary AI in this context:

Your Code
Takes an input string
Takes a seed AI Instruction Set(s)
Runs AI Instruction Sets
Rates Each AI Instruction Set against others and against test strings
Evolves AI to create a new set of AI Instruction Set(s) through random mutation and breeding of existing AIs.
=================
AI Code
Is not written by you (except for possibly a seed AI), to be created by your program instead.
Uses a set of *available* instructions that are or are inspired by a known Turing complete instruction set (such as RISC)
Should consist of references to the available instructions and values for them.
  1. The code you write does not parse the strings directly. Instead, it writes output that is a collection of instructions, and reads in a collection of instructions and applies these instructions. (Ugly as it may be, eval is allowed).

  2. It reads in multiple optional instruction sets.

  3. It rates those instruction sets based on which gets closest to parsing the input string into the target string.

  4. The best performing instructions sets are encouraged in some way.

  5. The worst performing instruction sets are discouraged and/or eliminated in some way.

  6. Using existing AI-oriented libraries is discouraged.

  7. Allowing evolutionary AIs to use develop using a turing-complete set of instructions is encouraged. (Example solution uses a modified RISC instruction set.)

  8. Instruction sets must be able to mutate (randomly change) between generations. They are allowed to breed (selectively change) between generations as well.

  9. Multiple iterations of comparing and evolving instructions sets is possible.

  10. How quickly your AIs evolve or how well they do the job doesn't matter so much as they can get better at the task over iterations.

  11. A seed starting instruction set is allowed. If your solution requires an inputed file for an initial instruction set, a functional example is required and counts towards the byte count.

  12. It handles if an instruction set it runs fails to complete, or times out if an AI instruction set goes on too long (default to 30 seconds).

  13. Program must accept in one arbitrary string from a source. (Your choice of a generic commonly used source, such as a web form, command line, or file). It outputs each AI instruction set's result in a similar format it took them in. It may also optionally accept a starter AI set of instructions.

  14. The AI code never gets to interact with the test string it's being graded against.

  15. Your program cannot do any string conversions on the input string on its own, only may act as it's instructed to by the AI.

  16. A seed AI is not allowed to have anything more than a start, end, or return call of some kind (it must evolve any processing steps on its own).


Test Cases:

Can the program evolve an AI that approaches being capable of string conversion of an unknown conversion? (It is recommended not to build the AI to these specific test cases, these are for the point of testing genericness. Do not specifically target these cases until reporting results, and others testing your program may test them against other string conversions and rate accordingly.)

Five examples follow -

abcdefghijklmnopqrstuvwxyz

will be converted into

zyxwvutsrqponmlkjihgfedcba

or possibly

1010101100110101011001

will be converted into

0101010011001010100110

or possibly

"Mary had a little lamb."

will be converted into

"Gary had a little ham."

or possibly

"Banana"

will be converted to

"Banananananananananananananananana."

Or maybe

The entire text of the Bible

will be converted to

The entire text of the Bible, but every instance of "sheep" is replaced with "codfish".


Short Diagram of interaction.

   STEP 1                         STEP 2                     STEP 3  ...

 Input String           ->
 Expected Output String ->   Your Code Starts  ->    Assorted AI Instruction sets. ->      ->        ->       ->      Your Code Processes AI Instruction Sets -> Your code compares, mutates, and breeds AIs to create new generation -> Return to Step 3
 Seed AI                ->                     (Example: AI1 -> Start(Input); Output(Input)
                                                         AI2 -> Start(Input); CP(Mem1, Mem2); Output (Mem2);)

Example

An on-a-whim project done that roughly followed these rules and inspired this challenge that ran <1000 lines of code (although short, it did not aim for minimal characters.)

myLittleAI

\$\endgroup\$
  • 1
    \$\begingroup\$ There are a lot of restrictions and rules, however there is no clear description of the task itself: What does "parse one string into another string" mean? About the rules: Overriding loop-holes such as allowing internet-connectivity is likely to create problems or allow boring answers. "Answer must evolve using options that are or are inspired by a Turing complete instruction set." seems like it's a non-observable requirement (and you override the rule in the second rule anyways). Why do you want to disallow libraries? \$\endgroup\$ – ბიმო Sep 22 '18 at 23:01
  • \$\begingroup\$ Some of the other rules don't make sense to me, but it's likely to be caused by me not being able to understand the challenge itself. \$\endgroup\$ – ბიმო Sep 22 '18 at 23:01
  • \$\begingroup\$ @BMO Reason to disallow libraries is that there are existing libraries that are AI libraries. Allowing them means you just call some monolithic AI library and you're done. I guess it'd make sense to just not allow AI libraries though? \$\endgroup\$ – liljoshu Sep 24 '18 at 15:57
  • \$\begingroup\$ Maybe disallowing AI-libraries could be a sensible idea, but I wouldn't know how to put this (ie. what is an AI-library and what is a regular library) formally. Though the standard (this does not mean that it's always the case or that you need to follow it) is to not disallow such things but rather discourage it. If I'd use a library which is not part of the standard libraries it would count as a different language, eg. Python 3 + scikit and in a perfect world less interesting submissions would be given less upvotes. \$\endgroup\$ – ბიმო Sep 24 '18 at 17:00
  • \$\begingroup\$ @BMO Rewrote it, does this look better? \$\endgroup\$ – liljoshu Sep 24 '18 at 18:29
  • \$\begingroup\$ I think the rules do look more structured and clean, but I still don't understand the challenge itself. Some questions I think the challenge should answer for which I can't find an answer might help: Are you requiring a program, function or a set of functions? What is the input and output format? What makes a solution valid? What is parsing string A to string B? \$\endgroup\$ – ბიმო Sep 24 '18 at 22:38
  • \$\begingroup\$ Also, keep in mind that golfed solutions might try to find some kind of weaknesses in your definitions to reduce the problem to the easiest way of solving it which might result in solutions that aren't very interesting from an AI perspective. This challenge might fit better test-battery (you can set a byte-limit motivated by your own code if you want). \$\endgroup\$ – ბიმო Sep 24 '18 at 22:43
  • \$\begingroup\$ There are 2 critical pieces to this challenge that need to be clear before we can really make this post: 1. What are "Instructions"? 2. When an InstructionSet applies a string, what feedback does the AI get? \$\endgroup\$ – Nathan Merrill Sep 25 '18 at 16:37
  • 1
    \$\begingroup\$ Finally, realize that rule #10 simply means I can iterate over every possible program until I land on one that works, no AI needed. \$\endgroup\$ – Nathan Merrill Sep 25 '18 at 16:40
  • \$\begingroup\$ @NathanMerrill Did some clarifying randomness... better? \$\endgroup\$ – liljoshu Sep 27 '18 at 18:49
  • \$\begingroup\$ Not really. Let's chat \$\endgroup\$ – Nathan Merrill Sep 27 '18 at 19:10
-2
\$\begingroup\$

Rotations Required

Given input 2 values:

\$x >= 0\$ :Distance to travel (float)

\$r>0\$ :Radius of wheel (float)

Output the number of rotations required by the wheel to travel that distance.

Constraints:

Your code must not contain any digits.

You cannot use pi functions (math.pi)

Output must be an integer.(In case exact int is not obtained, floor it) 1.0 is not a valid output, it should be 1.

Test Cases

x       r    o/p
50      1    7
0       34   0
50      0.3  26
44      33   0
5.5     5.5  0
105     5    3
155     5    4
6.28318 1    1 #This signifies that pi was approximated to 3.1419

Scoring:

Score= No. of bytes+20/number of digits taken for pi after decimal point

If you have taken more than 10 digits:

Score= No. of bytes

\$\endgroup\$
  • 3
    \$\begingroup\$ "You cannot use pi functions" is an unobservable requirement, which is not allowed. You need some test cases. The no-digits rule won't actually make this problem harder for most golflangs. \$\endgroup\$ – Nathan Merrill Oct 16 '18 at 12:43
  • \$\begingroup\$ @NathanMerrill The latter is less problematic (and more objective) than the former. \$\endgroup\$ – user202729 Oct 16 '18 at 14:21
  • \$\begingroup\$ Test cases are not strictly required, but it would make it easier to check if a solution is definitely incorrect. \$\endgroup\$ – user202729 Oct 16 '18 at 14:22
  • 3
    \$\begingroup\$ Info: Adding constraints just "because the challenge is too easy" usually doesn't make it more interesting (unless the constraints are the main difficulty of the challenge, for example for radiation-hardened challenges) \$\endgroup\$ – user202729 Oct 16 '18 at 14:24
  • \$\begingroup\$ I will add test cases. @NathanMerrill, there just shouldn't be any inbuilt functions that give pi directly is what I want to say. \$\endgroup\$ – Vedant Kandoi Oct 17 '18 at 5:35
  • \$\begingroup\$ @VedantKandoi I understand what you want, but we allow any language on this site, and it's impossible to define what a "pi-giving function" is to work for all possible languages. \$\endgroup\$ – Nathan Merrill Oct 17 '18 at 6:26
  • \$\begingroup\$ Is there any other way I could word it then, as I don't want python, java etc. users to use math.pi or should I just remove it? \$\endgroup\$ – Vedant Kandoi Oct 17 '18 at 7:15
  • \$\begingroup\$ Also, since pi is in the formula, exact int will never be obtained, and if anyone uses approximate value of pi, they may get exact int at certain value or 1 less than desired answer. What can I add for this? \$\endgroup\$ – Vedant Kandoi Oct 17 '18 at 7:48
  • \$\begingroup\$ I changed the scoring method for the above issue, so should be okay now. \$\endgroup\$ – Vedant Kandoi Oct 17 '18 at 8:15
  • \$\begingroup\$ Why would the output be floored? Surely you should use ceiling so that the wheel is actually travelling that distance. \$\endgroup\$ – Jo King Oct 17 '18 at 8:26
  • \$\begingroup\$ I was thinking of something like how many full rotations need to be completed. \$\endgroup\$ – Vedant Kandoi Oct 17 '18 at 8:31
  • 2
    \$\begingroup\$ "Not using a pi function" is a non-observable program requirement, which is one of the things to avoid when writing a challenge. I don't see any way to fix this challenge: fundamentally what it's asking is too trivial to be interesting. My advice would be to delete the body of this answer and then delete the answer (to keep the sandbox tidy) and then to try to come up with a challenge which is inherently interesting enough that it doesn't need that kind of restriction. \$\endgroup\$ – Peter Taylor Oct 17 '18 at 14:06
-2
\$\begingroup\$

Write a Self-Hosting Ouroboros: each quine produces the next quine AND its interpreter

My meta-questions, please give feedback and/or add your own:

  • Too elaborate or long post?
  • Rules too strict? Too lax?
  • Not having a deadline: good or bad idea?

A Quine is a program that prints its own source code as output when it is run.

A Self-Hosting Quine (which is something I just made up, although I'm sure it exists already) is a quine that also produces an interpreter/compiler/emulator/whatever for itself (from now on I will just say "interpreter").

I believe this actually means that a lot of essential functionality must be "circularly defined" - for example, to print output, the interpreter must rely on the parent interpreter's ability to print output. So maybe we should call this a Von Munchausen Quine?

An Ouroboros Program or Quine Relay is a quine that prints a different quine, which then prints yet another program, and so on, until the last quine produces the original quine. See this famous example that cycles through over a hundred languages.

A Self-Hosting Ouroboros, then, is quine that produces a program in another language, and also produces an interpreter for that language. The interpreter should be in the current language, so that the next quine can immediately be run and produce the quine after that.

Tangent: obviously, the idea can also be extended to interpreter multiquines but that can be another challenge. Let's make Von Munchausen's Ouroboros first!

Rules

  • The ouroboros must be able to make a complete cycle
  • Score by total quines in chain / shortest source code (in bytes) in the chain (bytes to allow non-textual outputs)
  • Empty quines and interpreters do not count - two character minimum
  • Code-golf languages allowed
  • No languages defined just for this challenge - no "I define language x to always produce quine y in C plus the complete GCC compiler when fed any input"-stuff please
  • Quines must be valid code in their programming languages
  • Interpreters that are partial language implementations are fine, however:
    • it must be able to run the quine, and produce the next quine (obviously).
    • it should be able to run any other correct code that is limited to the same language subset¹. No hyperfitting²!
    • for the sake of code golfing it may accept incorrect code that a normal interpreter should not (the quine is already restricted to correct code anyway)

Clarifications

Yes, you can make a quine that produces itself and its own interpreter

Counts as a 1-chain ouroboros.

What would an "interpreter" for machine code be?

An emulator. Which of course needs some way to load a program and produce the output. You may define a fictional simplified, minimal hardware set-up to do so. For example: a (partial) Z80 emulator where:

  • two hardware ports are connected to send output bytes to (one for interpreter, one for quine). Are those bytes interpreted as raw bytes/ASCI/UTF8 text/whatever? Up to you!
  • the program is already loaded in memory, at whatever address is most convenient (quine too big to fit in the addressable memory space? Define an input port to scan bytes from I guess :P)
  • the PC (program counter), and SP (stack pointer) registers initiate at whatever value is most convenient for creating a quine in Z80 opcode

Obviously, no set-ups with fictional ROM that just happens to contain a new quine, or stuff like that (even though this would be hard to really abuse, since that ROM would still need to be implemented in the emulator).

Am I seriously expecting anyone to create an emulator like this? No, but let's keep the possiblity open (some stack machines might be code golf-friendly enough for the challenge).

"Borrowing" snippets from each other is encouraged, but give accreditation and link to sources!

Because we all really just want to see how long this can get, no? Besides, whatever you take probably has to be heavily modified to fit it in your existing ouroboros chain anyway. Sharing is caring, and accreditation is the decent thing to do.

No dead-line, nor will a winner be selected. Just make as long a chain as possible.


¹ You wrote an interpreter for a subset of Rust, but it doesn't feature the borrow checker? That is fine long as:

  • it works with correct Rust code limited to the language subset
  • it works with the quine itself
  • the quine itself is correct rust code

² Example of what I do and do not consider hyperfitting: if your interpreter can deal with for(var i; i < 10; i++) { a[i] = i; } but crashes without the enclosing {} because it expects them to designate code blocks, that counts as a partial implementation. If var only expects i, or < only expects i and 10? Hyperfitting. If var only accepts single letter names, and < only expects variables on the left and literals on the right? Probably hyperfitting but debatable.

\$\endgroup\$
  • \$\begingroup\$ What would the interpreter of a program written in machine code be? \$\endgroup\$ – user202729 Oct 19 '18 at 15:14
  • \$\begingroup\$ How should we separate the quine output and the interpreter output? \$\endgroup\$ – Jo King Oct 21 '18 at 0:10
  • \$\begingroup\$ @user202729: an emulator \$\endgroup\$ – Job Oct 21 '18 at 13:01
  • \$\begingroup\$ @JoKing: hmm, good question. Two separate calls to whatever output method is chosen? (print or its equivalent) \$\endgroup\$ – Job Oct 21 '18 at 13:03
-2
\$\begingroup\$

Unicode encoder

Do Invent your own Unicode 7.0.0 encoding (as efficient as possible) with score 317754(the lowest possible score). Shortest encode+decode program win.

You can either write two programs doing encode and decode, or write one with argument/input method difference deciding whether it's encoding or decoding

As you may know, the Unicode standard has room for 1,114,111 code points, and each assigned code point represents a glyph (character, emoji, etc.).

Most code points are not yet assigned.

Current Unicode implementations take a lot of space to encode all possible code points (UTF-32 takes 4 bytes per code point, UTF-16: 2 to 4 bytes, UTF-8: 1 to 4 bytes, etc.)


Task
-

Today, your task is to implement your own Unicode implementation, with the following rules:

- Write an encoder and a decoder in any language of your choice
- The encoder's input is a list of code points (as integers) and it outputs a list of bytes (as integers) corresponding to your encoding.
- The decoder does the opposite (bytes => code points)
- Your implementation has to cover all Unicode 7.0.0 assigned code points
- It has to stay backwards-compatible with ASCII, i.e. encode Basic latin characters (U+0000-U+007F) on one byte, with 0 as most significant bit.
- Encode all the other assigned code points in any form and any number of bytes you want, as long as there is no ambiguity (i.e. two code points or group of code points can't have the same encoding and vice versa)
- Your implementation doesn't have to cover UTF-16 surrogates (code points U+D800-U+DFFF) nor private use areas (U+E000-U+F8FF, U+F0000-U+10FFFF)
- Your encoding must be context-independant (i.e. not rely on previously encoded characters) and does NOT require self-synchronization (i.e. each byte doesn't have to infer where it's located in the encoding of a code point, like in UTF-8).

To sum up, here are the blocks that you have to cover, in JSON:

[
  [0x0000,0x007F], // Basic Latin
  [0x0080,0x00FF], // Latin-1 Supplement
  [0x0100,0x017F], // Latin Extended-A
  [0x0180,0x024F], // Latin Extended-B
  [0x0250,0x02AF], // IPA Extensions
  [0x02B0,0x02FF], // Spacing Modifier Letters
  [0x0300,0x036F], // Combining Diacritical Marks
  [0x0370,0x03FF], // Greek and Coptic
  [0x0400,0x04FF], // Cyrillic
  [0x0500,0x052F], // Cyrillic Supplement
  [0x0530,0x058F], // Armenian
  [0x0590,0x05FF], // Hebrew
  [0x0600,0x06FF], // Arabic
  [0x0700,0x074F], // Syriac
  [0x0750,0x077F], // Arabic Supplement
  [0x0780,0x07BF], // Thaana
  [0x07C0,0x07FF], // NKo
  [0x0800,0x083F], // Samaritan
  [0x0840,0x085F], // Mandaic
  [0x08A0,0x08FF], // Arabic Extended-A
  [0x0900,0x097F], // Devanagari
  [0x0980,0x09FF], // Bengali
  [0x0A00,0x0A7F], // Gurmukhi
  [0x0A80,0x0AFF], // Gujarati
  [0x0B00,0x0B7F], // Oriya
  [0x0B80,0x0BFF], // Tamil
  [0x0C00,0x0C7F], // Telugu
  [0x0C80,0x0CFF], // Kannada
  [0x0D00,0x0D7F], // Malayalam
  [0x0D80,0x0DFF], // Sinhala
  [0x0E00,0x0E7F], // Thai
  [0x0E80,0x0EFF], // Lao
  [0x0F00,0x0FFF], // Tibetan
  [0x1000,0x109F], // Myanmar
  [0x10A0,0x10FF], // Georgian
  [0x1100,0x11FF], // Hangul Jamo
  [0x1200,0x137F], // Ethiopic
  [0x1380,0x139F], // Ethiopic Supplement
  [0x13A0,0x13FF], // Cherokee
  [0x1400,0x167F], // Unified Canadian Aboriginal Syllabics
  [0x1680,0x169F], // Ogham
  [0x16A0,0x16FF], // Runic
  [0x1700,0x171F], // Tagalog
  [0x1720,0x173F], // Hanunoo
  [0x1740,0x175F], // Buhid
  [0x1760,0x177F], // Tagbanwa
  [0x1780,0x17FF], // Khmer
  [0x1800,0x18AF], // Mongolian
  [0x18B0,0x18FF], // Unified Canadian Aboriginal Syllabics Extended
  [0x1900,0x194F], // Limbu
  [0x1950,0x197F], // Tai Le
  [0x1980,0x19DF], // New Tai Lue
  [0x19E0,0x19FF], // Khmer Symbols
  [0x1A00,0x1A1F], // Buginese
  [0x1A20,0x1AAF], // Tai Tham
  [0x1AB0,0x1AFF], // Combining Diacritical Marks Extended
  [0x1B00,0x1B7F], // Balinese
  [0x1B80,0x1BBF], // Sundanese
  [0x1BC0,0x1BFF], // Batak
  [0x1C00,0x1C4F], // Lepcha
  [0x1C50,0x1C7F], // Ol Chiki
  [0x1CC0,0x1CCF], // Sundanese Supplement
  [0x1CD0,0x1CFF], // Vedic Extensions
  [0x1D00,0x1D7F], // Phonetic Extensions
  [0x1D80,0x1DBF], // Phonetic Extensions Supplement
  [0x1DC0,0x1DFF], // Combining Diacritical Marks Supplement
  [0x1E00,0x1EFF], // Latin Extended Additional
  [0x1F00,0x1FFF], // Greek Extended
  [0x2000,0x206F], // General Punctuation
  [0x2070,0x209F], // Superscripts and Subscripts
  [0x20A0,0x20CF], // Currency Symbols
  [0x20D0,0x20FF], // Combining Diacritical Marks for Symbols
  [0x2100,0x214F], // Letterlike Symbols
  [0x2150,0x218F], // Number Forms
  [0x2190,0x21FF], // Arrows
  [0x2200,0x22FF], // Mathematical Operators
  [0x2300,0x23FF], // Miscellaneous Technical
  [0x2400,0x243F], // Control Pictures
  [0x2440,0x245F], // Optical Character Recognition
  [0x2460,0x24FF], // Enclosed Alphanumerics
  [0x2500,0x257F], // Box Drawing
  [0x2580,0x259F], // Block Elements
  [0x25A0,0x25FF], // Geometric Shapes
  [0x2600,0x26FF], // Miscellaneous Symbols
  [0x2700,0x27BF], // Dingbats
  [0x27C0,0x27EF], // Miscellaneous Mathematical Symbols-A
  [0x27F0,0x27FF], // Supplemental Arrows-A
  [0x2800,0x28FF], // Braille Patterns
  [0x2900,0x297F], // Supplemental Arrows-B
  [0x2980,0x29FF], // Miscellaneous Mathematical Symbols-B
  [0x2A00,0x2AFF], // Supplemental Mathematical Operators
  [0x2B00,0x2BFF], // Miscellaneous Symbols and Arrows
  [0x2C00,0x2C5F], // Glagolitic
  [0x2C60,0x2C7F], // Latin Extended-C
  [0x2C80,0x2CFF], // Coptic
  [0x2D00,0x2D2F], // Georgian Supplement
  [0x2D30,0x2D7F], // Tifinagh
  [0x2D80,0x2DDF], // Ethiopic Extended
  [0x2DE0,0x2DFF], // Cyrillic Extended-A
  [0x2E00,0x2E7F], // Supplemental Punctuation
  [0x2E80,0x2EFF], // CJK Radicals Supplement
  [0x2F00,0x2FDF], // Kangxi Radicals
  [0x2FF0,0x2FFF], // Ideographic Description Characters
  [0x3000,0x303F], // CJK Symbols and Punctuation
  [0x3040,0x309F], // Hiragana
  [0x30A0,0x30FF], // Katakana
  [0x3100,0x312F], // Bopomofo
  [0x3130,0x318F], // Hangul Compatibility Jamo
  [0x3190,0x319F], // Kanbun
  [0x31A0,0x31BF], // Bopomofo Extended
  [0x31C0,0x31EF], // CJK Strokes
  [0x31F0,0x31FF], // Katakana Phonetic Extensions
  [0x3200,0x32FF], // Enclosed CJK Letters and Months
  [0x3300,0x33FF], // CJK Compatibility
  [0x3400,0x4DBF], // CJK Unified Ideographs Extension A
  [0x4DC0,0x4DFF], // Yijing Hexagram Symbols
  [0x4E00,0x9FFF], // CJK Unified Ideographs
  [0xA000,0xA48F], // Yi Syllables
  [0xA490,0xA4CF], // Yi Radicals
  [0xA4D0,0xA4FF], // Lisu
  [0xA500,0xA63F], // Vai
  [0xA640,0xA69F], // Cyrillic Extended-B
  [0xA6A0,0xA6FF], // Bamum
  [0xA700,0xA71F], // Modifier Tone Letters
  [0xA720,0xA7FF], // Latin Extended-D
  [0xA800,0xA82F], // Syloti Nagri
  [0xA830,0xA83F], // Common Indic Number Forms
  [0xA840,0xA87F], // Phags-pa
  [0xA880,0xA8DF], // Saurashtra
  [0xA8E0,0xA8FF], // Devanagari Extended
  [0xA900,0xA92F], // Kayah Li
  [0xA930,0xA95F], // Rejang
  [0xA960,0xA97F], // Hangul Jamo Extended-A
  [0xA980,0xA9DF], // Javanese
  [0xA9E0,0xA9FF], // Myanmar Extended-B
  [0xAA00,0xAA5F], // Cham
  [0xAA60,0xAA7F], // Myanmar Extended-A
  [0xAA80,0xAADF], // Tai Viet
  [0xAAE0,0xAAFF], // Meetei Mayek Extensions
  [0xAB00,0xAB2F], // Ethiopic Extended-A
  [0xAB30,0xAB6F], // Latin Extended-E
  [0xABC0,0xABFF], // Meetei Mayek
  [0xAC00,0xD7AF], // Hangul Syllables
  [0xD7B0,0xD7FF], // Hangul Jamo Extended-B
  [0xF900,0xFAFF], // CJK Compatibility Ideographs
  [0xFB00,0xFB4F], // Alphabetic Presentation Forms
  [0xFB50,0xFDFF], // Arabic Presentation Forms-A
  [0xFE00,0xFE0F], // Variation Selectors
  [0xFE10,0xFE1F], // Vertical Forms
  [0xFE20,0xFE2F], // Combining Half Marks
  [0xFE30,0xFE4F], // CJK Compatibility Forms
  [0xFE50,0xFE6F], // Small Form Variants
  [0xFE70,0xFEFF], // Arabic Presentation Forms-B
  [0xFF00,0xFFEF], // Halfwidth and Fullwidth Forms
  [0xFFF0,0xFFFF], // Specials
  [0x10000,0x1007F], // Linear B Syllabary
  [0x10080,0x100FF], // Linear B Ideograms
  [0x10100,0x1013F], // Aegean Numbers
  [0x10140,0x1018F], // Ancient Greek Numbers
  [0x10190,0x101CF], // Ancient Symbols
  [0x101D0,0x101FF], // Phaistos Disc
  [0x10280,0x1029F], // Lycian
  [0x102A0,0x102DF], // Carian
  [0x102E0,0x102FF], // Coptic Epact Numbers
  [0x10300,0x1032F], // Old Italic
  [0x10330,0x1034F], // Gothic
  [0x10350,0x1037F], // Old Permic
  [0x10380,0x1039F], // Ugaritic
  [0x103A0,0x103DF], // Old Persian
  [0x10400,0x1044F], // Deseret
  [0x10450,0x1047F], // Shavian
  [0x10480,0x104AF], // Osmanya
  [0x10500,0x1052F], // Elbasan
  [0x10530,0x1056F], // Caucasian Albanian
  [0x10600,0x1077F], // Linear A
  [0x10800,0x1083F], // Cypriot Syllabary
  [0x10840,0x1085F], // Imperial Aramaic
  [0x10860,0x1087F], // Palmyrene
  [0x10880,0x108AF], // Nabataean
  [0x10900,0x1091F], // Phoenician
  [0x10920,0x1093F], // Lydian
  [0x10980,0x1099F], // Meroitic Hieroglyphs
  [0x109A0,0x109FF], // Meroitic Cursive
  [0x10A00,0x10A5F], // Kharoshthi
  [0x10A60,0x10A7F], // Old South Arabian
  [0x10A80,0x10A9F], // Old North Arabian
  [0x10AC0,0x10AFF], // Manichaean
  [0x10B00,0x10B3F], // Avestan
  [0x10B40,0x10B5F], // Inscriptional Parthian
  [0x10B60,0x10B7F], // Inscriptional Pahlavi
  [0x10B80,0x10BAF], // Psalter Pahlavi
  [0x10C00,0x10C4F], // Old Turkic
  [0x10E60,0x10E7F], // Rumi Numeral Symbols
  [0x11000,0x1107F], // Brahmi
  [0x11080,0x110CF], // Kaithi
  [0x110D0,0x110FF], // Sora Sompeng
  [0x11100,0x1114F], // Chakma
  [0x11150,0x1117F], // Mahajani
  [0x11180,0x111DF], // Sharada
  [0x111E0,0x111FF], // Sinhala Archaic Numbers
  [0x11200,0x1124F], // Khojki
  [0x112B0,0x112FF], // Khudawadi
  [0x11300,0x1137F], // Grantha
  [0x11480,0x114DF], // Tirhuta
  [0x11580,0x115FF], // Siddham
  [0x11600,0x1165F], // Modi
  [0x11680,0x116CF], // Takri
  [0x118A0,0x118FF], // Warang Citi
  [0x11AC0,0x11AFF], // Pau Cin Hau
  [0x12000,0x123FF], // Cuneiform
  [0x12400,0x1247F], // Cuneiform Numbers and Punctuation
  [0x13000,0x1342F], // Egyptian Hieroglyphs
  [0x16800,0x16A3F], // Bamum Supplement
  [0x16A40,0x16A6F], // Mro
  [0x16AD0,0x16AFF], // Bassa Vah
  [0x16B00,0x16B8F], // Pahawh Hmong
  [0x16F00,0x16F9F], // Miao
  [0x1B000,0x1B0FF], // Kana Supplement
  [0x1BC00,0x1BC9F], // Duployan
  [0x1BCA0,0x1BCAF], // Shorthand Format Controls
  [0x1D000,0x1D0FF], // Byzantine Musical Symbols
  [0x1D100,0x1D1FF], // Musical Symbols
  [0x1D200,0x1D24F], // Ancient Greek Musical Notation
  [0x1D300,0x1D35F], // Tai Xuan Jing Symbols
  [0x1D360,0x1D37F], // Counting Rod Numerals
  [0x1D400,0x1D7FF], // Mathematical Alphanumeric Symbols
  [0x1E800,0x1E8DF], // Mende Kikakui
  [0x1EE00,0x1EEFF], // Arabic Mathematical Alphabetic Symbols
  [0x1F000,0x1F02F], // Mahjong Tiles
  [0x1F030,0x1F09F], // Domino Tiles
  [0x1F0A0,0x1F0FF], // Playing Cards
  [0x1F100,0x1F1FF], // Enclosed Alphanumeric Supplement
  [0x1F200,0x1F2FF], // Enclosed Ideographic Supplement
  [0x1F300,0x1F5FF], // Miscellaneous Symbols and Pictographs
  [0x1F600,0x1F64F], // Emoticons
  [0x1F650,0x1F67F], // Ornamental Dingbats
  [0x1F680,0x1F6FF], // Transport and Map Symbols
  [0x1F700,0x1F77F], // Alchemical Symbols
  [0x1F780,0x1F7FF], // Geometric Shapes Extended
  [0x1F800,0x1F8FF], // Supplemental Arrows-C
  [0x20000,0x2A6DF], // CJK Unified Ideographs Extension B
  [0x2A700,0x2B73F], // CJK Unified Ideographs Extension C
  [0x2B740,0x2B81F], // CJK Unified Ideographs Extension D
  [0x2F800,0x2FA1F], // CJK Compatibility Ideographs Supplement
  [0xE0000,0xE007F], // Tags
  [0xE0100,0xE01EF]  // Variation Selectors Supplement
]

Total: 116,816 code points.

Scoring
--

Your score is the number of bytes that your encoder outputs when you feed it with all the 116,816 possible code points (in one time or separately).

\$\endgroup\$
  • \$\begingroup\$ I suppose 317754 is the optimal score, right? \$\endgroup\$ – user202729 Oct 22 '18 at 9:37
  • \$\begingroup\$ @user202729 Yes if there are 116,816 code points \$\endgroup\$ – l4m2 Oct 22 '18 at 9:38
  • 1
    \$\begingroup\$ p.s. I think you should expand it while it is on the sandbox, just in case somebody don't understand the specification. \$\endgroup\$ – user202729 Oct 22 '18 at 9:38
-2
\$\begingroup\$

Forcing a kernel panic from a mountaintop

This is a thought resulting from a curious incident where C# code opening file apparently caused a BSOD. In the conclusion, it was due to a faulty driver, but from that a thought came up --- can one cause a kernel panic (or BSOD) using managed code exclusively?

Why?

Typically in such environment, there are many compile-time and run-time checks that safeguard the code from doing something that would cause a kernel panic. For a mature managed environment, it should be impossible to cause the operating system to arrive into a bad state. In the case, though it was C# code, the fact that a faulty driver was involved breached the walled garden. But can we breach it from within?

Rules

  • The code must be managed in some fashion (e.g. Java, C#, VB.NET), and normally comes with both compile-time and run-time checks.
  • The code should be running in a virtual machine or equivalent. (e.g. Java's JVM or .NET's AppDomain)
  • The code should NOT rely on any external anything. No extern declarations, no networking, no dodgy APIs.
  • The code should NOT use any construct which allow direct access to resources (e.g. unsafe in C#)
  • The code should use only the native libraries & API available as part of its usual environment.
  • Throwing an exception is not sufficient. To qualify, the code must result in a kernel panic.

Criteria

Essentially a code-golf -

  • The less code to kernel panic, the better
  • The fewer dependencies the code uses to make it happen, the better
  • The code that consistently causes a kernel panic is better than one that only does it sometimes
\$\endgroup\$
  • 2
    \$\begingroup\$ Is the code considered malicious code? \$\endgroup\$ – user202729 Nov 10 '18 at 15:26
  • \$\begingroup\$ What is "managed code"? \$\endgroup\$ – user202729 Nov 10 '18 at 15:26
  • \$\begingroup\$ While it can be used with malicious intent, the goal is more toward proving whether it's possible to unintentionally break through the walled garden. RE: "managed code" --- it might be a .NET-specific term but I use it in general sense to refer to any programming language that usually run in a some kind of sandbox -- I cited Java's JVM or .NET's AppDomain as such examples. Those usually enforce runtime checks in addition to compile-time checks to prevent doing stupid thing like passing a null pointer which usually is a trappable exception. \$\endgroup\$ – this Nov 10 '18 at 19:06
-2
\$\begingroup\$

HTML-tac-toe

Build a one-player tic-tac-toe game with only HTML and CSS.

Introduction

You can do just about anything with a fully-featured programming language, but how much can you accomplish on a Neopets petpage? Inspired by http://www.neopets.com/~vuh

Challenge

Build a one-player tic-tac-toe game with only HTML and CSS.

  • Use no more than one file.
  • GIFs (including animations), PNGs, and JPEGs are allowed.
  • Flash, embedded scripts, iframes, and JavaScript are not allowed.
  • It must work in the at least two standard browsers (FF, Chrome, Safari, Opera, IE)

Inputs: The player will click on a space when it's their turn to move there.

Outputs: The page will show the current board state at all times. The page will play an optimal move whenever the player moves, unless the game is over.

You're free to decide who starts and who has X or O.

Scores

  • -10 per image
  • -1 per opening bracket or brace (< / { )

Brownie points for design, flair, and new tricks!

Example Input and Output

Input:

Click on the top left of an empty grid

Output:

Grid shows my mark where I clicked and the opposite mark in the left middle or top middle.

\$\endgroup\$
  • \$\begingroup\$ I'd recommend against restricting languages, and against score bonuses too \$\endgroup\$ – ASCII-only Jan 22 at 4:15
  • \$\begingroup\$ @ASCII-only I can drop the bonuses without much consequence, but it's not a new challenge without a language or host restriction. Any suggestions? \$\endgroup\$ – Qaz Jan 22 at 4:45
  • \$\begingroup\$ True, but... language restrictions are pretty frowned upon \$\endgroup\$ – ASCII-only Jan 22 at 4:47
  • 1
    \$\begingroup\$ Welcome to PPCG! You may want to check this post out, it certainly helped me when starting with writing my own challenges. Also, your post does not have a well-defined objective winning criterion. It seems like it is atomic code-golf or code-challenge [1/2] \$\endgroup\$ – ბიმო Jan 22 at 19:32
  • \$\begingroup\$ , but you will need to define how answers are scored (in this case lower is worse) and how ties are treated. Also why do you disallow GIFs but JPGs not? I know most will know, but maybe explain or at the very least link to somewhere where the rules for tic-tac-toe are explained. What counts as an X, what as an O? There are a lot of open question atm. [2/2] \$\endgroup\$ – ბიმო Jan 22 at 19:36
  • \$\begingroup\$ JPGs are allowed. (That's the same format as JPEG, just a different extension.) I can change it to 'images', but I'm worried about some image format I don't know of that makes the challenge trivial. More points, more better! That seems clear enough, but I can certainly spell it out. Are ties forbidden? Two entries with the same number of points seem equally good to me, but the first posted could be the winner. If I link to tic-tac-toe rules, does that answer "What counts as an X, what as an O?" or are you asking something else? \$\endgroup\$ – Qaz Jan 23 at 0:13
  • 3
    \$\begingroup\$ "Standard exceptions are allowed IF they work on Neopets.com." How do we know what works on Neopets.com? If we have to create accounts on a random third party site to test answers and know whether they're valid or not, the question should and probably will end up closed with a lot of downvotes. \$\endgroup\$ – Peter Taylor Jan 24 at 15:34
  • 1
    \$\begingroup\$ This isn't very interesting in general. It essentially amounts to creating every possible layout of a tic-tac-toe board and linking them together with clever CSS and HTML hacks so it fits in 25 pages. I think it could be made a bit more interesting by making it atomic code golf scoring on the total number of html files used, lowest scores win rather than limiting the total number of pages. \$\endgroup\$ – Beefster Jan 25 at 20:36
  • \$\begingroup\$ @PeterTaylor very well, dropped that altogether \$\endgroup\$ – Qaz Jan 25 at 22:53
  • \$\begingroup\$ @Beefster The page I link to as the inspiration (neopets.com/~vuh) uses only one html file, and the source isn't too hard to understand, so perhaps I should link to the creator of the page instead, limit the solutions to one page, or both. \$\endgroup\$ – Qaz Jan 25 at 22:53
  • 1
    \$\begingroup\$ I highly suggest looking through current codegolf questions to see which are well-received by the community. This question seems highly arbitrary and leaves too much under-specified. \$\endgroup\$ – qwr Jan 27 at 20:28
-2
\$\begingroup\$

Bit flipper

Given a string s and a positive number n, return the string s with n random bits flipped. (A random number can be generated in any way, including pseudo-random number generators)

Example:

Before:

Hello World

After (n = 2, 2 bits flipped):

Hello wOrld
\$\endgroup\$
  • 2
    \$\begingroup\$ How exact are the bytes being 'flipped'? Are we changing the bits? Is the output deterministic? It doesn't look like you're modifying any specific bit of the byte, or reversing it, or doing bitwise negation. \$\endgroup\$ – Rɪᴋᴇʀ Mar 21 at 1:55
  • 1
    \$\begingroup\$ @Riker well changing from uppercase to lowercase is just xor 32. But they'rem saying byte flipper not bit flipper which is a bit confusing \$\endgroup\$ – ASCII-only Mar 21 at 6:09
  • \$\begingroup\$ @Riker The bits are flipped \$\endgroup\$ – smileycreations15 Mar 21 at 9:42
  • \$\begingroup\$ @JoKing No, that was an example because I didn’t wanted binary non-unicode characters in the post. \$\endgroup\$ – smileycreations15 Mar 21 at 9:44
  • \$\begingroup\$ What is n? On the basis of what little is specified in the question, I would be tempted to write an implementation for n=0 which consists of the empty program in GolfScript... \$\endgroup\$ – Peter Taylor Mar 21 at 16:44
  • \$\begingroup\$ @PeterTaylor A user defined count of how many bytes will be flipped \$\endgroup\$ – smileycreations15 Mar 21 at 18:12
  • 1
    \$\begingroup\$ I think the confusion here is that "bytes" doesn't mean what you think it means. From the lone test case I think what you're trying to ask us is: given a string s and a number n, change the case of n random letters in s - would that be correct? \$\endgroup\$ – Shaggy Mar 22 at 0:41
  • \$\begingroup\$ I assume case was just an example of bit 5 flipping. I'd recommend writing it like Given a string s and a positive number n, return the string s with n random bits flipped. Though from there you run into problems about invalid unicode sequences in the output \$\endgroup\$ – Jo King Mar 22 at 3:45
  • \$\begingroup\$ @JoKing I replaced with your example. \$\endgroup\$ – smileycreations15 Mar 22 at 7:47
  • \$\begingroup\$ What do you mean by Default n = 3? Also, how should programs handle invalid unicode sequences? \$\endgroup\$ – Jo King Mar 22 at 9:14
  • \$\begingroup\$ @JoKing By default, n should be 3. And invalid unicode sequences should not be handled, and the data should be directly printed out to stdout or any output file. \$\endgroup\$ – smileycreations15 Mar 22 at 12:35
  • \$\begingroup\$ When you say random, do you mean of our choice? pseudo-random? fetched from random.org? \$\endgroup\$ – Artemis Fowl Mar 26 at 23:16
  • \$\begingroup\$ @ArtemisFowl It is selected by the program. \$\endgroup\$ – smileycreations15 Mar 27 at 10:45
  • \$\begingroup\$ @smileycreations15 It's gonna be hard to make that 100% random \$\endgroup\$ – Artemis Fowl Mar 27 at 15:46
  • 1
    \$\begingroup\$ @smileycreations15 Maybe you should add that to the question. \$\endgroup\$ – Artemis Fowl Mar 27 at 20:35
-3
\$\begingroup\$

Code-challenge: Guess my number

The challenge

You have a number from 1 to 10 in mind, and your program should ask questions to find out which number. These questions can be any questions, the program only has to find out the number as fast as possible.

Your program should ask a question, such as "Is the number a prime?", and the user must answer either y or n (yes or no). Ask questions until you know the number.

The scoring

To calculate the score, you need to take the sum of the question count for each number. For example, if you need 1 question to find the number 1, 2 questions to find the number 2, and so on, the score is 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10, so the score is 55.

Important note: the question count for a specific number must always be the same. For example, if you need 4 questions to find out the number 10, then you have to ask always 4 questions to find out the number 10, otherwise it is impossible to calculate the score.

\$\endgroup\$
  • 5
    \$\begingroup\$ boooring. The Huffman tree for a uniform set is any perfectly balanced tree. The question asks us to perform a binary search on the usr device. Is the number greater than 5? Is the number greater than 2? Is the number greater than 1? Hey' I think it's 1. \$\endgroup\$ – John Dvorak Jan 2 '14 at 11:49
  • 3
    \$\begingroup\$ Maybe if this were a pop-contest and the goal was to make the most original set of questions while still keeping the score at its theoretical minimum. \$\endgroup\$ – John Dvorak Jan 3 '14 at 5:28
-3
\$\begingroup\$

Bovine Ignorance

I'm curious about code which still works after being mangled by figlet, toilet, cowsay et al, but I'm not sure whether this in any way sane.

What I'm toying with is a challenge in which a participant may submit any program in any language. It should be possible to use this program's source code as input to cowsay or whatever, and the result should be another valid program in any language, which still does a similar thing. For instance, the following bf program prints Hello world! with no newline:

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

Running cat ./prog.bf | cowsay -e .. -T $'>.' yields the following output:

 _________________________________________
/ +++++ +++++ [ > +++++ ++ > +++++ +++++  \
| > +++ > + <<<< - ] > ++ . > + . +++++   |
| ++ . . +++ . > ++ . << +++++ +++++      |
| +++++ . > . +++ . ----- - . ----- --- . |
| > + .                                   |
| +++++++++++++++++++++++++++++++++++++++ |
\ ++                                      /
 -----------------------------------------
        \   ^__^
         \  (..)\_______
            (__)\       )\/\
             >. ||----w |
                ||     ||

Which is itself a valid bf program which prints Hello world!!!, followed by a newline.

The problem with using bf here is that it ignores most of the cow, making this a bit too easy. The problem with using any other language is that it doesn't ignore most of the cow, making this far too difficult. Is there a sensible middle ground I could pick for this? I don't think it's impossible, I'm fairly sure you can exploit cowsay's behavior on one-liners to produce valid svgs, but I'm not sure how best to pose this challenge. Any ideas?

\$\endgroup\$
  • 2
    \$\begingroup\$ I could not think of any language that falls in the middle ground. Even brainfuck is affected by the -----------------------------------------..>.---- inserted by cowsay. Most languages have strong parsing rules that would not cope with being post-processed by cowsay. The few exceptions for this will be either completely unaffected or badly affected, making the challenge uninteresting. \$\endgroup\$ – Victor Stafusa Feb 19 '14 at 12:32
  • \$\begingroup\$ Actually, you can't transform just any brainfuck program to cowsay-brainfuck. Namely those that can output fewer than three characters cannot be transformed at all. \$\endgroup\$ – John Dvorak Feb 19 '14 at 14:52
  • \$\begingroup\$ @JanDvorak, I was intending to allow competitors to choose the parameters of their calls to cowsay. For the uninitiated, -e controls the string used for eyes and defaults to oo, and -T controls the string used for the tongue, defaulting to ` U`. This is all yak-shaving, though, and having written this up and read the comments, I suspect that this idea has neither legs, horns nor udders. \$\endgroup\$ – ymbirtt Feb 19 '14 at 23:19
  • 2
    \$\begingroup\$ If I could propose a variant that is more feasible, you could do a challenge like "Write a program in your language of choice that draws ASCII art of a cow saying something (does not have to be identical or even similar to the cowsay art). The entire drawing must itself be valid source code that does something other than no-op. Post results of both programs." That gives people more leeway to work around the specific restrictions of their compiler. \$\endgroup\$ – Jonathan Van Matre Feb 21 '14 at 23:22
  • \$\begingroup\$ Ok, I found a language that falls within the middle ground: whitespace. Anyway, this question has a too narrow scope to develop an interesting challenge. \$\endgroup\$ – Victor Stafusa Feb 22 '14 at 18:31
  • \$\begingroup\$ @JonathanVanMatre That would be a subjective validity criterion, and would probably be closed as too broad. \$\endgroup\$ – wastl Jul 2 '18 at 13:55
-3
\$\begingroup\$

Create an Identicon Generator

The challenge is to create an identicon generator. The identicons must be randomly generated, so we get a new identicon for each key the program receives. You can input a key using std-in or you can use your language's random number generator for the key.

In order to make your identicon look reasonably nice, it must generate a picture, then rotate that picture around the bottom right corner, the way this mockup shows:

enter image description here

The output must be to a PNG file. Shortest code wins.

\$\endgroup\$
  • 5
    \$\begingroup\$ Far too broad. As this stands I can create a 1-pixel image whose colour is just the key. I don't think this question will be ready to go until you've found a way to prevent me from making the images differ only in their palette (and to pre-empt, I think that adding a rule "Images may not differ only in their palette" isn't a real fix). \$\endgroup\$ – Peter Taylor Mar 28 '14 at 14:50
  • 5
    \$\begingroup\$ If you just ask for "random" images, you'll get images that are either hardly random at all (a solitary pixel in a random location), or completely random (noise). To get something "reasonably nice", you'll have to provide very clear instructions on how to produce these images. I suggest you try creating a few of these yourself, and find a minimal set of rules that produces results that look OK. Include requirements on dimensions (100x100px?), selection of colours (at least 2, not too similar), and drawing method (e.g., "five triangles with random vertices and a minimum area of 20 px²"). \$\endgroup\$ – squeamish ossifrage Mar 28 '14 at 15:25
  • 1
    \$\begingroup\$ How important is the PNG file output? This will be a challenge in itself for many languages. Would you accept an uncompressed non-interlaced format like PPM? \$\endgroup\$ – trichoplax Apr 16 '14 at 9:45
-3
\$\begingroup\$

Underhand Bejewled

Help me to write a game of bejewled, which cannot be lost!

Bejewled game rules

If you ever played bejewled, you can skip this, but for those who did not see it ever:

  • Playing field of 8*8 grid is filled in with gems of 7 different types randomly
  • By swapping two adjective stones, your goal is to create a line of at least three same type of stones in the either vertical or horizontal line
  • If did so, the gems will dissappear, points are added (say 20 points for a matching) and new gems are provided randomly from the top
  • image related:

enter image description here

Your challenge

Provide me a game which cannot be lost. In other words, the gems falling from the top are not random at all, but are falling in order that there is always at least one possibility to match three gems

But, from looking at the code at level of newbie programmer, it should look like that game acts as if it was random

Output

Playable game. As long as it is the grid of 8*8 filled in with 7 different types of "gems" the game is ok. It does not to have killer graphics, neither it does not need to be playable by mouse. (But in that case please make sure you show which "gem" is hovered and then selected)

Winning criteria

This is popularity contest. So highest rated game wins

\$\endgroup\$
  • 1
    \$\begingroup\$ I think this is too big a task to work well for an underhanded contest. The programs will be way too large for anyone to actually read the source and try to find what's underhanded about it. \$\endgroup\$ – Martin Ender Nov 11 '14 at 8:32
  • \$\begingroup\$ Thats what I was also afraid of. I will either take it as lesson to progress on my programming skill, or abandon the idea completly \$\endgroup\$ – Pavel Janicek Nov 11 '14 at 8:38
-3
\$\begingroup\$

This and this gave me an idea, but I'm not quite sure if this can be done at all, or if it is trivial. If it is, maybe point out how it could be changed to be interesting.

Anti golfing - Write the longest program not repeating any character

Well, it's just what the title says. Finally you're allowed to use as much bytes as possible.

Conditions

  • The code of the program or function should not use any character that is used in the code before.

  • Your program should print some sort of result to stdout, or into a file or return a value. You're not allowed to output or return the empty string or only a newline.

  • Other than that your program might do anything. Read input, print lots of output, or what you can think of, but you have to explain what it does, of course.

  • Only characters in the ASCII range [32 .. 126] and newlines are allowed, which limits the maximal code length to 96 bytes.

  • Variable names are only allowed to consist of a single character

  • String literals or the like are forbidden. They could be used to hold the unused characters (though they would need two " in most languages anyway).

  • The same rule applies for similar literal constructs like blocks or what else is there in some languages.

  • Even if the length of a string literal would be used to generate a number, it is forbidden.

  • Variables can not just be declared and never be used. They have to be reflected in the output somehow.

  • If you've read and understood the above rules and still found a loophole and used it, you should go and stand in the corner for a while, thinking about what you've done.

So all in all, only use characters for actual code that does something generating the output, might it be calculating a value or formatting. And don't put unused characters somewhere in your code as a literal. Numbers are an exception, but I guess it's no problem to use them anyway.

I guess you should have a pretty good idea of what would be considered cheating here.

Example in awk

BEGIN{gsub(a,9);print $j-13+d^c/4*5678%20}

It prints 15.5, score is 42.

It replaces the empty string a with 9 in $0, which is the empty string in the beginning. So $0 becomes 9.

Then it prints the result of 9-13+1/4*5678%20.

($j is $0 (==9), because j is not defined

d^c ist 1, because c and d are not defined)

Please don't invent languages for this ;)

The longest code in bytes wins.

\$\endgroup\$
  • 1
    \$\begingroup\$ Are you sure you want to allow ASCII 127? That's the unprintable<DEL> character. The main problem with this challenge is "only use characters for actual code that does something". This is essentially unenforceable, because there may be arbitrarily complicated no-ops in the code. It's also why most code-bowling challenges fail to be popular/interesting. \$\endgroup\$ – Martin Ender Sep 14 '15 at 7:32
  • \$\begingroup\$ Well, I thought about making it a "most votes win" challenge, but I guess that would be unfair for less known users. I don't know what could be done with what you are pointing out. \$\endgroup\$ – Cabbie407 Sep 14 '15 at 7:51
  • 2
    \$\begingroup\$ I don't think this is a good candidate for a popularity contest. Popularity contests shouldn't be used as a cop out if the actual spec is a bit vague. They work best for challenges where the actual scoring criterion can be well specified but is more easily judged by humans than machines (e.g. "visually approximate a given image with these constraints..."). \$\endgroup\$ – Martin Ender Sep 14 '15 at 7:54
  • \$\begingroup\$ Yeah, it's hard to formulate the rules for this. But I think it's not always about finding a winner anyway. Thought this might be fun. Resolved the character 127 situation btw.. \$\endgroup\$ – Cabbie407 Sep 14 '15 at 7:57
  • \$\begingroup\$ How could I change that rule? I'm thinking about "only use code that contributes to the generation of the output" \$\endgroup\$ – Cabbie407 Sep 14 '15 at 8:02
  • 2
    \$\begingroup\$ How do you define "contribute"? E.g. this GolfScript program prints the length of the block in {...} which is a convenient way to stuff all characters except in '"# in there. Do all those random characters actually contribute? In Slashes everything which isn't an unescaped slash is printed to STDOUT, so as long as I put \/ together, I can put any characters I want there and they'll all contribute. \$\endgroup\$ – Martin Ender Sep 14 '15 at 8:07
  • \$\begingroup\$ Hmm, I thought this would be covered by forbidding string literals.. might think about extending that rule to blocks. Well, I'm not that fluent at esolangs. \$\endgroup\$ – Cabbie407 Sep 14 '15 at 8:10
  • \$\begingroup\$ It's trivial to use all possible 96 bytes. Trust me. If you really want to see the program I'm thinking of, I suppose I could write it, but I'm pretty sure it can be done. \$\endgroup\$ – mbomb007 Sep 16 '15 at 18:34
  • \$\begingroup\$ Yeah, I guess you're right. i have no idea how it would be done, but alright. \$\endgroup\$ – Cabbie407 Sep 16 '15 at 20:10
  • \$\begingroup\$ Not to mention this is pretty much a duplicate of codegolf.stackexchange.com/questions/30159/… \$\endgroup\$ – pppery Aug 6 '17 at 12:52
-3
\$\begingroup\$

Linear Time Sorting

It was another slow day at Initech Inc. when a feature request came in:

New Feature: Ability to sort by cash value in the transaction form. But make it a fast one!

Well it looks simple.. but what do the requester mean by fast one? Let's call Jim, from sales he probably knows what's going on.

Jim: Well you know , our Business Inc. contact is very passionate about 

programming and computer science! In fact he had this idea that we should 

do sorting in how that was called.. linear time?


You: Well you know that's impossible?

Jim: But it was already approved by their cto and all! You need to do something

You and Jim came up with a plan.. nobody will notice if that big of a list isn't sorted enough, right?

Your task

Your task is to write a linear time sorting program. It will be scored on accuracy of the sort as compared to list sorted by regular sorting algorithm but it must work on O(N) time in the worst case, where N is length of the input.

Input will be in the form of list of string-double tuples, e.g:

[("aaaa",2.0) , ("aaba",1.0)]

The program should sort on the number value of the tuple, i.e. in the above case the order should be reversed. There may be multiple inputs with the same double values, but no string value is repeated. In the event that two inputs have the same integer value the perfect solution is to keep the order as it is. The double value may be any floating-point value that fits in 8 byte double precision variable. NaNs should be placed at the end of the list.

The score is calculated as number of "bubble sort operations" (switch an element with the next/previous element) needed to achieve perfect output from the output of your algorithm.

Sandbox Worries

Well I don't know how clear my explanation of challenge was and if it is interesting to the PPCG crowd.

Obviously there is a need for testing program and test cases.

\$\endgroup\$
  • \$\begingroup\$ How big will the test cases be? If you pick a fixed size, the response will be "n passes of bubble sort where n is the size of the largest test". Bam, linear with perfect score. \$\endgroup\$ – John Dvorak Apr 11 '16 at 10:12
  • \$\begingroup\$ @JanDvorak I rephrased the scoring sentence to more reflect what I meant. In that case the score wouldn't be perfect as after just n switches the list wouldn't be the most ordered. EDIT: I think I understood it now. Well I think you can somehow exclude answers like that with some caveats in the rules, like "Your algorithm cannot make any assumtions about length of the input" \$\endgroup\$ – Lause Apr 11 '16 at 10:17
  • \$\begingroup\$ I don't make any assumptions. It sorts every array up until the largest test case correctly and all other arrays partially. \$\endgroup\$ – John Dvorak Apr 11 '16 at 10:28
  • 1
    \$\begingroup\$ An algorithm that fares better than n-pass bubble sort is to do a level-n mergesort. If the length exceeds 2^n, sort each [k::len/2^n] subarray separately. \$\endgroup\$ – John Dvorak Apr 11 '16 at 10:32
  • \$\begingroup\$ But then you're making assumptions based on the size of the test cases - if somehow the test cases were changed (but still fitting the rules) to test cases which are much longer (for example you prepared for max 10 element list and you get 100000 element list) your program isn't linear. \$\endgroup\$ – Lause Apr 11 '16 at 10:41
  • \$\begingroup\$ The problem with a spec is that it cannot change once you've posted the challenge, and you can't define "making assumptions based on the size of the test cases". You can't even ban all magic numbers - I can simply use functions merge1 .. merge20 \$\endgroup\$ – John Dvorak Apr 11 '16 at 10:47
  • \$\begingroup\$ It isn't the spec - the way the test cases used to grade the result are constructed is described but do I have to post the test cases (but those used to score) themselves? \$\endgroup\$ – Lause Apr 11 '16 at 10:50
  • \$\begingroup\$ You need to define the test cases, and you can't change them based on the answers (if only because updating the score of every answer would be a nuisance). Maybe you could ask for asymptotic behavior, but that can be surprisingly hard to measure. \$\endgroup\$ – John Dvorak Apr 11 '16 at 10:53
  • \$\begingroup\$ Hidden test cases are a problem as well, because then we can't test the submissions after you're gone. \$\endgroup\$ – John Dvorak Apr 11 '16 at 10:55
  • \$\begingroup\$ The idea was to pregenerate some test cases (undisclosed) and some test cases that are disclosed (for testing purposes during the coding) and then do a cutoff time for the challenge where all the solutions are tested against the undisclosed challenges. Also obviously after the cutoff time the test cases would be disclosed. \$\endgroup\$ – Lause Apr 11 '16 at 10:56
  • \$\begingroup\$ 1. Most real-life data types can be sorted in linear time, so the premise of the question seems badly flawed. 2. "Input will be in the form of list of string-double tuples ... There may be multiple inputs with the same integer values" Huh? Where do the integer values come from? 3. "The double value may be any floating-point value" Where do NaNs sort? \$\endgroup\$ – Peter Taylor Apr 11 '16 at 16:00
  • \$\begingroup\$ 1. The idea is that the data may be the worst case for any algorithm that can achieve linear sorting time 2. It was a typo 3. At the end - I will put it into the question \$\endgroup\$ – Lause Apr 11 '16 at 18:36
  • \$\begingroup\$ Why does the input being worst case make any difference? The solution will still be perfect, so you'll need a tie-breaker to separate every single answer. \$\endgroup\$ – Peter Taylor Apr 11 '16 at 21:27
-3
\$\begingroup\$

Alphabetization 101 (popularity contest)

Your task is to use all 52 letters of both the uppercase and lowercase alphabet, ONCE and ONCE only, and make a program.

You are free to use any other ASCII character more than once, or use a letter of the alphabet more than once if it's required for the language to function.

Meta:

  • Not sure if this has been done before.
  • Any questions regarding the task?
\$\endgroup\$
  • \$\begingroup\$ Not really meta: Is there any place I can go to (like a chat or something) to post a question about BF? StackOverflow probably isn't suitable. \$\endgroup\$ – Qwerp-Derp Apr 17 '16 at 6:48
  • 1
    \$\begingroup\$ Come to our chatroom! :) \$\endgroup\$ – Leaky Nun Apr 17 '16 at 6:50
  • 3
    \$\begingroup\$ I would vote to close this as too broad. It's not a particularly interesting restriction per se, and it certainly doesn't make a good question without some restriction on the task to be performed. \$\endgroup\$ – Peter Taylor Apr 17 '16 at 14:07
  • \$\begingroup\$ @PeterTaylor That's why it's a popularity contest, though - it lets the people decide whether the program made is good or not. What WOULD be a good restriction on the task? \$\endgroup\$ – Qwerp-Derp Apr 18 '16 at 1:40
  • \$\begingroup\$ The popularity-contest tag is not an excuse for a broad challenge. "Write a program that does anything..." is pretty much the definition of "too broad", regardless of any source code restriction put on the program. So at least you should choose a specific task. Could be anything really, but if it relates to the restriction it might be more interesting (e.g. a pangram checker). Even so, I agree with Peter that the restriction isn't particularly interesting. There are tons of languages where it's trivial to avoid unwanted letters and then include the remaining ones in a string or comment. \$\endgroup\$ – Martin Ender Apr 21 '16 at 7:04
-3
\$\begingroup\$

Why did I come to Sandbox?

I have a very specific challenge, and I wanted to see if it was too specific.

The challenge is to output "Valdosta ACM" using the shortest number of characters with the BrainF**k programming language.

I've noticed it isn't the norm to specify a programming language on this domain, so I've come here to get feedback on whether or not this is acceptable.


Introduction

As a challenge to the members of my local Association for Computing Machinery(ACM) chapter, I asked them to produce the shortest Brainf**k code that would output "Valdosta ACM".

This was a very fun challenge for all of our members, and we got very competitive! I was impressed with the solutions turned in, but I wondered if it was possible to beat our best solution. Surely it's possible, but who could do it?

Challenge

Output the string "Valdosta ACM".

Stipulations:

  • Use only the Brainf**k programming language (you can test your code here)

  • No input can be accepted by your program

  • Your program must halt

  • The space in the string must be ASCII character #032.

These are the ASCII values of each character, as they appear in the string, for convenience:

 086 097 108 100 111 115 116 097 032 065 067 077

The winner is determined by the shortest code, by character count.

Example Input and Output

Input:

NO input is allowed

Output:

Valdosta ACM

\$\endgroup\$
  • \$\begingroup\$ Welcome to Programming Puzzles & Code Golf! Thanks for using the Sandbox. :) A few things to note: 1.) Generally we discourage language-specific challenges, 2.) typically code golf is scored by bytes rather than characters, and 3.) printing a fixed string like this would be insufficiently different from the Hello, World! challenge to avoid it being closed as a duplicate. \$\endgroup\$ – Alex A. Apr 25 '16 at 3:38
  • \$\begingroup\$ Thanks Alex! Since I want to compare the results of my local competition with the results of the challenge here, is there anything I could change about the challenge to make it acceptable? I don't see a way to do this, but I was so excited about seeing if anyone here could do better than our coders. And thanks for the warm welcome! :) \$\endgroup\$ – Matt C Apr 25 '16 at 3:48
  • \$\begingroup\$ You could look at Brainf**k solutions to other challenges (like this one), and see if the techniques used there can help you improve your solution. \$\endgroup\$ – ugoren Apr 25 '16 at 7:09
  • \$\begingroup\$ We also have a tips question that may be of interest. \$\endgroup\$ – trichoplax Apr 26 '16 at 6:30
  • 2
    \$\begingroup\$ Although this particular challenge is probably too similar to "Hello, World!" (as Alex pointed out), if you had a different challenge that you wanted to see solutions for in a specific language, you can still post it but just allow all languages to compete. If you don't see solutions in your specific language you can post a bounty for that language to encourage it. \$\endgroup\$ – trichoplax Apr 26 '16 at 6:33
-3
\$\begingroup\$

Cops and robbers : Programmers/Hackers

  • This challenge is quite different from my previous challenges. This challenge is an endless competition between robbers and cops, which are respectively hackers and programmers. One of them will ever win!!!
  • This will evolve to code de/obfuscating when it gets to the higher stages: a skillful programmer who is struggling to save his program from a sourcecode-mangling attempted by a cunning "robber" who tries to impose his existence by patching his name instead of the name of the "programmer" in the output console without changing anything else in the code. The story begins this way:

  • Programmer is at the point of executing his recently made C code, so he included this trivial line to show off:

C (1)

    printf("[Programmer's username]")

After executing this program programmer saw this on the screen:

[Robber's username]

which indicates the presence of some evil code at the compiler level that compromises his code, which follows:

Matlab (2)/parser

      a=findstr(code,'printf(''[Programmer's username]'')'); if a code(a:20)='printf(''[Robber's username]'')';end

The programmer cannot modify the counter-program in the compiler, so he must rather change the program content to escape the twiddling:

PHP (3)

      $a='[programmer's username]';echo $a;

The score is now 3, which is the number of steps from the beginning. The current user would win only if the hacker did not figure out something like:

PHP/Regex(pcre flavor) (4)

      $code=ereg_replace("(\$\w)\='programmer';(.*?);echo\s\1","\1\='robber';\2;echo\s\1",$code)

Since the solution above does not satisfy the rules (see the bottom of this question), the score stays unchanged, and the programmer can make a counter example, and take out the score from last submitter with a penalty on his score equivalent of how much he earned in the earlier level, where the counter example can be something as:

PHP (4)

      $a='programmer';$b=$a;$a='unrelated';echo $a;

Or he can adjust his program in higher scale to escape all the regex-trapping in a superior range, So the cycle goes on until no post can be added and the last submitter before the end of June is declared a potential winner meanwhile.

The hacker can also fix his regex and regain his score, so the recent scoring will be abrogated from programmer.

Perl/dynamic-regex (4)

local @a=('');

sub check{
  if (grep {$_ eq @_[1]} @a)  
   {push @a,@_[0]; } 
  elsif  (grep {$_ eq @_[0]} @a)   {
    my @del_indexes = grep { @a[$_] eq @_[0] } 0..$#a;
    foreach $item (@del_indexes) {
     splice (@a,$item,1);
    }
  }   
return 1;
}

sub actor{
if (grep {$_ eq @_[0]} @a)
 {return "print robber";}
else
 {return "print ".@_[0];}
}


sub initiate{
push(@a,@_[0]);
return 1;
}

$code =~ s/(((\w+)\="programmer"(??{initiate($3);}))|(print\s(\w+))|((\w+)\=(\w+)(?{check(($7),($8));})(?1)))/print($2);actor($5)/pegmx;

As you can see this Perl program prints b in the first case because the variable b is compromised after the first assignment, but in the second case the regex modifies the output because d receives the target-string transitively. Let's just stop here and not mess the fun (of course, if there will be some).

Scoring and rules

How is the score counted ?

  • Any hacker/programmer is scored for his code as the actual level L the game is on.
  • A partial dynamic regex within the core of the program is scored L + (2^L)/log(length of program + length of characters which do not belong to the regex)), where the log is base 2. For the second example of level (4) the length of the compacted program is 480, and the length of regex is 136, so the score is 4+2^4/log2(480+480-136) ~= 4+16/9.6
  • A fully functional regex as in the first example level (4) is scored L + (2^L)/log(length of regex), where the log is base 2, in that case S = 4 + 2^4 / log(91) ~= 4+16/6.5
  • Scores are added progressively to submitters, and when a level is surpassed with no regex, it is still open for scores, while the actual winner remains unchanged.
  • A penalty on a certain-leveled score when the regex/parser is revealed out of rules and the game is regressed to this stage until the issue is fixed, rules are cited below:

Rules:

  • The main rule: the hacker-program must compromise an output to the console, which is the username of the programmer. Any other behavior is unaccepted simply because a string variable of [programmer's username] can be used in other order rather than printing, a counter-example is easy, converting the string to integer then use it for arithmetic calculations that harms the main program once intentionally modified.
  • Also one of the following factors declared by any counter-example bans the targeted flawed regex/parser as non rule-complying:
    • The regex/parser prints anything other than a chosen string preferably set as the username of the robber.
    • The regex/parser generates a program which does not compile.
    • The regex/parser does not print anything, or compromises a segment of code that is needed for tasks other than printing .
  • The variable which stores the program is named code by default, also you may assume that is one-liner, and any non-significant spaces are omitted, and that it is fully working by default.
  • The regex/parser deals with one variant of one code proportion in a comprehensive way, i.e. if a print function is used, that encompasses all printing functions in all languages puts,disp,..etc. Also, code separators can be unified to one characterL either , or ; or a significant space needlessly of enumerating all keywords/syntaxes, this is not a contest about a working code in a specific programming language.
  • To prevent endless program/regex loops let's just not making a jokey sequence as a='programmer';print a / /(\w)\='programmer';print\s\1/ / a='programmer';b=a;print b / /(\w)\='programmer';(\w)\=\1;print\s\2/ because the first person who makes a regex/parser which palliates to a same replicated idea will take out all attributed scores to this idea from their owners, so any anaphoric sequences like this in addition that they are set to same level, they are unneeded.
  • Any language that uses pointers/addresses/classes like C++ are welcome, as long as they help to evade the hacker.
\$\endgroup\$
  • 3
    \$\begingroup\$ Please, for the love of god, spell things correctly. In the first bit alone I spotted a ton of spelling mistakes without even looking for them. Also, that whole first list is... basically impossible to understand, at least for me. Maybe use full sentences? \$\endgroup\$ – Nic Hartley May 10 '16 at 21:29
  • 1
    \$\begingroup\$ Have you seen our cops-and-robbers challenges? It sounds like that is what you are trying to do here. That said, there are a couple of problems with the spec: Defining what parts of the language counts as a "partial regex" or "full regex" is really tough, especially when we get into esoteric languages. \$\endgroup\$ – Nathan Merrill May 10 '16 at 21:36
  • 1
    \$\begingroup\$ Could you add a short summary to the post? I don't understand what the actual task here is. Is this a cops-and-robbers or answer-chaining challenge, or something entirely different? \$\endgroup\$ – Zgarb May 10 '16 at 21:36
  • \$\begingroup\$ i will see what cops and robbers is \$\endgroup\$ – Abr001am May 10 '16 at 21:39
  • \$\begingroup\$ @NathanMerrill this is not a code golf so i dont see the point of introducing esolangs here \$\endgroup\$ – Abr001am May 10 '16 at 22:28
  • 1
    \$\begingroup\$ @Agawa001 Esoteric languages are still useful outside of golfing. You can use them to make it tough for regexes to match. \$\endgroup\$ – Nathan Merrill May 10 '16 at 23:06
  • 3
    \$\begingroup\$ The introduction is very long and after reading it I have no idea what the task is. I would have to vote to close this as "Unclear what you're asking" in its current state. \$\endgroup\$ – Peter Taylor May 11 '16 at 7:45
  • \$\begingroup\$ So what's the core mechanic? Is this an answer-chaining question where answers must alternate programmer and hacker? But if the programmer can change language at will, how can the hacker hope to win? \$\endgroup\$ – Peter Taylor May 12 '16 at 12:06
  • \$\begingroup\$ @PeterTaylor yes it is answer chaining but the last submitter can post two consecutive answers and be the robber and cop themselves, the programmer change his code, hacker changes his regex taken consideration of all last regex/parsers. \$\endgroup\$ – Abr001am May 12 '16 at 16:13
  • 1
    \$\begingroup\$ I have no idea what this challenge is supposed to be. The very little explanation of the concept is muddled by spelling and grammar issues. Please, learn English spelling and grammar before trying to write a challenge. \$\endgroup\$ – Mego May 13 '16 at 5:18
  • \$\begingroup\$ @PeterTaylor refer at the 4th rule, procedures which accomplishes a specific task in different languages are dealt as one thing, this is not a challenge about checking language-syntaxes, when a programmer changes language, consider all previous regex/parsers changed to trap same functionnalities of previous code on the new language. \$\endgroup\$ – Abr001am May 28 '16 at 11:37
-3
\$\begingroup\$

Challenge

Write a program that takes an numerical input n and outputs the nth number that is not a perfect square.

Rules

This is , so least bytes wins.

\$\endgroup\$
  • 3
    \$\begingroup\$ What's the maximum expected input? Does it expect 0? How do we handle 0? Is there a requirement on the efficiency for large inputs? Also give some example inputs and outputs. \$\endgroup\$ – Patrick Roberts Jun 17 '16 at 20:19
  • \$\begingroup\$ Here's some test cases I just generated: 1->2,2->3,3->5,4->6,5->7,6->8,7->10,8->11,9->12,10->13,11->14,12->15,13->17,14->18,15->19,16->20,17->21,18->22,19->23,20->24,21->26,22->27,23->28,24->29,25->30,26->31,27->32,28->33,29->34,30->35,31->37,32->38,33->39,34->40,35->41,36->42,37->43,38->44,39->45,40->46,41->47,42->48,43->50,44->51,45->52,46->53,47->54,48->55,49->56,50->57,51->58,52->59,53->60,54->61,55->62,56->63,57->65,58->66,59->67,60->68,61->69,62->70,63->71,64->72,65->73,66->74,67->75,68->76,69->77,70->78,71->79,72->80 Is this the function you expect? \$\endgroup\$ – Patrick Roberts Jun 17 '16 at 20:41
  • \$\begingroup\$ Yes, yes it is. \$\endgroup\$ – weatherman115 Jun 17 '16 at 20:42
  • \$\begingroup\$ Can you address my other questions please? Namely, the largest expected input and how to handle input of 0. \$\endgroup\$ – Patrick Roberts Jun 17 '16 at 20:43

You must log in to answer this question.

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