[bug] Fix namespace issue. Fix typo in README.
This commit is contained in:
parent
c51556a7ad
commit
a74b1ce714
14
README.md
14
README.md
|
@ -10,7 +10,7 @@ The problem stated was:
|
|||
Given a number (assume base 10) less than 10,000, write a program in
|
||||
C++ that will reverse the digits of that number, calculate the
|
||||
original number to the power of the new number, and print it out.
|
||||
You may not use Boost, GMP, or any library other than that provide
|
||||
You may not use Boost, GMP, or any library other than that provided
|
||||
by the C++ Standard Library.
|
||||
|
||||
I don't know C++. I haven't ever written C++ profesionally, and I
|
||||
|
@ -18,11 +18,11 @@ haven't actually *looked* at C++ since 1999 or so. As a professional,
|
|||
I'm aware of what's going on in the zeitgeist, and at my job at Spiral
|
||||
Genetics I interacted with two very talented C++ developers a lot, so I
|
||||
was aware of things like the emerging C++ Standard Library and RAII and
|
||||
so forth. I didn't know what they *meant*, but I had heard them. I've
|
||||
also been aware of the emerging standards in C++11 and C++14, mostly
|
||||
thanks to Slashdot, Lobsters, and their ilk (don't read the comments,
|
||||
don't **ever** read the comments), so I'd *heard* about auto_ptr and
|
||||
C++11 lambdas and the like.
|
||||
so forth. I didn't know what they *meant*, but I had heard of them.
|
||||
I've also been aware of the emerging standards in C++11 and C++14,
|
||||
mostly thanks to Slashdot, Hacker News, and their ilk (don't read the
|
||||
comments, don't **ever** read the comments), so I'd *heard* about
|
||||
auto_ptr and C++11 lambdas and the like.
|
||||
|
||||
It took about an hour of googling to get up to speed on things like
|
||||
namespaces, containers, for_each, lambdas, and the like. I really like
|
||||
|
@ -31,7 +31,7 @@ the new unique\_ptr construction. That's very nice.
|
|||
My basic solution degrades to 4th-grade mathematics: Break the
|
||||
multiplicand up into a list of single digits, multiply each digit
|
||||
with the multiplier, then redistribute the values up the tens, hundreds,
|
||||
etc. etc. This solution is not particularly fast or space-efficient,
|
||||
etc., etc. This solution is not particularly fast or space-efficient,
|
||||
but it has the virtue of being comprehensible by any ten-year-old.
|
||||
|
||||
As usual, I've provided a test suite, as well as a pair of utility
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace cheapgmp {
|
||||
|
||||
using namespace std;
|
||||
|
||||
ulong tolong(const gmrep in) {
|
||||
int pos = 1;
|
||||
ulong ret = 0;
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace cheapgmp {
|
||||
wstring tostring(gmrep);
|
||||
ulong tolong(gmrep);
|
||||
std::wstring tostring(gmrep);
|
||||
ulong tolong(gmrep);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "cheapgmp.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace cheapgmp {
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
|
||||
/* Given a list representing a decimal number as a multiplicand,
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
#include <list>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace cheapgmp {
|
||||
typedef list<ulong> lmrep;
|
||||
typedef unique_ptr<lmrep> gmrep;
|
||||
typedef std::list<ulong> lmrep;
|
||||
typedef std::unique_ptr<lmrep> gmrep;
|
||||
gmrep makepower(const ulong, const ulong);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
using namespace cheapgmp;
|
||||
|
||||
wstring sample123 = L"72367033806371673149109894141163778628811792657571658906010558390395870363798401744095280686155507736404921657070284961721828960592977909542637098897697223102622628566787654091327825453991595140205701412961364188732408936197890553699715836951569999800431957769217006743321026257517932764164662319487914962533302741368207211189494615326552790667720411285474162636765168907211924134973374304496019635376665858559941735703924836467756917247995469583487467791524582153744522107597865277798136080074161485280424274076931083994487111719562249702540362855712911132265966235754355353516703339043001506118520760359577737869472018617942120590873170710805078696371738906375721785723";
|
||||
std::wstring sample123 = L"72367033806371673149109894141163778628811792657571658906010558390395870363798401744095280686155507736404921657070284961721828960592977909542637098897697223102622628566787654091327825453991595140205701412961364188732408936197890553699715836951569999800431957769217006743321026257517932764164662319487914962533302741368207211189494615326552790667720411285474162636765168907211924134973374304496019635376665858559941735703924836467756917247995469583487467791524582153744522107597865277798136080074161485280424274076931083994487111719562249702540362855712911132265966235754355353516703339043001506118520760359577737869472018617942120590873170710805078696371738906375721785723";
|
||||
|
||||
ulong sample6 = 46656;
|
||||
|
||||
|
|
Loading…
Reference in New Issue