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: 
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).
Imperative (and possible faster) version:

```
  if (sorted.isEmpty) {
    None
  } else {
    var sortedTail = sorted.tail
    if (sortedTail.isEmpty) {
      None
    } else {
      var minDiff = Int.MaxValue
      var prev = sorted.head
      do {
        val curr = sortedTail.head
        minDiff = minDiff min math.abs(curr - prev)
        sortedTail = sortedTail.tail
        prev = curr
      } while (!sortedTail.isEmpty)
      Some(minDiff)
    }
  }

```