Platform
Resources
Pricing
Sign in
Get started
Mikal Hitsøy Henriksen
Workspace
Fork
Published
By
Mikal Hitsøy Henriksen
Edited
Apr 12, 2022
1 fork
1 star
Insert cell
Insert cell
x
=
[
]
Insert cell
function
*
permute
(
arr
)
{
if
(
arr
.
length
<=
1
)
{
yield
Array
.
from
(
arr
)
;
return
;
}
for
(
let
i
=
arr
.
length
;
i
--
>
0
;
)
{
const
x
=
arr
.
shift
(
)
;
for
(
let
sub
of
permute
(
arr
)
)
{
sub
.
unshift
(
x
)
;
yield
sub
;
}
arr
.
push
(
x
)
;
}
}
Insert cell
p
=
[
...
permute
(
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
]
)
]
Insert cell
sums
=
_
(
p
)
.
map
(
(
a
)
=>
_
.
chunk
(
a
,
3
)
.
map
(
(
b
)
=>
b
[
0
]
*
100
+
b
[
1
]
*
10
+
b
[
2
]
)
)
.
groupBy
(
_
.
sum
)
.
value
(
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
x
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
permute
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
p
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
sums
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML