# Advent Of Code 2016 Day 9 Part 1 Solution

This code gives the solution to Part 1 of this question:

Summary: You have to find the length of the input string after using the markers to duplicate parts of it. A marker is enclosed in parentheses and contains two numbers separated by an x. The first number is the number of following characters to copy, the second is the amount of times to do so. If a marker is within the characters to be copied, do not parse it; treat it normally.

// AOC-9.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>

std::string output = "";

int main()
{
for(size_t i = 0; i < input.length(); i++)
{
if(input[i] == '(')
{
std::cout << i << "    " << advance << std::endl;
}
else
{
output += input[i];
}
}
std::cout << output.length();
std::cin.get();
return 0;
}

{
char* ch = &(input[i+1]);
std::string num1, num2, copy;
size_t count1, count2;
while((*ch) != 'x')
{
num1 += *ch;
ch++;
}
ch++;
while((*ch) != ')')
{
num2 += *ch;
ch++;
}
std::cout << num1 << std::endl;
std::cout << num2 << std::endl;
count1 = std::stoi(num1);
count2 = std::stoi(num2);
ch++;
for(size_t j = 0; j < count1; j++)
{
copy += *ch;
ch++;
}
for(size_t j = 0; j < count2; j++)
{
output += copy;
}
return count1;
}


I have used the std::clock on this code and it gives me an execution time of 8 milliseconds, which I find to be satisfactory, but perhaps improvable. Any help is much appreciated!