Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Array
- def jumble
- self.sort {|x, y| (rand 3) - 1}
- end
- def middle
- self.slice(1, size - 2) || []
- end
- def last_el
- size > 1 ? last : ''
- end
- end
- class String
- def cambridge_jumble
- a = split('')
- a.first + a.middle.jumble.join('') + a.last_el
- end
- end
- 'I consider myself up on psycho linguistics but I hadnt heard of that one'.split.map {|x| x.cambridge_jumble}.join ' '
Add Comment
Please, Sign In to add comment