Introduction
You use Twitter (let's pretend, if not), where you are limited to 140 characters per individual tweet you care to share with the world. If you wanted to tweet to your followers Abraham Lincoln's Gettysburg Address, then you would need to break up the text into multiple 140-character chunks in order to get the whole message out. However, those chunks should not always be exactly 140 characters long. Say for example, we broke the speech into 17-character chunks, we'd end up with these tweets:
- FOUR SCORE AND SE
- VEN YEARS AGO OUR
- FATHERS BROUGHT
- FORTH ON THIS CON
- TINENT A NEW NATI
- ON CONCEIVED IN L
- (and so on)
That's no good! When individual words are broken up, then it can get difficult to understand what you are trying to say. Also, in the twitterverse, one of your followers may come across a specific tweet and not realize that there's more to the message, so you'll want to number your tweets so they have some context to work with (still using 17-character chunks):
- (1/7) FOUR SCORE AND
- (2/7) SEVEN YEARS AGO
- (3/7) OUR FATHERS
- (4/7) BROUGHT FORTH ON
- (5/7) THIS CONTINENT A
- (6/7) NEW NATION
- (7/7) CONCEIVED IN...
You could manually figure out the best configuration for your tweets by hand, but that's what we have computers for!
Challenge
In the shortest code possible, parse the Gettysburg Address (or any text, but we'll stick with this one as an example) into a set of tweets consisting of no more than 140 characters (assume ASCII, since our example text should not have any uncommon/unusual bits in it).
Details
- Your function/program/etc should take in a single string argument and output one line of text for each tweet.
- Assume this input will never result in more than 99 total tweets when parsed, regardless of how you choose to parse (so long as that choice still fits the other points of the challenge).
- Tweets need to include a
tweet number
oftotal tweets
indicator in the format "(x/y)
" preceding the body of the tweet.- This count will take up part of your 140-character space!
- Tweet chunks may only be split on newlines or spaces.
- No hyphens, periods, commas or other punctuation is allowed, unless immediately preceded or followed by a space or newline.
- Tweets should consist of as many complete words as possible.
- This constraint is a little flexible, e.g. when your final tweet only has one word
- This is code golf, so the shortest code wins.
Full Text of Gettysburg Address
(Your code should still be able to handle any ASCII string passed to it.)
FOUR SCORE AND SEVEN YEARS AGO OUR FATHERS BROUGHT FORTH ON THIS CONTINENT A NEW NATION CONCEIVED IN LIBERTY AND DEDICATED TO THE PROPOSITION THAT ALL MEN ARE CREATED EQUAL. NOW WE ARE ENGAGED IN A GREAT CIVIL WAR TESTING WHETHER THAT NATION OR ANY NATION SO CONCEIVED AND SO DEDICATED CAN LONG ENDURE. WE ARE MET ON A GREAT BATTLEFIELD OF THAT WAR. WE HAVE COME TO DEDICATE A PORTION OF THAT FIELD AS A FINAL RESTING PLACE FOR THOSE WHO HERE GAVE THEIR LIVES THAT THAT NATION MIGHT LIVE. IT IS ALTOGETHER FITTING AND PROPER THAT WE SHOULD DO THIS. BUT IN A LARGER SENSE WE CAN NOT DEDICATE, WE CAN NOT CONSECRATE, WE CAN NOT HALLOW, THIS GROUND. THE BRAVE MEN LIVING AND DEAD WHO STRUGGLED HERE HAVE CONSECRATED IT FAR ABOVE OUR POOR POWER TO ADD OR DETRACT. THE WORLD WILL LITTLE NOTE NOR LONG REMEMBER WHAT WE SAY HERE BUT IT CAN NEVER FORGET WHAT THEY DID HERE. IT IS FOR US THE LIVING RATHER TO BE DEDICATED HERE TO THE UNFINISHED WORK WHICH THEY WHO FOUGHT HERE HAVE THUS FAR SO NOBLY ADVANCED. IT IS RATHER FOR US TO BE HERE DEDICATED TO THE GREAT TASK REMAINING BEFORE US, THAT FROM THESE HONORED DEAD WE TAKE INCREASED DEVOTION TO THAT CAUSE FOR WHICH THEY GAVE THE LAST FULL MEASURE OF DEVOTION, THAT WE HERE HIGHLY RESOLVE THAT THESE DEAD SHALL NOT HAVE DIED IN VAIN, THAT THIS NATION UNDER GOD SHALL HAVE A NEW BIRTH OF FREEDOM, AND THAT GOVERNMENT OF THE PEOPLE BY THE PEOPLE FOR THE PEOPLE SHALL NOT PERISH FROM THE EARTH.