17
\$\begingroup\$

Actually not inspired neither by Atbash Self Palindromes nor by Generalized Gematria Calculator.

Given a string s of length n, output the Revu'a sequence, which is the first character of s, the first two characters of s, ... the first n–2 characters of s, the first n–1 characters of s, the entire s.

The string will only consist of Unicode (any encoding you want) characters that have strong directionality and are found in the range 0x0000 through 0xFFFF. However, no directionality control characters will occur. All characters in any given string will have the same directionality.

You may return in array notation ["t","te","tes","test"], as a space-separated string "t te tes test", as multi-line text
t
te
tes
test
, a pre-formatted array

t
te
tes
test
, or anything similar. Amounts of leading, separating, and trailing spacing is not important, and neither are trailing newline. Ask if in doubt.

Right-to-Left input must result in Right-to-Left output in proper order:
Input: "נחמן"
Output: "נ נח נחמ נחמן" or

נ
נח
נחמ
נחמן
, or ["נ","נח","נחמ","נחמן"]. Among invalid results are "נחמן נחמ נח נ" ,"ן מן חמן נחמן", and "נחמן חמן מן ן".

\$\endgroup\$
2
  • \$\begingroup\$ 1) shouldn't it be ["ן",‎ "נח",‎ "נחם",‎ "נחמן"]? ‎(2) bonus points if when given that particular string, you finish off with "מאומן". \$\endgroup\$ May 2, 2021 at 18:55
  • \$\begingroup\$ @NoLongerBreathedIn I didn't want to bother people with converting letterforms. And sure, if you implement "m'uman" you'll get cookies ;-) \$\endgroup\$
    – Adám
    May 2, 2021 at 18:57

34 Answers 34

1
2
0
\$\begingroup\$

Burlesque, 2 bytes

iT

Try it online!

iT # Generate inits
\$\endgroup\$
0
\$\begingroup\$

GolfScript, 10 bytes

Courtesy to a'_' for saving two bytes by removing redundant bits!

:i,,{)i<}/

Nice short and cute response :)

:i,,{)i>}% #Revu'a Sequence
:i           #Remember the input as i
  ,,         #Array from 0 to i-1
    {   }% #Block, for each element, map this
    {)  }% #Increment the number by 1
    { i }% #Move i to the top of the stack
    {  >}% #Print the characters less than the index i

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ GolfScript, 10 bytes. Explanation. (Because < isn't order-sensitive, and you can return as a list.) \$\endgroup\$
    – user92069
    Feb 22, 2020 at 2:46
  • \$\begingroup\$ Oh, durr! Didn't even think about doing listwise comparisons - mental slip there, good find! \$\endgroup\$
    – Mathgeek
    Feb 24, 2020 at 13:15
0
\$\begingroup\$

Vyxal, 1 byte

¦

Try it Online!

But that's boring, so here's something a bit more interesting:

6 bytes

żƛw?$i

Try it Online!

Explained

żƛw?$i  
        # Implicit input of string
żƛ      # Over each integer n in range(1, len(input) + 1):
   ?    #   input[
  w $i  #         :n] (python indexing)
        # Implicitly print the result of the above.
\$\endgroup\$
0
\$\begingroup\$

Thunno 2, 1 byte

ƒ

Try it online!

Try it online!

Built-ins for prefixes.

\$\endgroup\$
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.