Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @BleedingWithin,validated by @cheeser,@Czaporka and @Descko.
If you have any issues, feel free to ping them.
Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @BleedingWithin,validated by @cheeser,@Czaporka and @Descko.
If you have any issues, feel free to ping them.
For this one I wanted to iteratively add the first x letters reversed. For example, with ‘ABCD’, to iteratively add '', 'A', 'BA', 'CBA', … And I thought, this should be possible in Python with
text = 'ABCD'
for i in range(len(text)):
to_add = text[i:0:-1]
#some more code
which I expected would give me iteratively '', 'A', 'BA', … BUT it did not. Instead, it gives '', 'B', 'CB' (and I understand why: it stops before index 0, rather than including it).
So I tried with text[i::-1] → that gives me 'A', 'BA', … (but I want the first one to be '').
→ is there any way to iteratively get what I want in one slice? (text[:i][::-1] gives me what I need - but I hate that it is with two times slicing).
JS and TS test cases (at least) are too weak. A solution which checks for whether a substring starting from the back to front exists in the given string can easily pass all validators.