Question: I write a python telnet client to communicate with a server through telnet. However, many people tell me that it's no secure. How can I convert it to ssh? Should I need to totally rewrite my program?

Answer: 
```
val sorted = List(1, 5, 15, 37, 39, 42, 50)
(sorted.tail,sorted).zipped.map(_-_).min
//res2: Int = 2

```

**[Edit]**

You can use a fold as well:

```
sorted.tail.foldLeft((sorted.head,Int.MaxValue))((x,y) => (y, math.min(y-x._1,x._2)))._2

```
Here's what I would do:

1. write a function that transforms a list of n numbers into a list of (n - 1) gaps
2. write/use a function that selects the smallest number from a list

Don't forget to handle the empty list case for part 1! (Incidentally, Part 2 could be written as a fold).