I thought of a new way to generate my passwords, and even though it's probably not very clever in the long run, it could still make for a fun code-golf.
Taking a string of words, the password is generated thus:
- Pick the nth character in the nth word
- If n is larger than the word, continue counting backwards
Example:
This is a fun task!
T s a u !
T is the first character
s is the second
a is the first, but going back and forth it is also the third
u is the second but because of counting backwards it's also the fourth
'!' is the fifth character in 'task!' and thus will be included in the final password, Tsau!
Rules
- Input will be a string
- Separate the string on spaces, all other characters must be included
- Uppercase letters must remain uppercase, same with lowercase
- You take n steps in each word, where n is the number of words that have come before plus one
- If n is larger than the word, you must step backwards through the word, if you hit the start, you go forward again until you have stepped n times
- The first and last character is only stepped once, so 'fun' on the seventh position as an example goes 'funufun' and ends on n, not 'funnuff' and ends on f
- Output must be a string
Examples:
Input Output
Once Upon A Time OpAe
There was a man Taaa
Who made a task Waak
That was neat! Taa
This is a long string to display how the generator is supposed to work Tsagnoyotoipto
The shortest code in bytes wins!
to
is the 12th word (0-indexed) in the long string, and therefore the code letter should bet
, noto
. \$\endgroup\$Tsau!
is chinese forFuck!
\$\endgroup\$