Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- irb(main):007:0> s = " ¥ · £ · € · $ · ¢ · ₡ · ₢ · ₣ · ₤ · ₥ · ₦ · ₧ · ₨ · ₩ · ₪ · ₫ · ₭ · ₮ · ₯ · ₹"
- => " ¥ · £ · € · $ · ¢ · ₡ · ₢ · ₣ · ₤ · ₥ · ₦ · ₧ · ₨ · ₩ · ₪ · ₫ · ₭ · ₮ · ₯ · ₹"
- 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)
- => [" ¥ · £ · € · ", "$ · ¢ · ₡ · ", "₢ · ₣ · ₤ ·", " ₥ · ₦ · ₧ ", "· ₨ · ₩ · ₪", " · ₫ · ₭ · ", "₮ · ₯ · ₹ ¥", " · £ · € · $ ", "· ¢ · ₡ · ₢ ", "· ₣ · ₤ · ₥", " · ₦ · ₧ · ", "₨ · ₩ · ₪ ·", " ₫ · ₭ · ₮ ", "· ₯ · ₹"]
Advertisement
Add Comment
Please, Sign In to add comment