SHARE
TWEET

subsum.jl

ablmf Dec 9th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. ~
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top