Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8ce7895
add (solution): add addition task
Rikitick Nov 26, 2025
9402675
add (solution): add char_changer task
Rikitick Nov 26, 2025
80dc57e
add (solution): add check_flags task
Rikitick Nov 26, 2025
3f647a2
add (solution): add length_lit task
Rikitick Nov 26, 2025
b50d9bb
add (solution): add print_bits task
Rikitick Nov 26, 2025
ee50f09
add (solution): add quadratic task
Rikitick Nov 26, 2025
573b181
add (solution): add rms task
Rikitick Nov 26, 2025
5aa6519
add (solution): add addition task
Rikitick Dec 4, 2025
bdadfb5
add (solution): add quadratic task
Rikitick Dec 4, 2025
6a4b005
add 02_week
Rikitick Dec 8, 2025
086d65f
add (solution): add addition task
Rikitick Dec 8, 2025
541a260
add (solution): add char_changer task
Rikitick Dec 8, 2025
65add83
add (solution): add print_bits task
Rikitick Dec 8, 2025
e9531fd
add (solution): add quadratic task
Rikitick Dec 8, 2025
412fe66
add (solution): add func_array task
Rikitick Dec 8, 2025
b52a152
add (solution): add last_of_us task
Rikitick Dec 8, 2025
5874a3d
add (solution): add little_big task
Rikitick Dec 8, 2025
856803d
add (solution): add swap_ptr task
Rikitick Dec 8, 2025
a7eefbe
add (solution): add pretty_array task
Rikitick Dec 9, 2025
36240fb
add (solution): add longest task
Rikitick Dec 9, 2025
54bee4b
add (solution): add data_stats task
Rikitick Dec 16, 2025
10707a7
add (solution): add easy_compare task
Rikitick Dec 16, 2025
7016626
add (solution): add enum_operators task
Rikitick Dec 16, 2025
1107258
add (solution): add filter task
Rikitick Dec 16, 2025
0d083b8
add (solution): add filter task
Rikitick Dec 16, 2025
b7a67be
add (solution): add minmax task
Rikitick Dec 16, 2025
a236f5c
change in main.cpp
Rikitick Dec 16, 2025
59ca329
add (solution): add os_overload task
Rikitick Dec 17, 2025
de774e1
add (solution): add range task
Rikitick Dec 17, 2025
fa9b711
add (solution): add unique task
Rikitick Dec 17, 2025
541c88a
change in main
Rikitick Dec 17, 2025
73389a5
add 04_week
Rikitick Dec 18, 2025
eca65d4
add (solution): add phasor task
Rikitick Dec 23, 2025
e8966cc
add (solution): add queue task
Rikitick Dec 23, 2025
ddef04f
add fixes to 04_week
Rikitick Dec 23, 2025
526bb1b
add (solution): add queue task
Rikitick Dec 23, 2025
39167d8
add (solution): add stack task
Rikitick Dec 24, 2025
e6a7df0
add (solution): add queue task
Rikitick Dec 24, 2025
0ad1565
add (solution): add queue task
Rikitick Dec 26, 2025
a3b4cb1
add (solution): add ring_buffer task
Rikitick Dec 26, 2025
2079c05
add (solution): add ring_phasor task
Rikitick Dec 26, 2025
ba80fc5
add (solution): add ring_ring_buffer task
Rikitick 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
3 changes: 1 addition & 2 deletions 01_week/tasks/addition/addition.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <cstdint>
#include <stdexcept>


int64_t Addition(int a, int b) {
throw std::runtime_error{"Not implemented"};
return static_cast<int64_t>(a) + b;
}
42 changes: 41 additions & 1 deletion 01_week/tasks/char_changer/char_changer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
#include <cstddef>
#include <stdexcept>
#include <bits/stdc++.h>


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

auto parse = [&](size_t i, char cymbol) {
if (i > 0 && array[i] == array[i-1]) {
if (cntRepeat != 1)
--resInd;
++cntRepeat;
res[resInd] = (cntRepeat > 9) ? '0' : '0' + cntRepeat;
}
else {
res[resInd] = cymbol;
cntRepeat = 1;
}
++resInd;
};

for (size_t i = 0; i < size; ++i) {
if ('0' <= array[i] && array[i] <= '9')
parse(i, '*');
else if ('a' <= array[i] && array[i] <= 'z')
parse(i, array[i] - ' ');
else if ('A' <= array[i] && array[i] <= 'Z')
parse(i, array[i]);
else if (array[i] == ' ') {
res[resInd] = delimiter;
++resInd;
while (array[i] == ' ')
++i;
--i;
}
else if (array[i] != '\0')
parse(i, '_');
}

for (size_t i = 0; i < size; ++i)
array[i] = res[i];

return resInd;
}
33 changes: 32 additions & 1 deletion 01_week/tasks/check_flags/check_flags.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstdint>
#include <stdexcept>
#include <bits/stdc++.h>


enum class CheckFlags : uint8_t {
Expand All @@ -14,5 +15,35 @@ enum class CheckFlags : uint8_t {
};

void PrintCheckFlags(CheckFlags flags) {
throw std::runtime_error{"Not implemented"};
uint8_t value = static_cast<uint8_t>(flags);

if (value == static_cast<uint8_t>(CheckFlags::NONE)) {
std::cout << "[]";
return;
}
else if (value >= 1 << 6) {
std::cout << "";
return;
}

std::cout << "[";

bool first = true;
auto try_print = [&](CheckFlags f, const char* name) {
if (value & static_cast<uint8_t>(f)) {
if (!first)
std::cout << ",";
std::cout << name;
first = false;
}
};

try_print(CheckFlags::TIME, "TIME");
try_print(CheckFlags::DATE, "DATE");
try_print(CheckFlags::USER, "USER");
try_print(CheckFlags::CERT, "CERT");
try_print(CheckFlags::KEYS, "KEYS");
try_print(CheckFlags::DEST, "DEST");

std::cout << "]";
}
17 changes: 17 additions & 0 deletions 01_week/tasks/length_lit/length_lit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

constexpr long double operator"" _ft_to_m(long double x) {return x * 0.3048L;}
constexpr long double operator"" _ft_to_cm(long double x) {return x * 30.48L;}
constexpr long double operator"" _ft_to_in(long double x) {return x * 12.0L;}

constexpr long double operator"" _in_to_m(long double x) {return x * 0.0254L;}
constexpr long double operator"" _in_to_cm(long double x) {return x * 2.54L;}
constexpr long double operator"" _in_to_ft(long double x) {return x / 12.0L;}

constexpr long double operator"" _m_to_ft(long double x) {return x * 3.280839895L;}
constexpr long double operator"" _m_to_in(long double x) {return x * 39.37007874L;}
constexpr long double operator"" _m_to_cm(long double x) {return x * 100.0L;}

constexpr long double operator"" _cm_to_m(long double x) {return x / 100.0L;}
constexpr long double operator"" _cm_to_ft(long double x) {return x * 0.0328084L;}
constexpr long double operator"" _cm_to_in(long double x) {return x * 0.3937007874L;}
27 changes: 26 additions & 1 deletion 01_week/tasks/print_bits/print_bits.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
#include <cstddef>
#include <stdexcept>
#include <bits/stdc++.h>


void PrintBits(long long value, size_t bytes) {
throw std::runtime_error{"Not implemented"};
size_t bits = bytes*8;
bool reverse = false;
bool res[bits] = {0};

if (value < 0) {
reverse = true;
value = -value - 1;
}

for (size_t i = bits; i > 0 && value != 0; --i) {
res[i-1] = value % 2;
value /= 2;
}

if (reverse)
for (size_t i = 0; i < bits; ++i)
res[i] ^= 1;

std::cout << "0b";
for (size_t i = 0; i < bits; ++i) {
if (i % 4 == 0 && i != 0)
std::cout << '\'';
std::cout << res[i];
}
std::cout << '\n';
}
45 changes: 44 additions & 1 deletion 01_week/tasks/quadratic/quadratic.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
#include <cmath>
#include <stdexcept>
#include <iomanip>
#include <bits/stdc++.h>


void SolveQuadratic(int a, int b, int c) {
throw std::runtime_error{"Not implemented"};
if (a == 0 && b == 0 && c == 0)
std::cout << "infinite solutions";
else if (a == 0 && b == 0 && c != 0)
std::cout << "no solutions";
else if (a == 0 && b != 0 && c == 0)
std::cout << "0";
else if (a == 0 && b != 0 && c != 0)
std::cout << std::setprecision(6) << static_cast<long double>(-c) / b;
else if (a != 0 && b == 0 && c == 0)
std::cout << "0";
else if (a != 0 && b == 0 && c != 0) {
if (c > 0)
std::cout << "no solutions";
else {
long double x = sqrt(static_cast<long double>(-c) / a);
std::cout << std::setprecision(6) << -x << ' ' << x;
}
}
else if (a != 0 && b != 0 && c == 0) {
long double x = static_cast<long double>(-b) / a;
if (x < 0)
std::cout << std::setprecision(6) << x << " 0";
else
std::cout << std::setprecision(6) << "0 " << x;
}
else {
long long d = static_cast<long double>(b)*b - 4LL*a*c;
if (d < 0)
std::cout << "no solutions";
else if (d == 0)
std::cout << std::setprecision(6) << static_cast<long double>(-b) / (2.0L*a);
else {
long double sqrtd = sqrt(d);
long double x1 = (static_cast<long double>(-b) + sqrtd) / (2.0L*a);
long double x2 = (static_cast<long double>(-b) - sqrtd) / (2.0L*a);
if (x1 < x2)
std::cout << std::setprecision(6) << x1 << ' ' << x2;
else
std::cout << std::setprecision(6) << x2 << ' ' << x1;
}
}
}
10 changes: 8 additions & 2 deletions 01_week/tasks/rms/rms.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#include <cstdef>
#include <stdexcept>
#include <bits/stdc++.h>


double CalculateRMS(double values[], size_t size) {
throw std::runtime_error{"Not implemented"};
if (size == 0 || values == nullptr)
return 0.0;
long double sum = 0.0L;
for (size_t i = 0; i < size; ++i)
sum += values[i] * values[i];
sum /= size;
return sqrt(sum);
}
9 changes: 7 additions & 2 deletions 02_week/tasks/func_array/func_array.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <cstddef>
#include <stdexcept>


double ApplyOperations(double a, double b /* other arguments */) {
throw std::runtime_error{"Not implemented"};
double ApplyOperations(double a, double b, double (*funcs[])(double a, double b), size_t size) {
double res = 0.0;
for (size_t i = 0; i < size; ++i)
if (funcs[i])
res += funcs[i](a, b);
return res;
}
11 changes: 9 additions & 2 deletions 02_week/tasks/last_of_us/last_of_us.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include <stdexcept>


/* 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, bool (*predicate)(int a)) {
if (!(begin && end && predicate && begin < end))
return end;
const int* first = begin;
const int* last = end-1;
for (; last >= first; --last)
if (predicate(*last))
return last;
return end;
}
40 changes: 36 additions & 4 deletions 02_week/tasks/little_big/little_big.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <cstring>

void PrintByte(unsigned char byte) {
std::cout << std::setw(2) << static_cast<int>(byte);
}

void PrintMemory(int value, bool reverse = false) {
const size_t size = sizeof(int);
unsigned char bytes[size];

std::memcpy(bytes, &value, size);
std::cout << "0x" << std::hex << std::uppercase << std::setfill('0');

void PrintMemory(int /* write arguments here */) {
throw std::runtime_error{"Not implemented"};
if (reverse)
for (size_t i = size; i > 0; --i)
PrintByte(bytes[i-1]);
else
for (size_t i = 0; i < size; ++i)
PrintByte(bytes[i]);

std::cout << std::endl;
}

void PrintMemory(double /* write arguments here */) {
throw std::runtime_error{"Not implemented"};
void PrintMemory(double value, bool reverse = false) {
const size_t size = sizeof(double);
unsigned char bytes[size];

std::memcpy(bytes, &value, size);
std::cout << "0x" << std::hex << std::uppercase << std::setfill('0');

if (reverse)
for (size_t i = size; i > 0; --i)
PrintByte(bytes[i-1]);
else
for (size_t i = 0; i < size; ++i)
PrintByte(bytes[i]);

std::cout << std::endl;
}
28 changes: 26 additions & 2 deletions 02_week/tasks/longest/longest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
#include <stdexcept>


/* return_type */ FindLongestSubsequence(/* ptr_type */ begin, /* ptr_type */ end, /* type */ count) {
throw std::runtime_error{"Not implemented"};
char* FindLongestSubsequence(char* begin, char* end, size_t& count) {
if (!begin || !end || end - begin == 0) {
count = 0;
return nullptr;
}

size_t curLen = 0;
char* startPtr = nullptr;
char curChar = *begin;
for (; begin <= end; ++begin) {
if (curChar != *begin) {
if (curLen > count) {
count = curLen;
startPtr = begin - curLen;
}
curLen = 1;
curChar = *begin;
}
else
++curLen;
}
return startPtr;
}

const char* FindLongestSubsequence(const char* begin, const char* end, size_t& count) {
return FindLongestSubsequence(const_cast<char*>(begin), const_cast<char*>(end), count);
}
33 changes: 31 additions & 2 deletions 02_week/tasks/pretty_array/pretty_array.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
#include <stdexcept>
#include <iostream>

void PrintArray(const int* begin, const int* end, size_t limit = 0) {
const bool reverse = (begin > end);
const size_t len = std::abs(end - begin);

void PrintArray(/* write arguments here */) {
throw std::runtime_error{"Not implemented"};
if (len == 0) {
std::cout << "[]\n";
return;
}

const int* cur = begin;
size_t cnt = 0;

std::cout << "[";

for (size_t i = 0; i < len; ++i) {
std::cout << *cur;
if (i != len - 1) {
if ((limit > 0) && (cnt == limit - 1)) {
std::cout << ", ...\n ";
cnt = 0;
}
else {
std::cout << ", ";
++cnt;
}
}

if (i != len - 1)
cur = reverse ? cur - 1 : cur + 1;
}
std::cout << "]\n";
}
Loading