Is it a stochastic matrix?
Haskell, 57 55 bytes
import Data.List
s a=all((==100).sum)<$>[transpose a,a]
Input of type (Eq a, Num a) => [[a]]
. Outputs boolean list [left-stochastic, right-stochastic]
Thanks to @proudhaskeller for saving 2 bytes
R, 55 bytes
function(m)c(all(colSums(m)==100),all(rowSums(m)==100))
Unnamed function where m
is assumed to be an R-matrix.
Output:
[1] TRUE FALSE
: Left stochastic[1] FALSE TRUE
: Right stochastic[1] TRUE TRUE
: Doubly[1] FALSE FALSE
: None
05AB1E, 13 11 10 bytes
Right stochastic: [0,1]
Left stochastic: [1,0]
Doubly stochastic: [1,1]
None of those: [0,0]
Dø2FOTnQPˆ
Try it online!
Explanation
D # duplicate input
ø # transpose the copy
2F # 2 times do (once for each matrix)
O # sum of the rows
TnQ # is equal to 100
P # product
ˆ # add to global list
# implicitly print global list at the end of the program