Returns the maximum score one can get by optimally

Info icon This preview shows pages 3–4. Sign up to view the full content.

View Full Document Right Arrow Icon
/** * Returns the maximum score one can get by optimally * distributing pebbles across the specified game board, * subject to the constraints described above. The function * doesn't describe the optimal distribution of pebbles, just * the best possible score. * * You may assume that the Grid<int> has exactly two rows * and at least one column. */ int ComputeMaxScore(Grid< int >& board); 5 7 1 8 4 8 3 6 7 1 3 3 4 9 6 1 2 1 1 5 1 5 9 2 3 2
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4 Problem 4: String Explosions Given a string str and a character delim , write a function called Explode which returns the "explosion" of str in a Vector<string> , which is the ordered collection of str ’s delim -delimited substrings. Here are some examples of how Explode should work: Explode("171.64.42.111", '.'); should return ["171", "64", "42", "111"] Explode("usr/class/cs106x/WWW", '/'); should return ["usr", "class", cs106x", "WWW"] Explode("XOXXOOOXXOOX", 'X’) should return ["", "O", "", "OOO", "", "OO", ""] Note the last example makes it clear what happens when the delim characters appear on either end of the str , or when two instances of delim appear consecutively. In general, a string str with k instances of delim returns a Vector<string> of length k + 1 . Vector<string> Explode(string str, char delim);
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern