Skip to content

venth/katas-rxjava-oracle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RxJava Oracle kata

Inspired by: kata-rx made by Varokas.

Chapter 1 - Birth

Far beyond the edge of the world there lived a peasant in a small village. One night she woke him an extraordinary idea - I could become Oracle, Reactive Oracle. If there would be only tutor willing to show me the way.

Reactive Oracle needs time (up to 3 seconds) to ponder a question and provide random answer from list:

  • Insanity: doing the same thing over and over again and expecting different results.
  • A person who never made a mistake never tried anything new.
  • Gravitation is not responsible for people falling in love.
  • Look deep into nature, and then you will understand everything better.

Would you like to become the tutor and guide of a simple peasant to his way of enlightenment?

Tips: Make slices as follows:
  • Reactive Oracle answers always with the same sentence
  • Reactive Oracle answers with a constant delay of 3 seconds
  • The delay becomes random - up to 3 seconds
  • Add more answers and choose first or last
  • Randomly choose answers

Chapter 2 - Pilgrim

What is Reactive Oracle, if nobody knows about his existence? It's like a sound of a falling tree in an empty forest. Reactive Oracle lived a simple live enjoying his existence. He was almost happy... Almost.

One day the village visited by a young pilgrim. He saw Reactive Oracle meditating and his curiosity lead him closer.

Reactive Oracle said:

  • Ask me three times and listen to my answers.

The pilgrim thought: I'll ask question and the next question after I've heard the answer to the previous question and I'll ask third time when the second answer will pass.

Dear tutor would you like to help Reactive Oracle in his search for happiness and make the pilgrim to ask his question?

Tips: Make slices as follows:
  • Create Pilgrim that asks Reactive Oracle once
  • Concatenate second answer with the first one
  • Concatenate third answer with the second and first one

Chapter 3 - Quick Questions

The pilgrim was surprised by wisdom and knowledge radiating from Reactive Oracle answers and only if Reactive Oracle could think quickly through asked questions the pilgrim could become a king. The pilgrim started to think through the issue. The challenge looked impossible to overcome. His thoughts become more and more grim. Suddenly two joyful children come closer and began to ask questions Reactive Oracle one by the other.

Reactive Oracle still pondered their questions but responded both of them at same time. The pilgrim realized: - I can ask all my question at the same time and listen to Reactive Oracle answers when he'll speak them.

Dear tutor would you like to help the hungry pilgrim to quench his thirst of knowledge?

Tips: Make slices as follows:

Chapter 4 - Taxes

The pilgrim enlighten by Reactive Oracle and his own cleverness became a king. Suddenly two other peasants in Reactive Oracle's village were touched by Reactive Gods and two more Reactive Oracles began answering questions.

The king lead peaceful live and his people were happy. Then unavoidable event happened - the king began to seek the hand of a princess from a neighboring kingdom. The kingdom treasury barely sustained raising needs of the king in love.

The king decided to ask Reactive Oracles, if he shall raise taxes. He expected one answer and if only there will be only one Reactive Oracle, all the things would become easy. Unfortunately there are three Reactive Oracles and each of them can provide can answer yes or no to the king's question.

The king realized: - Majority wins. I'll ask Reactive Oracles and take majority as the answer.

Dear tutor would you like to help the uncertain king to ask three Reactive Oracle at the same time and pick answer of the majority?

Tips: Make slices as follows:
  • create King asking one Reactive Oracle shall I raise taxes?
  • make King to ask additional Reactive Oracle, in case of stale first one is winning
  • make King to ask additional Reactive Oracle - majority wins
  • make King to ask additional Reactive Oracle, in case of stale first one is winning

Chapter 5 - Let him sleep

People of the king were satisfied by the king doing guided by Reactive Oracles. Time passed and asking Reactive Oracles questions became the king's habit.

The king observed that randomly Reactive Oracles fall into a slumber and can provide an answer after four days. Waiting for a wise answer is always worthy to wait and if the king would be a more patient man then whole country would be happier. The king told to himself, if there could be only to way to omit answer of the sleepy ones...

Dear tutor would you like to help the impatient king to be enlighten by Reactive Oracle wisdom and limit time to answer of Reactive Oracles up to 10 seconds?

Tips: Make slices as follows:
  • make one oracle to answer with delay of 20 seconds, wait till all of them provide answer
  • introduce random delay for all Reactive Oracles, wait till all of them provide answer
  • introduce timeout for each Reactive Oracles, in case of timeout answer for shall I raise taxes is always No

Chapter 6 - Heal the broken one

In time the king married the princess from the neighboring kingdom. She's beauty was astonishing. The king asked the queen: - Would you like my Dear to learn my wisest advisors? She answered: - With a pleasure my Beloved King.

They set out to meet Reactive Oracles. Reactive Oracles were meditating bathed in summer sun rays. The king said: - Please, my Curly Spark ask Reactive Oracles a question. The queen asked a question, then another and another pleased by wisdom of heard answers. Then Reactive Oracles opened their eyes and began to shake moved to the depths by beauty of the queen. The answers started to be replaced randomly by .... ordinary exceptions - how sad.

Dear tutor would you like to help Reactive Oracles regaining their senses by suppressing random exceptions caused by striking beauty of the queen?

Tips: Make slices as follows:
  • make Reactive Oracle fail to answer because of exception that occurs randomly
  • make failing Reactive Oracle suppress error and answer always No
  • make failing Reactive Oracle repeat 3 times and in case the error still exists answer always No
  • make failing Reactive Oracle repeat till error will not occur

About

Group of katas for rxjava

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages