Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby day15 #288

Merged
merged 11 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Exercism Workspace

| Month | Name | Languages |
| :--- | :--- | :--- |
| January | Introduction | ✓ |
| January | Introduction | ✓ (jq, Rust) |
| February | Functional | Haskell (5/5) |
| March | Mechanical | C (2/5), C++ (5/5), Go (3/5), Rust (5/5) |
| April | Analytical | Python (5/5) |
Expand Down
15 changes: 2 additions & 13 deletions cpp/isbn-verifier/isbn_verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,22 @@ namespace isbn_verifier {
bool is_valid(isbn_number_t number) {
bool result{false};

if (number.empty()) {
return result;
}

const std::string re_valid_str{R"--(^[0-9][0-9-]+[0-9X]$)--"};
const std::string re_valid_str{
R"--(^[0-9]-?[0-9]{3}-?[0-9]{5}-?[0-9X]$)--"};
const std::regex re_valid_exp(re_valid_str, std::regex_constants::egrep);
if (!std::regex_search(number, re_valid_exp)) {
return result;
}

const std::string re_digits_str{R"--([0-9]|X)--"};
const std::regex re_digits_exp(re_digits_str, std::regex_constants::egrep);

auto digits_begin =
std::sregex_iterator(number.begin(), number.end(), re_digits_exp);
auto digits_end = std::sregex_iterator();

int sum{0};
int pos{10};

auto digit_count = std::distance(digits_begin, digits_end);

if (digit_count != 10) {
return result;
}

for (auto iter = digits_begin; iter != digits_end; iter++) {
auto re_match = *iter;
const std::string digit_str = re_match[0];
Expand All @@ -44,7 +34,6 @@ bool is_valid(isbn_number_t number) {
}

sum += digit * pos;

pos -= 1;
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/isbn-verifier/isbn_verifier.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>clang_version</key>
<string>Debian clang version 16.0.6 (++20230610113348+7cbf1a259152-1~exp1~20230610233446.99)</string>
<string>Debian clang version 16.0.6 (++20230919124242+7cbf1a259152-1~exp1~20230919124333.105)</string>
<key>diagnostics</key>
<array>
</array>
Expand Down
2 changes: 1 addition & 1 deletion cpp/isbn-verifier/isbn_verifier_test.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>clang_version</key>
<string>Debian clang version 16.0.6 (++20230610113348+7cbf1a259152-1~exp1~20230610233446.99)</string>
<string>Debian clang version 16.0.6 (++20230919124242+7cbf1a259152-1~exp1~20230919124333.105)</string>
<key>diagnostics</key>
<array>
</array>
Expand Down
72 changes: 38 additions & 34 deletions cpp/isbn-verifier/run-tests-cpp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Running automated test file(s):
Running: make clean
rm -rf ./build

real 0m0.011s
user 0m0.002s
sys 0m0.007s
real 0m0.017s
user 0m0.001s
sys 0m0.016s

===============================================================================

Expand Down Expand Up @@ -55,12 +55,16 @@ make[1]: Leaving directory '/home/vpayno/git_vpayno/exercism-workspace/cpp/isbn-

=== All Tests Passed ===

find . -regextype posix-egrep -regex "^.*(tests-main|CompilerId).*[.](gcda|gcno)$" -print -delete
find . -regextype posix-egrep -regex '^.*(tests-main|CompilerId).*[.](gcda|gcno)$' -print -delete
./build/CMakeFiles/3.22.2/CompilerIdCXX/CMakeCXXCompilerId.gcno
./build/CMakeFiles/isbn-verifier.dir/test/tests-main.cpp.gcno
./build/CMakeFiles/isbn-verifier.dir/test/tests-main.cpp.gcda

find . -regextype posix-egrep -regex "^.*[.](gcda|gcno)9260"
find . -regextype posix-egrep -regex '^.*[.](gcda|gcno)$'
./build/CMakeFiles/isbn-verifier.dir/isbn_verifier_test.cpp.gcno
./build/CMakeFiles/isbn-verifier.dir/isbn_verifier.cpp.gcno
./build/CMakeFiles/isbn-verifier.dir/isbn_verifier.cpp.gcda
./build/CMakeFiles/isbn-verifier.dir/isbn_verifier_test.cpp.gcda

gcovr --print-summary
------------------------------------------------------------------------------
Expand All @@ -69,28 +73,28 @@ Directory: .
------------------------------------------------------------------------------
File Lines Exec Cover Missing
------------------------------------------------------------------------------
isbn_verifier.cpp 29 29 100%
isbn_verifier.cpp 24 24 100%
isbn_verifier_test.cpp 51 51 100%
test/catch.hpp 34 29 85% 1642-1643,2301-2302,2560
------------------------------------------------------------------------------
TOTAL 114 109 95%
TOTAL 109 104 95%
------------------------------------------------------------------------------
lines: 95.6% (109 out of 114)
branches: 41.1% (156 out of 380)
lines: 95.4% (104 out of 109)
branches: 40.3% (149 out of 370)

real 0m12.048s
user 0m11.206s
sys 0m0.836s
real 0m10.677s
user 0m9.866s
sys 0m0.807s

===============================================================================

cmake-format --in-place CMakeLists.txt
WARNING config_util.py:307: The following configuration options were ignored:
max_subargs_per_line

real 0m0.158s
user 0m0.117s
sys 0m0.043s
real 0m0.198s
user 0m0.118s
sys 0m0.081s

===============================================================================

Expand All @@ -110,31 +114,31 @@ found lint:
Convention: 3


real 0m0.173s
user 0m0.139s
sys 0m0.037s
real 0m0.186s
user 0m0.120s
sys 0m0.067s

===============================================================================

Running: clang-format-16 -style=file -i ./isbn_verifier.cpp ./isbn_verifier_test.cpp ./isbn_verifier.hpp

real 0m0.028s
user 0m0.014s
sys 0m0.014s
real 0m0.018s
user 0m0.006s
sys 0m0.012s

===============================================================================

Running: ../../.github/citools/cpp/clang-check
clang-check-16 --analyze ./isbn_verifier.cpp ./isbn_verifier_test.cpp ./isbn_verifier.hpp
Running: clang-check-16 --analyze ./isbn_verifier.cpp ./isbn_verifier_test.cpp ./isbn_verifier.hpp

real 0m3.501s
user 0m3.396s
sys 0m0.105s
real 0m3.189s
user 0m3.085s
sys 0m0.103s


real 0m3.503s
user 0m3.397s
sys 0m0.106s
real 0m3.191s
user 0m3.085s
sys 0m0.105s

===============================================================================

Expand All @@ -145,15 +149,15 @@ Running: ../../.github/citools/cpp/clang-tidy | head -n 100
Suppressed 116244 warnings (116239 in non-user code, 5 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

real 0m21.584s
user 0m21.439s
sys 0m0.142s
real 0m19.478s
user 0m19.345s
sys 0m0.130s
Running: clang-tidy-16 ./isbn_verifier.cpp ./isbn_verifier_test.cpp ./isbn_verifier.hpp


real 0m21.586s
user 0m21.442s
sys 0m0.142s
real 0m19.480s
user 0m19.346s
sys 0m0.132s

===============================================================================

6 changes: 0 additions & 6 deletions cpp/protein-translation/protein_translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,13 @@ ProteinList proteins(RnaSequence rna_sequence) {
return result;
}

if (rna_sequence.length() % k_codon_length != 0) {
return result;
}

const std::string re_str{R"--((\w\w\w))--"};
const std::regex re_exp(re_str);

auto words_begin =
std::sregex_iterator(rna_sequence.begin(), rna_sequence.end(), re_exp);
auto words_end = std::sregex_iterator();

// auto codon_count = std::distance(words_begin, words_end);

for (auto i = words_begin; i != words_end; ++i) {
auto match = *i;

Expand Down
2 changes: 1 addition & 1 deletion cpp/protein-translation/protein_translation.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>clang_version</key>
<string>Debian clang version 16.0.6 (++20230610113348+7cbf1a259152-1~exp1~20230610233446.99)</string>
<string>Debian clang version 16.0.6 (++20230919124242+7cbf1a259152-1~exp1~20230919124333.105)</string>
<key>diagnostics</key>
<array>
</array>
Expand Down
2 changes: 1 addition & 1 deletion cpp/protein-translation/protein_translation_test.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>clang_version</key>
<string>Debian clang version 16.0.6 (++20230610113348+7cbf1a259152-1~exp1~20230610233446.99)</string>
<string>Debian clang version 16.0.6 (++20230919124242+7cbf1a259152-1~exp1~20230919124333.105)</string>
<key>diagnostics</key>
<array>
</array>
Expand Down
66 changes: 35 additions & 31 deletions cpp/protein-translation/run-tests-cpp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Running automated test file(s):
Running: make clean
rm -rf ./build

real 0m0.008s
user 0m0.001s
real 0m0.018s
user 0m0.000s
sys 0m0.006s

===============================================================================
Expand Down Expand Up @@ -55,12 +55,16 @@ make[1]: Leaving directory '/home/vpayno/git_vpayno/exercism-workspace/cpp/prote

=== All Tests Passed ===

find . -regextype posix-egrep -regex "^.*(tests-main|CompilerId).*[.](gcda|gcno)$" -print -delete
find . -regextype posix-egrep -regex '^.*(tests-main|CompilerId).*[.](gcda|gcno)$' -print -delete
./build/CMakeFiles/3.22.2/CompilerIdCXX/CMakeCXXCompilerId.gcno
./build/CMakeFiles/protein-translation.dir/test/tests-main.cpp.gcno
./build/CMakeFiles/protein-translation.dir/test/tests-main.cpp.gcda

find . -regextype posix-egrep -regex "^.*[.](gcda|gcno)6783"
find . -regextype posix-egrep -regex '^.*[.](gcda|gcno)$'
./build/CMakeFiles/protein-translation.dir/protein_translation_test.cpp.gcno
./build/CMakeFiles/protein-translation.dir/protein_translation.cpp.gcno
./build/CMakeFiles/protein-translation.dir/protein_translation.cpp.gcda
./build/CMakeFiles/protein-translation.dir/protein_translation_test.cpp.gcda

gcovr --print-summary
------------------------------------------------------------------------------
Expand All @@ -69,28 +73,28 @@ Directory: .
------------------------------------------------------------------------------
File Lines Exec Cover Missing
------------------------------------------------------------------------------
protein_translation.cpp 27 20 74% 11,15,19,40,42,53,55
protein_translation.cpp 25 19 76% 11,15,34,36,47,49
protein_translation_test.cpp 69 69 100%
test/catch.hpp 48 27 56% 1448-1450,1642-1643,1827-1833,1835-1836,2016-2017,2039-2040,2227,2229,2560
------------------------------------------------------------------------------
TOTAL 144 116 80%
TOTAL 142 115 81%
------------------------------------------------------------------------------
lines: 80.6% (116 out of 144)
branches: 40.9% (265 out of 648)
lines: 81.0% (115 out of 142)
branches: 40.9% (264 out of 646)

real 0m12.058s
user 0m11.233s
sys 0m0.822s
real 0m10.987s
user 0m10.156s
sys 0m0.818s

===============================================================================

cmake-format --in-place CMakeLists.txt
WARNING config_util.py:307: The following configuration options were ignored:
max_subargs_per_line

real 0m0.153s
user 0m0.100s
sys 0m0.055s
real 0m0.189s
user 0m0.114s
sys 0m0.076s

===============================================================================

Expand All @@ -110,31 +114,31 @@ found lint:
Convention: 3


real 0m0.179s
user 0m0.139s
sys 0m0.042s
real 0m0.180s
user 0m0.122s
sys 0m0.058s

===============================================================================

Running: clang-format-16 -style=file -i ./protein_translation.cpp ./protein_translation_test.cpp ./protein_translation.hpp

real 0m0.020s
real 0m0.021s
user 0m0.011s
sys 0m0.009s

===============================================================================

Running: ../../.github/citools/cpp/clang-check
clang-check-16 --analyze ./protein_translation.cpp ./protein_translation_test.cpp ./protein_translation.hpp
Running: clang-check-16 --analyze ./protein_translation.cpp ./protein_translation_test.cpp ./protein_translation.hpp

real 0m3.521s
user 0m3.415s
sys 0m0.106s
real 0m3.146s
user 0m3.056s
sys 0m0.089s


real 0m3.523s
user 0m3.416s
sys 0m0.106s
real 0m3.148s
user 0m3.056s
sys 0m0.091s

===============================================================================

Expand All @@ -145,15 +149,15 @@ Running: ../../.github/citools/cpp/clang-tidy | head -n 100
Suppressed 116113 warnings (116108 in non-user code, 5 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.

real 0m22.911s
user 0m22.779s
sys 0m0.128s
real 0m20.351s
user 0m20.232s
sys 0m0.114s
Running: clang-tidy-16 ./protein_translation.cpp ./protein_translation_test.cpp ./protein_translation.hpp


real 0m22.913s
user 0m22.780s
sys 0m0.130s
real 0m20.352s
user 0m20.233s
sys 0m0.116s

===============================================================================

4 changes: 4 additions & 0 deletions ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@
- [matching-brackets](./matching-brackets/README.md)
- [perfect-numbers](./perfect-numbers/README.md)
- [sum-of-multiples](./sum-of-multiples/README.md)
- [microwave](./microwave/README.md)
- [bob](./bob/README.md)
- [isbn-verifier](./isbn-verifier/README.md)
- [protein-translation](./protein-translation/README.md)
Loading