Advertisement
f0rsakenbg

Untitled

Jun 7th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. InputLs = [
  2. [1, 2, 3, 6, 8],
  3. [4, 5, 7, 9]
  4. ] &
  5. [P1Lst, P2Lst] <=> InputLs &
  6. Count = compute sum (Len) where
  7. (
  8. L1 = m:lst.member (InputLs) &
  9. Len = :lst.length (L1)
  10. ) &
  11. N = to_integer (sqrt (Count)) &
  12. RowElements = compute list (Res) where
  13. (
  14. Row = m:type.enum_nbr (1, N) &
  15. Res = compute list (El) where
  16. (
  17. El = m:type.enum_nbr (1 + (Row - 1) * N, N * Row) &
  18. nop
  19. )
  20. ) &
  21. ColElements = compute list (Res) where
  22. (
  23. Col = m:type.enum_nbr (1, N) &
  24. Res = compute list (El) where
  25. (
  26. El = m:type.step_nbr (Col, N * N, N) &
  27. nop
  28. )
  29. ) &
  30. LDiag = compute list (El) where
  31. (
  32. El = m:type.step_nbr (1, N * N, N + 1) &
  33. nop
  34. ) &
  35.  
  36. RDiag = compute list (El) where
  37. (
  38. El = m:type.step_nbr (N, N * N - 1, N - 1) &
  39. nop
  40. ) &
  41. List1 = :lst.append (RowElements, ColElements) &
  42. List2 = :lst.append (List1, [LDiag]) &
  43. WinList = :lst.append (List2, [RDiag])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement