This file contains 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 <date> | |
#include <vector> | |
#include <string> | |
#include <iostream> | |
int main(int argc, char *argv[]) { | |
const std::vector<std::string> month_names = { | |
"", "January", "February", "March", "April", "May", "June", "July", | |
"August", "September", "October", "November", "December" | |
}; |
This file contains 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 <future> | |
#include <vector> | |
#include <atomic> | |
#include <random> | |
#include <string> | |
const int n_tasks = 1000; | |
std::atomic<bool> flags[n_tasks] = {}; |
This file contains 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 <algorithm> | |
#include <iostream> | |
#include <random> | |
std::vector<int> &factor(int n, std::vector<int> &prime_factors) { | |
auto i = 2; | |
while (n > 1) { | |
if (0 == n % i) { | |
prime_factors.push_back(i); | |
n /= i; |
This file contains 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 <algorithm> | |
#include <functional> | |
#include <iomanip> | |
#include <iostream> | |
#include <iterator> | |
#include <map> | |
#include <memory> | |
#include <string> | |
#include <type_traits> | |
#include <utility> |
This file contains 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
#define NOMINMAX | |
#include "scoped_resource.h" | |
#include <Audioclient.h> | |
#include <atlbase.h> | |
#include <audiopolicy.h> | |
#include <mmdeviceapi.h> | |
#include <chrono> |
This file contains 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 <future> | |
#include <vector> | |
#include <cassert> | |
struct S { | |
bool on_main_thread = false; | |
int tasks_run_on_this_thread = 0; | |
S() { std::cerr << "S ctor\n"; } |
This file contains 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 <vector> | |
#include <iostream> | |
#include <tuple> | |
#include <functional> | |
template<typename Container> | |
struct enumerate_iterator { | |
typename Container::size_type i; | |
typename Container::iterator v; |
This file contains 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 <vector> | |
#include <algorithm> | |
void make_killer(int size, std::vector<int>& v) { | |
int candidate = 0; | |
int num_solid = 0; | |
int gas = size - 1; | |
std::vector<int> tmp(size); | |
v.resize(size); |
This file contains 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 <iomanip> | |
#include <algorithm> | |
#include <iterator> | |
#include <vector> | |
#include <functional> | |
#include <cassert> | |
#include <chrono> | |
#include <array> | |
#include <memory> |
This file contains 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 <vector> | |
#include <algorithm> | |
#include <iterator> | |
#include <chrono> | |
#include <random> | |
#include <iostream> | |
#include <functional> | |
std::vector<int> all_equal(std::vector<int>::size_type n) { | |
return std::vector<int>(n, 1000000); |