# Sandbox for Proposed Challenges

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

Sandbox FAQ

## Posting

Write your challenge just as you would when actually posting it, though you can optionally add a title at the top. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it.

When you think your challenge is ready for the public, go ahead and post it, and replace the post here with a link to the challenge and delete the sandbox post.

## Discussion

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

• Parts of the challenge you found unclear
• Problems that could make the challenge uninteresting or unfit for the site

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

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

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

## Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

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

Get the Sandbox Viewer to view the sandbox more easily!

# Let's rise higher!

(I am posting this challenge in sandbox because this kind of exceptional challenges are often closed, and then downvoted to oblivion, so I want to get your feedback and with kind help you fix the specifications in this challenge, and make it interesting, Thanks!)

# Challenge

The main objective of the challenge is pretty simple, this is an answer chaining contest, where you have to serially print numbers from 1. That means User 1's answer will print 1, then User 2's answer will print 2 and so on. But there are some rules to make the contest tougher.

# Rules

• You can't use the characters of the source code used in the previous answer.

• Each answer cannot use more than 12 distinct bytes.

• You cannot post 2 answers in a row, let me explain, suppose you have written answer no. 5, now you cannot write answer no. 6, you have to wait someone to post a valid answer no. 6 (That prints 6 without using characters in answer no. 5), and after that you can write a valid answer no. 7 following the rules.

• Program cannot take input or access internet.

• Standard loopholes apply.

# Scoring criterion

This is not challenge, so there is a custom objective scoring criteria. Try to make your score higher.

• Each answer's initial score is 1. (Only chain beginning answer has score 0).

• For each distinct byte you use, your score is increased by the number of distinct bytes. That means if your number of distinct bytes is 6, then your score increases by 1+2+3+4+5+6, and if your number of distinct bytes is 7, then your score increases by 1+2+3+4+5+6+7 and so on.

• You have to calculate distinct byte difference with the previous answer, and add/subtract score using the 2nd rule. So if byte difference is 3 then you will get a +1+2+3 score, or if -3 (Previous answer has 3 more distinct bytes than yours), then -1-2-3.

• For first 40 bytes you will get a 0.15 score, but from then you have to minus 0.5 score. An example if your score has total 45 bytes then your score bonus will be (40*0.15)-(5*0.5)=6-2.5=3.5, so you have to add +3.5 to your score. (The score criteria is to encourage medium length smart answers.)

A total example:

Suppose,

• Your previous answer has 4 distinct bytes, and a total of 20 bytes
• Your answer has 7 distinct bytes, and a total of 56 bytes

Distinct byte difference: (7-4)=3
Total score: 1+(1+2+3+4+5+6+7)+(1+2+3)+(40*0.15)-(16*0.5)=33


So you get a score of 33 for this condition.

# Answer Number. Language Name, x Bytes, y Distinct bytes, Score: Z

source code

(TIO/Any other interpreter link) -> Not required, but preferred


example

1. Powershell, x Bytes, y Distinct Bytes, Score: Z

......


# Winning criterion

Winner will be determined after 30 days, winner is determined by total score. But users are welcome to continue the chain after that!

Suppose you have three answers with score 33,16,78 then your total score will be 33+16+78=127.

And there is two special prizes from me after 30 days:

• +150 bounty for the winner.
• +50 bounty for the single answer with highest score! (Such as man of the match in Cricket)

# 1. PowerShell, 1 byte, 1 distinct byte, Score: 0

1


Try it online!

---

# Meta

• Are all rules clear?

• Please improve the scoring criterion and rules. (Especially please improve the second rule, I am not very sure about that.)

• Please make me a javascript snippet for leaderboard, to sort users by their total score.

• There are a bunch of small things that could be clarified (particularly the scoring), but I think there is a larger problem you should try to fix first. Answer-chaining challenges rely on the task becoming more difficult as more answers are posted, but since you are only restricted by the previous response getting an optimal score will probably not be difficult until the number of answers is very large (much larger than 100). If you fix this, then the problem becomes that if finding a good answer is difficult, posting for more score becomes a race, which usually isn't fun. Mar 3 at 18:32
• @FryAmTheEggman if the number of answers are large, then you would sort the question by active. What are the other problems please say. Mar 4 at 6:58
• The number of answers being large isn't the problem. Please re-read my comment - it is talking about how the challenge isn't a good answer-chaining challenge because the approach for each link in the chain is too similar. Try writing what you think the next solution would be, and the one after that, and I think you will start to see the problem. Mar 4 at 14:42

# Finish what John McCarthy started (WIP) code-golfinterpreterlisp

This does not have anything to do with Joseph McCarthy or communism. Some background from Wikipedia (you can skip ahead if you like):

John McCarthy published the first paper on Lisp in 1960 while a research fellow at the Massachusetts Institute of Technology. In it he described a language of symbolic expressions (S-expressions) that could represent complex structures as lists. Then he defined a set of primitive operations on the S-expressions, and a language of meta-expressions (M-expressions) that could be used to define more complex operations. Finally, he showed how the meta-language itself could be represented with S-expressions, resulting in a system that was potentially self-hosting.[3] The draft version of this paper is known as "AI Memo 8".[4]

Example M-expressions

McCarthy had planned to develop an automatic Lisp compiler (LISP 2) using M-expressions as the language syntax and S-expressions to describe the compiler's internal processes. Stephen B. Russell read the paper and suggested to him that S-expressions were a more convenient syntax. Although McCarthy disapproved of the idea, Russell and colleague Daniel J. Edwards hand-coded an interpreter program that could execute S-expressions.2 This program was adopted by McCarthy's research group, establishing S-expressions as the dominant form of Lisp.

Interpret a subset of M-expressions, where 9 primitive functions have already been defined.

## Syntax

Atoms: An atom is a series of any characters excluding [, ], ;. While an atom name can include whitespace, leading and trailing whitespace is ignored. Some examples include foo, lambda (also a function name), and nil (also a list). Atoms act as both variables and data (they're like strings).

Booleans: The atom t is truthy, whereas the atom nil is falsy.

quote: A series of expressions between square brackets, delimited by semicolons. [a; [b; c]; de] is equivalent to the S-expression (QUOTE (A (B C) DE)). It is somewhat like this JS list: ["a", ["b", "c"], "de"].

cond: A series of if-then pairs between square brackets, delimited by semicolons, with an arrow -> (you can use any other character(s)) separating the if-then pairs. e.g. [atom[x] -> x; t -> car[x]] yields x if it's an atom, or the first element of x if it's a list. It is guaranteed that at least one of the cases will be true.

Function application: Functions can be called using functionname[arg1; arg2; ...; argN].

• car - Return the first element of its argument.
• cdr - Return its argument without the first element.
• cons - Prepend its first argument to its second argument.
• eq - Check if its two arguments are equal.
• atom - Check if its argument is an atom.
• lambda - Define an anonymous function using the syntax lambda[[param1; param2; ...; paramN]; bodythatusesparams].
• label - Store a function using a name. For example, label[drop2; lambda[[xs]; cdr[cdr[xs]]]] defines a function drop2 that drops the first two elements of its first argument.

# Rules

• Functions may use lexical or dynamic scope, or some crazy mixture of both.

Much of this question is copied from this challenge and the Wikipedia article on M-expressions.

# Questions for Meta

• For cond, should I use the [condition -> res; condition2 -> res2; ...] syntax, or should I keep it like the linked challenge?
• Should answers support higher-order functions?
• Does anyone have any good examples using Mexprs?
• I did a double-take at the title, which sounds like the challenge is to root out communists still hiding in the US state department to finish what Joseph McCarthy started...
– xnor
Jan 20 at 10:23
• @xnor Uh...that certainly was not what I intended. I could probably say "Finish what John McCarthy started" or just "Interpret M-expressions", although the latter sounds more boring. There's also a Eugene McCarthy, apparently, so I guess just McCarthy is too ambiguous.
– user
Jan 20 at 13:59
• Mar 10 at 16:41
• If you want do disallow trivial answers that use quit or comments or something, you could require all 3 programs to be irreducible. However, I think it might not be as interesting like that, because it would then just be the same as all the existing irreducible restricted-source challenges. It's still an interesting challenge to optimise the length of three similar programs with the same charset. Extra feedback: I'd recommend changing Hello, World! to another string because many languages have Hello World built-ins. Mar 10 at 16:47
• Also, maybe specify that functions are allowed as well as programs, according to our I/O defaults. And can you clarify whether the Hello World has to include the quotes? Mar 10 at 16:51
• @pxeger Thanks, I have updated my post and I agree that the irreducible rule is not needed. Even a "trivial" answer seems challenging to arrive at. About the string, maybe I can change it to "Hello, Permutations!" which also goes with the challenge title, but I am unsure if I should. Mar 10 at 17:18
• Hello, Permutations! sounds fine - I think it would be a good idea. Again, can you clarify whether you want the double quotes around "Hello, Permutations!" to be outputted literally or not? Mar 10 at 17:25
• @pxeger Changed it, and its clarified now. Mar 10 at 17:29

# Uppercase JSON member names

Given a single valid JSON value, uppercase all member names. That is, you must also return valid JSON that encodes an equivalent value, except that all names of members in all objects, have been converted to uppercase according to one of the Unicode methods (simple or full).

Details:

• The given value can be null, a number, a string, an array, or an object. There may therefore not be any names to convert, but such names can also "hide" as elements/members of arrays/objects in arrays/objects, …

• Dictionaries are considered unordered.

• Names and strings will only encode ASCII.

• Keys will be unique, even after case conversion.

• Floating point imprecision is tolerated.

## Example input A

["a\":",{"b":"c"}]


### Example outputs

["a\":",{"B":"c"}]

[
"a\":",
{
"B" : "c"
}
]


## Example input B

{"h\u0065re":
"are'=",    "be"
:{"dra\u0000gons":true,"b\\e\"ar\ns":"two"},"\t":[1e-0,null,3e+2
,  {"":""} ,{
},
"name\":\"value",[false,[],[[]]]]}


### Example outputs

{
"BE": {
"B\\E\"AR\nS": "two",
"DRA\u0000GONS": true
},
"HERE": "are'=",
"\t": [1,
null,
300,
{
"": ""
},
{
},
"name\":\"value",
[false,
[],
[[]]]]
}

{"BE":{"B\\E\"AR\nS":"two","DRA\u0000GONS":true},"HERE":"are'=","\t":[1,null,300,{"":""},{},"name\":\"value",[false,[],[[]]]]}

• Is order of keys in a dictionary matters? For example, input {"b":0,"a":0}, may I output {"A":0,"B":0}? Will there be any duplicate object keys? For example, is {"a":1,"a":2} a valid input? ECMA-404 allow duplicate keys, but RFC 8259 disallow it. For above input, may I output {"A":2} only? What about duplicate keys after conversion? For example, is input {"a":1,"A":2}valid? And what should I output?
– tsh
Mar 15 at 6:28
• @tsh How is this?
Mar 15 at 6:33
• May I assume keys only contains characters in range U+0020~U+00FE? For example, are keys like {"großes":1,"æða":2,"ｈｅｌｌｏ":3,"βῆτα":4} invalid?
– tsh
Mar 15 at 6:33
• @tsh non-ASCII keys are literally mentioned in the bullet points and included in the example case.
Mar 15 at 6:33
• May I output DRA\u0000GᎤNSS for dra\u0000gꭴnßinstead of DRA\u0000GᎤNß?
– tsh
Mar 15 at 6:37
• @tsh Silly me for not thinking of the various methods. Addressed.
Mar 15 at 6:42
• @tsh All answered: 1: "Dictionaries are unordered." 2: "Keys will be unique" 3: "Keys will be unique, even after case conversion."
Mar 15 at 6:44
• May I use different unicode normalization from inputs? For example, Input {"e\u0301":1}, may I output {"\u00c9":1}? And for input {"\u00e9":1}, may I output {"E\u0301":1}?
– tsh
Mar 15 at 6:47
• @tsh Good point. Addressed now. Do you think it would be an improvement to restrict input to ASCII only?
Mar 15 at 6:52
• Try to support uppercase for non-ASCII would simply require submission in some languages with such a built-in support. And as code-golf context, no one would likely to handle it manually. So restrict it to ASCII only would be helpful to let more languages involved.
– tsh
Mar 15 at 7:14
• @tsh Done. How is this?
Mar 15 at 7:16
• You are still using "ꭴ" in it. Also suggest testcases with object in array: {"extra":[0, {"key":[[[{"inner":{}}]]]}]}
– tsh
Mar 15 at 7:24
• @tsh Did you refresh? I don't see any "ꭴ". There are objects in the "\t" array.
Mar 15 at 7:27
• Will input always be a json object (dictionary)? For example, another testcase ["a",{"b":"c"}], null, And maybe it need more testcases. And if I try to parse the JSON string first, may floating point errors allowed? For example, input {"a":[17706675576718736274, 300223795848957673199326286566205161047]}, may I output {"A":[17706675576718735000,3.0022379584895768e+38]}
– tsh
Mar 15 at 7:31
• @tsh Good questions. Should all be addressed now.
Mar 15 at 7:36

## Minimally Making Change

• What is expected output for 10? To my understanding, it should be 0010, but you give 5100. Am I misunderstand something?
– tsh
Mar 16 at 11:33
• @tsh They have to be able to make all cents 1-10 with the coins. So they need 5 pennies for making 1-4 and the nickel to make 9. Hopefully clarified a bit Mar 16 at 12:35

# Find the Best Set of Adapters

Moved here: Find the Best Set of Adapters

• This reminds me of one of the 2020 AoC challenges, don't remember exactly what the task was but it had a similar premise. (Also there's no need to disallow standard loopholes explicitly, they're disallowed by default :p) Mar 12 at 1:44
• It was "Day 10: Adapter Array" but that was about finding the number of ways to reach the result and the adapters were a bit different. Mar 12 at 3:42
• This looks like it'll be a fun challenge, although I'd be careful to look around because there might be a duplicate with an entirely different name/background that involves doing the exact same thing. Mar 12 at 4:14
• May it contains adapter from A -> A? Although it would be not useful. It could be included in testcases. (make sure implementation will not fall into infinity loop in such case.) Will it possible 0 adapter is required (Same type for both computer and phone already)? If so, add another testcase for it.
– tsh
Mar 15 at 9:00
• Also, is it possible that part of given graph is not connected to computer / phone types. For example, A, C; A->B; B->C; X->Y; Y->Z.
– tsh
Mar 15 at 9:02
• Current testcases does not contains cycle. It would be helpful to include one: A, C; A->B; B->C; C->A for example.
– tsh
Mar 15 at 9:04
• Your description says "Unfortunately, none of them can go straight from my phone to my computer". but your last testcase output 1. One of them should be incorrect.
– tsh
Mar 15 at 9:04
• Thanks, @tsh for the great feedback. I have edited the question with your suggestions in mind. Mar 15 at 18:37
• 2nd test case seems incorrect.
– tsh
Mar 16 at 11:28
• @tsh thanks, fixed Mar 16 at 15:45

# Fortuitous Numbers

Four is Magic is a very interesting math game.

1. We start out with a number: 1
2. We spell it into English: “one”
3. We find the sum of the letters: 3
4. Go back to step 2, until the game ends at “4”

The reason “4” is Magic, is that “Four” has 4 letters, and no other number has this property.

### Fortuitous Numbers

In this game, I’m making one change.

1. Take for example the number: 24.
2. Write it out in English: “twenty four”
3. Note that there are 2 words
4. Take the product of the word lengths
5. 24 - “twenty four” - 6 * 4 = 24

4 and 24 are Fortuitous Numbers. Are there any more?

### The challenge

Your challenge is to create a piece of code that will generate all Fortuitous Numbers.

Specifically:

1. Solutions should be found by the program, not chached by you.
2. We never say, “one hundred and one”. Exclude the “and”
3. The only output should contain a comma separated list of only the solutions:
4,
24,
n,
m,

1. The code should have no limit as to how large the number can go. If you have trouble finding names, used the ones mentions in this Wikipedia article. This will take you smoothly to 103003 and beyond.
2. Hint: Look at the sequence, A058230.

### Bonus!

1. Program generates the first 9 solutions relatively quickly (under 5 minutes time.)
2. Program also finds Fortuitous Numbers if type a -> b -> ... -> a instead of just a -> a

## ROT47(code) code-golfciphersource-layout

ROT13 is a Caesar cipher where every letter is replaced by the 13th letter that follows it in the alphabet.

Every letter and its counterpart:

a b c d e f g h i j k l m n o p q r s t u v w x y z
n o p q r s t u v w x y z a b c d e f g h i j k l m

ROT47 is a deritave of ROT13 which includes all the ASCII printable characters except space. Rot47 substitutes every character with the 47th character that follows it in the ASCII range.

Every character and its counterpart:

! " # $% & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _  a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ P Q R S T U V W X Y Z [ \ ] ^ _  a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ ! " #$ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O

I ROT47( your code) and you ROT47( the output)

• Your code is supposed to at least output 1 character within the [33,126] ASCII range.
• When ROT47 is applied on your code, the output should also be ROT47 of the previous output
• solve in the fewest bytes possible

Below a ROT47 converter taken from decode

var input = document.getElementById("input");
var editor = CodeMirror(input, {
lineNumbers: true,
tabSize: 2,
mode: 'javascript',
theme: 'monokai'
});
editor.setSize(900, 100);
document.getElementById("button").onclick = function(){
editor.setValue(rot47(editor.getValue()));
}

//implementation below from https://www.dcode.fr/rot-47-cipher
// Javascript
function rot47(x){
var s='';
for(var i=0;i<x.length;i++){
var j=x.charCodeAt(i);
if((j>=33)&&(j<=126)){
s+=String.fromCharCode(33+((j+14)%94));
}
else {
s+=String.fromCharCode(j);
}
}
return s;
}
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.60.0/codemirror.min.js" integrity="sha512-hc0zo04EIwTzKLvp2eycDTeIUuvoGYYmFIjYx7DmfgQeZPC5N27sPG2wEQPq8d8fCTwuguLrI1ffatqxyTbHJw==" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.60.0/theme/monokai.min.css" integrity="sha512-R6PH4vSzF2Yxjdvb2p2FA06yWul+U0PDDav4b/od/oXf9Iw37zl10plvwOXelrjV2Ai7Eo3vyHeyFUjhXdBCVQ==" crossorigin="anonymous" />
<body style="background-color:#333333
">
<div id="input">
</div></br>
<button id="button" style="background-color: #17202a
;color:white">ROT47</button>
</body>

### Meta questions:

• Is it an interesting challenge?
• Is the explanation clear?
• suggestion for a title.
• why does it look normal in edit mode but not in the result 😡. Mar 23 at 19:43
• Fixed the formatting. SE doesn't show tables unless they have an empty line before and after them Mar 23 at 19:56
• so valid answers and their input must be printable ASCII? Or should it ignore anything not printable?
– Wezl
Mar 24 at 16:45
• It looks like the reference implementation leaves non-printable characters and space alone. It would be helpful to specify that.
– Wezl
Mar 24 at 16:50
• Well, if you look on main, this is a alternate of an alternate of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off of a rip-off. (see this). Which is not to say it's a bad challenge. Mar 25 at 8:40

# To count the sum of all Unicode characters of a given input under an interesting constraint

• Welcome to the site, and thank you for using the sandbox! Can you confirm that answering with a normal (base-10) number is OK?
Mar 25 at 6:37
• Thanks for the comment, edited accordingly- Final answer can to be calculated in any base (either Hexadecimal, or base-10 or binary as per the program) no need to convert back. Mar 25 at 9:55
• I know you've posted this already, but generally I recommend leaving challenges in the sandbox for a week.
Mar 25 at 11:19
• Ohk. I will remember it from the next time. thanks a lot Mar 25 at 11:19
• I've edited this down to a stub now that it's been posted to save space Mar 30 at 21:38

# Sum of two squares

Given an integer $$\n\$$, determine whether $$\n\$$ can be expressed as the sum of two square numbers, that is $$\\exists a,b\in\mathbb Z|n=a^2+b^2\$$.

   0 -> truthy
1 -> truthy
2 -> truthy
3 -> falsy
4 -> truthy
5 -> truthy
6 -> falsy
7 -> falsy
11 -> falsy
9997 -> truthy
9999 -> falsy


Relevant OEIS sequences:

This is , so shortest answer as measured in bytes wins.

• This is a subset of this problem.
– hyper-neutrino Mod
Mar 31 at 5:29
• @HyperNeutrino yes, and I have that listed as a related problem. There's actually another method of solving this problem involving prime factors which doesn't work for that one, so I'm hoping that's novel enough to warrant a separate challenge. Mar 31 at 18:16
• My bad, didn't notice the link. And yes, I don't think it'd be a duplicate here; I do agree that there will probably be unique approaches to this specific problem.
– hyper-neutrino Mod
Mar 31 at 18:18
• A couple answers here used the prime-factorization approach, and a few used the approach of counting divisors of the form 4k+1 and 4k+3 respectively.
– xnor
Apr 2 at 6:50

# Irreducible Rube Goldberg Sort (WIP)

You are given a list containing at least 10 integers. You must sort them in the most complicated and roundabout way possible.

Your task is to write $$\n\$$ programs (or functions) which, when combined in a specific constant sequence (specifically, feeding the output of the current step into the input of the next step), result in a sorted version of the original list. This sequence of programs should be set up in such a way that the system will not work if any subset of steps is removed. (for example, compressing and decompressing the stream, roundabout encryption that cancels itself out, etc...)

Your score is $$\n\$$. Highest score wins.

## Rules, Clarifications, and Notes

• Standard rules and loopholes apply
• Any method of I/O is fair game. It does not need to be consistent across all programs/functions.
• You may use any number of programming languages to solve the problem.
• It should not take an unreasonably long time to sort a list of up to 1000 elements using your system of programs. It should be reasonable to run it from start to finish during a lunch break (30 minutes)
• Lists can contain any integer from -999,999,999 to 999,999,999, inclusive, and may contain indistinguishable duplicates.
• Your system of programs should work for lists of any size if given enough time and space.
• What is there to put an upper bound on the size, other than irreducibility? I'm almost certain there's a way to get an infinite score pretty trivially. Apr 1 at 16:30
• I suspect there's a way to have an arbitrarily complicated sequence of programs as well and I'm not quite sure how to limit that, aside from performance (the 30 minute rule) Apr 1 at 16:33
• Does the process have to be deterministic (e.g. no implementation of bogosort)? I think your rules imply that, but it might be good to state explicitly. Apr 1 at 18:17
• Throwing in a randomizer step probably wouldn't be irreducible. Apr 1 at 19:13
• So a recursive approach (e.g. one similar to Stooge sort) is a no-starter? Apr 4 at 23:31
• @Bubbler feeding a step's output into its own input is not allowed, so yes, that probably wouldn't work. Basically, the idea is that you could run this as a bash pipeline and no matter what the input sequence is, you wouldn't be able to remove any subset of steps and have it still work. Apr 5 at 23:06

# Dominate a zero-sum game

Write a rectangular code that takes a rectangular input and output it. If the code is repeated horizonally and vertically for times, output the input rectangular repeated for same amount of times.

Take an example, if your submission is

CODE
HERE


, then program

CODECODECODECODE
HEREHEREHEREHERE
CODECODECODECODE
HEREHEREHEREHERE


inputting

01
23
45


should output

01010101
23232323
45454545
01010101
23232323
45454545

• Nice one. But I didn't understand if there is s specific output.
– math
Apr 4 at 11:51

Create a C program that is less than 120 characters the produces the most ASM possible.

This limit does not include the def of main, or including headers. If a function is called the chars in the function count toward limit. The same goes for macros. The compiler used will be GCC 10.2 -O3 targeting x86-64.

The code conforms to these parameters and produces the most instructions wins.

I have a few questions regarding this. Is the character limit too limiting? Is the choice of compiler a good one? Is the optimization level being -O3 a good idea? Please share any other thoughts you have.

Thanks

• I don’t see a reason to limit the size of the program. You could score based on Assembly Instructions per Source Byte to encourage small code sizes without excluding a clever 121 byte solution. I also don’t think the rules around #include headers and counting the size of any functions called are clear (How many characters are in printf?). You could ban explicit #includes but allow implicit function declarations as long as the compiler accepts them. Apr 5 at 2:17
• Should printf be 6 chars or should it be the size of the definition of the function printf? I'm not sure about this. Apr 5 at 3:57

# KotH: Assembly Anarchy

Draft. Just posting this so I don't forget I had this idea. Feel free to suggest improvements to the general idea here.

Basically, there would be a computer with memory and a processor. Programs would be submitted in a custom assembly language, and they would try to run a function (their flag) as many times as possible. They could try to interfere with other programs, by doing things like replacing the pointer to another bot's flag with their own, or preventing other bots from being run.

• I like the concept. It needs a lot of fleshing out, though. Apr 9 at 13:42

# Poor Man's DRM

Write a program that only prints Welcome at the first execution and first execution only. All executions after the first execution should only print Where money.

Anything is allowed as long as the following condition is met: An execution ends after the program exits. So the second execution can only start after the first execution exits completely.

Reason for the condition: to prevent submissions that linger around in the memory and keep a runtime counter.

• any things that are disallowed? E.g. can a program write to its source file?
– Wezl
Apr 8 at 20:18
• @Wezl no, actually that's what I originally had in mind when writing this, but I decided to keep all the options open. -- edit for clarification: by "no", I meant it is allowed. Apr 8 at 20:18
• @goodguy Nice challenge. You may want to look at Standard Loopholes and main article
– math
Apr 9 at 14:36

# Cooperative counting

• looks like a nice challenge
– math
Apr 9 at 11:11
• I can't wait to code a bot for this challenge!
– math
Apr 10 at 8:56
• @math patience :) Apr 10 at 9:45

# Find the traitor cops-and-robbers (WIP)

In this challenge, the cops are the robbers/moles and the robbers are the cops/investigators.

## Cops

Cops will write a program that will output one of the following strings:

• "Hello World!"
• "Totally not evil stuff"
• "Good morning"
• "Innocent things"

However, when n specific characters are removed, where 0 < n < length of cop's program, the resulting program should output one of the following strings:

• "Bye World!"
• "Top secret stuff"
• "Evil things"
• "Horrible morning"

Cops will reveal the original program and n, but not the resulting program. They will also reveal the 2 strings that must be outputted by the original and transformed programs.

A cop's score is $$\\binom n r\$$, or $$\\frac{n!}{r!(n-r)!}\$$, where $$\r\$$ is the size of the cop's program and $$\n\$$ is the number of characters to be deleted. The lower the score, the better.

### Rules

• The original and transformed program may output in different ways, as long as the cop specifies what they are.
• The characters to be deleted do not have to be adjacent.

## Robbers

Robbers must find a way to make the cop's program output the chosen 2nd string by removing any n characters (not necessarily the same as the cop's).

## Example cop

Python, n = 1

a = ["Totally not evil stuff", "Hello World!"][01]
print(a)


The original string is "Hello World!", and the transformed program prints "Totally not evil stuff".

## Example robber

a = ["Totally not evil stuff", "Hello World!"][0]
print(a)


Deleting the 1 at the end of the first line prints the target string.

## Questions for Meta:

• Which original and transformed strings should I use?
• Is this a duplicate?
• This could be kind of difficult to write a cop for that doesn't just rely on someone brute forcing it Apr 11 at 0:21
• @RedwolfPrograms Hmm, you're right. I guess just saying "pls don't brute force" wouldn't work. Maybe instead of a string, submissions could implement a mathematical function? You wouldn't be able to verify, say, cosine using just brute force.
– user
Apr 11 at 0:23
• That could be really cool actually. If you had a variety of ones like sqrt, tan, factorial, sum of proper divisors, and so on it would be a lot of fun. Apr 11 at 0:30
• @RedwolfPrograms Only problem would be that there wouldn't be any more traitors to root out :( I made the challenge just for the title
– user
Apr 11 at 0:46

# Exchange of money in least notes

Suppose A and B are two good friends. A has borrowed $$\n\$$ dollar from B. Now B wants the money back from A and A is also ready to give it. But the problem is A has only $$\x\$$ dollar notes and B has $$\y\$$ dollar notes. They both want to keep the number of notes in exchange as low as possible.

As an example if $$\n=37\$$, $$\x=5\$$ and $$\y=2\$$, then the least amount of notes in exchange will be nine 5 dollar noted from A then four 2 dollar notes from B will make 37. This solution is found through brute forcing with a python program.

Here in the challenge your input will be values of $$\n, x, y\$$ and output should be the least of amount of notes as possible for A, B. A will give notes first and B later. Input and output seperator can be anything, no leading zeros in input numbers, no negative numbers in input. Standard loopholes apply and shortest code wins.

Test Cases

37 5 2 -> 9 4
89 3 8 -> 35 8
100 12 7 -> 13 8

• I'm almost certain there's a closed form solution to this, and if not one that's very close to closed form. Apr 12 at 4:57
• Is it guaranteed that the given values of $n$, $x$ and $y$ lead to a valid solution? E.g. there's no solution for $n=21$, $x=6$, $y=4$. Apr 12 at 8:22
• @Delfad0r input is guaranteed to valid Apr 12 at 8:23

# Basic Typescript Types

• suggested testcase: string | string, number & number
– tsh
Apr 14 at 10:15
• @tsh I just posted the question, thanks for the suggestion, I'll add the testcases there. Apr 14 at 10:17

# Matching to Homologous group

• 1. The underscore doesn't really seem necessary to me since there can't be any other syntax. 2. Can we assume the input will always be one of those categories? If not, add some test cases, and clarify the possible elements/other syntax that might be in the input. 3. Add classification tag? 4. Will you allow output as any 6 distinct values (not saying it has to be, but some challenges do allow this to remove the part of compressing some strings), or does it have to be those strings? If so, do they need to be capitalised exactly like that? Apr 11 at 16:15
• @pxeger the input is guaranteed to be in 6 categories. Classification tag added. About the underscore i'll think later. And output needs to be exactly capitalized like in question. Thanks! Apr 11 at 16:18
• Also maybe add some more test cases with larger numbers (more than 1 digit)? And clarify what integer syntax is allowed (areleading zeroes allowed, can the number be <2)? Apr 11 at 16:21

# It seems $$\2^n\$$?

Let $$\a_0=1\$$ and $$\a_{i+1}=1+\sum_{j=0}^ia_i\$$, then $$\a_i=2^i\$$, which is no fun.

Now we reverse half of the value, $$\a_{i+1}=L(1+\sum_{j=0}^ia_i)\$$ for odd $$\i\$$, where $$\L\$$ reverse the number, e.g. 15=>51, 1230=>321.

Solve $$\a_i\$$. You can choose 1-index, or reverse each output(output $$\L(a_i)\$$).

First elements

1,2,4,8,16,23,55,11,121,242,484,869,1837,4763,8437,47861,64735,74921,204391,287804,696586,2713931,4107103,6024128,14238334,86667482,115144150,3882032,234170332,466043864,934384528,6509678681,8378447737,47459865761,64216761235,74225334821,202658857291,285417713504,690735428086,2716580741831,4098051598003,6006913016918,14203016212924,84852423060482,113258455486330,66279019615622,292795930588282,465671168195585,1051263029372149,8924478506252012,11027004564996310,2629992190045022,24684001320037642,48257004620086394,97625007260161678,653323025410052591,848573039930375947,4981570689706417961,6678716769567169855,1793343193533475331,15150776732667815041,28003653356435510303,58305206821771140385,77082245346314016611,193692658989856297381,267495217979713583783,654880535959426178545,907532588191701679031,2217293660110554036121,2422708011220237854344,6857295331441345926586,27135819628826609541731,40850410291709301394903,60898720681438502800718,142599541264857105590524,840181112417925280991582,1125380194947639492172630,625434898725989830670522,2876195288621268815015782,4651300367352427750932575,10403690944594965380964139,87282916703998198818370802,108090298593188129580299080,61895061952673681795081612,278075659139049940955679772,445953119188990872813151655,1002104437467090754724511199,8932209449051814394788024002,10936418323985995904237046400,829047480819917974663827812,22701884128791909783137920612,42214857266591838575286730454,87618625524175658141562571678,653341521382613153840152732571,828578772430964470123277875927,4581575556420498291684457517561,6238733101282427231931013269415,3883562026836445846520266477421


• 1) You should make it clear whether we need to print the $i$'th term, or the first $i$ terms or we can print the infinite sequence. Usually challenges like these allow all of these options. 2) Can you clarify what does "reverse each output" mean? So instead of $a_i$, the solutions can also print reverse of it? 3) There also needs to be a winning criterion. Apr 19 at 7:39

# Close neighbours stick together

• I felt like I'd done this at some point but couldn't find anything in my last 100 or so answers... I think it's a good easy level problem. Apr 18 at 20:53

# Posted ;)

• So this is just abs(x-y), since I can just represent the days using integers? Doesn't seem very interesting Apr 14 at 9:32
• I think restricting the input to being one of the 7 days (maybe in whatever consistent case answers want) would be a better version of this Apr 14 at 9:57
• Won't this be simple (x-y+7)%7?
– tsh
Apr 14 at 10:26

# Plz Halp, Need Investors ASAP

• This might be a duplicate, but searching is going to be difficult because of how many ways you can describe the challenge. One thing that might make it interesting is giving each investor an amount of money they'll invest, then have the programs maximize the money invested (for example, by skipping three meetings with investors promising $1 and going to a single meeting with an investor who promises $10). Apr 26 at 19:00
• The thing about that is that the algorithm gets a lot harder - I'm pretty sure you need DP to solve your variant. Also, I did spend quite a while looking for any duplicates and could not find any. Apr 26 at 19:07

# Number to set - duplicate

• Dupe Apr 27 at 18:36
• aw rats, but thank you
– Wezl
Apr 27 at 18:37

# Decompress a Sparse Matrix (WIP)

The dual of this challenge

Decompress a sparse matrix reversing the method here Compressed sparse row (CSR, CRS or Yale format).

There will be 4 inputs, either as separate variables or as a list of lists:

• V, a list of the nonzero elements of the matrix in row-major form. This is of length NNZ (the number of nonzero elements in the original matrix)
• NCOLS - the number of columns in the original matrix.
• JA - a list of the column indices of the elements in V, also of length NNZ. (zero-indexed)
• IA - a list that yields the number of nonzero elements in each row. IA[0] = 0, IA[i] = IA[i - 1] + <number of nonzero elements in row i>. The number of nonzero elements in row i is IA[i + 1] - IA[i].

Input will be a list of 3 lists and the number of columns in the original matrix, e.g. either

[
[5, 8, 3, 6],
[0, 0, 2, 3, 4],
[0, 1, 2, 1],
4]
]


Or

V = [5, 8, 3, 6]
NCOLS = 4
IA = [0, 0, 2, 3, 4]
JA = [0, 1, 2, 1]


Output will be a decompressed matrix/list of lists:

[[0 0 0 0],
[5 8 0 0],
[0 0 3 0],
[0 6 0 0]]


If your language doesn't support actual data structures, input and output may be text.

# Test cases

Input 1:

[ 5, 8, 3, 6 ]
[ 0, 0, 2, 3, 4 ]
[ 0, 1, 2, 1, ]
4


Output 1:

[[0 0 0 0],
[5 8 0 0],
[0 0 3 0],
[0 6 0 0]]


Input 2

[ 10 20 30 40 50 60 70 80 ]
[  0  2  4  7  8 ]
[  0  1  1  3  2  3  4  5 ]
6


Output 2:

[[10 20 0 0 0 0],
[0 30 0 40 0 0],
[0 0 50 60 70 0],
[0 0 0 0 0 80]]


Input 3:

[ ]
[ 0 0 0 0 ]
[ ]
3


Output 3:

[[0 0 0],
[0 0 0],
[0 0 0]]


Input 4:

[ 1 1 1 1 1 1 1 1 1 ]
[ 0 3 6 9 ]
[ 0 1 2 0 1 2 0 1 2 ]
3


Output 4:

[[1 1 1],
[1 1 1],
[1 1 1]]


Input 5:

[ 5, -9, 0.3, -400 ]
[ 0, 0, 2, 3, 4 ]
[ 0, 1, 2, 1, ]
4


Output 5:

[[0 0 0 0],
[5 -9 0 0],
[0 0 0.3 0],
[0 -400 0 0]]


Assume inputs may contain any real number, you need not consider mathematical symbols or exponential representation (e.g. 5,000 will never be entered as 5e3). You will not need to handle inf, -inf, NaN or any other 'pseudo-numbers'. You may output a different representation of the number (5,000 may be output as 5e3 if you so choose).

# Scoring

This is a , fewest bytes wins.

• I'd suggest to at least briefly explain how the decompressing works in the post. The challenges should be self-contained as much as possible. Apr 22 at 23:55
• @bubbler, that's coming, but I need to figure out how to do that/explain it myself. I've left (WIP) on the question because of this. Apr 23 at 0:11
• @Pureferret I think it would be better to allow only nonzero integers instead of any real number. It'd be easier for most languages that way
– user
May 2 at 20:59
• @user I think it's more interesting seeing those languages work around those difficulties. Also the original challenge required them, so it I my makes sense this one does too. May 2 at 21:14
• @Pureferret I'm not sure many golfing languages support arbitrary precision floating point numbers. Would they be able to use strings, then? Edit: could you at least restrict it to rational numbers? Unlike Jon Skeet, most of us here don't know all the digits of pi :P
– user
May 2 at 21:17
• @user it needn't be arbitrary, just as long as it matches the test cases May 2 at 23:46
• You do need a objective winning criterion. See why here. Nice challenge though! Probably simplest to just make the criteria [code-golf]. Most [code-golf] challenges don't result in an accepted answer though, so you should be fine. Apr 29 at 12:48
• @ausername Thanks for the feedback, I'll work on the winning criterion
– user100752
Apr 29 at 12:51
• You don't need the last part, by the way. It's usually implied.
– user
Apr 29 at 19:30
• @user according the the comment above, the person said this needed a Winning Criterion thats the reason i added it.
– user100752
Apr 29 at 19:55
• Sorry, I meant just the last sentence. Also, you don't need to make "Winning criterion" a separate header.
– user
Apr 29 at 20:05
• @user Alright, gonna remove it
– user100752
Apr 29 at 20:08