-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchallenge.hpp
More file actions
73 lines (54 loc) · 1.96 KB
/
challenge.hpp
File metadata and controls
73 lines (54 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// challenge.hpp
// Challenges
//
// Created by Carlos Álvaro on 22/07/2020.
// Copyright © 2020 cdalvaro. All rights reserved.
//
#ifndef challenges_c0011_challenge_hpp
#define challenges_c0011_challenge_hpp
#include <vector>
#include "challenges/ichallenge.hpp"
namespace challenges {
/**
@class Challenge11
@brief This class is intended to solve Challenge 11
@link https://projecteuler.net/problem=11 @endlink
*/
class Challenge11 : virtual public IChallenge {
public:
//! @copydoc IChallenge::Type_t
using Type_t = std::size_t;
/**
@brief Class constructor
This is the main constructor of Challenge11 class
@param numbers_to_take The number of adjacent numbers to compute the
product
*/
explicit Challenge11(const Type_t &numbers_to_take);
/**
@brief Default destructor
*/
~Challenge11() override = default;
/**
This method contains the algorithm that solves challenge 11
@return The solution for challenge 11
*/
Solution_t solve() final;
private:
//! The matrix type
using Matrix_t = std::vector<std::vector<int>>;
Type_t numbers_to_take; ///< The number of adjacent numbers to compute the product
static const Matrix_t matrix; ///< The matrix to be explored
static const std::size_t number_of_rows; ///< The number of rows of the matrix
static const std::size_t number_of_columns; ///< The number of columns of the matrix
/**
Return the maximum product for the given position
@param row Row number
@param column Column number
@return The maximum product for the given position
*/
[[nodiscard]] Type_t maxProductForPosition(const std::size_t &row, const std::size_t &column) const;
};
} // namespace challenges
#endif /* challenges_c0011_challenge_hpp */