Article 5H9WF [SOLVED] Numbers to score and identify a situation

[SOLVED] Numbers to score and identify a situation

by
lucmove
from LinuxQuestions.org on (#5H9WF)
By "numbers to score and identify a situation" I mean, for example, file permissions. 4, 2, 1, and 0 allow very unique and specific sum combinations that identify each specific situation and can be translated into one single number.

0 (0+0+0) - No permission.
1 (0+0+1) - Only execute permission.
2 (0+2+0) - Only write permission.
3 (0+2+1) - Write and execute permissions.
4 (4+0+0) - Only read permission.
5 (4+0+1) - Read and execute permission.
6 (4+2+0) - Read and write permissions.
7 (4+2+1) - Read, write, and execute permission.

Each sum is unique.

I don't know if there is a name for that specifically in math. Is there?

Anyway, how far can I go and how am I supposed to find other numbers?

In my code, zero is not possible because I iterate through a list of conditions and add a value to a variable whenever a condition is true. So I'm using 1, 2, 3, and 7:

1+2=3
1+3=4
1+7=8
2+3=5
2+7=9
3+7=10 (*)
1+2+3=6
1+2+7=10 (*collision!)
2+3+7=12
1+3+7=11

So 7 is not good because it may cause a collision. Thinking "manually," I conclude that I should replace it with 13, merely because it is the smallest number that is not the sum of any two or three of the smaller numbers, i.e. it is out of reach of collisions.

But no.

1+2=3
1+3=4
1+13=14
2+3=5
2+13=15
3+13=16 (*)
1+2+3=6
1+2+13=16 (*collision!)
1+3+13=17
2+3+13=18
1+2+3+13=22

OK, I'm learning a lesson here. 7 is not the problem. The real problem is I can't have 1, 2, and 3 because 1+2=3 and that will always be trouble further ahead. One more try:

2, 3, 6, 10:

2+3=5
2+6=8
2+10=12
3+6=9
3+10=13
6+10=16
2+3+6=11
2+3+10=15
2+6+10=18
3+6+10=19
2+3+6+10=21

Good. No collisions.

But finding 6 and 10 was tedious. What is the correct logic for this? Is there some way to calculate it?

If I need more numbers (and I do), what would the next numbers be? How am I supposed to find them?

TIAlatest?d=yIl2AUoC8zA latest?i=bECP3F_nTD8:S4qJ8miMNT8:F7zBnMy latest?i=bECP3F_nTD8:S4qJ8miMNT8:V_sGLiP latest?d=qj6IDK7rITs latest?i=bECP3F_nTD8:S4qJ8miMNT8:gIN9vFwbECP3F_nTD8
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments