Thread: computing points depending from values of vector

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    5

    computing points depending from values of vector

    Hello,
    I am pretty new to the c++ language I am doing a coding challenge regarding checking the values of a vector.

    I have been stuck on this challenge for hours and I can't think of a proper solution.

    I have a vector which is called values that looks like this :

    Code:
    std::vector <char > values {a,b,a,b,b,b,a,a,a,a,b,b,a};
    
    Then after three values a column is started , so at the end this is how the values should be looked at
    Code:
    abaaa
    bbab
    abab
    Player 1 has the letter a and player 2 the letter b.
    If player one has orthogonally connecting a's (exluding diagonal a's) he get's points at the end of the iteration.
    If one a is not connected to any other a player 1 get's one point. Two a's are worth 2 points and for 3 a's 5 points. Always excluding diagonal a's.
    If there are more than 3 connected a's player 1 gets 2 points extra. for example 4 a's 7 points and 5' as 9 points.
    This applies for player 2 as well.
    The tricky part is that a player can get points for more than one group of orthogonally connects a's or b's.
    So for example if player 1 has a group of 3 'as he gets 5 points. If he also has a single a he get's a point.
    So at the end he get's 6 points altogether.

    in this case:
    Code:
    abaaa
    bbab
    abab
    Player 1 gets : 9+1+1
    Player 2 gets: 7+2

    I hope my question is clear.
    I would be thankful for any hint.
    Last edited by kaido; 01-07-2021 at 10:48 AM. Reason: removed the +2 points

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 12-23-2020, 12:38 PM
  2. Replies: 4
    Last Post: 12-10-2013, 02:29 AM
  3. Bidirectional loop? (Increase/decrease depending on values)
    By BlueGooGames in forum C Programming
    Replies: 4
    Last Post: 01-08-2011, 12:08 PM
  4. Replies: 10
    Last Post: 06-10-2010, 09:52 PM
  5. Computing Large Values
    By swbluto in forum C++ Programming
    Replies: 8
    Last Post: 04-07-2005, 03:04 AM

Tags for this Thread