Skip to main content
3 of 3
deleted 1 character in body
xash
  • 11.3k
  • 1
  • 14
  • 39

J, 45 bytes

Takes input as k on the left side and n, luck on the right side.

[:(+/%#){:@]+/@}.&|:1+[:/:~"1[#.inv(i.@^+&|/)

Try it online!

How it works

[:(+/%#){:@]+/@}.&|:1+[:/:~"1[#.inv(i.@^+&|/)
                                    i.@^+&|/ 0..k^(|n| + |luck|)
                             [#.inv          to base k 0 0 0..5 5 5
                        /:~"1                sort each roll
                    1+                       0 0 0 -> 1 1 1
        {:@]   }.&|:                         transpose and drop luck rows
                                             negative values drop from end
            +/                               sum each roll
  (+/%#)                                     average of all rolls                   
           
xash
  • 11.3k
  • 1
  • 14
  • 39