MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / func7

Function func7

CPP/pandigital_numbers/code.cpp:52–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52vector<int> func7(string str, vector<int> &values)
53{
54 int num = stoi(str);
55 int a, b;
56 b = num % 10;
57 num /= 10;
58 a = num % 10;
59 num /= 10;
60
61 vector<int> vec;
62
63 for (int i = 0; i < values.size(); i++)
64 {
65 // Subtracting 2 times the last digit from the rest gives a multiple of 7. (Works because 21 is divisible by 7.)
66 if (((a * 10 + b) - (2 * i)) % 7 == 0 && values[i] == 0)
67 {
68 vec.push_back(i);
69 }
70 }
71
72 return vec;
73}
74
75vector<int> func11(string str, vector<int> &values)
76{

Callers 1

funcFunction · 0.85

Calls 2

push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected