### Haiku

As part of his science fair project, my 3^{rd}-grader needed a large number of random strings of 8 digits, in each of which “1” appears four times, and “2”–“5” appear once each.

```
#!/usr/bin/ruby
class Array
def scramble
p = dup
collect { p.delete_at(rand(p.length) - 1) }
end
end
100.times { puts [1,1,1,1,2,3,4,5].scramble.join }
```

## Re: Haiku

Mathematica is pretty good at this kind of things. The package Combinatorica contains a wealth of combinatorial algorithms (it seems to be loaded automatically in the version 7 of Mathematica). Anyway, the full list of numbers satisfying the constraints you stated can be found by using

`FromDigits /@ Permutations[{1,1,1,1,2,3,4,5}]`

which is very concise. There are 1680 such numbers.