Commits

Lars Viklund  committed 4c0c3a9

Solved problem #145.

  • Participants
  • Parent commits f8f617b

Comments (0)

Files changed (4)

File Windows/Windows.vcxproj

     <ClInclude Include="..\src\112.h" />
     <ClInclude Include="..\src\061.h" />
     <ClInclude Include="..\src\139.h" />
+    <ClInclude Include="..\src\145.h" />
     <ClInclude Include="..\src\bignum.h" />
     <ClInclude Include="..\src\bits.h" />
     <ClInclude Include="..\src\conversion.h" />

File Windows/Windows.vcxproj.filters

     <ClInclude Include="..\src\098.h">
       <Filter>Header Files\Problems</Filter>
     </ClInclude>
+    <ClInclude Include="..\src\145.h">
+      <Filter>Header Files\Problems</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\src\main.cc">
+#pragma once
+#include "problem.h"
+#include "conversion.h"
+
+template <>
+void Problem<145>()
+{
+	mpz_class count = 0;
+	for (long n = 1; n < NUM4(1,000,000,000); ++n)
+	{
+		if (n % NUM2(100,000) == 0)
+			std::cerr << (n / NUM2(100,000)) << std::endl;
+		auto s = itoaz(n);
+		if (s.back() == '0')
+			continue;
+		std::string rs(s.rbegin(), s.rend());
+		auto rn = atoiz(rs);
+		if (n >= rn)
+			continue;
+
+		std::string ssum = itoaz(n + rn);
+		if (ssum.end() == std::find_if(ssum.begin(), ssum.end(), [](char ch)
+		{
+			return ((ch - '0') % 2) == 0;
+		}))
+			++count;
+	}
+	std::cerr << (count * 2) << std::endl;
+}
-#include "098.h"
+#include "145.h"
 
 int main()
 {
-	Problem<98>();
+	Problem<145>();
 }