-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_project.sh
53 lines (45 loc) · 1.56 KB
/
make_project.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
_TARGET=$1
if [ -z $_TARGET ]; then
echo "Usage: $0 <project_name>"
exit 1
fi
if [ -d $_TARGET ]; then
echo "Project $_TARGET already exists"
exit 1
fi
mkdir $_TARGET
cd $_TARGET
cargo new $_TARGET
mv $_TARGET rust
mkdir cpp
touch cpp/main.cpp
echo '
// My essentials that I always include:
#define _HAS_CXX20 1
#if _HAS_CXX20 // NOTE: Though I just need C++17 so I can use std::optional and lamdas, I believe Hackerrank allows UP TO uses C++20
#include <algorithm> // std::sort, std::transform, std::find (std::find - make sure to override operator==)
#include <array>
#include <cassert> // assert()
#include <chrono> // for start/end time measurement
#include <cstdint> // std::uint16_t, etc - I''m too used to rust types...
#include <fstream> // for reading in file
#include <functional> // lambdas!
#include <iostream> // std::cout
#include <memory> // std::shared_ptr, std::make_shared
#include <optional> // a bit different from Rust Option<T> but still, useful!
#include <stack> // commonly used when I need to convert recursive to iterative
#include <string>
#include <tuple>
#include <unordered_map> // use map if need keys to be ordered, but generally, I just need key to be hashed...
#include <unordered_set>
#include <utility> // std::pair, etc
#include <vector>
#else
// fail compiler if C++ version is less than C++20
// but without using static_assert() because it''s not available until C++17
#error This code requires at least C++17
#endif // !_HAS_CXX20 || !_HAS_CXX17
using namespace std;
' > cpp/main.cpp
git add .