# Recipe for diced shark fin

How may the following shark-fin-shaped Goal distribution be cooked up with 44 ingredients in a roll recipe R based on the roll sum of two 6-sided dice with non-standard allotments of dots?

     Goal:  Shark fin distribution of results calculated by R from the sum
of two dice whose sides have a,b,c,d,e,f and g,h,i,j,k,l dots

total dots  =  a+b+c+d+e+f + g+h+i+j+k+l
operators   =  p
+  operand sum =  q
========================================================
ingredients =  total dots + operators + operand sum
=  a+b+c+d+e+f+g+h+i+j+k+l + p + q
=  44


That is: ­ The number 1 is served up by R from the roll sum of only 1 of the 36 possible two-die combinations; ­ the number 2 is served up from the roll sums of just 2 combinations; ­ and so on, up to the number 8 being served up by R from the roll sums of the remaining 8 combinations. ­ R may serve up the same number from differently-valued roll sums.

As outlined in the shaded text box for the Goal, “ingredients” is the total of: ­ the numbers of dots on all sides of both dice, the number of operators in the roll recipe, and the operands of those operators.

For this puzzle, “number” means an integer that is at least 0, “dice” have 6 sides, each side with a number (0 or more, as just noted) of dots, and “roll sum” is the total number of dots facing up on the two dice. Relative positions of sides on the dice are inconsequential.

A “roll recipe,” R, consists of a series of operations with operators and operands. Each operation revises a progressive result whose initial value is the roll sum. The roll sum is not otherwise available in calculation. An “operand” is a number, shown as n in the following list of “operators” in play. (The current result is not called an operand here, even though it technically is one, and it only appears on one side of each operation.) A roll recipe is in effect a set of nested parentheses that surround a roll sum by operations and operands.

  OPERATOR    REVISED result

−         result − n         subtraction
n − result

×         result × n         multiplication

/         result / n         integer division  (e.g, 8/3 = 2, −8/3 = −2)
n / result

max       result max n        whichever is more, result or n
min       result min n        whichever is less, result or n


The tag means that a correct solution explains how it can be derived without a computer or unreasonable labor. Feel free, though, to use a computer for exploring or verifying a hunch, for demonstrating some limit, or for anything else interesting. Creative solutions that go outside the parameters here will receive a vote of appreciation from this puzzle’s poser.

On to examples of non-Goal distributions. ­ For comparison to the shark fin Goal above, a familiar triangular Standard distribution with 42 ingredients is served up with no calculation on the raw roll sum of two standard dice (sides are numbered 1,2,3,4,5,6):

 Standard:  Unrevised roll sum of two dice with sides numbered 1,2,3,4,5,6
recipe   R  =  [1,2,3,4,5,6 + 1,2,3,4,5,6]

total dots  =  42  =  1+2+3+4+5+6 + 1+2+3+4+5+6
operators   =   0
+  operand sum =   0
======================
ingredients =  42


An Almost-shark-fin distribution may be cooked up with 53 ingredients by taking the roll sum of two standard dice, again, but now subtracting 1 from it and capping that at 8 :

   Almost:  recipe   R  =  ([1,2,3,4,5,6 + 1,2,3,4,5,6] − 1) min 8
\__________/
operations
total dots  =  42  =  1+2+3+4+5+6 + 1+2+3+4+5+6
operators   =   2  =  "−"  "min"
+  operand sum =   9  =  1 + 8
======================
ingredients =  53


The same Almost distribution may be cooked up with a Better roll recipe that has many fewer ingredients by numbering the dice 0,1,1,2,2,3 and 0,2,3,4,5,7, capping their roll sum at 7, and adding 1 to that :

   Better:  recipe   R  =  ([0,1,1,2,2,3 + 0,2,3,4,5,7] min 7) + 1

total dots  =  30  =  0+1+1+2+2+3 + 0+2+3+4+5+7
operators   =   2  =  "min"  "+"
+  operand sum =   8  =  7 + 1
======================
ingredients =  40


Open-ended Bounty challenge, apparently resolved: ­ Fewest ingredients to cook up a shark fin Goal distribution with a roll recipe R that has only one operation (operators = 1). ­ At post time the secret Bounty recipe to beat has 74 ingredients. ­ Update: Even without beating the initial secret Bounty recipe, solver newbie has earned two bounties with a solution that (unless someone happens to notice an oversight in the approach): (a) lists all 1-operation roll recipes of 74 ingredients, going on to prove that fewer ingredients will not suffice, and (b!) serendipitously proves that no solution exists directly from a no-recipe raw roll sum, which is quite a relief for this puzzle’s poser.

• Are we allowed to invoke the sum multiple times? (e.g. if we want to square the sum, can we do S*S at a 1 operator cost?) Apr 1, 2020 at 18:27
• [rewritten comment] Thank you, @phenomist , for pointing out uses of operations that are more general than intended here. The pertinent paragraph has been edited to somewhat clarify the simplistic scope of operations. Apr 1, 2020 at 19:22
• I started reading at the top of this puzzle and said "humn's finally got a new question!" Apr 2, 2020 at 16:48

On the bounty challenge:

Here is a secret bounty recipe that uses one operation and 74 ingredients.

dices have number [0,2,7,8,9,9] and [3,4,6,7,8,8], operation is /2. I also found some other similar solutions, all with 74 ingredients.

How I got this solution:

/2 is the first operation coming to my mind, so I just enumerated all dice pairs with small ingredients (with computer, of course) and verified to see if they work. All such dice pairs I found: [0,1,3,4,5,5],[3,5,10,11,12,12] [0,2,4,5,7,7],[2,5,9,10,10,10] [0,2,7,8,9,9],[3,4,6,7,8,8] [0,3,7,8,8,8],[2,4,6,7,9,9] [1,2,4,5,6,6],[2,4,9,10,11,11] [1,3,5,6,8,8],[1,4,8,9,9,9] [1,3,8,9,10,10],[2,3,5,6,7,7].

Also,

A complete search was conducted. These are the only secret bounty recipe with the fewest ingredients. https://ideone.com/oDbJe3

Besides this direct 'proof', intuitively, if we use only plus/minus/max/min, we still need to get a 1234567 or 2345678 pattern which is quite unlikely (I think a case-by-case analysis can show that). Multiplying will leave holes. constant/sum is also a bad idea because you need to let constant/sum to have values 1~8. This brings the constant to be at least $$42$$ and thus the greatest pair at least $$22$$. The only sensible candidate is then sum/constant. $$204=\sum_{i=1}^8 i^2=\sum_{i} \sum_j \lfloor \frac{a_i+b_j}{c}\rfloor\le \frac{1}{c}(\sum_{i} \sum_j (a_i+b_j))= \frac{6}{c}((\sum_{i} a_i)+(\sum_j b_j))$$. Therefore, if we choose $$c>2$$, $$(\sum_{i} a_i)+(\sum_j b_j)$$ will be at least $$102$$. We're quite lucky because that lowerbound for $$c=2$$ is $$68$$ and we have sum $$71$$ in the above solution.

On the general question:

Here is a secret recipe with 61 57 ingredients.

dice pair [0,1,1,2,4,5],[0,2,2,5,6,6]. operation is +1 *4 /5 min7 +1. (sum->min((sum+1)*4/5,7)+1)

• Maybe I’m slow, but what’s the 1 way to get a 1 in your solution? Almost looks like you need a rot13(sybbe) function in there as well... Apr 2, 2020 at 4:34
• True about rot13(sybbe) being part of this solution, @El-Guest . It is built into the rot13(vagrtre qvivqr), which rot13(ebhaqf gbjneq) 0. Apr 2, 2020 at 4:50
• Added some explanations. @humn I also suspect 74 is indeed mimimum. The easiest way to 'prove' this is probably just trying all the possible operations and operands no greater than 74. I'll try although that doesn't sound like a very satisfying proof to me. Apr 2, 2020 at 5:14
• I've added my search result & some intuitive explanation. 74 is indeed minimum. @humn Also, great catch! Apr 2, 2020 at 6:23
• Your code looks complete, @newbie, and is fun to experiment with. The second bounty is on its way because you validated the premise of this puzzle, which i had only assumed, that some manipulation of the roll sum is necessary. Any no-recipe solution would have been found by your program in multiple ways, such as "min 8" on a roll sum that already didn't exceed 8. Apr 5, 2020 at 22:10