Skip to main content
added 1102 characters in body
Source Link
Jakube
  • 21.9k
  • 3
  • 27
  • 108

Pyth, 23 21 bytes

GitHub repository for Pyth

Ju+G*]GHQYFNJjdmsqdNJ

Input is a list of integers, like [3, 21, 1]1, 2]. Try it online: Pyth Compiler/Executor

Uses a quite similar idea as randomra's J code. The first part of the code Ju+G*]GHQY generates n parts of similar things. For the example input [3, 1, 1, 2] the result looks like this:

[
 [], 
 [], 
 [], 
 [[], [], []], 
 [[], [], [], [[], [], []]], 
 [[], [], [], [[], [], []], [[], [], [], [[], [], []]]], 
 [[], [], [], [[], [], []], [[], [], [], [[], [], []]]]
]

First three identical elements, than one element , then one element again and at the end two identical elements.

Ju+G*]GHQY
 u      QY  reduce the input Q, start with empty list G=[]
            for each H in input, replace the value of G by:
  +G*]GH       G+[G]*H
J           store the result in J

The second part of the code is comparing the elements of the Cartesian product and printing it.

FNJjdmsqdNJ
FNJ          for N in J:
     m    J     map each element d of J to
       qdN          the boolean value of d == N
      s             and convert it to an integer (0 = False, 1 = True)
   jd           print the resulting list seperated by d (=space)

Pyth, 23 21 bytes

GitHub repository for Pyth

Ju+G*]GHQYFNJjdmsqdNJ

Input is a list of integers, like [3, 2, 1]. Try it online: Pyth Compiler/Executor

Uses a quite similar idea as randomra's J code.

Pyth, 23 21 bytes

GitHub repository for Pyth

Ju+G*]GHQYFNJjdmsqdNJ

Input is a list of integers, like [3, 1, 1, 2]. Try it online: Pyth Compiler/Executor

Uses a quite similar idea as randomra's J code. The first part of the code Ju+G*]GHQY generates n parts of similar things. For the example input [3, 1, 1, 2] the result looks like this:

[
 [], 
 [], 
 [], 
 [[], [], []], 
 [[], [], [], [[], [], []]], 
 [[], [], [], [[], [], []], [[], [], [], [[], [], []]]], 
 [[], [], [], [[], [], []], [[], [], [], [[], [], []]]]
]

First three identical elements, than one element , then one element again and at the end two identical elements.

Ju+G*]GHQY
 u      QY  reduce the input Q, start with empty list G=[]
            for each H in input, replace the value of G by:
  +G*]GH       G+[G]*H
J           store the result in J

The second part of the code is comparing the elements of the Cartesian product and printing it.

FNJjdmsqdNJ
FNJ          for N in J:
     m    J     map each element d of J to
       qdN          the boolean value of d == N
      s             and convert it to an integer (0 = False, 1 = True)
   jd           print the resulting list seperated by d (=space)
added 8 characters in body
Source Link
Jakube
  • 21.9k
  • 3
  • 27
  • 108

Pyth, 2323 21 bytes

GitHub repository for Pyth

Ju+G*]GHQYjbmj\ msqdkJJJu+G*]GHQYFNJjdmsqdNJ

Input is a list of integers, like [3, 2, 1]. Try it online: Pyth Compiler/Executor

Uses a quite similar idea as randomra's J code.

Pyth, 23 bytes

GitHub repository for Pyth

Ju+G*]GHQYjbmj\ msqdkJJ

Input is a list of integers, like [3, 2, 1]. Try it online: Pyth Compiler/Executor

Uses a quite similar idea as randomra's J code.

Pyth, 23 21 bytes

GitHub repository for Pyth

Ju+G*]GHQYFNJjdmsqdNJ

Input is a list of integers, like [3, 2, 1]. Try it online: Pyth Compiler/Executor

Uses a quite similar idea as randomra's J code.

links mess with the leaderboard ;)
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

Pyth:Pyth, 23 bytes

GitHub repository for Pyth

Ju+G*]GHQYjbmj\ msqdkJJ

Input is a list of integers, like [3, 2, 1]. Try it online: Pyth Compiler/Executor

Uses a quite similar idea as randomra's J code.

Pyth: 23 bytes

Ju+G*]GHQYjbmj\ msqdkJJ

Input is a list of integers, like [3, 2, 1]. Try it online: Pyth Compiler/Executor

Uses a quite similar idea as randomra's J code.

Pyth, 23 bytes

GitHub repository for Pyth

Ju+G*]GHQYjbmj\ msqdkJJ

Input is a list of integers, like [3, 2, 1]. Try it online: Pyth Compiler/Executor

Uses a quite similar idea as randomra's J code.

Source Link
Jakube
  • 21.9k
  • 3
  • 27
  • 108
Loading