Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = File.readlines("teste.txt")
- teste = Array.new(a.size)
- copia = Array.new(a.size)
- valor = 0
- while valor < teste.size
- teste[valor] = a[valor]
- copia[valor] = a[valor]
- valor +=1
- end
- def converter(str)
- begin
- Integer(str)
- rescue ArgumentError
- nil
- end
- end
- novo = Array.new(a.size)
- contador = 1
- start = 1
- c = 0
- puts teste
- until teste.empty?
- if teste.size == 1
- break
- end
- if teste[start] == nil
- start = 1
- end
- variavel = teste[start][0]
- if converter(variavel) == contador
- contador.to_i
- novo[c] = teste[start][2]
- teste.delete_at(start)
- c += 1
- contador += 1
- end
- start += 1
- end
- puts novo
- =========
- 7
- 4 u
- 1 s
- 7 z
- 3 o
- 6 d
- 5 l
- 2 h
Add Comment
Please, Sign In to add comment