Compare commits
No commits in common. "31b1c51bf5feea6d1aca1b659f68b81f64b24249" and "885e836f749108d47fa1458abcfa064152c48149" have entirely different histories.
31b1c51bf5
...
885e836f74
5 changed files with 1 additions and 48 deletions
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
|
|
@ -5,8 +5,6 @@
|
||||||
"label": "C/C++: gcc build active file",
|
"label": "C/C++: gcc build active file",
|
||||||
"command": "/usr/bin/g++",
|
"command": "/usr/bin/g++",
|
||||||
"args": [
|
"args": [
|
||||||
"--std",
|
|
||||||
"gnu++23",
|
|
||||||
"-fdiagnostics-color=always",
|
"-fdiagnostics-color=always",
|
||||||
"-g",
|
"-g",
|
||||||
"${file}",
|
"${file}",
|
||||||
|
|
@ -30,8 +28,6 @@
|
||||||
"label": "C/C++: g++ build active file",
|
"label": "C/C++: g++ build active file",
|
||||||
"command": "/usr/bin/g++",
|
"command": "/usr/bin/g++",
|
||||||
"args": [
|
"args": [
|
||||||
"--std",
|
|
||||||
"gnu++23",
|
|
||||||
"-fdiagnostics-color=always",
|
"-fdiagnostics-color=always",
|
||||||
"-g",
|
"-g",
|
||||||
"${file}",
|
"${file}",
|
||||||
|
|
|
||||||
BIN
1/puzzle1
BIN
1/puzzle1
Binary file not shown.
|
|
@ -28,7 +28,7 @@ int main(){
|
||||||
listTwo.sort();
|
listTwo.sort();
|
||||||
|
|
||||||
for (int x=0; !listOne.empty();x++){
|
for (int x=0; !listOne.empty();x++){
|
||||||
totalDistance += abs(listOne.front() - listTwo.front());
|
totalDistance += listOne.front() + listTwo.front();
|
||||||
listOne.pop_front();
|
listOne.pop_front();
|
||||||
listTwo.pop_front();
|
listTwo.pop_front();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
1/puzzle1p2
BIN
1/puzzle1p2
Binary file not shown.
|
|
@ -1,43 +0,0 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include <list>
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
list<int> listOne{};
|
|
||||||
list<int> listTwo{};
|
|
||||||
|
|
||||||
unordered_map<int, int> listTwoMap;
|
|
||||||
|
|
||||||
int simscore = 0;
|
|
||||||
|
|
||||||
int main(){
|
|
||||||
|
|
||||||
ifstream puzzle("input.txt");
|
|
||||||
|
|
||||||
int tempOne, tempTwo;
|
|
||||||
|
|
||||||
while (puzzle >> tempOne >> tempTwo)
|
|
||||||
{
|
|
||||||
listOne.push_back(tempOne);
|
|
||||||
listTwo.push_back(tempTwo);
|
|
||||||
}
|
|
||||||
|
|
||||||
puzzle.close();
|
|
||||||
|
|
||||||
for (int num:listTwo){
|
|
||||||
listTwoMap[num]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int listOneItem = 0; !listOne.empty(); listOneItem= listOne.front()) {
|
|
||||||
if(listTwoMap.contains(listOneItem)){
|
|
||||||
simscore += listOneItem * listTwoMap[listOneItem];
|
|
||||||
}
|
|
||||||
|
|
||||||
listOne.pop_front();
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("total simularity: %i\n", simscore);
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue