Odd word problem
Odd word problem is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Write a program that solves the odd word problem.
Description: You are promised an input stream consisting of English letters and punctuations. It is guaranteed that
- the words (sequence consecutive letters) are delimited by on and only one punctuation; that
- the words will be at least one letter long; and that
- a full stop (.) appears after, and only after, the last word.
For example, what,is,the;meaning,of:life.
is such a stream with six words. Your task is to reverse the letters in every other word while leaving punctuations intact, producing e.g. "what,si,the;gninaem,of:efil.", while observing the following restrictions:
- Only I/O allowed is reading or writing one character at a time;
- You are not to explicitly save characters in a collection data structure, such as arrays, strings, hash tables, etc, for later reversal;
- You are allowed to use recursions, closures, continuations, threads, coroutinnes, etc.
Test case: work on both the "life" example given above, and the text we,are;not,in,kansas;any,more.