Number distribution

Posted by Carra on Stack Overflow See other posts from Stack Overflow or by Carra
Published on 2011-11-28T16:09:35Z Indexed on 2011/11/28 17:53 UTC
Read the original article Hit count: 204

Problem: We have x checkboxes and we want to check y of them evenly.

Example 1: select 50 checkboxes of 100 total.

[-]
[x]
[-]
[x]
...

Example 2: select 33 checkboxes of 100 total.

[-]
[-]
[x]
[-]
[-]
[x]
...

Example 3: select 66 checkboxes of 100 total:

[-]
[x]
[x]
[-]
[x]
[x]
...

But we're having trouble to come up with a formula to check them in code, especially once you go 11/111 or something similar. Anyone has an idea?

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about language-agnostic