Skip to content

Commit adb2329

Browse files
committed
2024-08-06
1 parent bb91b94 commit adb2329

File tree

7 files changed

+51
-18
lines changed

7 files changed

+51
-18
lines changed

clevercode/perskods.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ int main() {
88
s += n * m[i];
99
}
1010
printf("%c\n", b[s % 11]);
11-
}
11+
}

clevercode/tomati.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ int main() {
1717
r = rt + lt + 1;
1818

1919
printf("%d", r);
20-
}
20+
}

codewars/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ If you're looking for a specific kata, it's recommended to go by the url.
393393
* circles-in-polygons: https://www.codewars.com/kata/5a026a9cffe75fbace00007f
394394
* easy-logs: https://www.codewars.com/kata/5b68c7029756802aa2000176
395395
* a-wolf-in-sheeps-clothing: https://www.codewars.com/kata/5c8bfa44b9d1192e1ebd3d15
396+
* flick-switch: https://www.codewars.com/kata/64fbfe2618692c2018ebbddb
397+
* sentence-smash: https://www.codewars.com/kata/53dc23c68a0c93699800041d
396398

397399
## Beta
398400

codewars/flick-switch.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Flick Switch
2+
// https://www.codewars.com/kata/64fbfe2618692c2018ebbddb
3+
// 8kyu, Clang 8 C++17
4+
5+
#include <string>
6+
#include <vector>
7+
8+
std::vector<bool> flick_switch(const std::vector<std::string>& arr) {
9+
std::vector<bool> result;
10+
result.reserve(arr.size());
11+
bool state = true;
12+
for (auto i : arr) {
13+
if (i == "flick") state = !state;
14+
result.push_back(state);
15+
}
16+
return result;
17+
}

codewars/sentence-smash.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Sentence Smash
2+
// https://www.codewars.com/kata/53dc23c68a0c93699800041d
3+
// 8kyu, Clang 8 C++17
4+
5+
#include <string>
6+
#include <vector>
7+
8+
std::string smash(const std::vector<std::string>& words) {
9+
if (words.size() == 0) return "";
10+
std::string result = words[0];
11+
for (int i = 1; i < words.size(); ++i)
12+
result += " " + words[i];
13+
return result;
14+
}

hackerrank/mini-max-sum.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void miniMaxSum(std::vector<int> arr) {
1616
int main() {
1717
std::string str;
1818
std::vector<int> arr;
19-
19+
2020
while (std::cin >> str)
2121
arr.push_back(std::stol(str));
2222

hackerrank/plus-minus.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
#include <iomanip>
33

44
int main() {
5-
int n, a = 0, b = 0, c = 0, d;
6-
std::cin >> n;
7-
for (int i = 0; i < n; i++) {
8-
std::cin >> d;
9-
if (d > 0)
10-
a++;
11-
else if (d < 0)
12-
b++;
13-
else
14-
c++;
15-
}
16-
std::cout << std::fixed << std::setprecision(6) <<
17-
(float)a / n << "\n" <<
18-
(float)b / n << "\n" <<
19-
(float)c / n << std::endl;
5+
int n, a = 0, b = 0, c = 0, d;
6+
std::cin >> n;
7+
for (int i = 0; i < n; i++) {
8+
std::cin >> d;
9+
if (d > 0)
10+
a++;
11+
else if (d < 0)
12+
b++;
13+
else
14+
c++;
15+
}
16+
std::cout << std::fixed << std::setprecision(6) <<
17+
(float)a / n << "\n" <<
18+
(float)b / n << "\n" <<
19+
(float)c / n << std::endl;
2020
}

0 commit comments

Comments
 (0)