From cd1fc54c84f69a046186e19e33f473cbb1a8b6be Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Thu, 15 Nov 2018 14:59:28 +0100 Subject: [PATCH] 06_STD: Anpassungen, mehr Punkte vergeben --- src/07_STD/MP/grundgeruest.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/07_STD/MP/grundgeruest.cpp b/src/07_STD/MP/grundgeruest.cpp index 7171022..bbb136b 100644 --- a/src/07_STD/MP/grundgeruest.cpp +++ b/src/07_STD/MP/grundgeruest.cpp @@ -59,21 +59,15 @@ int stringSimilarity(std::string string1, std::string string2) { if(string1map.size() == string2map.size()) points += 10; int equalCharCount = 0; - int equalChars = 0; - for(std::pair count : characterCount) { - //BUG: equalCharCount ist nicht immer korrekt - if(string1map[count.first] == string2map[count.first]) equalCharCount++;//gleiche Anzahl an gleichen Zeichen - if(string1map[count.first] != 0 && string2map[count.first] != 0) equalChars++;//Zeichen exsistiert in beiden - } - if(equalChars > 0) { - points += characterCount.size() / equalChars * 10; - } - if(equalCharCount > 0) { - points += characterCount.size() / equalCharCount; - std::cout << "equalCharCount = " << equalCharCount << std::endl; + for(std::pair c : characterCount) { + int charCount = c.second / 2; + if(charCount == string1map[c.first] && charCount == string2map[c.first]) { + equalCharCount++; + } } - + //gleiche Anzahl an gleichen Zeichen +10 Punkte + if(equalCharCount == characterCount.size()) points += 10; //TODO: Punkte für gleiche Buchstaben und gleiche Buchstaben Anzahl vergeben