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

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

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

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

# Shift right by half a bit code-golfmathnumberarithmetic

abcdefghijklmno
pqrstuvwxyz{|}~

¡,,#$%⅋,)(*+'-˙/ 0ƖᄅƐㄣϛ9ㄥ86:;>=<¿ @∀qƆpƎℲפHIſʞ˥WNO ԀQɹS┴∩ΛMX⅄Z]\[^‾ ,ɐqɔpǝɟƃɥᴉɾʞlɯuo dbɹsʇnʌʍxʎz}|{~  The rest of the characters are kept as-is(yes, the unprintable characters are in the ASCII character set). The characters that are larger than 0x7f will be mapped back by subtracting the character code by 128. If you are using a character that is larger than 256, modulo the character's character code by 128 before checking the availability. ## Rules • No standard loopholes, please. • Input and output will be taken with our standard input methods. • If you force Jono 2906 to change a key on their keyboard (allowing typing your specified character), you will get a penalty of +2 bytes for every key you add. • I don't think I quite follow. Are we given a character as input and need to output the upside-down version? – AdmBorkBork Aug 27 '19 at 14:06 • (1) I still find the question confusing even as to the basic functionality required. The "Input/Output" section seems to me to say that it's a Kolmogorov problem, but the "Rules" section talks about input. (2) If a character remapping is involved, the question should list Unicode codepoints for the characters in question, and should list test cases with Unicode codepoints. (3) Is the last rule saying that the program must work as is and after mangling? Or is it just a gimmick ("Post your code upside down, but it only has to work the right way up")? – Peter Taylor Aug 28 '19 at 8:39 • "The rest of the characters are not kept as-is(yes, the unprintable characters in the ASCII character set)." should this not be there? As for that entire paragraph, if I understand correctly: unprintable characters < 33 (as well as 127) will be kept as is; printable ASCII characters displayed will be converted to upside down; other printable ASCII characters and any character above 127 will be modulo-128 before doing the same check. – Kevin Cruijssen Aug 28 '19 at 9:24 • As for the last rule: we can only use those upside down characters in our source code, and when converting it to regular it should also work? So both programs ABC and ∀qƆ should work exactly the same? – Kevin Cruijssen Aug 28 '19 at 9:25 ## Wrong position I typr re;atively accuratrly, but so,etimes I made a whole nlock of text illegible by shifting a key right. So I need a program that corrects my text back to its original meaning. ## Rules • You have to left shift on a standard English QWERTY keyboard. • Whitespace do not count for the procedure before left-shifting and are kept as-is in a standard left-shifting procedure. If the key is the leftmost letter/symbol on a keyboard(i.e. The ~key, Q key, A key, Z key.), the key is kept as-is. If you reach a control character while left-shifting (Caps lock and Shift), their effects will not be triggered and the character before left-shifting is kept. • This is a contest; the shortest answer wins. • Both the input and the output shall be given via our default methods. ## Representation of a subset of the QWERTY keyboard that you will need The two lines connected are possible values of the key: shifted/unshifted. ~!@#$%^&*()_+
1234567890-=

QWERTYUIOP{}|
qwertyuiop[]\

ASDFGHJKL:"
asdfghjkl;'

ZXCVBNM<>?
zxcvbnm,./

(Space)
(Space)


## Input

The input will always be a non-empty string conforming the rules above.

## Output

The output will be the input string corrected to the originally intended meaning.

## Examples:

Yjod ,sfr yjr, imjsppu/ -> This made them unhappy.
vpfr hp;g -> code golf


## Feedback

I think this is not a duplicate; however, is any part of this challenge unclear or needs improvements?

• I think you are mixing up left and right. Clearly, ~, Q, A and Z are leftmost keys, NOT rightmost. And your examples appear to be left-shifting, not right-shifting. – wastl Sep 7 '19 at 11:27
• "I think this is a duplicate" - so why sandbox it? Or did a not go missing in editing? – Peter Taylor Sep 9 '19 at 8:36
• Thank you. Predominantly my mouse was not working again, I didn't get around to fix this. – user85052 Sep 9 '19 at 8:56
• "sonetimes" and "vlock" are shifted the wrong way. – Hiatsu Sep 9 '19 at 16:20

# Path to Path Rearrangement

In the xkcd comic "Map of the Internet", a special fractal path was used, similar to this:

0  1  14 15
3  2  13 12
4  7  8  11
5  6  9  10


Ascii art version:

-0---1  14---15--16 19--20---21
|   |       |   |       |
3---2  13---12 17---18 23---22
|           |           |
4   7---8   11 30---29 24---25
|   |   |   |   |   |       |
5---6   9---10 31  28--27---26
|
58---57 54---53 32  35--36---37
|   |   |   |   |   |       |
59  56---55  52 33---34 39---38
|           |           |
60---61 50---51 46---45 40---41
|   |       |   |       |
63---62 49---+---47 44--43---42
\|/


This path, known as the Hilbert curve, has some interesting properties. Among other things, it can be flipped diagonally without changing most of those properties.

-0   3---4---5  58--59---60  63->
|   |       |   |       |   |
1---2   7---6  57---56 61---62
|           |
14---13  8---9  54---55 50---49
|   |       |   |       |   |
15  12--11---10 53--52---51   48
|                           |
16---17 30---31--32--33 46---47
|   |           |   |
19---18 29---28 35---34 45---44
|           |   |           |
20  23---24  27 36  39---40  43
|   |   |   |   |   |   |   |
21---22 25---26 37---38 41---42


Your task is to apply this transformation. Given a space on one path, find the corresponding location on the other. For example, the fourth space in the top path is located at (0, 2), which is the 14th space along the second path, so the correct output for 4 is 14.

As with similar challenges, this can be done as:

• An infinite sequence along the second path of the corresponding locations along the first path
• A function/program that takes a numbered position on the first path and returns the distance to that point on the second path.
• A function/program that takes a numbered position on the first path and returns all path 1 positions along path 2 to the point specified.

The first 64 terms of this sequence (zero indexed, add one to each for one indexed) are:

0 3 2 1 14 15 12 13 8 11 10 9 6 7 4 5 58 57 56 59 60 63 62 61 50 49 48 51 52 55 54 53 32 35 34 33 46 47 44 45 40 43 42 41 38 39 36 37 26 25 24 27 28 31 30 29 18 17 16 19 20 23 22 21


This is code golf, so shortest code in bytes wins.

## Meta Questions

• Do I need a better description of the paths?
• Is the challenge itself clear?
• Any other issues I should fix before posting?
• The default output formats for sequence challenges can be found in the tag wiki – Jo King Sep 10 '19 at 4:03
• (1) Related. (2) I don't find "Find the location along the second path of a point on the first path" at all clear. It seems to be talking about output in 2D. I think it would be clearer to say "Given an index on the first path, output the index of the same coordinate on the second path". And then give a worked example (e.g. 4 vs 14). – Peter Taylor Sep 10 '19 at 10:53

# Is this number part of a Collatz Prime sequence?

Each step of a Collatz Sequence can be summarized as:

$$p_{2} = \frac{3*p_1+1}{2}$$

Where p1 is the input number, and p2 is the output number.

You task is to find where both the input and output are primes.

Here are some test cases:

1  -> (3*1+1)/2 = 4  : false
3  -> (3*3+1)/2 = 5  : true
5  -> (3*5+1)/2 = 8  : false
7  -> (3*7+1)/2 = 11 : true
11 -> (3*11+1)/2= 17 : true
15 -> (3*15+1)/2= 23 : false
91 -> (3*91+1)/2=137 : true
97 ->(3*97+1)/2 = 146: false
`

Output should be some truthy value, and false may be an error.

• What is the definition defining? Is $p$ a Collatz prime iff it's a prime and $\frac{3p+1}2$ is a prime? If $p$ a Collatz prime iff it's a prime and $\frac{2p-1}3$ is a prime? Or is a prime Collatz if either of those conditions hold? – Peter Taylor Sep 13 '19 at 10:56
• @PeterTaylor are they not the same thing? – Pureferret Sep 13 '19 at 11:09
• Alternative phrasing: which of $p_1$ and $p_2$ are you calling a Collatz prime? – Peter Taylor Sep 13 '19 at 11:11
• @PeterTaylor I mean $p_1$ – Pureferret Sep 13 '19 at 11:22
• So neither the input prime nor the Collatz prime need to be prime? – Jonathan Frech Sep 17 '19 at 7:56
• "Input MAY be non-prime, in which case the output is always false (see 15)" -- did you specifically define this behavior or why is the above the case? – Jonathan Frech Sep 17 '19 at 8:00
• @JonathanFrech I'm (personally) only interested in going from prime to prime, but I wanted to define the haviour for non-prime input. When I say 'may be non-prime' I mean, it should be able to handle it, it's an allowed/expected input but not one that gives a True output. – Pureferret Sep 17 '19 at 10:55
• To me it feels like an unnatural extra constraint. – Jonathan Frech Sep 17 '19 at 12:54
• @JonathanFrech it's just defining how to behave with certain inputs. – Pureferret Sep 18 '19 at 9:12
• Citing Exceptional edge cases; such out-of-place definitions are generally frowned upon. – Jonathan Frech Sep 18 '19 at 9:56
• @JonathanFrech I've changed the initial ask, and now it shouldn't be an exception – Pureferret Sep 18 '19 at 10:23
• Cf. A158709. – Jonathan Frech Sep 18 '19 at 10:53