Skip to content

Instantly share code, notes, and snippets.

@tomaszbartoszewski
Last active July 15, 2024 00:36
Show Gist options
  • Save tomaszbartoszewski/234079d9366b0df34b3ca0e84c60df9f to your computer and use it in GitHub Desktop.
Save tomaszbartoszewski/234079d9366b0df34b3ca0e84c60df9f to your computer and use it in GitHub Desktop.

You are given the following text:

lorem ipsum dolor sit amet consectetur lorem ipsum et mihi quoniam et adipiscing elit.sed quoniam et advesperascit et mihi ad villam revertendum est nunc quidem hactenus ex rebus enim timiditas non ex vocabulis nascitur.nummus in croesi divitiis obscuratur pars est tamen divitiarum.nam quibus rebus efficiuntur voluptates eae non sunt in potestate sapientis.hoc mihi cum tuo fratre convenit.qui ita affectus beatum esse numquam probabis duo reges constructio interrete.de hominibus dici non necesse est.eam si varietatem diceres intellegerem ut etiam non dicente te intellego parvi enim primo ortu sic iacent tamquam omnino sine animo sint.ea possunt paria non esse.quamquam tu hanc copiosiorem etiam soles dicere.de quibus cupio scire quid sentias.universa enim illorum ratione cum tota vestra confligendum puto.ut nemo dubitet eorum omnia officia quo spectare quid sequi quid fugere debeant nunc vero a primo quidem mirabiliter occulta natura est nec perspici nec cognosci potest.videmusne ut pueri ne verberibus quidem a contemplandis rebus perquirendisque deterreantur sunt enim prima elementa naturae quibus auctis virtutis quasi germen efficitur.nam ut sint illa vendibiliora haec uberiora certe sunt.cur deinde metrodori liberos commendas.mihi inquam qui te id ipsum rogavi nam adhuc meo fortasse vitio quid ego quaeram non perspicis.quibus ego vehementer assentior.cur iustitia laudatur mihi enim satis est ipsis non satis.quid est enim aliud esse versutum nobis heracleotes ille dionysius flagitiose descivisse videtur a stoicis propter oculorum dolorem.diodorus eius auditor adiungit ad honestatem vacuitatem doloris.nos quidem virtutes sic natae sumus ut tibi serviremus aliud negotii nihil habemus.

Here are a few facts and definition about the text above:

  • Everything is lowercase.
  • There are only letters, full stops (.), and single whitespace characters.
  • A word is defined as a sequence of letters delimited by either a whitespace or a full stop . character.
  • A full stop character is not considered a word. A full stop is never preceded or followed by whitespace.
  • Any two words are separated either by a single whitespace character (dolor sit), or by a full stop with no spaces (elit.sed)
  • A sentence is defined as a sequence of words delimited by a full stop . character.

Note:

  • You are free to copy paste the text above as a string in your preferred language, there is no need to read from a file in your code.
  • The text has been cleaned up to allow for trivial parsing, we are not particularly interested in parsing techniques for now.
  • At this stage, your solution is only required to work with the text above, do not worry about the general case.
  • Strive to write clear and maintainable code, performance comes later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment