mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated comments and made sure style was consistent
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
//ProjectEuler/C++/Source/Problem24.cpp
|
||||
//ProjectEuler/ProjectEulerCPP/Source/Problem24.cpp
|
||||
//Matthew Ellison
|
||||
// Created: 11-11-18
|
||||
//Modified: 07-14-19
|
||||
//Modified: 07-09-20
|
||||
//What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
|
||||
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/myClasses
|
||||
/*
|
||||
Copyright (C) 2019 Matthew Ellison
|
||||
Copyright (C) 2020 Matthew Ellison
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -30,13 +30,16 @@
|
||||
#include "../Headers/Problem24.hpp"
|
||||
|
||||
|
||||
int Problem24::NEEDED_PERM = 1000000; //The number of the permutation that you need
|
||||
std::string Problem24::nums = "0123456789"; //All of the characters that we need to get the permutations of
|
||||
//The number of the permutation that you need
|
||||
int Problem24::NEEDED_PERM = 1000000;
|
||||
//All of the characters that we need to get the permutations of
|
||||
std::string Problem24::nums = "0123456789";
|
||||
|
||||
//Constructor
|
||||
Problem24::Problem24() : Problem("What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?"){
|
||||
|
||||
}
|
||||
|
||||
//Solve the problem
|
||||
void Problem24::solve(){
|
||||
//If the problem has already been solved do nothing and end the function
|
||||
if(solved){
|
||||
@@ -56,6 +59,13 @@ void Problem24::solve(){
|
||||
solved = true;
|
||||
}
|
||||
|
||||
//Reset the problem so it can be run again
|
||||
void Problem24::reset(){
|
||||
Problem::reset();
|
||||
permutations.clear();
|
||||
}
|
||||
|
||||
//Return a string with the solution to the problem
|
||||
std::string Problem24::getString() const{
|
||||
//If the problem hasn't been solved throw an exception
|
||||
if(!solved){
|
||||
@@ -84,8 +94,3 @@ std::string Problem24::getPermutation() const{
|
||||
}
|
||||
return permutations.at(NEEDED_PERM - 1);
|
||||
}
|
||||
|
||||
void Problem24::reset(){
|
||||
Problem::reset();
|
||||
permutations.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user