Advertisement
ablmf

subsum.jl

Dec 9th, 2019
2,328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.71 KB | None | 0 0
  1. using Combinatorics
  2.  
  3. if length(ARGS) >=1
  4.     set_size_1 = parse(Int,ARGS[1])
  5. else
  6.     set_size_1 = 30
  7. end
  8. println(set_size_1)
  9.  
  10. set_size_2 = 8
  11. set_size_3 = 4
  12.  
  13. set_1 = (1:set_size_1)
  14. max_sum = sum(set_size_1:-1:set_size_1-set_size_3+1)
  15. println(max_sum)
  16.  
  17. sarray = Array{UInt8}(undef, max_sum)
  18.  
  19. for set_2 = combinations(set_1, set_size_2)
  20.     found = true
  21.     sarray .= 0
  22.     for set_3 = combinations(set_2, set_size_3)
  23.         s = sum(set_3)
  24.         if sarray[s]>=1
  25.             found = false
  26.             break
  27.         else
  28.             sarray[s]+=1
  29.         end
  30.     end
  31.     if found
  32.         println(set_2)
  33.         println(sarray)
  34.     end
  35. end
  36.  
  37. println("finished")
  38. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement