Skip to main content
deleted 5 characters in body
Source Link
rnso
  • 1.7k
  • 10
  • 8

Racket 8684 bytes

(for/sum((p(permutations(range(length lll)))))(for/product((lk lll)(c p))(list-ref lk c)))

Racket 86 bytes

(for/sum((p(permutations(range(length ll)))))(for/product((l ll)(c p))(list-ref l c)))

Racket 84 bytes

(for/sum((p(permutations(range(length l)))))(for/product((k l)(c p))(list-ref k c)))
added 44 characters in body
Source Link
rnso
  • 1.7k
  • 10
  • 8

Racket 86 bytes

(define for/sum(f(p(permutations(range(length ll) 
  ))))(let* for/product((lrl ll)(c p))(list-ref)
        l c)))

Ungolfed:

(ndefine (lengthf ll))
       
  (for/sum (pl(p (permutations (range n)(length ll)))
    (for/sum ((p pl)) 
      (for/product ((rl nll)(c p)) 
        (lr (lr ll r) (lrlist-ref pl r))c))))

Racket

(define (f ll) 
  (let* ((lr list-ref)
         (n (length ll))
         (pl (permutations (range n))))
    (for/sum ((p pl)) 
      (for/product ((r n)) 
        (lr (lr ll r) (lr p r))))))

Racket 86 bytes

(for/sum((p(permutations(range(length ll)))))(for/product((l ll)(c p))(list-ref l c)))

Ungolfed:

(define (f ll)  
  (for/sum ((p (permutations (range (length ll))))) 
    (for/product ((l ll)(c p)) 
      (list-ref l c))))
deleted 39 characters in body
Source Link
rnso
  • 1.7k
  • 10
  • 8
(define (f ll) 
  (let* ((lr list-ref)
         (n (length ll))
         (pl (permutations (range n)))
         (get (λ (rr cc) (lr (lr ll rr) cc))))
    (for/sum ((p pl)) 
      (for/product ((r n)) 
        (getlr (lr ll r) (lr p r))))))

The code can easily be modified for unequal number of rows and columns.

(define (f ll) 
  (let* ((lr list-ref)
         (n (length ll))
         (pl (permutations (range n)))
         (get (λ (rr cc) (lr (lr ll rr) cc))))
    (for/sum ((p pl)) 
      (for/product ((r n))
        (get r (lr p r))))))
(define (f ll) 
  (let* ((lr list-ref)
         (n (length ll))
         (pl (permutations (range n))))
    (for/sum ((p pl)) 
      (for/product ((r n)) 
        (lr (lr ll r) (lr p r))))))

The code can easily be modified for unequal number of rows and columns.

Source Link
rnso
  • 1.7k
  • 10
  • 8
Loading