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

# Is this entire list likewise-modulus-aligned?

A pair of numbers are aligned in a modulus when they all share the same remainder when they can be put under the modulus function against an integer greater than or equal to 2 and less than or equal to the absolute value of both.

For example,

13 and 22 are aligned numbers under 3 because
13%3 = 1
22%3 = 1

3<=13, 3<=22, and 3>=2

All our requirements are met.


A list is likewise-modulus-aligned when all the elements are aligned under the same modulus base.

## Challenge

Take in a list (not necessarily non-empty) of non-zero integers (not necessarily positive nor unique), and check if all the elements are likewise-modulus-aligned. Output is a truthy or falsy value.

Note; This is a "true-until-proven-otherwise" problem, meaning a single value in the list or an empty list will return TRUE.

## Example I/O

      In      | Out | Why
--------------|-----|---------
[5 7]|TRUE |1 mod 2
[7 12 18]|FALSE|(7,18) are not mod-aligned
[7 11 19]|TRUE |1 mod 2
[5 13 28 44]|FALSE|(5,28) are not mod-aligned
[10 13 37 108]|FALSE|(37,108) aren't aligned in any base below 10
[]|TRUE |No disproven pairs
[42]|TRUE |No disproven pairs
[-5 13 16]|TRUE |1 mod 3
[1 9 18]|FALSE|Arrays of size 2 or greater with 1 or -1 will always be false
[14 17 19]|FALSE|Every pair is modulus-aligned, but not under the same base
[17,22,32,107]|TRUE |2 mod 5
[4,8,12]|TRUE |0 mod 2
[-1,1]|FALSE|No mod 1 allowed
[1]|TRUE |No disproven pairs
[7,7,7]|TRUE |Numbers >=2 are always mod-aligned with themselves
[2,2,8,8]|TRUE |0 mod 2
[3 9 22 22]|FALSE|Pairs don't suddenly make (9,22) mod-aligned.


## Sandbox Questions

I'm gauging the interest to this question and seeing if this is an acceptable and unique challenge, just want to make sure I haven't missed another post doing a similar thing.

I changed the rules to be a lot more lenient on the comparisons, might do the pairwise comparison as a bonus or follow-up challenge later. But this is a compromise I can live with.

## Extra Hints/Tips

For all non-1 derivations, a number will be aligned with its negative self.
1 is never aligned with any other number, nor will -1.
A number that is a multiple of another will be aligned with that number in all its factors.
Numbers that share factors will always align, but numbers that don't share factors also may.
All odd numbers are aligned with each other, as are all even numbers.

• I'm not clear on why this challenge asks to compare all pairs of a list, rather than just a single pair. The condition covers pairs of numbers, so it would be more natural to just receive a pair of numbers as input. – isaacg Feb 19 at 18:21
• Because it's a combination of that function and a list-pair function with interesting shortcuts that can overlap. Asking for a pair could take X bits, and pushing all pairs to a function could take Y, but the combination of the two isn't necessarily X+Y. In my going at it, I saved like 8 bytes in the mix by being clever. This way, there are several ways to solve while still being a challenge. – Mathgeek Feb 19 at 18:24
• Some test cases that are not 1 mod x would be good – Jo King Feb 20 at 5:21
• Good suggestion, Jo. I just added one, and I'll add a few more in a bit - I hadn't even caught that! – Mathgeek Feb 20 at 13:32
• While what you observed can be true, in my experience it is not usually a source of interest in golfing to combine tasks unnecessarily. Similarly, does including negative numbers make this task more interesting? In most languages this will not make a difference, but it will make answering in some languages (consider Retina) substantially more difficult - to the point where people probably won't answer. I always try to recommend making a challenge as simple as possible - just like writing a proof. – FryAmTheEggman Feb 20 at 18:59
• I made negative numbers allowed because negative modulus is still a valid application of modulus - but that argument of "combining two things" is applicable to like literally every other code golf question. The string-wise calculus question could have just been "print out which of two characters is the largest", but then there was added difficulty to comparing pairs and assigning those values to distinct characters. This isn't just an arbitrary expansion, it's a setwise comparison of several elements applied over a function; You see these "expansions" all the time, so why is this one an issue? – Mathgeek Feb 20 at 19:24
• I agree that the part of the challenge where you check every pair seems unnecessary, and was going to comment on this independently. I think just having two numbers as inputs would make a better challenge overall. Or, have all numbers in the list need to be aligned by the same modulus, which seems like a more natural extension. – xnor Feb 20 at 19:33
• Okay, what about a fairer follow-up instead - instead of checking if all pairs are modulus-aligned, a list is modulus-aligned if all the entries share an identical mod-point. ie: They all have to be n mod m together for the list to be valid. Think that's still a more fair question? I think submitting pairs only is a very low-level simple problem that doesn't have any real puzzle or golfing elements to it, so I'd like it to be slightly more complex somehow. – Mathgeek Feb 20 at 19:37
• What you and xnor propose sounds good to me. I tried to phrase what I said as suggestions and opinions, because that is all they are. There isn't anything wrong with what you have, but I know I'd be more likely to answer if you changed some things about it. The same is true for many challenges on this site (including my own). Over time, I've come to see that including requirements that are technically valid but aren't necessary rarely adds interest to a challenge. – FryAmTheEggman Feb 20 at 20:29
• Doesn't [10 13 37 109] satisfy 1 mod 3 (and therefore it is modulus-aligned)? – Bubbler Feb 20 at 23:45
• You're correct fixed! – Mathgeek Feb 21 at 13:14
• @KevinCruijssen But that's fine. If I have a list [7, 14], they are aligned under Base 7. – Mathgeek Feb 21 at 14:40
• I also just read the "(not necessarily positive nor unique)" part of your challenge, so you might want to add a few test cases containing multiple of the same number in that case. – Kevin Cruijssen Feb 21 at 14:46
• Nice challenge btw. And good choice on explicitly mentioning "Note; This is a "true-until-proven-otherwise" problem, meaning a single value in the list or an empty list will return TRUE.", since those [1]/[-1] test cases are really annoying in my approach. ;) I had a prepared solution which worked for all initial test cases in 10 bytes, but now it's 50% larger to 15 bytes just to fix those two test cases, haha. Looking forward to when it goes live. I would leave it in the sandbox for a little while longer for others to give feedback though, just in case. Oh, and welcome to CGCC! – Kevin Cruijssen Feb 21 at 15:05
• @xnor yes, the question then dissolves to finding whether the gcd of the differences of consecutive elements is >1. – Don Thousand Feb 21 at 16:09

## Square-Cube Digit Usage

• In response to the first sentence: nice. – Lyxal Feb 20 at 0:43
• I'm not exactly sure how your title relates to the challenge. Obviously "Square-Cube Digit Usage" won't exactly roll off the tongue, but what you have now seems misleading. – FryAmTheEggman Feb 20 at 20:22
• Nice challenge. I prepared a solution for when it goes live. I would add a few more test cases first, though. One suggestion: 1333 (or 3133/3313/3331) -> 111 (first positive integer as input that has a 3-digit number as output). Here the results for the first 10,000 inputs. – Kevin Cruijssen Feb 21 at 10:53

# Draw an American flag for any amount of states

The flag of the United States of America goes by many names. The Stars and Stripes. Old Glory. The Last Known Non-Erotic Usage Of The Verb 'To Spangle'.

It is also one of the few flags semi-regularly updated. The red and white stripes represent the 13 original states, but one more star has been added to the blue canton for every state that joined the union later. This last happened in 1960, when Hawaii got in. Flag designs with 51 stars are already waiting for when Puerto Rico or Washington D.C. are made states, but this vexillologist is lazy. You are to make a program that can draw the flag with any number of stars desired!

### Specification

Here's a neat image of the official, government-standardised design for the current U.S. flag:

Disregard the contents of the canton for now. Your program must draw a flag that adheres to only the ratios I give here:

• A (the height of the flag) = 1
• B (the width of the flag) = 19/10
• C (the height of the canton) = 7/13
• D (the width of the canton) = 19/25
• L (the height of any stripe) = 1/13

Because raster solutions are not exact and this flag is commonly misdrawn anyway, there's tolerance of 2% for every ratio, taking the flag height as the base.

Furthermore, the correct colours must be used.

• Every odd-numbered stripe must be this shade (hex): #B22234
• The blue canton must be in this shade: #3C3B6E
• Every even-numbered stripe, and every star, must be in this shade: #FFFFFF

Conversions to other colour coordinate systems can be found on the wiki page as well.

### Stars

Your program must takes as input any integer between 0 and 200, and draw that number of stars within the canton. The following rules apply.

• Each star must have five outer points and be five-fold rotationally symmetrical.
• Each star must be the same size.
• The bounding circles of stars may overlap, but the surface of the stars itself may not overlap.
• The bounding circles of the stars may go outside the canton, but the surface of the stars itself may not go outside the canton.
• I don't want solutions that just place every star on the same line; that would leave a lot of blue canton untouched, which would be a waste. So, as a rule, the combined surface area of the bounding circles of every star in the canton must be at least 20% of the surface area of the canton.

Since overlapping bounding circles still count, you get a formula for the minimum width w of the star, where a is the area of the canton and n the number of stars: . See here for how it's derived.

### Other specifications

There's no minimum or maximum size for your output image, though I recommend something that will allow 200 stars to fit but still be demonstrably star-shaped. When they are only a few pixels high, it becomes hard to argue that they have the required amount of points. Obviously, for vector solutions any size is permissible.

This is , so the smallest program wins!

### Test cases

Because I gave no specific arrangement of the stars (you may arrange them however you want), there is an infinite number of correct and incorrect solutions for each number of stars. These are just examples of valid and invalid solutions:

Valid:

Invalid (stars too small):

Valid:

Invalid (stars of unequal size, going out of the canton):

Invalid (stars have too many points, stripes have wrong colours, colours are the wrong hue, proportions are wrong):

## Sandbox

Do I need more test cases? Any other feedback?

• If you really want to allow 0 as an input, you'll need an exception to the rule that the combined areas of the bounding circle must be at least 20% of the area of the canton. (If there aren't any stars, there aren't any bounding circles, so the combined areas would be 0.) – Mitchell Spector Mar 7 at 2:19
• I know it's less thematic, but maybe the task could be just to draw the canton? Arranging and drawing the stars is the interesting part, whereas the stripes aren't changing, so in terms of golfing the stripes seem somewhat extraneous. I guess you could also have the number of stripes be variable. – xnor Mar 7 at 17:40

## Symmetrical difference code-golf

Post'd.

• If a language supports it, can we take output and input as sets instead of a lists? – Chas Brown Apr 9 at 8:08
• I don't think it's a dupe. Post it. – HighlyRadioactive Apr 27 at 0:02

# Help, I've mixed my week up!

My dog ate my calendar, and now my days are all mixed up. I tried putting it back together, but I keep mixing up the days of the week! I need some help putting my calendar back together, with the days in the correct order.

And since I need my calendar put together as fast as possible, don't waste my time by sending me superfluous bytes. The fewer bytes I have to read, the better!

## Input

The days of the week, in any order. Input can be taken as a list of strings, or a space separated string, or any reasonable way of representing 7 strings (one for each day of the week).

The strings themselves are all capitalized, as weekdays should be, so the exact strings are:

Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday


## Output

The days of the week, in sorted order (Monday - Sunday). Output can be as a list of strings, or printed with some delimiter.

## Disclaimer

Note that this is a challenge, with the added benefit of being able to use the input to shorten your code. You are not required to use the input if you don't want to.

## Examples

To see example input and output, you can consult this python script.

## For the sandbox

• You cannot use 6 tags, and this still needs [code-golf]. Otherwise this seems to be a nice challenge. (I can see a 4-6 Jelly solution by sort-nth permutation though) – my pronoun is monicareinstate Apr 28 at 1:03
• @mypronounismonicareinstate I forgot about the code-golf tag, but of course it should be there. I have my own solution in MathGolf (not quite 4 bytes), but I'm interested in different approaches. – maxb Apr 28 at 6:19

# Fold my ACGT proteins code-golfstringbiologychemistry

Quoting Wikipedia, "Protein folding is the physical process by which a protein chain acquires its native 3-dimensional structure, a conformation that is usually biologically functional, in an expeditious and reproducible manner.". I don't know what that means but by means of a game called Foldit it seems we can use protein folding in some way to help and fight diseases.

Please bear in mind that the task described was inspired by the isolated meaning of the words in "protein folding" and doesn't necessarily translate into how protein folding really works! i.e. the title is just a pun.

# Implement the Polygamma function

The Polygamma function of order $$\m\$$, $$\\psi^{(m)}(z)\$$, is the $$\(m + 1)\$$th derivative of the logarithm of the gamma function, which is also the $$\m\$$th derivative of the digamma function. Your task is to take an integer $$\m\$$ and a positive real number $$\z\$$ and output $$\\psi^{(m)}(z)\$$

## Definitions

For those unfamiliar with the functions above (Gamma, Digamma and Polygamma), here are a few different definitions for each:

### $$\\Gamma(z)\$$

• The gamma function is an extension of the factorial ($$\x! = 1\cdot2\cdot3\cdots(x-1)\cdot(x)\$$) to real numbers
• $$\\Gamma(z) = \int_{0}^{\infty}x^{z-1}e^{-x}dx\$$
• $$\\Gamma(n) = (n - 1)! \:,\:\: n \in \mathbb{N}\$$
• $$\\Gamma(n+1) = n\Gamma(n) \:,\:\: n \in \mathbb{N}\$$\$

### $$\\psi(z)\$$

• The digamma function is the logarithmic derivative of the gamma function
• $$\\psi(z) = \frac{d}{dz}\ln(\Gamma(z))\$$
• $$\\psi(z) = \frac{\Gamma'(z)}{\Gamma(z)}\$$
• $$\\psi(z + 1) = \psi(z) + \frac{1}{z}\$$

### $$\\psi^{(m)}(z)\$$

• The polygamma function of order $$\m\$$ is the $$\m\$$th derivative of the digamma function
• $$\\psi^{(m)}(z) = \frac{d^m}{dz^m}\psi(z)\$$
• $$\\psi^{(m)}(z) = \frac{d^{m+1}}{dz^{m+1}}\ln(\Gamma(z))\$$
• $$\\psi^{(m)}(z+1)= \psi^{(m)}(z) + (-1)^m\frac{m!}{z^{m+1}}\$$

You are to take two inputs, a natural number $$\m\$$ and a positive real number $$\z\$$, and output $$\\psi^{(m)}(z)\$$. The inputs and outputs will always fit within the number bounds of your language, but your algorithm must work theoretically for any and all inputs.

As the output is usually going to be a real number, rather than an integer, the output should show at least 5 decimal places. This may be optionally ignored if the output is an integer, but not if the decimal part of the output begins with .00000. For example, $$\\psi^{(6)}(20) = -0.000002172607350\$$, so an output of $$\-0.00000\$$ is acceptable, but $$\0\$$ is not. Note that the sign is required.

This is so the shortest code in bytes wins.

## Test cases

Results may differ due to floating point inaccuracies, Python's scipy library was used to generate the values. Values are rounded to 15d.p., unless otherwise stated.

 m,                  z -> ψ⁽ᵐ⁾(z)
17,                  2 -> 1357763223.715975761413574
5,                 40 -> 0.000000249389435
9,           53.59375 -> 0.000000000012010
35,                  9 -> 469354.958166260155849
46,                  5 -> -7745723758939047727202304.000000000000000
7, 1.2222222222222222 -> 1021.084176496877490
28,               6.25 -> -2567975.924144014250487
2,               7.85 -> -0.018426049840992


This table has the values of $$\\psi^{(m)}(z)\$$ for $$\0 \le m \le 9\$$ and $$\1 \le z \le 20\$$:


+---+------------------------+---------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+
|   |           1            |          2          |         3          |         4          |         5          |         6          |         7          |         8          |         9          |         10         |         11         |         12         |         13         |         14         |         15         |         16         |         17         |         18         |         19         |         20         |
+---+------------------------+---------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+
| 0 |   -0.577215664901533   |  0.422784335098467  | 0.922784335098467  | 1.256117668431800  | 1.506117668431800  | 1.706117668431800  | 1.872784335098467  | 2.015641477955610  | 2.140641477955610  | 2.251752589066721  | 2.351752589066721  | 2.442661679975812  | 2.525995013309145  | 2.602918090232222  | 2.674346661660794  | 2.741013328327460  | 2.803513328327460  | 2.862336857739225  | 2.917892413294781  | 2.970523992242149  |
| 1 |   1.644934066848227    |  0.644934066848227  | 0.394934066848226  | 0.283822955737115  | 0.221322955737115  | 0.181322955737115  | 0.153545177959338  | 0.133137014694031  | 0.117512014694031  | 0.105166335681686  | 0.095166335681686  | 0.086901872871768  | 0.079957428427324  | 0.074040268664010  | 0.068938227847684  | 0.064493783403239  | 0.060587533403239  | 0.057127325790783  | 0.054040906037696  | 0.051270822935203  |
| 2 |   -2.404113806319188   |  -0.404113806319189 | -0.154113806319189 | -0.080039732245115 | -0.048789732245114 | -0.032789732245115 | -0.023530472985855 | -0.017699569195768 | -0.013793319195768 | -0.011049834970802 | -0.009049834970802 | -0.007547205368999 | -0.006389797961592 | -0.005479465690312 | -0.004750602716552 | -0.004158010123959 | -0.003669728873959 | -0.003262645625435 | -0.002919710097314 | -0.002628122402315 |
| 3 |   6.493939402266829    |  0.493939402266829  | 0.118939402266829  | 0.044865328192755  | 0.021427828192755  | 0.011827828192755  | 0.007198198563125  | 0.004699239795945  | 0.003234396045945  | 0.002319901304290  | 0.001719901304290  | 0.001310093231071  | 0.001020741379219  | 0.000810664701232  | 0.000654479778283  | 0.000535961259764  | 0.000444408525389  | 0.000372570305061  | 0.000315414383708  | 0.000269374221340  |
| 4 |  -24.886266123440890   |  -0.886266123440879 | -0.136266123440878 | -0.037500691342113 | -0.014063191342113 | -0.006383191342113 | -0.003296771589026 | -0.001868795150638 | -0.001136373275638 | -0.000729931168235 | -0.000489931168235 | -0.000340910050701 | -0.000244459433417 | -0.000179820455575 | -0.000135196191875 | -0.000103591253604 | -0.000080703070010 | -0.000063799959344 | -0.000051098643488 | -0.000041405977726 |
| 5 |  122.081167438133861   |  2.081167438133896  | 0.206167438133897  | 0.041558384635954  | 0.012261509635954  | 0.004581509635954  | 0.002009493175049  | 0.000989510004771  | 0.000531746332896  | 0.000305945162117  | 0.000185945162117  | 0.000118208290511  | 0.000078020533309  | 0.000053159387985  | 0.000037222150950  | 0.000026687171526  | 0.000019534614153  | 0.000014563111016  | 0.000011034967722  | 0.000008484266206  |
| 6 |  -726.011479714984489  |  -6.011479714984437 | -0.386479714984435 | -0.057261607988551 | -0.013316295488551 | -0.004100295488551 | -0.001528279027645 | -0.000654007738836 | -0.000310684984930 | -0.000160150871077 | -0.000088150871077 | -0.000051203486564 | -0.000031109607963 | -0.000019635233198 | -0.000012804988755 | -0.000008590996985 | -0.000005908787970 | -0.000004154139804 | -0.000002978092040 | -0.000002172607350 |
| 7 |  5060.549875237640663  |  20.549875237639476 | 0.862375237639470  | 0.094199654649073  | 0.017295357774073  | 0.004392957774073  | 0.001392271903016  | 0.000518000614207  | 0.000217593204539  | 0.000100511115987  | 0.000050111115987  | 0.000026599144024  | 0.000014877714841  | 0.000008699205352  | 0.000005284083130  | 0.000003317553637  | 0.000002144087193  | 0.000001421585007  | 0.000000964233099  | 0.000000667475582  |
| 8 | -40400.978398747647589 | -80.978398747634884 | -2.228398747634885 | -0.179930526327158 | -0.026121932577158 | -0.005478092577158 | -0.001477178082416 | -0.000478010895205 | -0.000177603485537 | -0.000073530517936 | -0.000033210517936 | -0.000016110901963 | -0.000008296615840 | -0.000004494456155 | -0.000002542957742 | -0.000001494142013 | -0.000000907408791 | -0.000000567407762 | -0.000000364140247 | -0.000000239189714 |
| 9 | 363240.911422382690944 | 360.911422382626938 | 6.536422382626807  | 0.391017718703625  | 0.044948382766125  | 0.007789470766125  | 0.001788099024012  | 0.000503455497598  | 0.000165497161722  | 0.000061424194120  | 0.000025136194120  | 0.000011145599233  | 0.000005284884641  | 0.000002652620244  | 0.000001398085550  | 0.000000768796112  | 0.000000438758675  | 0.000000258758130  | 0.000000157124373  | 0.000000097937278  |
+---+------------------------+---------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+--------------------+

• Mathematica: PolyGamma. – my pronoun is monicareinstate Jul 27 at 3:37
• Looks good, except that I have no idea where to start. – Bubbler Jul 31 at 1:00

# Convert LifeOnTheEdge to LifeOnTheSlope

Your task here is to take a LifeOnTheEdge pattern and convert it to LifeOnTheSlope.

A LifeOnTheEdge pattern is composed of these four characters: |_L . A pattern corresponds to a certain arrangement of "on" edges in a square grid. The pattern is placed in the grid first with the characters in the cells, and each of the four letters specifies the state of the edges on the left and the bottom of that cell. | means the edge on the left is on, _ means the bottom edge is on, L means both of them are on and   means neither of them are on.

For example the following LifeOnTheEdge:

|_L
|


translates to:

. . . . .
|   |
. ._._. .
|
. . . . .


Your task is however convert it to LifeOnTheSlope. LifeOnTheSlope is a LifeOnTheEdge equivalent but only uses three symbols: /\ . You should rotate the pattern 45-degree clockwise, for example the above example translates to:

/

/\/
\


# Sandbox

I'm not sure if I described the problem clearly. Improvements on the wording and other things?

• Nice challenge! The task is clear, I just think you may specify if and how leading/trailing newlines/spaces are allowed, for example in the example there may be a trailing space. And also.. Are the set of characters strictly fixed? People usually ask for free sets, for example some values [1,2,3,0] instead of |_L but since this is ascii-art I think it's fine to have a fixed set. Let's see if anyone else has any opinion. – AZTECCO Aug 2 at 12:35
• @AZTECCO For the second question I'm fine with both options. This convertion is a thing that annoys me in my CA exploration. – HighlyRadioactive Aug 2 at 12:38

# The Turing Text Tape code-golf

## Introduction

Ah, INTERCAL...
As much as I'd like encourage everyone to Try it Online sometime, text output is just painful.
According to the docs it uses the "Turing Text Model". While an... interesting concept, using it is about as much fun as shooting yourself in the foot. And what do we do with a task like this? Automate it.

## The Turing Text Model

The characters INTERCAL knows are printed on a circular tape that can only be moved in the positive direction. Printing is done by passing tape head movement commands in an array to the READ OUT statement. Every ASCII character is written on the inside of that tape (The outside has the characters for the input on it, duh). This results in the characters' bytes being on the tape in reverse. Also the tape head moves backwards along the character list, because its positioning is based on the outside of the tape.
The head starts at position 0.

Now the magic starts. I'll be using Truttle1's explanation on how to achieve output.

1. Set up an array with the output length.
2. Fill the entries in the array with tape head movement values.
1. Find the current character's ASCII value in binary
2. Reverse it and convert back a number n.
3. Subtract n from the current head postion and modulo by 256 if needed, resulting in a value r
4. r is the value you need to store in the array
5. The head is now at position n.
3. DO READ OUT the array.

• Array is pre-initialized with 0, first index is 1
• INTERCAL uses extended 8-bit ASCII characters, hence the tape length of 256.

## Challenge

Given an input string, output a valid INTERCAL program that prints that string and terminates.

## Examples

Prints "BUZZ"

DO ,1 <- #4
DO ,1 SUB #1 <- #190
DO ,1 SUB #2 <- #152
DO ,1 SUB #3 <- #336


Whitespace is optional. The following prints "FIZZ"

DO,1<-#4DO,1SUB#1<-#158DO,1SUB#2<-#208DO,1SUB#3<-#312PLEASEREADOUT,1PLEASEGIVEUP


(Examples shamelessly stolen from Truttle1's FizzBuzz program from the video.)

You can find an ungolfed reference implementation in python 3 here

## Rules

• No standard loopholes
• This is , shortest code wins.
• You can expect input >= 1, ASCII characters only
• Output optimisation is optional.
• The program may not throw any errors apart from the RANDOM COMPILER BUG
• You may not use compiler flags, e.g. to turn off politeness checking

## Sandbox stuff

This better not be a duplicate. I didn't find anything though, so it shouldn't be.

• Is there anything that can be worded better?
• Are there some edge-cases that need an example?
• Should I add any rules; if so, which?

# Stroke Count of a Chinese Numeral codegolf

Given an integer $$\n\in\left[0,10^{12}\right)\$$ in any convenient format, compute the number of strokes needed to write that number in (simplified) Chinese.

### Background

Chinese numbers are expressed with a system of digits and places, just like in English, but grouped by powers of 10000 rather than 1000.

At the lowest level, Chinese characters are a collection of strokes, laid out in a certain order and manner. The number of strokes needed to write a certain character is that character's stroke count.

With their English equivalents and stroke count, the (simplified) characters used to write numbers are:

num   char　 strokes
0     零*    13
1     一     1
2     二**   2
3     三     3
4     四     5
5     五     4
6     六     4
7     七     2
8     八     2
9     九     2
10    十     2
100   百     6
1000  千     3
10^4  万     3
10^8  亿     3
* 0 can also be written 〇, but we won't use that here.
** 两 is largely interchangeable with 二, apart from never
appearing before 十. For simplicity, we won't consider
it here, but 两 is very common in actual usage.


For example, 987654321 is 九亿八千七百六十五万四千三百二十一: nine hundred-thousand (九 亿), eight thousand seven hundred sixty-five ten-thousand (八千七百六十五 万), four thousand three hundred twenty-one (四千三百二十一). 53 strokes are needed to write this out.

Additionally, there are some special rules involving the digits 0 and 1. These can vary slightly between regional dialects, so we'll choose these:

• When there are non-trailing 0s in a group of 4 digits, they are combined into a single 零. No place designation is used.

(This is because e.g. 一百二 is a common way to say 120. We won't consider that form.)

• 1020 is 一千二十.
• 60708 is 六万七百八.
• 300004005 is 三亿四千五.
• 0 is 零.
• If the number would begin with 一十, the 一 is omitted.

• Powers of 10 are 一, 十, 一百, 一千, 一万, 十万, 一百万, etc.
• 111 is 一百一十一.

## Test Cases

           n  strokes  chinese
0  13       零
10  2        十
236  17       二百三十六
7041  26       七千零四十一
100000  5        十万
860483  42       八十六万零四百八十三
4941507  52       四百九十四万一千五百零七
51001924  38       五千一百万一千九百二十四
105064519  70       一亿零五百零六万四千五百一十九
300004005  31       三亿四千零五
1240601851  56       十二亿四千零六十万一千八百五十一
608726402463  79       六千零八十七亿二千六百四十万二千四百六十三
`

## Sandbox notes

How can the organization be improved?

Is anything unclear?

Are there any edge cases I may missed in the test cases, or ambiguities that need explaining?

• Related (not dupe). Stroke count is actually good idea because it avoids the need to hardcode Chinese characters. The description looks clear enough to me. – Bubbler yesterday
• Might be useful: tio.run/… – user202729 yesterday
• (to read the test cases) – user202729 yesterday