Advertisement
Guest User

partitions

a guest
Jul 12th, 2019
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. n = 20;
  2. Manipulate[
  3. f[l_] := Accumulate[Join[{{0, 0}}, MapIndexed[#1 (
  4. With[{i = #2[[1]]},
  5. N[{Sin[2 Pi i/k], Cos[2 Pi i / k]}]
  6. ]
  7. ) &, l]]];
  8.  
  9. partitions = IntegerPartitions[n];
  10. paths = f /@ partitions;
  11. Graphics[
  12. {
  13. Thick,
  14. Opacity[0.5],
  15. PointSize[Large],
  16. Table[
  17. {
  18. ColorData["DarkRainbow"][i/Length[paths]],
  19. Line[paths[[i]]],
  20. Point[paths[[i, -1]]]
  21. },
  22. {i, Length[paths]}
  23. ]
  24. }
  25. ],
  26. {k, 3, 20, 1}
  27. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement