# What is the Sandbox?

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

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

## 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]

# Hello, Quine! code-golfquinehello-worldrestricted-source

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

## Rules

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

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

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

# The Self-Referential Algorithm

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

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

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

# The Compressor

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

[list to come]

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

## Rules

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

## Examples

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

### Alternative: code-golf

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

7160708104901559695507628057638725214364226867212714872539720713967912042100814603497742352846014272

Write the shortest possible program that outputs this number.

Related: No strings (or numbers) attached

Questions? Clarifications?

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

# Ulam spiral 2

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

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

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

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

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

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

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

Proposal:

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

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

# Shortest golang code to println the first byte of a function’s code

## Rules

• The code must be a function which takes another function as parameter and will print the first cpu instruction byte of parameter such as :

.

func dummy() {
}
print_first_native_instruction_byte(dummy)


would print :

0x90


which is a nop instruction on x86.

• You don’t need to perform disassembling : if the first instruction is longer than one byte, just print it’s first byte anyway without caring about instruction meaning or instruction length. Please note this is harder than just printing the value pointed by &dummy in the case of my example though.
• The function parameter must be a go function, not a cgo or assembly function.
• You can include as many golang packages as you want.
• The code need to be written in Go. A well known language developped at Google and part of the four Google’s app engines supported languages and answers should be able to run on the official go playground.

## Winner

The one with the shortest code… Import statements included.

• Please note this is a little harder than just getting the value of &dummy in my example code, and requires internal knowlwedge of the official go implementation. but it doesn’t requires architecture specific code beside handling big endian or little endian. – user2284570 Oct 1 '17 at 20:37

# Preposition, not possession

## Enthralling background

Back in 1960s Soviet Russia, communism was the thing, and –– as we all know –– in a completely socialist society, there is ideally no personal property.

Our dear client is an author who is moving to the Soviet Union. However, as is Bolshevik custom, our client is afraid his works will be censored. That is why we are going to help this industrious author by revising his writings so that they will not be censored.

What will be censored? Any overt references to ownership.

How will we do this? Quite simply: we will replace all possession with preposition.

## Let's get specific

### Example

Text in parenthesis is added; text in curly-brackets is removed.

[Input]   All the author's works will be censored!
[Output]  All (the works of )the author{'s works} will be censored!


### Algorithmically

1. For each word with a 's attached to it:
2. Call the word with an 's attached to it _word_
3. Call the following word _object_
4. Remove all 'ss and _object_
5. Insert The _object_ of two words before _word_
6. If there are not two words before _word_, place _object_ right before _word_.

Here are some more examples:

Then the red horse stopped and took the orangutang's oranges. What a fuss ensued!
Then the red horse stopped and took the oranges of the orangutang. What a fuss ensued!

It is the people's right to not own anything!
It is the right of the people to not own anything!

The world's tallest building was once the Empire State Building.
The tallest of the world building was once the Empire State Building.

Bill likes Fred's shoes, and Jill likes Beth's dress.
Bill likes the shoes of Fred, and Jill likes the dress of Beth.

Ryan's fear was a stack overflow.
The fear of Ryan was a stack overflow.


# Output the first digit of Graham's number

Code golf

Write a program that will output the first digit of Graham's number (and nothing else), terminate and produce no error.

I'll be lenient about loopholes. But if your submission is something like print("4"), the burden of proof will be on you.* Also, if you submit 9 answers like that, each printing one digit, then yes, one will definitely be correct, but I will need to know which one, and, you guessed it, the burden of proof is on you.*

* Catch: at the moment, no one has yet worked out what the first digit of Graham's number is.

But I want a "practical" solution. Yes, the algorithm is simple, but I'm sure your computer doesn't have unlimited storage. Nor do language implementations have arbitrarily large int. (OK, some do, but there is memory constraint.)

However, you will have a tape device attached to your computer. The library which is automatically loaded into the interpreter or compiler controls the tape device. Here things do become theoretical: the tape has a beginning, but no end, or you can imagine the device will manufacture more tape to extend it if more is needed. The tape has discrete positions. On each position a sector is stored. The device has access to one sector at the time but it can move the tape. All sectors have the same size.

The library provides you with the following functions (subroutines, whatever):
- detect if the tape is at the beginning
- move the tape left by n positions (stops at the beginning if sent beyond)
- move the tape right by n positions (n has to be one of atomic integer types of your chosen language)
- read the whole sector at current position
- read a part of the sector (zero indexed location within the sector and number of bytes to be read are arguments of an atomic integer type)
- overwrite the whole sector
- overwrite a part of the sector

The names of functions are your choice, as is the size of a sector. Reading loads the contents into a variable / into the memory area starting with a pointer given as an argument. Similar about writing.

Because the tape is effectively infinite, you have no function to tell you the actual position on the tape, as you'd have no way to store the result on a "real" computer.

So the real parts are: computer, possibly tape device.
Theoretical parts are:
- infinite storage tape or availability of material to manufacture as much tape as needed, which may well exceed the total amount of matter in our universe
- the computer, device, tape, ... not deteriorating, getting tangled up nor power falling or anything else going wrong for the time it takes the program to complete the task, which may well exceed total lifetime of our universe.

# Sandbox questions

Ideas how to improve the question... or should I abandon the idea?

• As you say this is code-golf, I think you should better define your library functions (are they well-written and only require one-byte functions or is there considerable cost to using specific library features). – Jonathan Frech Nov 11 '17 at 22:26
• @JonathanFrech I thought I made clear about each of the 7 functions what they do. As for functions' names, some esoteric languages use funny identifiers so I thought I would leave naming to contestants. (I guess everyone will use single character names.) I'm open to suggestions if anyone has a better idea. – Heimdall Nov 12 '17 at 12:19
• Some languages doesn't even have definition of "function" (BF, ///). Some other languages doesn't have definition of "extension/library" (Jelly). Practical is subjective. Sector size is not specified. Atomic integer type is not defined. The amount of memory the program takes depends on several things, not just the program. – user202729 Nov 12 '17 at 12:42
• @user202729 Maybe I should just name the functions and languages that can't handle named functions are out. Although brainfuck should be fine because its built-in commands will, using the library, manipulate the tape device (which enables it to be infinite, not possible otherwise); a sector would then probably only contain 8 or 16 bits. The solution in infinite brainfuck does indeed exist (because it's Turing complete) but how long is it? – Heimdall Nov 12 '17 at 15:13
• Language specific things are heavily discouraged. I would expect some downvotes if you say that. / Some languages may already had that name as builtin (Mathematica E, N). / The issue of unclear-ness of other specifications still remains. – user202729 Nov 12 '17 at 16:47
• @user202729 What other specifications? Anyway, I'm trying to be as language-open as possible, but apart from very few I don't know of any other languages that actually have access to something infinite. So for other languages some kind of extension to get new actions is necessary. Is that too language specific? Maybe I should give up on this question, considering the popularity vote... – Heimdall Nov 13 '17 at 10:23

# Highest code size∕output ratio to generate a large executable section inside an elf file.

Your challenge is to create the shortest code in your language of choice or the tools of your choice (like objcopy) that will create an elf file with a the executable section as large as possible.
I mean that if I extract the.text section of the elf binary, the resulting extracted file should be at least 90% of the elf binary.

# Requirements

• The program should takes the desired section size as input.
• The .text section name needs to corresponds to the executable section.
• The type of the .text section should bePROGBITSand it should contains instructions.
• The elf file should have a .shstrtab section.
• The .text section should be readable and writable.
• The target architecture should be Pnacl or armelv7 or x86_64.
• The elf file should be valid and pass Google nacl’s validation whitelist in order to be loaded (but I don´t care if the sandbox segfault).
If you have no idea about what Google native client is, just create a script that call the patched version of binutils from the nacl_sdk, or make sure the elf file is valid and can be executed on Linux.

Of course, you normally can’t use a compiler because it would takes too much computational years in order to finish.

# Winner

The answer with the highest code size∕program output ratio.

• Why not make scoring output size / code size? – dkudriavtsev Apr 4 '17 at 3:49
• Make it a code-challenge – dkudriavtsev Apr 4 '17 at 3:49
• This is essentially the same challenge as this one, and would be closed as a duplicate. Although it's not exactly the same, some answers to the previous question would require very little modification and answers to this question would also require very little modification to be answers to the other one. – Peter Taylor Apr 4 '17 at 8:37
• @Alt-F4 : it was a code challenge. – user2284570 Apr 4 '17 at 21:52
• @PeterTaylor : they were no answer to the previous question. In order to be closed as a duplicate the target needs to be already answered. You known it was closed an unclear, so please suggest change to make this answer clearer. – user2284570 Apr 4 '17 at 21:54
• Huh? It's open and has 15 answers. – Peter Taylor Apr 4 '17 at 22:09
• @PeterTaylor sorry, I thought to an another question that was closed as unclear and didn’t take time to read your link. In that case NO, the aim is to not use the compiler in order to actually build the file. This normally can’t be done with a compiler or an assembler. – user2284570 Apr 4 '17 at 22:16
• Can't it? Why not? – wizzwizz4 Dec 16 '17 at 19:55
• Wait... shortest code that generate any program? Or what? Don't think this is a good idea... – user202729 Jan 6 '18 at 12:10

## Brainf*** Polygot

Write a brainf*** interpreter in as many languages as possible.

You will take the brainf*** code on standard input, and then execute it.

Your score is bytes / (n * sqrt n) (where n is the number of languages in which your program works), which you will seek to minimize.

• I don't think the generic "preform <simple task> in as many languages as possible" [polyglot] task is gonna cut it anymore. Maybe add some new BF-related task. – Esolanging Fruit Jan 24 '18 at 5:04
• @EsolangingFruit This isn't "preform some simple task". This is "be Turing complete". No other polygot challenge can be used a universal turing machine. In particular, it requires you to use the turing complete facilities of all the languages involved. – PyRulez Jan 24 '18 at 5:06
• If your goal is "prove turing completeness", then maybe "write a polyglot interpreter for a Turing-complete language". Allow different languages to interpret different TC languages. – Esolanging Fruit Jan 24 '18 at 5:10
• @EsolangingFruit I guess that would make it more interesting. I kind of like the idea of them all doing the same thing though, so you can just "feed in" an algorithm and get an instant polygot. – PyRulez Jan 24 '18 at 5:19
• @EsolangingFruit What about a caveat that the you must feed in the currently executing language as a parameter (for example, when run with python, it executes the code with "python" as its first input). – PyRulez Jan 24 '18 at 5:20
• In my opinion, polyglot challenges are better when you're solving different problems in each language. That has the advantage of being more interesting to solve, as well as not needing to ban multiple similar versions of the same language (since making polyglots would be trivial in those). – Esolanging Fruit Jan 24 '18 at 5:25
• Alternatively, a more difficult version: a polyglot in some set of languages languages that acts a compiler from BF to a new polyglot in each of those languages. In that case you probably want to score by no. of languages – Esolanging Fruit Jan 24 '18 at 5:27
• @EsolangingFruit OW, that sounds even cooler! – PyRulez Jan 24 '18 at 5:39

# Gatherer Golf: The 61 Dwarves

Gatherer is the official tool for searching for Magic: The Gathering cards. Its advanced mode allows searching by most of the criteria you could hope for, as well as simple boolean combinations within a single kind of criterion (for example, you can do "name contains X or Y and not Z").

I've been using it a lot recently, and have been trying to get better at more quickly finding the exact set of cards I need. For example, if I want creatures that can generate mana, searching for "dd {" seems to be the minimal exact string match on their rules text.

For this inaugural Gatherer Golf, your challenge is to create a query that lists, exactly, the 61 Dwarf cards (not counting creatures that are all creature types), without using the key "subtype". The result generated the normal way can be found here.

Rules

• Your score is the length of the full URL in Gatherer. For example, searching for "name contains Dw or Resp and type contains Creature" generates the URL gatherer.wizards.com/Pages/Search/Default.aspx?action=advanced&name=|[Dw]|[Resp]&type=+[%22Creature%22] for a score of 104.

• Lowest score wins.
• Your URL can be manually generated; it doesn't have to be possible to create it via the advanced search form.
• Cards added to Gatherer after this challenge was posted (in this case, after Rivals of Ixalan) do not invalidate existing answers. Your answer may include or exclude any card published after that date, regardless of whether it's a dwarf, and answers that no longer give correct results (for example, because the Oracle text of a card changed) do not need to be deleted.
• Other than as described above, all cards in Gatherer are relevant to this challenge, regardless of whether they're legal for tournament play.
• The cards may be listed in any order. This may be relevant if your search contains more than just dwarves, but concentrates all the dwarves into one page of the search results.
• I'm not sure that this requires code to solve. Also, I'd ban the word "subtype" in the query, as that's more solid than "without querying on subtype" – Nathan Merrill Jan 31 '18 at 20:26
• Thanks, edited. I was thinking of the query itself as code--it's declarative and certainly doesn't meet our definition of a programming language, but I'd've expected an HTML or SQL golfing challenge to be on-topic here and this seems the same in principle. – histocrat Jan 31 '18 at 21:02
• I wouldn't expect HTML golfing to be on-topic; and SQL meets the definition of a programming language. IMO the way to make this on-topic is to somehow supply a database (maybe abusing imgur with steganography?) and then ask for a program which takes input as a list of card names to match and outputs a minimal query. – Peter Taylor Feb 2 '18 at 12:28

# xkcd-esque Reverse Code Golf

## Introduction

A new xkcd comic came out recently, seemed to be a fun challenge and a change from the usual code golfing.

So I set out on making this challenge!

## Challenge

Make a short snippet of code in any language which, when read out, sounds like 1 sentence of normal English literature (for example, Moby Dick in the comic).

## Rules

• The snippet doesn't have to run, so you are free to add statements which would not execute (for example: undeclared variables, functions, etc.). However, it must be syntactically correct.

• A word in this challenge is any sequence of letters considered as valid English as in a dictionary. Articles (a, an, the) are counted as words.

• To prevent too long answers, the maximum number of words will be fixed at 200 individual words. This includes operator expansion.

• The maximum length of any function or variable name will be 10 words.

• The expansion used for an operator must be specified in the answer.

• Imported and built-in functions are not considered as operators.

• Since this is reverse code golf, the answer with the most points wins.

Scoring criteria:

• Characters used to structure code (0): All kinds of brackets, statement terminators, whitespace, etc.
• Comments and String literals (0): To avoid making large comments/literals with actual literature
• Names of functions or variables (1 per character):
• Keywords (2 per letter): Using keywords in the story as valid syntax.
• Operators (2 per letter of expansion): For example, > is worth 2x13 (isGreaterThan).

# Examples

Valid:

try { throw IngTheBallAnd; } catch (Ing it) {}
// Worth 3x2 + 5x2 + 13 + 5x2 + 3 + 5 = 37 points

let myLife = "a quote";
// Worth 3x2 + 6 + 2x2 = 16 points ("=" used as "be")


Invalid:

// One does not simply write everything in a comment
// Worth 0


Hope this meets PPCG puzzle criteria :D

• Define "short" Otherwise answers could just go on and on to approach infinite score. – Adám Feb 28 '18 at 10:05
• How long may function/variable names be? – Adám Feb 28 '18 at 10:07
• How do we determine the exact expansion of operators? E.g. is * "times" or "multipliedBy"? – Adám Feb 28 '18 at 10:09
• So the APL function ×× would count as 28: (signOfTheTimes)? Indeed APL functions often read nicely as plain English. E.g. (?∘≢⊃⊢)¨(⊂⍳3)/⍨¨1+⊢ reads as "a random number up to (?) the length (≢) selects from (⊃) the value of (⊢) each of (¨) the entire (⊂) indices until (⍳) three (3) replicated (/) by (⍨) each of (¨) one (1) added to (+) the value of the argument (⊢). – Adám Feb 28 '18 at 10:26
• @Adám I'll edit my answer to answer these. As for APL, I guess my puzzle is no match for it :P – K3v1n Feb 28 '18 at 10:46
• @Adám I'd actually aim for english literature rather than procedure sentences – K3v1n Feb 28 '18 at 10:50
• What is a "determiner"? Some programming languages do not use white space. What is a word? – Adám Feb 28 '18 at 11:05
• "Context" determination of expansion is not an exact science. As long as your challenge has that feature, I predict it will be closed as "unclear what you are asking". – Adám Feb 28 '18 at 11:07
• Are built-in functions "keywords"? What about imported functions? – Adám Feb 28 '18 at 11:08
• @Adám Edited to answer. Determiners were meant to be Articles (a, an, the). Lack of whitespace is not a concern as long as it is readable. I mentioned the need for specifying the intended meaning of operators before, but it was a partial change. – K3v1n Feb 28 '18 at 12:13
• built-in functions are not considered as operators? Uh, what exactly is an operator then? Some languages use single letters as operators. I'm afraid this question makes far too many assumptions about the features of programming languages. A common mistake, but often hard to fix. Compare to the problems with atomic code-golf. – Adám Feb 28 '18 at 12:53
• There have been a few questions about reading code as sentences, e.g. 1, 2, 3. Because answers can't be objectively scored, those are popularity-contests. However those types of challenge have mostly fallen out of scope on the site and are very hard to get right, see the tag wiki for more infos. – Laikoni Feb 28 '18 at 12:56
• Hmm.... alrighty. I shall disband this puzzle. I hope someone can make a better puzzle with the comic, it ought to get its own challenge ;) – K3v1n Feb 28 '18 at 13:17
• No one have said that? Welcome to PPCG! – Weijun Zhou Mar 1 '18 at 0:05
• Note that this is called code-bowling on PPCG. Typically code bowling questions have strict scoring rules to avoid arbitrary score inflation which usually prevents large variable/function names. – Jo King Mar 1 '18 at 2:19

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

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

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.

• Is there anything else that could make this challenge a bit more interesting? Maybe a scoring method? – RamenChef Mar 26 '18 at 14:01
• @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? – user9206 Mar 26 '18 at 14:05
• What counts as a "window"? I think this might be quite hard to define objectively in a way which is OS-agnostic. – Peter Taylor Mar 26 '18 at 15:38

# 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.
• If it only has to be run once a day, wouldn't millis() % 2 be truly random? – geokavel Apr 2 '18 at 3:22
• @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. – Esolanging Fruit Apr 2 '18 at 4:11
• Is a time cost of maybe read a file in nanoseconds allowed? – l4m2 Apr 2 '18 at 4:42
• In its current form, it appears to be impossible to define the validity criteria objectively. Temporary -1. – user202729 Apr 2 '18 at 6:39
• @user202729 If it were up to you, how would you define them? – Esolanging Fruit Apr 2 '18 at 6:45
• /dev/random seems to be really random. Is it allowed? – my pronoun is monicareinstate Apr 2 '18 at 7:30
• @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. – Esolanging Fruit Apr 2 '18 at 7:42
• Would a HRNG such as RdRand work? – my pronoun is monicareinstate Apr 2 '18 at 8:24
• ... I admit that my downvote/comment is not constructive, but I found absolutely no way to objectively define the challenge. – user202729 Apr 2 '18 at 14:02
• Maybe define "real random" as "not only based on xxx"(currently last state, calling current) – l4m2 Apr 2 '18 at 15:38
• @l4m2 That was what I was trying to imply by saying it shouldn't be pseudorandom. – Esolanging Fruit Apr 2 '18 at 18:47
• @EsolangingFruit but you need to define what's pseudo – l4m2 Apr 2 '18 at 18:52

# 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]

• 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. – moonheart08 Mar 29 '18 at 16:38
• @moonheart08 would banning hardcoding the test cases help? – Dat Mar 29 '18 at 17:57
• "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. – Kevin Cruijssen Apr 3 '18 at 12:54

# ♫ 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);
}
}

• What if my platform doesn't support windows that large? – Nissa Apr 20 '18 at 23:17
• What is the 400x400 measured in? Pixels? Does it qualify if I somehow emulate a screen with larger resolution? – user202729 Apr 21 '18 at 9:23
• Does making the whole screen black count? – user202729 Apr 21 '18 at 9:24
• Stephen then make the whole screen black? What kind of system doesn't support that? – Jared K Apr 22 '18 at 0:16
• user202729 i was thinking pixels – Jared K Apr 22 '18 at 0:16
• 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. – JayCe Jun 11 '18 at 3:34

# 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?

• 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 – HyperNeutrino May 2 '18 at 13:09
• 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. – HyperNeutrino May 2 '18 at 13:09
• IMO this is well past the threshold of "Too Broad", so I would vote to close for that reason. – Peter Taylor May 2 '18 at 15:23

(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"
> 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?
• Any reason why full programs are not allowed? – user202729 May 2 '18 at 9:29
• What happens if the language is not compiled? – user202729 May 2 '18 at 9:32
• (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.) – user202729 May 2 '18 at 9:59
• If the string is possibly not known at compile time, how can it produce a type error at compile time? – Angs May 2 '18 at 10:04
• 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.. – Kevin Cruijssen May 2 '18 at 10:07
• 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. – Adám May 2 '18 at 10:08
• @Angs dependent typing. In fact, this challenge is about dependent typing. – Akangka May 2 '18 at 10:17
• @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. – Akangka May 2 '18 at 10:21
• @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. – Akangka May 2 '18 at 10:26
• @Adám nice suggestion. But the type-safe feature (i.e. all error is on type-checking time) is integral part of the challenge – Akangka May 2 '18 at 10:28
• @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. – Adám May 2 '18 at 12:12
• 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. – user202729 May 3 '18 at 1:26
• @Adám I actually implement your suggestion, except the throw an error part. I make the challenge require the result is type error – Akangka May 3 '18 at 2:03
• @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. – Adám May 3 '18 at 5:46
• @Adám thanks about float dots. About language specific features, I just want to create a challenge about dependent typing. – Akangka May 3 '18 at 6:50

# 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)

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

• – Beefster Jun 1 '18 at 16:27
• 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. – Jared K Jun 1 '18 at 16:38
• 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. – LyricLy Jun 3 '18 at 5:32
• 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


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

• @AdmBorkBork : So i should put nothing ? – Muhammad Salman Jun 1 '18 at 14:59
• @AdmBorkBork : Thanks, done. – Muhammad Salman Jun 1 '18 at 15:01
• 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" – Kamil Drakari Jun 1 '18 at 15:07
• 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. – Kamil Drakari Jun 1 '18 at 15:09
• @KamilDrakari : Changed. Hopefully better – Muhammad Salman Jun 1 '18 at 15:09
• @KamilDrakari : I think I will put that as something I would like to know (reasons why this is sandboxed)\ – Muhammad Salman Jun 1 '18 at 15:09
• 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 ><+-.,[]" – Kamil Drakari Jun 1 '18 at 15:32
• @KamilDrakari : Okay – Muhammad Salman Jun 1 '18 at 15:34
• What happens if you move left of the starting position on the tape? Is it undefined behaviour or does it have to work? – wastl Jun 1 '18 at 18:58
• @wastl : undefined behaviour is ok. – Muhammad Salman Jun 1 '18 at 19:00
• 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. – Rɪᴋᴇʀ Jun 1 '18 at 22:37
• 1. Hopefully done, 2. done, 3. Ok, 2 votes for not having comments. – Muhammad Salman Jun 2 '18 at 9:26
• 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)? – Jo King Jun 4 '18 at 2:11
• @JoKing : yes, you can – Muhammad Salman Jun 4 '18 at 7:42

# 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
• Actually we have no standard rule for code-bowling to prevent unused code. – user202729 Jul 5 '18 at 9:52
• (although for this particular challenge, it's not possible to make program arbitrarily long) – user202729 Jul 5 '18 at 9:53
• 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 – Jo King Jul 5 '18 at 10:34
• @JoKing Your solution seems to break the "no rubbish rule" – l4m2 Jul 6 '18 at 1:10
• As user202729 says, there is no standard "rubbish rule". And if there was, there would be many ways of getting around it. – Jo King Jul 6 '18 at 1:25
• 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... – Jo King Jul 7 '18 at 3:25
• @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. – Nathaniel Jul 7 '18 at 4:28
• The "unused code" test is unlikely to be practical for programs longer than about 100 characters. – Peter Taylor Jul 7 '18 at 12:04

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

• Actually I think there are just 12 dimensions. – user202729 Jul 12 '18 at 14:55
• @user202729 More dimensions exist and you can use them, but they are initally empty – l4m2 Jul 12 '18 at 14:59
• What does it mean to sort an infinite-dimension cube? Currently this very unclear. – Laikoni Jul 13 '18 at 12:46
• @Laikoni I'd say code shows enough to understand, so it's not ready to post but not unclear – l4m2 Jul 13 '18 at 14:25
• 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. – sundar - Reinstate Monica Jul 15 '18 at 10:41
• @sundar I think the sandbox is exactly the place for improving challenges. I'm not sure if using the chat room is necessary. – user202729 Jul 19 '18 at 14:35
• @Laikoni Better now? – user202729 Jul 19 '18 at 15:10

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

• 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. – ბიმო Jul 27 '18 at 20:49
• Warning: Most low-level languages are not known to be TC. For example C (which is only recently proved TC, AFAIK. Ref) – user202729 Jul 28 '18 at 9:21
• 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? – user202729 Jul 28 '18 at 9:23
• @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. – ბიმო Jul 28 '18 at 15:21
• @OMᗺ Just saying...... // For the first comment, typically the answerer just specify the regex flavor in the answer. – user202729 Jul 28 '18 at 15:23
• 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, .... – user202729 Aug 1 '18 at 2:49

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

### Scoring:

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

• 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 – Kroppeb Aug 25 '18 at 11:26
• Even with "no constant over 10" the strategy above will still works in languages such as cat. – user202729 Aug 25 '18 at 14:16
• @kroppeb that's interesting, thanks. – NoOneIsHere Aug 25 '18 at 14:49
• 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? – Jo King Aug 28 '18 at 6:14

## 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.)

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

• 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? – ბიმო Sep 22 '18 at 23:01
• 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. – ბიმო Sep 22 '18 at 23:01
• @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? – liljoshu Sep 24 '18 at 15:57
• 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. – ბიმო Sep 24 '18 at 17:00
• @BMO Rewrote it, does this look better? – liljoshu Sep 24 '18 at 18:29
• 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? – ბიმო Sep 24 '18 at 22:38
• 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). – ბიმო Sep 24 '18 at 22:43
• 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? – Nathan Merrill Sep 25 '18 at 16:37
• Finally, realize that rule #10 simply means I can iterate over every possible program until I land on one that works, no AI needed. – Nathan Merrill Sep 25 '18 at 16:40
• @NathanMerrill Did some clarifying randomness... better? – liljoshu Sep 27 '18 at 18:49
• Not really. Let's chat – Nathan Merrill Sep 27 '18 at 19:10

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

• "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. – Nathan Merrill Oct 16 '18 at 12:43
• @NathanMerrill The latter is less problematic (and more objective) than the former. – user202729 Oct 16 '18 at 14:21
• Test cases are not strictly required, but it would make it easier to check if a solution is definitely incorrect. – user202729 Oct 16 '18 at 14:22
• 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) – user202729 Oct 16 '18 at 14:24
• I will add test cases. @NathanMerrill, there just shouldn't be any inbuilt functions that give pi directly is what I want to say. – Vedant Kandoi Oct 17 '18 at 5:35
• @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. – Nathan Merrill Oct 17 '18 at 6:26
• 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? – Vedant Kandoi Oct 17 '18 at 7:15
• 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? – Vedant Kandoi Oct 17 '18 at 7:48
• I changed the scoring method for the above issue, so should be okay now. – Vedant Kandoi Oct 17 '18 at 8:15
• Why would the output be floored? Surely you should use ceiling so that the wheel is actually travelling that distance. – Jo King Oct 17 '18 at 8:26
• I was thinking of something like how many full rotations need to be completed. – Vedant Kandoi Oct 17 '18 at 8:31
• "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. – Peter Taylor Oct 17 '18 at 14:06

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

• Too elaborate or long post?
• Rules too strict? Too lax?

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.

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

# 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.)

-

- 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
[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
[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
[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
[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
[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
[0x111E0,0x111FF], // Sinhala Archaic Numbers
[0x11200,0x1124F], // Khojki
[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
[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).

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

# 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
• Is the code considered malicious code? – user202729 Nov 10 '18 at 15:26
• What is "managed code"? – user202729 Nov 10 '18 at 15:26
• 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. – this Nov 10 '18 at 19:06