123456789
bool are_all_same_suit(vector<string> input) { char suit = input.at(0).at(0); for (auto comparison : input) { if (comparison.at(0) != suit) return false; } return true; }
bool all_cards_of_same_suit( const std::vector<std::string>& cards ) { if( cards.empty() ) return true ; const char suit = cards[0][0] ; // note: can read char at position zero even if the string is empty // http://en.cppreference.com/w/cpp/algorithm/all_any_none_of return std::all_of( cards.begin()+1, cards.end(), [suit] ( const auto& str ) { return str[0] == suit ; } ) ; }