Solutions in R, Swift, Scala, javascript, Python (in the R dir since I'm using RStudio's Python REPL) and mebbe others
R