Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7154dec
add (solution): add addition task
notron124 Nov 21, 2025
abb00b8
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025 into 1-week-one
notron124 Nov 24, 2025
4141f23
wip (solution): wip char_changer task
notron124 Nov 24, 2025
16fe4e3
add (solution): add char_changer task
notron124 Nov 25, 2025
e6233b8
add (solution): add check_flags task
notron124 Nov 26, 2025
520f1f2
add (solution): add length_lit task
notron124 Nov 26, 2025
057cea0
add (solution): add print_bits task
notron124 Nov 27, 2025
5af2950
add (solution): add rms task
notron124 Nov 27, 2025
f2b2c19
Merge pull request #1 from notron124/1-week-one
notron124 Nov 27, 2025
bff7344
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
notron124 Nov 27, 2025
7345a15
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
notron124 Dec 5, 2025
706b609
add (solution): add swap_ptr task
notron124 Dec 5, 2025
6d51ad2
add (solution): add last_of_us task
notron124 Dec 5, 2025
6a45716
add (solution): add func_array task
notron124 Dec 6, 2025
3febd06
add (solution): add longest task
notron124 Dec 6, 2025
cc12364
add (solution): add little_big task
notron124 Dec 8, 2025
1aaa0c9
add (solution): add pretty_array task
notron124 Dec 8, 2025
635fcdf
Merge pull request #2 from notron124/2-week-two
notron124 Dec 8, 2025
e26d95b
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
notron124 Dec 14, 2025
aabca70
Merge branch 'main' of github.com:notron124/psds-cpp-2025
notron124 Dec 14, 2025
12fe9b9
add (solution): add data_stats task
notron124 Dec 14, 2025
45ed16c
add (solution): add easy_compare task
notron124 Dec 15, 2025
44d8762
add (solution): add find_all task
notron124 Dec 15, 2025
8504d0e
WIP task filter
notron124 Dec 15, 2025
6b566ab
WIP enum operators
notron124 Dec 17, 2025
d455bf1
add (solution): add enum_operators task
notron124 Dec 18, 2025
7a87f24
add (solution): add unique task
notron124 Dec 18, 2025
5afec6c
add (solution): add range task
notron124 Dec 18, 2025
0c21b29
add (solution): add os_overoad task
notron124 Dec 18, 2025
7bc19a1
add (solution): add minmax task
notron124 Dec 18, 2025
2adfae0
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025 into 3-week-…
notron124 Dec 18, 2025
f128b9c
removed 04_week tests
notron124 Dec 18, 2025
42b81c6
add (solution): add filter task
notron124 Dec 18, 2025
23e327e
add (fix): add easy_compare task
notron124 Dec 18, 2025
e81fc9c
add (optimisation): add filter task
notron124 Dec 18, 2025
6095c22
Merge pull request #3 from notron124/3-week-three
notron124 Dec 18, 2025
9efba7f
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
notron124 Dec 19, 2025
83f3bce
Removed CMakeLists backups
notron124 Dec 19, 2025
55ccf15
add (solution): add stack task
notron124 Dec 21, 2025
5b5b649
add (solution): add queue task
notron124 Dec 23, 2025
a9ddb14
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
notron124 Dec 23, 2025
bd18c29
fix (solution): add queue fix
notron124 Dec 23, 2025
857c48f
Merge branch 'main' of github.com:notron124/psds-cpp-2025 into 4-week…
notron124 Dec 23, 2025
0ebcff7
wip ring buffer
notron124 Dec 24, 2025
0a479eb
wip ring_buff 2
notron124 Dec 24, 2025
270198a
wip ring_buffer 3
notron124 Dec 24, 2025
8f37dc1
wip ring_buffer 4
notron124 Dec 24, 2025
d05dff0
add (solution): add ring_buffer task
notron124 Dec 25, 2025
1da7fd8
add (solution): add phasor task
notron124 Dec 26, 2025
666f3ee
Merge pull request #4 from notron124/4-week-four
notron124 Dec 26, 2025
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
/build-asan
4 changes: 2 additions & 2 deletions 01_week/tasks/addition/addition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@


int64_t Addition(int a, int b) {
throw std::runtime_error{"Not implemented"};
}
return static_cast<int64_t>(a) + static_cast<int64_t>(b);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишний каст, второй операнд не следует приводить явно, так как он бы преобразовался с помощью неявного каста. Принято использовать такую возможность и не писать явный каст самостоятельно второй раз

}
78 changes: 77 additions & 1 deletion 01_week/tasks/char_changer/char_changer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,83 @@
#include <cstddef>
#include <stdexcept>

// Есть ощущение, что это можно решить как-то более лаконично и просто

/**
* @brief Получить длину последовательности из одинаковых знаков.
* @param array указатель на элемент массива, с которого начнется проверка.
* @return Длина последовательности.
* @note Все символы будут сравниваться с первым из переданного массива.
*/
size_t GetIdenticalCharSequenceLen(char *array) {
size_t sequenceLen = 0;

if (array[0] == '\0') {
return 0;
}

while (array[0] == array[sequenceLen]) {
++sequenceLen;
}

return sequenceLen;
Copy link
Contributor Author

@18thday 18thday Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

много лишних пустых строк

}

/**
* @brief Сконвертировать одинаковые символы.
* @param array указатель на начало обрабатываемого массива.
* @param convertedSymIdx ссылка на индекс последнего сконвертированного символа.
* @param currentSymIdx ссылка на индекс текущего обрабатываемого символа.
* @param swapChar знак, на который будет произведена замена array[convertedSymIdx].
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

символ, знак обычно про дургое

* @return none
*/
void ConvertIdenticalCharacters(char array[], size_t& convertedSymIdx, size_t& currentSymIdx, char swapChar) {
size_t sequenceLen = GetIdenticalCharSequenceLen(&array[currentSymIdx]);

array[convertedSymIdx++] = swapChar;

if (sequenceLen == 1) {
currentSymIdx += sequenceLen;
return;
}

if (sequenceLen >= 10) {
array[convertedSymIdx++] = '0';
} else {
array[convertedSymIdx++] = sequenceLen + '0';
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в данном случае тернарный оператор был бы в одну строку


currentSymIdx += sequenceLen;
}

size_t CharChanger(char array[], size_t size, char delimiter = ' ') {
throw std::runtime_error{"Not implemented"};
size_t convertedSymbolIdx = 0, currentSymbolIdx = 0;

while(currentSymbolIdx < size && convertedSymbolIdx < size) {
if (array[currentSymbolIdx] == '\0') {
break;
}

if (isspace(array[currentSymbolIdx])) {
currentSymbolIdx += GetIdenticalCharSequenceLen(&array[currentSymbolIdx]);

array[convertedSymbolIdx++] = delimiter;
continue;
}

if (isalnum(array[currentSymbolIdx])) {
if (isdigit(array[currentSymbolIdx])) {
ConvertIdenticalCharacters(array, convertedSymbolIdx, currentSymbolIdx, '*');
continue;
}

ConvertIdenticalCharacters(array, convertedSymbolIdx, currentSymbolIdx, toupper(array[currentSymbolIdx]));
continue;
}

ConvertIdenticalCharacters(array, convertedSymbolIdx, currentSymbolIdx, '_');
}

array[convertedSymbolIdx] = '\0';
return convertedSymbolIdx;
}
45 changes: 43 additions & 2 deletions 01_week/tasks/check_flags/check_flags.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cstdint>
#include <stdexcept>

#include <string>

enum class CheckFlags : uint8_t {
NONE = 0,
Expand All @@ -13,6 +13,47 @@ enum class CheckFlags : uint8_t {
ALL = TIME | DATE | USER | CERT | KEYS | DEST
};

// В данном случае можно было использовать map, но с ним придется использовать
// static_cast<int>. Так же map отсортирует значения по возрасанию, соответственно
// использовать enum написанный иначе будет невозможно.
const std::vector<std::pair<CheckFlags, std::string_view>> checkNames = {
{CheckFlags::TIME, "TIME"},
{CheckFlags::DATE, "DATE"},
{CheckFlags::USER, "USER"},
{CheckFlags::CERT, "CERT"},
{CheckFlags::KEYS, "KEYS"},
{CheckFlags::DEST, "DEST"},
};
Copy link
Contributor Author

@18thday 18thday Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше поместить в безымянный namespace, чтобы переменная не была в глобальной области видимости.
Можно было написать constexpr функцию, которая бы возвращала значение через switch


void PrintCheckFlags(CheckFlags flags) {
throw std::runtime_error{"Not implemented"};
if (flags > CheckFlags::ALL) {
return;
}

std::string needed_checks = "[";

if (flags == CheckFlags::NONE) {
needed_checks += "]"; // Такая модификация происходит inplace, не
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, если естьместо, но лучше данный случай обработать отдельно сразу выводя в поток, а std::string создавать позже для общего случая

// создавая дорогостоящие копии
std::cout << needed_checks;
return;
}

bool first = true;
for (const auto& [key, val] : checkNames) {
if (static_cast<uint8_t>(flags) & static_cast<uint8_t>(key)) {
if (!first) {
needed_checks += ","; // добавляем запятую перед элементом, а не после,
// проверяя на первый элемент, это гарантирует, что лишних
// запятых не будет
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

комментарий тут излишний, тем более он трехстрочный, это и так понятно по коду

}

needed_checks += val;
first = false;
}
}

needed_checks += "]";

std::cout << needed_checks;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

с тем же успехом можно было сразу писать в поток (буфур потока), линейная логика

}
51 changes: 51 additions & 0 deletions 01_week/tasks/length_lit/length_lit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
constexpr long double METER_IN_FOOT = 0.3048;
constexpr long double INCH_IN_FOOT = 12;
constexpr long double METER_IN_INCH = 0.0254;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это хорошо


constexpr long double operator""_ft_to_m(long double foot) {
return foot * METER_IN_FOOT;
}

constexpr long double operator""_m_to_ft(long double meter) {
return meter / METER_IN_FOOT;
}

constexpr long double operator""_ft_to_cm(long double foot) {
return foot * METER_IN_FOOT * 100;
}

constexpr long double operator""_cm_to_ft(long double cm) {
return cm / (METER_IN_FOOT * 100);
}

constexpr long double operator""_ft_to_in(long double foot) {
return foot * INCH_IN_FOOT;
}

constexpr long double operator""_in_to_ft(long double inch) {
return inch / INCH_IN_FOOT;
}

constexpr long double operator""_in_to_m(long double inch) {
return inch * METER_IN_INCH;
}

constexpr long double operator""_m_to_in(long double meter) {
return meter / METER_IN_INCH;
}

constexpr long double operator""_in_to_cm(long double inch) {
return inch * METER_IN_INCH * 100;
}

constexpr long double operator""_cm_to_in(long double inch) {
return inch / (METER_IN_INCH * 100);
}

constexpr long double operator""_m_to_cm(long double meter) {
return meter * 100;
}

constexpr long double operator""_cm_to_m(long double cm) {
return cm / 100;
}
14 changes: 12 additions & 2 deletions 01_week/tasks/print_bits/print_bits.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#include <cstddef>
#include <stdexcept>

#include <string>

void PrintBits(long long value, size_t bytes) {
throw std::runtime_error{"Not implemented"};
std::string byteForm = "0b";
// i < bytes * 8 сработает, потому что 0ULL - 1 переполняется в ULL_MAX
for (size_t i = (bytes * 8 - 1); i < bytes * 8; --i) {
byteForm += ((value >> i) & 0x01U) + '0';

if (i != 0 && i % 4 == 0) {
byteForm += "'";
}
}

std::cout << byteForm << std::endl;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно сразу писать в буфер потока, но так тоже хорошо

}
64 changes: 61 additions & 3 deletions 01_week/tasks/quadratic/quadratic.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,64 @@
#include <stdexcept>
#include <cmath>
#include <iomanip>

// Уверен, что это можно сделать значительно качественнее, но дедлайн близко,
// поэтому спагетти код >:)

void SolveQuadratic(int a, int b, int c) {
throw std::runtime_error{"Not implemented"};
}
void SolveQuadratic(int a, int b, int c) {
if (!a && !b && !c) {
Copy link
Contributor Author

@18thday 18thday Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

числовые значения принято явно сравнивать с нулем, а вот указатели приводить так к булеву типу окей

std::cout << "infinite solutions";
return;
}

if (!a && !b) {
std::cout << "no solutions";
return;
}

std::cout << std::setprecision(6);

if (!a) {
std::cout << (static_cast<double>(-c) / b);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как будто внешние () лишние

return;
}

if (!b) {
if (static_cast<double>(-c) / a < 0) {
std::cout << "no solutions";
return;
}

double root = std::sqrt(static_cast<double>(-c) / a);

if (root == 0) {
std::cout << root;
} else {
std::cout << -root << " " << root;
}

return;
}

double d = static_cast<double>(b) * b - 4.0 * a * c;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше d обозначить полным именем

double x1 = 0.0, x2 = 0.0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

по аналогии с кодом выше root1, root2 было бы лучше


if (d < 0) {
std::cout << "no solutions";
return;
}

if (d > 0) {
x1 = ((-b - std::sqrt(d)) / (2.0 * a));
x2 = ((-b + std::sqrt(d)) / (2.0 * a));

if (x1 > x2) {
std::cout << x2 << " " << x1;
} else {
std::cout << x1 << " " << x2;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно задействовать тернарный оператор

return;
}

std::cout << -b / (2.0 * a);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это короткая ветвь, было бы лучше поместив её в условие и выйти из функции а ветввь с d >0 сделать без вложенности

}
17 changes: 13 additions & 4 deletions 01_week/tasks/rms/rms.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#include <cstdef>
#include <cstddef>
#include <stdexcept>

#include <cmath>

double CalculateRMS(double values[], size_t size) {
throw std::runtime_error{"Not implemented"};
}
if (size == 0 || values == NULL) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr - это c++
Для указателей можно просто !values

return 0.0;
}

double sum = 0.0;
for (size_t i = 0; i < size; ++i) {
sum += values[i] * values[i];
}

return std::sqrt(sum / static_cast<double>(size));
}
19 changes: 16 additions & 3 deletions 02_week/tasks/func_array/func_array.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#include <stdexcept>

typedef double(*operations_t)(double, double);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в C++ коде принято использовать using, и выглядело бы понятнее


double ApplyOperations(double a, double b /* other arguments */) {
throw std::runtime_error{"Not implemented"};
}
double ApplyOperations(double a, double b, operations_t mathOperations[], size_t size) {
if (size == 0 || mathOperations == nullptr) {
return 0.0;
}

double sum = 0.0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лишняя пустая строка

for (size_t i = 0; i < size; ++i) {
if (mathOperations[i] != nullptr) {
sum += mathOperations[i](a, b);
}
}

return sum;
}
26 changes: 23 additions & 3 deletions 02_week/tasks/last_of_us/last_of_us.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
#include <stdexcept>

typedef bool (*predicate_func_t)(int);

/* return_type */ FindLastElement(/* ptr_type */ begin, /* ptr_type */ end, /* func_type */ predicate) {
throw std::runtime_error{"Not implemented"};
}
const int* FindLastElement(const int* begin, const int* end, predicate_func_t predicate) {
if (begin == nullptr || end == nullptr) {
return end;
}

if (begin >= end) {
return end;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в данном случае можно объединить условия, поскольку возвращается указатель за последний элемент


const int* result = end;

// begin и end передаются by copy, так что инкремент указателя
// не повлияет на переданный указатель
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это лишний комментаарий

while (begin != end) {
if (predicate(*begin)) {
result = begin;
}
++begin;
}

return result;
}
Loading
Loading