I got the intersection of a set finally working but I can not make the Union of a set work. Basicly I need to get the union of 7 sets. For example:

1234

456

789

1456

812

367

13467

Now am doing this with a big string where I store the 7 sets but I just can't find the logic to compare each of them and only add the new one. Now I have to do this with simple code, meaning I have to make the functions myself and I can't use any functions from libraries. Please give me some help here with the logic behind this.