Here is some code to implement block randomization when you have awkward integer problems. For example you want to allocate 4 treatment conditions with equal probability across two blocks with 6 units each. Ideally you then want to be sure that (a) each condition is assigned three times and (b) each block gets each condition.