Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 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
0a672bb
review fixes №1
notron124 Jan 30, 2026
0f8501b
review fixes #2
notron124 Feb 4, 2026
fedc8a6
review fixes №3
notron124 Feb 5, 2026
cc40f74
Merge pull request #5 from notron124/review_fixes
notron124 Feb 5, 2026
983130f
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
notron124 Feb 8, 2026
d224fa1
add (solution): add tracer task
notron124 Feb 8, 2026
2bf0972
add (solution): add string_view task
notron124 Feb 8, 2026
4bbad35
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025 into 5-week-…
notron124 Feb 8, 2026
5202c54
wip cow_string task
notron124 Feb 11, 2026
5f36202
wip №2 cow_string task
notron124 Feb 11, 2026
3f3d8e0
add (solution): add cow_string task
notron124 Feb 12, 2026
a6e8ad5
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025 into 5-week-…
notron124 Feb 13, 2026
a5b7743
add (refactoring): add cow_string task, add string_view task
notron124 Feb 13, 2026
23296e3
wip №1 simple_vector task
notron124 Feb 13, 2026
826f2d3
add (solution): add simple_vector task
notron124 Feb 14, 2026
b12e33f
Merge pull request #6 from notron124/5-week-five
notron124 Feb 14, 2026
9e16a6c
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
notron124 Feb 14, 2026
915d830
add (fix): add string_view task
notron124 Feb 14, 2026
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
6 changes: 2 additions & 4 deletions 01_week/tasks/addition/addition.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include <cstdint>
#include <stdexcept>


int64_t Addition(int a, int b) {
throw std::runtime_error{"Not implemented"};
}
return static_cast<int64_t>(a) + b;
}
68 changes: 66 additions & 2 deletions 01_week/tasks/char_changer/char_changer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,71 @@
#include <cctype>
#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].
* @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;
}

array[convertedSymIdx++] = sequenceLen >= 10 ? '0' : sequenceLen + '0';

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;
}
44 changes: 41 additions & 3 deletions 01_week/tasks/check_flags/check_flags.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cstdint>
#include <stdexcept>

#include <iostream>
#include <string>
#include <vector>

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

namespace {
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"},
};
}


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

if (flags == CheckFlags::NONE) {
std::cout << "[]";
return;
}

std::string needed_checks = "[";

bool first = true;
for (const auto& [key, val] : checkNames) {
if (static_cast<uint8_t>(flags) & static_cast<uint8_t>(key)) {
if (!first) {
needed_checks += ",";
}

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.

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

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

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

void SolveQuadratic(int a, int b, int c) {
throw std::runtime_error{"Not implemented"};
}
void SolveQuadratic(int a, int b, int c) {
if (a == 0 && b == 0 && c == 0) {
std::cout << "infinite solutions";
return;
}

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

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

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

if (b == 0) {
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 discriminant = static_cast<double>(b) * b - 4.0 * a * c;
double root1 = 0.0, root2 = 0.0;

if (discriminant == 0) {
std::cout << -b / (2.0 * a);
return;
}

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

root1 = ((-b - std::sqrt(discriminant)) / (2.0 * a));
root2 = ((-b + std::sqrt(discriminant)) / (2.0 * a));

root1 > root2 ? std::cout << root2 << " " << root1 :
std:: cout << root1 << " " << root2;
}
18 changes: 13 additions & 5 deletions 01_week/tasks/rms/rms.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#include <cstdef>
#include <stdexcept>

#include <cstddef>
#include <cmath>

double CalculateRMS(double values[], size_t size) {
throw std::runtime_error{"Not implemented"};
}
if (size == 0 || !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));
}
20 changes: 16 additions & 4 deletions 02_week/tasks/func_array/func_array.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
#include <stdexcept>
#include <cstddef>

using operations_t = double(*)(double, double);

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;
for (size_t i = 0; i < size; ++i) {
if (mathOperations[i] != nullptr) {
sum += mathOperations[i](a, b);
}
}

return sum;
}
19 changes: 15 additions & 4 deletions 02_week/tasks/last_of_us/last_of_us.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
#include <stdexcept>
typedef bool (*predicate_func_t)(int);

const int* FindLastElement(const int* begin, const int* end, predicate_func_t predicate) {
if (!begin || !end || 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;
while (begin != end) {
if (predicate(*begin)) {
result = begin;
}
++begin;
}

/* return_type */ FindLastElement(/* ptr_type */ begin, /* ptr_type */ end, /* func_type */ predicate) {
throw std::runtime_error{"Not implemented"};
}
return result;
}
33 changes: 26 additions & 7 deletions 02_week/tasks/little_big/little_big.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
#include <stdexcept>
#include <cstring>
#include <iostream>

template<typename T>
void PrintMemory(T num, bool isReversed = false) {
std::string output = "";

void PrintMemory(int /* write arguments here */) {
throw std::runtime_error{"Not implemented"};
}
// Надеюсь использование memcpy разрешено
Copy link
Contributor Author

Choose a reason for hiding this comment

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

тут больше ожидалось reinterpret_cast, чтобы поупражняться

unsigned char bytes[sizeof(T)];
std::memcpy(bytes, &num, sizeof(T));

size_t start = isReversed ? (sizeof(T) - 1) : 0;
int step = isReversed ? -1 : 1;

for (size_t i = start; i < sizeof(T); i += step) {
unsigned char currentByte = bytes[i];

for (int j = 4; j >= 0; j -= 4) {
int remainder = (currentByte >> j) & 0xf;
char hexChar = 0;

void PrintMemory(double /* write arguments here */) {
throw std::runtime_error{"Not implemented"};
}
hexChar = remainder < 10 ? '0' + remainder : 'A' + (remainder - 10);

output += hexChar;
}
}
output = "0x" + output;
std::cout << output << std::endl;
}
Loading