Guest User

Untitled

a guest
Mar 12th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.77 KB | None | 0 0
  1. irb(main):007:0> s = " ¥ · £ · € · $ · ¢ · ₡ · ₢ · ₣ · ₤ · ₥ · ₦ · ₧ · ₨ · ₩ · ₪ · ₫ · ₭ · ₮ · ₯ · ₹"
  2. => " ¥ · £ · € · $ · ¢ · ₡ · ₢ · ₣ · ₤ · ₥ · ₦ · ₧ · ₨ · ₩ · ₪ · ₫ · ₭ · ₮ · ₯ · ₹"
  3. irb(main):008:0> taken = 0; chunks = (s * 2).chars.slice_before {|c| taken += c.bytesize; (taken > 20).tap {|overflow| taken = c.bytesize if overflow } }.map(&:join)
  4. => [" ¥ · £ · € · ", "$ · ¢ · ₡ · ", "₢ · ₣ · ₤ ·", " ₥ · ₦ · ₧ ", "· ₨ · ₩ · ₪", " · ₫ · ₭ · ", "₮ · ₯ · ₹ ¥", " · £ · € · $ ", "· ¢ · ₡ · ₢ ", "· ₣ · ₤ · ₥", " · ₦ · ₧ · ", "₨ · ₩ · ₪ ·", " ₫ · ₭ · ₮ ", "· ₯ · ₹"]
Advertisement
Add Comment
Please, Sign In to add comment