# Generalized Birthday Problem

## MATL, 16 bytes

```
365:Z^!tXM=s>~Ym
```

First input is `N`

, second is `k`

.

**Try it online!**

This is an enumeration-based approach, like Dennis' Jelly answer, so input numbers should be kept small due to memory limitations.

```
365: % Vector [1 2 ... 365]
Z^ % Take N implicitly. Cartesian power. Gives a 2D array with each
% "combination" on a row
! % Transpose
t % Duplicate
XM % Mode (most frequent element) of each column
= % Test for equality, element-wise with broadcast. For each column, gives
% true for elements equal to that column's mode, false for the rest
s % Sum of each column. Gives a row vector
>~ % Take k implicitly. True for elements equal or greater than k
Ym % Mean of each column. Implicitly display
```

## Jelly, ~~17~~ 16 bytes

```
ĠZL
365ṗÇ€<¬µS÷L
```

Extremely inefficient. Try it online! (but keep **N** below **3**)

### How it works

```
365ṗÇ€<¬µS÷L Main link. Left argument: N. Right argument: K
365ṗ Cartesian product; generate all lists of length N that consist of
elements of [1, ..., 365].
Ç€ Map the helper link over all generated lists. It returns the highest
amount of people that share a single birthday.
< Compare each result with K.
¬ Negate.
µS÷L Take the mean by dividing the sum by the length.
ĠZL Helper link. Argument: A (list of integers)
Ġ Group the indices have identical values in A.
Z Zip; transpose rows with columns.
L Take the length of the result, thus counting columns.
```