Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a = [2, 4, 2, 23, 26, 5456, 565, 12, 347]
- # 1
- a = a.sort
- puts a.inspect
- # 2
- puts a.max
- puts a.min
- puts a.minmax.inspect
- # 4
- puts a.uniq.inspect
- # 3
- (0..a.length - 1).step(2).each do |index|
- a[index] = a[index] * (-1)
- end
- puts a.inspect
- b = []
- (0..a.length - 1).step(2).each do |index|
- b[index/2] = a[index]
- end
- puts b.inspect
Advertisement
Add Comment
Please, Sign In to add comment