N
N
nano_e_t_42016-11-04 06:31:09
Programming
nano_e_t_4, 2016-11-04 06:31:09

How to write a sequence?

Hello everyone Plz tell me
how to arrange such a sequence mathematically (or better, even in the form of an algorithm or in pseudocode) - so that you can arrange
an array A = [a, a, a, a, b, b, b, b, b, b in a loop ,c,c,c,c,c,c,d,d,d,d]
arrayB =
I need to get array B from array A
for the second day already, I can’t really figure it out
thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-11-04
@nano_e_t_4

As I see it:
1) N=5, LastSymbol = ""
2) If LastSymbol != first element of arrayA, then N = N - 1, LastSymbol = first element of arrayA
3) Take N elements from arrayA in a loop, write the resulting array to array B
4) Go to step 2
But what happens if array A has an inappropriate number of letters ... here you need to understand the task itself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question