I am a beginner in python and I have some difficulties with this language.

I have not been able to solve an exercise. That's what I do:

- Code: Select all
`> A: 2`

> B: 4

> N: 10

> SEQ: 01010010010001000111101100001010011001111000010010011110010000000

23: 00

15: 10 01

12: 100

11: 001 000 11

10: 010

8: 0100

7: 1001 0010

6: 0000 111

5: 1000 110 011

4: 1100 0011 0001

I have to detect, in a sequence of data bits, the patterns having a length between A and B (included) that are repeated more often.

The tool needed to get the highest frequency patterns N (number of occurrences) appearing in different sequence.

I have to count the number of occurrence of each pattern contained in a sequence of bits.

A is the minimum length of the pattern

B is the maximum length of pattern

N is the number of distinct frequency patterns for search

As a result, the Python script to display a list of N groups of motifs found. every line should be in the format: frequency: pattern ... pattern, where the frequency is the

number of occurrences of patterns. The lines should appear in descending order depending on the frequency patterns, and or within the same line, the patterns must appear in

the descending order of length. Patterns of the same length must be entered in order decreasing their numeric value. If there are less than N distinct frequencies, the output list can be less than N lines.

I can only use conditional statements, loops, functions, strings, tuples and lists.

Sorry for my english (google translate)