Skip to main content
deleted 1 character in body
Source Link
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                   
           

J, 45 bytes

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

[:(+/%#){:@]+/@}.&|:[:>:@/:~"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                   
           

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                   
           
deleted 39 characters in body
Source Link
xash
  • 11.3k
  • 1
  • 14
  • 39

J, 4645 bytes

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

[:(+/%#){:@]+/@}.&|:[:>:@/:~"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                   
           

Try it online!

J, 46 bytes

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

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

How it works

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

Try it online!

J, 45 bytes

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

[:(+/%#){:@]+/@}.&|:[:>:@/:~"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                   
           
Source Link
xash
  • 11.3k
  • 1
  • 14
  • 39

J, 46 bytes

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

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

How it works

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

Try it online!