// 흐미... 심심해서 해본게 생각보다 시간을 많이 까먹었다.
// TDD는 정말 중요하다.
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
// TDD는 정말 중요하다.
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
void process(void);
int main(void)
{
process();
return 0;
}
{
process();
return 0;
}
void process(void)
{
string alpha = "0123456789";
int synap = 0;
int soft = 0;
int wants = 0;
int you = 0;
int result = 0;
int count = 0;
//'SYNAP + SOFT = WANTS + YOU'
// 0123456789
// AFNOPSTUWY
do
{
if (alpha[5] == '0' || alpha[8] == '0' || alpha[9] == '0')
continue;
synap = (alpha[5]-'0')*10000 + (alpha[9]-'0')*1000 + (alpha[2]-'0')*100 + (alpha[0]-'0')*10 + (alpha[4]-'0');
soft = (alpha[5]-'0')*1000 + (alpha[3]-'0')*100 + (alpha[1]-'0')*10 + (alpha[6]-'0');
wants = (alpha[8]-'0')*10000 + (alpha[0]-'0')*1000 + (alpha[2]-'0')*100 + (alpha[6]-'0')*10 + (alpha[5]-'0');
you = (alpha[9]-'0')*100 + (alpha[3]-'0')*10 + (alpha[7]-'0');
if (synap + soft == wants + you)
{
cout << synap << " + " << soft << " = " << wants << " + " << you << endl;
result += wants + you;
cout << result << endl;
}
} while (next_permutation(alpha.begin(), alpha.end()) );
}