Ask Your Question
0

how do change a string of letters into integers using sagecell?

asked 2016-11-13 18:22:55 +0100

I am a high school teacher and I want to change letters into integers. Then, I am taking the numbers into a matrix mXn dimension. I want to show how to multiply matrices to encode a message. Then, decode the message by multiplying by the inverse of a matrix. I know some if any basics using sagemathcell or python.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-11-13 19:09:15 +0100

ndomes gravatar image

An example:

S = 'my message'
print S
L = list(S) 
print L
L_int = [ord(s) for s in L]
print L_int
print [chr(i) for i in L_int]
print ''.join([chr(i) for i in L_int])
print

M = matrix(2,5,L_int)
M
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-11-13 18:22:55 +0100

Seen: 592 times

Last updated: Nov 13 '16