This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <algorithm> | |
using std::cout; | |
using std::endl; | |
using std::string; | |
using std::vector; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
# Tricky multiplication | |
def tricky_mul(arr): | |
mul = 1 | |
new_arr = [] | |
for a in arr: | |
new_arr.append(mul) | |
mul *= a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <random> | |
using std::cout; | |
using std::endl; | |
using std::vector; | |
int get_missed(const vector<int>& arr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <forward_list> | |
using std::cout; | |
using std::endl; | |
using std::string; | |
using std::forward_list; | |
void show_list(const string& title, const forward_list<int>& num) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
void string_to_int_vector(const std::string s, std::vector<int>& vec) | |
{ | |
for (size_t start = 0, end = 0; end < std::string::npos; start = end + 1) { | |
end = s.find('.', start); | |
size_t len = end - start; | |
vec.push_back(std::stoi(s.substr(start, len))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++17 | |
#include <vector> | |
#include <random> | |
#define RAND_SEED -1 // ключ для генерации карты (разные значения дадут разные карты при равных значениях нижеследующих параметров), -1 означает использование random_device | |
#define ISLAND_SIZE 35 // 30 - малые, 35 - средние, 40 - большие, 45 - огромные острова | |
#define ISLAND_COUNT_COEF 50 // коэффициент кол-ва островов: рекомендую - 100 для ISLAND_SIZE 30; 50 для ISLAND_SIZE 35; 25 для ISLAND_SIZE 40; 10 для ISLAND_SIZE 45 | |
class Islands |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <windows.h> | |
std::string ArgvToCommandLine(int argc, const char** argv) | |
{ | |
std::string result; | |
for (int i = 0; i < argc; ++i) { | |
std::string temp = argv[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <string_view> | |
#include <vector> | |
#include <algorithm> | |
// CLASS DECLARATION /////////////////////////////////////////////////////////////////////////////// | |
class FileMask | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <forward_list> | |
using std::cout; | |
using std::forward_list; | |
using std::next; | |
template <typename T> | |
forward_list<T> forward_list_merge(forward_list<T> list1, const forward_list<T>& list2) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Реализация алгоритма "Посмотри-и-скажи" (Look-and-Say). | |
// Вариант, итерационно формирующий результирующее значение (строку цифр). Цифры хранятся в виде 2-х битов на цифру. | |
// Самый медленный алгоритм, требующий наиболее значительного кол-ва памяти (119 Гб для N = 100, 8.4 Гб для N = 90). | |
// Хочу отметить, что дополнительные расчёты, связанные с хранением чисел в формате 2-х битов на цифру | |
// компенсируются меньшим кол-вом обращений к памяти, в результате чего скорость данного алгоритма почти не | |
// отличается от алгоритма, использующего 1 байт на цифру, однако он значительно менее требователен к памяти. | |
// Результат (в отличие от look-and-say.cpp) формируется лишь на последней итерации. | |
// В реализации используется один массив, работающий по принципу двунаправленного чтения и записи. |