python,numpy,matrix,pandas,symmetric

Not sure whether this is all that much more efficient, but you could pivot and then add the frame to its transpose, something like: df = pd.read_csv("input.txt", header=None, delim_whitespace=True) df = df.pivot(0,1,2) df.add(df.T, fill_value=0).fillna(0) A B C A 0 1 2 B 1 0 3 C 2 3 0 Here...

Here's a way to define spouse/2: married(bill, hillary). married(tom, mary). married(sam, linda). spouse(X, Y) :- \+ married(X, Y) -> married(Y, X) ; married(X, Y). So if there's no way to make married(X, Y) true, then it will try married(Y, X). Otherwise, married(X, Y). | ?- spouse(X, Y). X = bill...

I want to get result true if all binary relations are symmetric, otherwise false. all_relations_symmetric :- not(some_relations_not_symmetric). some_relations_not_symmetric :- married(X, Y), not(married(Y, X)). For your first example: ?- all_relations_symmetric. false. For the second one: ?- all_relations_symmetric. true. ...

php,encryption,aes,symmetric,128bit

The block size of RIJNDAEL-128/ECB is ...well 128 bit, i.e. 16 bytes. But your input currently is 32 bytes and therefore the output is also two blocks i.e. 32 bytes long. Your plaintext looks like it's "hex-encoded" like the key. So, treat it like the key. Also base64_encode() is not...

SSH tunneling: client -> public relay -> webserver

If there is a linear relationship between the variables, you can use that same relationship after applying T because T, being a linear transformation, will preserve those relationships. So, let's assume that the relationship you have verifies y - x = y' - x'. This assumption is consistent with the...

java,function,matrix,boolean,symmetric

You should just Google this stuff. There were plenty of answers out there. But all you have to do is check if (a,b) is the same as (b,a). public static boolean isSymetric(int[][] array){ for(int a = 0; a < array.length; a++){ for(int b = 0; b < array.length; b++){ if(array[a][b]!=array[b][a]){...