diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/Aufgabe1/.idea/.gitignore b/Aufgabe1/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/Aufgabe1/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/Aufgabe1/.idea/Aufgabe1.iml b/Aufgabe1/.idea/Aufgabe1.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/Aufgabe1/.idea/Aufgabe1.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/Aufgabe1/main.cpp b/Aufgabe1/main.cpp
index 6f06580..53b0b47 100644
--- a/Aufgabe1/main.cpp
+++ b/Aufgabe1/main.cpp
@@ -117,6 +117,25 @@ int solve(std::vector& left, std::vector& right) {
return sum;
}
+int countOccurenceInList(std::vector& vec, int element) {
+ int occurences = 0;
+ for(const auto& i: vec) {
+ if(i == element) {
+ occurences++;
+ }
+ }
+ return occurences;
+}
+
+int calcSimilarity(std::vector& left, std::vector& right) {
+ int similarityScore = 0;
+ for(int i : left) {
+ int occurencesInRightList = countOccurenceInList(right, i);
+ similarityScore += i * occurencesInRightList;
+ }
+ return similarityScore;
+}
+
int main() {
std::string inputFile = "../input.txt";
std::vector input = readTextFromFile(inputFile);
@@ -124,5 +143,8 @@ int main() {
int result = solve(leftArray, rightArray);
std::cout << "The result is: " << result << std::endl;
+
+ int similarityScore = calcSimilarity(leftArray, rightArray);
+ std::cout << "The similarity is " << similarityScore << std::endl;
return 0;
}