fork(1) download
  1. clearing = %w[a b c d e f 1 g h i j 1 k 2 l 2 2 m n o p q r s 1 t u v w x 1 y z].map do |ele|
  2. Integer(ele) rescue ele
  3. end
  4. expected = %w[a b c d e f l m n o p q r s]
  5. clearing << 2
  6. iters = 0
  7. while clearing.include? 1
  8. from = clearing.index(1)
  9. to = clearing[from..-1].index(2) + from
  10. clearing.slice!(from..to)
  11. end
  12. clearing.delete(2)
  13. p clearing
  14. p expected
  15. puts "Matches!" if clearing == expected
Success #stdin #stdout 0.05s 9704KB
stdin
Standard input is empty
stdout
["a", "b", "c", "d", "e", "f", "l", "m", "n", "o", "p", "q", "r", "s"]
["a", "b", "c", "d", "e", "f", "l", "m", "n", "o", "p", "q", "r", "s"]
Matches!