The challenge is to write codegolf for the permanent of a matrix.
The permanent of an
A = (
i,j) is defined as
S_n represents the set of all permutations of
As an example (from the wiki):
Your code can take input however it wishes and give output in any sensible format but please include in your answer a full worked example including clear instructions for how to supply input to your code. To make the challenge a little more interesting, the matrix may include complex numbers.
The input matrix is always square and will be at most 6 by 6.
You will also need to be able to handle the empty matrix which has permanent 1. There is no need to be able to handle the empty matrix (it was causing too many problems).
[[ 0.36697048+0.02459455j, 0.81148991+0.75269667j, 0.62568185+0.95950937j], [ 0.67985923+0.11419187j, 0.50131790+0.13067928j, 0.10330161+0.83532727j], [ 0.71085747+0.86199765j, 0.68902048+0.50886302j, 0.52729463+0.5974208j ]]
[[ 0.83702504+0.05801749j, 0.03912260+0.25027115j, 0.95507961+0.59109069j], [ 0.07330546+0.8569899j , 0.47845015+0.45077079j, 0.80317410+0.5820795j ], [ 0.38306447+0.76444045j, 0.54067092+0.90206306j, 0.40001631+0.43832931j]]
[[ 0.61164611+0.42958732j, 0.69306292+0.94856925j, 0.43860930+0.04104116j, 0.92232338+0.32857505j, 0.40964318+0.59225476j, 0.69109847+0.32620144j], [ 0.57851263+0.69458731j, 0.21746623+0.38778693j, 0.83334638+0.25805241j, 0.64855830+0.36137045j, 0.65890840+0.06557287j, 0.25411493+0.37812483j], [ 0.11114704+0.44631335j, 0.32068031+0.52023283j, 0.43360984+0.87037973j, 0.42752697+0.75343656j, 0.23848512+0.96334466j, 0.28165516+0.13257001j], [ 0.66386467+0.21002292j, 0.11781236+0.00967473j, 0.75491373+0.44880959j, 0.66749636+0.90076845j, 0.00939420+0.06484633j, 0.21316223+0.4538433j ], [ 0.40175631+0.89340763j, 0.26849809+0.82500173j, 0.84124107+0.23030393j, 0.62689175+0.61870543j, 0.92430209+0.11914288j, 0.90655023+0.63096257j], [ 0.85830178+0.16441943j, 0.91144755+0.49943801j, 0.51010550+0.60590678j, 0.51439995+0.37354955j, 0.79986742+0.87723514j, 0.43231194+0.54571625j]]
You may not use any pre-existing functions to compute the permanent.