Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python 8 Pattern Horseracing

blacktiger

New Coder
The whole program will be based on values that will be entered by a user either "B" or "P"

Suppose user entered values
1. B
2. P
3. B
4. P
5. P

Now we should collect these data in set of three and we will therefore get -> BPB, PP...
Now our second set is incomplete, we will wait if user enters another values

6. B
7. P
8. P
9. P

Now we have BPB, PPB, PPP. Now we will count if any of these sets matches with our eight patterns

What are my eight patterns?

BBB, BPB, BPP, BBP, PPP, PPB, PBP, PBB

Then we will count if our collected sets match with any of these eight patterns

BBB - 0
PPB - 1
PPP - 1
BPB - 1
PBP - 0
PBB - 0
BPP - 0
BBP - 0

We will keep counting these patterns until we are left with only one pattern with zero frequency

Suppose after 30 entries we have below data

BBB - 1
PPB - 1
PPP - 1
BPB - 1
PBP - 3
PBB - 1
BPP - 2
BBP - 0

Now, the program should alert the user and print this left pattern for e.g BBP. And now if next three entries are exact same we will print true otherwise false.
 

New Threads

Buy us a coffee!

Back
Top Bottom