Add array tally for ruby
This commit is contained in:
parent
2b242e2254
commit
75a9e9cf02
1 changed files with 7 additions and 0 deletions
|
@ -12,3 +12,10 @@ puts true if arr.uniq.length == 1
|
||||||
```ruby
|
```ruby
|
||||||
(subarray & array) == array
|
(subarray & array) == array
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Compute values occurences
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
[1, 1, 2, 3, 4, 5, 5, 5, 5].tally
|
||||||
|
=> {1=>2, 2=>1, 3=>1, 4=>1, 5=>4}
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue