Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

60%
+1 −0
Challenges Expected value of highest dice rolled

Dyalog APL, 16 bytes {(+/÷≢)⌈/¨,⍳⍵/6} Explanation: ,⍳⍵/6 generate a list of all the possible sets of rolls ⌈/¨ find the maximum of each +/÷≢ find the average (sum up all values and divide ...

posted 1y ago by RubenVerg‭  ·  edited 1y ago by RubenVerg‭

Answer
#2: Post edited by user avatar RubenVerg‭ · 2023-07-07T11:33:33Z (over 1 year ago)
  • # Dyalog APL, 16 bytes
  • ```apl
  • {(+/÷≢)⌈/¨,⍳⍵/6}
  • ```
  • Explanation:
  • * `,⍳⍵/6` generate a list of all the possible sets of rolls
  • * `⌈/¨` find the maximum of each
  • * `+/÷≢` find the average (sum up all values and divide by the length of the list)
  • this is *incredibly* slow and expensive memory-wise, but hey it works :)
  • # Dyalog APL, 16 bytes
  • ```apl
  • {(+/÷≢)⌈/¨,⍳⍵/6}
  • ```
  • Explanation:
  • * `,⍳⍵/6` generate a list of all the possible sets of rolls
  • * `⌈/¨` find the maximum of each
  • * `+/÷≢` find the average (sum up all values and divide by the length of the list)
  • this is *incredibly* slow and expensive memory-wise (computing 9 and 10 required increasing the default workspace memory size from .5GB to 2GB), but hey it works :)
#1: Initial revision by user avatar RubenVerg‭ · 2023-07-07T11:32:31Z (over 1 year ago)
# Dyalog APL, 16 bytes

```apl
{(+/÷≢)⌈/¨,⍳⍵/6}
```

Explanation:

* `,⍳⍵/6` generate a list of all the possible sets of rolls
* `⌈/¨` find the maximum of each
* `+/÷≢` find the average (sum up all values and divide by the length of the list)

this is *incredibly* slow and expensive memory-wise, but hey it works :)