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 Probability of rolling all 6 dice faces

Dyalog APL, 21 bytes {≢⍸6=(≢∪)¨⍳⍵/6}÷(6∘*) Bruteforce solution :) ⍳⍵/6 n-dimensional array of all possibilities of rolling $n$ dice, each element is a vector of the dice values ≢ count the ...

posted 10mo ago by RubenVerg‭  ·  edited 10mo ago by RubenVerg‭

Answer
#2: Post edited by user avatar RubenVerg‭ · 2023-07-09T09:55:51Z (10 months ago)
-1 byte
  • # Dyalog APL, 22 bytes
  • ```apl
  • {+/6=(≢∪)¨,⍳⍵/6}÷(6∘*)
  • ```
  • Bruteforce solution :)
  • * `,⍳⍵/6` of all possibilities of rolling $n$ dice, as a list of lists
  • * `+/` count the elements where
  • * `(≢∪)¨` the length of the unique elements
  • * `6=` is equal to 6
  • * `÷` and divide by
  • * `6∘*` 6 to the power of $n$
  • # Dyalog APL, 21 bytes
  • ```apl
  • {≢⍸6=(≢∪)¨⍳⍵/6}÷(6∘*)
  • ```
  • Bruteforce solution :)
  • * `⍳⍵/6` n-dimensional array of all possibilities of rolling $n$ dice, each element is a vector of the dice values
  • * `` count the elements
  • * `⍸` where it is true that
  • * `(≢∪)¨` the length of the unique elements
  • * `6=` is equal to 6
  • * `÷` and divide by
  • * `6∘*` 6 to the power of $n$
#1: Initial revision by user avatar RubenVerg‭ · 2023-07-08T15:38:14Z (10 months ago)
# Dyalog APL, 22 bytes

```apl
{+/6=(≢∪)¨,⍳⍵/6}÷(6∘*)
```

Bruteforce solution :)

* `,⍳⍵/6` of all possibilities of rolling $n$ dice, as a list of lists
* `+/` count the elements where
* `(≢∪)¨` the length of the unique elements
* `6=` is equal to 6
* `÷` and divide by
* `6∘*` 6 to the power of $n$