#Dyalog APL, (削除) 67 (削除ここまで)(削除) 59 (削除ここまで) 51 bytes
Dyalog APL, (削除) 67 (削除ここまで)(削除) 59 (削除ここまで) 51 bytes
#Dyalog APL, (削除) 67 (削除ここまで)(削除) 59 (削除ここまで) 51 bytes
Dyalog APL, (削除) 67 (削除ここまで)(削除) 59 (削除ここまで) 51 bytes
#Dyalog APL, (削除) 67 (削除ここまで) 59(削除) 59 (削除ここまで) 51 bytes
And the following link runs n=5 thousands of times and gathers statistics about the frequency of each partition:
⎕rl←0 ⋄ {⍺,⍴⍵}⌸ {⍵=0:⍬⋄a,a∇⍵-a←1+(+/(?+/)>+\)⍺↑⍵⊃{⍵,⊂⌽1,+/ ̈⍵↑ ̈⍨⌽⍳⍴⍵}⍣⍵⊢⍬}⍨ ̈10000⍴5
More improvements, with help from Roger Hui :
replace
{⍵=0:A⋄B}with×ばつ⍵:B⋄A}. Signum (×ばつ⍵) returns true for⍵>0and false for⍵=0.replace
(+/(?+/)>+\)with+/b<?⊃⌽b←+\, it saves a characteruse a matrix instead of vector of vectors to compute
p: replace⍵⊃{⍵,⊂⌽1,+/ ̈⍵↑ ̈⍨⌽⍳⍴⍵}⍣⍵⊢⍬with⊃↓(0,⍨⊢⍪⍨1 1⍉+\)⍣⍵⍪1.
×ばつ⍵:a,a∇⍵-a←1++/b<?⊃⌽b←+\⍺↑⊃↓(0,⍨⊢⍪⍨1 1⍉+\)⍣⍵⍪1⋄⍬}⍨ (51 bytes)
#Dyalog APL, (削除) 67 (削除ここまで) 59 bytes
And the following link runs n=5 thousands of times and gathers statistics about the frequency of each partition:
⎕rl←0 ⋄ {⍺,⍴⍵}⌸ {⍵=0:⍬⋄a,a∇⍵-a←1+(+/(?+/)>+\)⍺↑⍵⊃{⍵,⊂⌽1,+/ ̈⍵↑ ̈⍨⌽⍳⍴⍵}⍣⍵⊢⍬}⍨ ̈10000⍴5
#Dyalog APL, (削除) 67 (削除ここまで) (削除) 59 (削除ここまで) 51 bytes
And the following link runs n=5 thousands of times and gathers statistics about the frequency of each partition:
⎕rl←0 ⋄ {⍺,⍴⍵}⌸ {⍵=0:⍬⋄a,a∇⍵-a←1+(+/(?+/)>+\)⍺↑⍵⊃{⍵,⊂⌽1,+/ ̈⍵↑ ̈⍨⌽⍳⍴⍵}⍣⍵⊢⍬}⍨ ̈10000⍴5
More improvements, with help from Roger Hui :
replace
{⍵=0:A⋄B}with×ばつ⍵:B⋄A}. Signum (×ばつ⍵) returns true for⍵>0and false for⍵=0.replace
(+/(?+/)>+\)with+/b<?⊃⌽b←+\, it saves a characteruse a matrix instead of vector of vectors to compute
p: replace⍵⊃{⍵,⊂⌽1,+/ ̈⍵↑ ̈⍨⌽⍳⍴⍵}⍣⍵⊢⍬with⊃↓(0,⍨⊢⍪⍨1 1⍉+\)⍣⍵⍪1.
×ばつ⍵:a,a∇⍵-a←1++/b<?⊃⌽b←+\⍺↑⊃↓(0,⍨⊢⍪⍨1 1⍉+\)⍣⍵⍪1⋄⍬}⍨ (51 bytes)
#Dyalog APL, 67(削除) 67 (削除ここまで) 59 bytesp←{⍵,⊂1,⍨+/ ̈⌽⍵↑ ̈⍨⌽⍳⍴⍵}⍣⎕⊢⍬⋄f←{⍵=0:⍬⋄a,a∇⍵-a←{1++/(?+/⍵)>+\⍵}⍺↑⍵⊃p}⍨
p←{⍵,⊂1,⍨+/ ̈⌽⍵↑ ̈⍨⌽⍳⍴⍵}⍣⎕⊢⍬⋄f←{⍵=0:⍬⋄a,a∇⍵-a←{1++/(?+/⍵)>+\⍵}⍺↑⍵⊃p}⍨ (67 bytes)
p is a vector of vectors in which p[n][k] is the number of partitions of n into k summands, or equivalently: the number of partitions with greatest summand k. We build p by starting with the empty vector ⍬, reading n (the ⎕ reads input) and repeatedly applying the following:
The link to tryapl.org runs Some improvements:
inline
pat the cost of slightly worse (but still good enough) performancein the computation of
prearrange⌽and1,to save a characterturn
{1++/(?+/⍵)>+\⍵}into a train with1+in front:1+(+/(?+/)>+\)make
fan anonymous function and supply⎕(eval'ed input) as an argument to obtain a complete program
f 5{⍵=0:⍬⋄a,a∇⍵-a←1+(+/(?+/)>+\)⍺↑⍵⊃{⍵,⊂⌽1,+/ ̈⍵↑ ̈⍨⌽⍳⍴⍵}⍣⍵⊢⍬}⍨⎕ (59 bytes)
And the following link runs n=5 thousands of times and gathers statistics about the frequency of each partition.:
⎕rl←0 ⋄ {⍺,⍴⍵}⌸ {⍵=0:⍬⋄a,a∇⍵-a←1+(+/(?+/)>+\)⍺↑⍵⊃{⍵,⊂⌽1,+/ ̈⍵↑ ̈⍨⌽⍳⍴⍵}⍣⍵⊢⍬}⍨ ̈10000⍴5
#Dyalog APL, 67 bytesp←{⍵,⊂1,⍨+/ ̈⌽⍵↑ ̈⍨⌽⍳⍴⍵}⍣⎕⊢⍬⋄f←{⍵=0:⍬⋄a,a∇⍵-a←{1++/(?+/⍵)>+\⍵}⍺↑⍵⊃p}⍨
p is a vector of vectors in which p[n][k] is the number of partitions of n into k summands, or equivalently: the number of partitions with greatest summand k. We build p by starting with the empty vector ⍬, reading n (the ⎕ reads input) and repeatedly applying the following:
The link to tryapl.org runs f 5 thousands of times and gathers statistics about the frequency of each partition.
#Dyalog APL, (削除) 67 (削除ここまで) 59 bytes
p←{⍵,⊂1,⍨+/ ̈⌽⍵↑ ̈⍨⌽⍳⍴⍵}⍣⎕⊢⍬⋄f←{⍵=0:⍬⋄a,a∇⍵-a←{1++/(?+/⍵)>+\⍵}⍺↑⍵⊃p}⍨ (67 bytes)
p is a vector of vectors in which p[n][k] is the number of partitions of n into k summands, or equivalently: the number of partitions with greatest summand k. We build p by starting with the empty vector ⍬, reading n (the ⎕ reads input) and repeatedly applying the following:
Some improvements:
inline
pat the cost of slightly worse (but still good enough) performancein the computation of
prearrange⌽and1,to save a characterturn
{1++/(?+/⍵)>+\⍵}into a train with1+in front:1+(+/(?+/)>+\)make
fan anonymous function and supply⎕(eval'ed input) as an argument to obtain a complete program
{⍵=0:⍬⋄a,a∇⍵-a←1+(+/(?+/)>+\)⍺↑⍵⊃{⍵,⊂⌽1,+/ ̈⍵↑ ̈⍨⌽⍳⍴⍵}⍣⍵⊢⍬}⍨⎕ (59 bytes)
And the following link runs n=5 thousands of times and gathers statistics about the frequency of each partition:
⎕rl←0 ⋄ {⍺,⍴⍵}⌸ {⍵=0:⍬⋄a,a∇⍵-a←1+(+/(?+/)>+\)⍺↑⍵⊃{⍵,⊂⌽1,+/ ̈⍵↑ ̈⍨⌽⍳⍴⍵}⍣⍵⊢⍬}⍨ ̈10000⍴5