How can I validate that consecutive numbers in a string aren't sequential?
<p>I've been tasked with a very simple password verification scheme, but for the life of me, I cannot seem to get this right. Here is the task:</p>

<blockquote>
  <p>The user sends a numeric password of 6 characters through a form. In
  order to force secure passwords create a validation that the numbers
  cannot consecutively go up or down.</p>
</blockquote>

<p>Here is what I have:</p>

<pre><code>password = '246879'
new_password = password.split('').map { |s| s.to_i }

new_password.each_with_index do |val, index|

  next_element = new_password[index + 1]
  prev_element = new_password[index - 1]

  if new_password[index] + 1 == next_element
    puts 'next bad'
    break
  elsif
    new_password[index] - 1 == prev_element
    puts 'prev bad'
    break
  end
end
</code></pre>

<p>The password should fail on the 87 because 7 is one less than 8.</p>