Skip to content

Instantly share code, notes, and snippets.

@elliotdavies
Last active June 28, 2019 14:21
Show Gist options
  • Save elliotdavies/deb98672076d8b3009a937f3cf9902bd to your computer and use it in GitHub Desktop.
Save elliotdavies/deb98672076d8b3009a937f3cf9902bd to your computer and use it in GitHub Desktop.
# String matrices
You're working on a piece of code that deals with matrices of numbers. Unfortunately, you have to integrate with a legacy system that gives you the matrices as strings.
The legacy system gives you some strings like so:
`1,2,3 4,5,6 7,8,9`
All rows are guaranteed to be the same length (you don't have to check for this) and are separated by spaces. Numbers in a row do _not_ have spaces between them and are separated by commas.
Write a program that can parse such a string and return the matrix's rows and columns (so here, `[[1,2,3],[4,5,6],[7,8,9]]`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment