formatting source-code for 153fb7b8a5

This commit is contained in:
github-actions
2020-05-30 04:02:09 +00:00
parent 92fe9495ec
commit 8a2de9842b
175 changed files with 1671 additions and 3460 deletions

View File

@@ -17,18 +17,14 @@
* @return Index where the pattern starts in the text
* @return -1 if the pattern was not found.
*/
int brute_force(const std::string &text, const std::string &pattern)
{
int brute_force(const std::string &text, const std::string &pattern) {
size_t pat_l = pattern.length();
size_t txt_l = text.length();
int index = -1;
if (pat_l <= txt_l)
{
for (size_t i = 0; i < txt_l - pat_l + 1; i++)
{
if (pat_l <= txt_l) {
for (size_t i = 0; i < txt_l - pat_l + 1; i++) {
std::string s = text.substr(i, pat_l);
if (s == pattern)
{
if (s == pattern) {
index = i;
break;
}
@@ -44,10 +40,8 @@ const std::vector<std::vector<std::string>> test_set = {
{"bba", "bb", "0"}, {"bbca", "c", "2"}, {"ab", "b", "1"}};
/** Main function */
int main()
{
for (size_t i = 0; i < test_set.size(); i++)
{
int main() {
for (size_t i = 0; i < test_set.size(); i++) {
int output = brute_force(test_set[i][0], test_set[i][1]);
if (std::to_string(output) == test_set[i][2])