Skip to content

Commit ec20793

Browse files
committed
Update generate_template
1 parent 9459dd9 commit ec20793

6 files changed

+95
-7
lines changed

Diff for: .gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* text=auto
2+
*.h text eol=lf
3+
*.cc text eol=lf
4+
*.sh text eol=lf

Diff for: README.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
# LeetCode
22

3-
## 解释
3+
## Solution ideas
44

5-
位于`doc`目录下
5+
Under `doc` directory.
66

7-
## 编译
7+
## Debug
8+
9+
```shell
10+
./leetcode Solution
11+
```
12+
13+
## Generate template
14+
15+
```shell
16+
generate_template Solution
17+
```
18+
19+
## Compile
820

921
```shell
1022
mkdir build
1123
cd build
1224
cmake ..
1325
make
14-
```
26+
```

Diff for: generate_template

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
################################################################################
3+
#
4+
# Copyright (c) 2019 NUAA AeroLab
5+
#
6+
# @author Jiang Yang ([email protected])
7+
# @date 2019-05
8+
# @brief
9+
# @version 0.0.1
10+
#
11+
# Last Modified: 2019-05-21
12+
# Modified By: Jiang Yang ([email protected])
13+
#
14+
################################################################################
15+
set -e
16+
17+
# get scripts directory
18+
CMAKE_SOURCE_DIR=$(dirname $(readlink -f $0))
19+
# update cmake source path
20+
CMAKE_SOURCE_DIR=$(pwd)
21+
cd ${CMAKE_SOURCE_DIR}
22+
23+
if [ ! -n "$1" ]; then
24+
echo "Please input solution."
25+
exit 1
26+
else
27+
SOLUTION=$1
28+
fi
29+
30+
cp -f ${CMAKE_SOURCE_DIR}/src/0.template.cc ${CMAKE_SOURCE_DIR}/src/${SOLUTION}.cc
31+
32+
sed -i "s/isValid/`expr ${SOLUTION}`/g" \
33+
${CMAKE_SOURCE_DIR}/src/${SOLUTION}.cc

Diff for: src/0.template.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
* @brief
99
* @version 0.0.1
1010
*
11-
* Last Modified: 2018-12-21
11+
* Last Modified: 2019-05-21
1212
* Modified By: Jiang Yang ([email protected])
1313
*
1414
*/
1515
#include "headers.h"
1616

1717
class Solution
1818
{
19-
public:
19+
public:
2020
bool isValid(string s)
2121
{
2222
return true;
2323
}
2424
};
2525

26-
TEST(isValid, isValid)
26+
TEST(isValid, isValid_1)
2727
{
2828
Solution s;
2929
EXPECT_TRUE(s.isValid(""));

Diff for: src/computerArae.cc renamed to src/computeArea.cc

File renamed without changes.

Diff for: src/maxSumAfterPartitioning.cc

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
*
3+
* Copyright (c) 2018 NUAA Jiang Yang
4+
*
5+
* @file
6+
* @author Jiang Yang ([email protected])
7+
* @date 2018-11
8+
* @brief
9+
* @version 0.0.1
10+
*
11+
* Last Modified: 2019-05-21
12+
* Modified By: Jiang Yang ([email protected])
13+
*
14+
*/
15+
#include "headers.h"
16+
17+
class Solution
18+
{
19+
public:
20+
int maxSumAfterPartitioning(vector<int> &A, int K)
21+
{
22+
return 0;
23+
}
24+
};
25+
26+
TEST(maxSumAfterPartitioning, maxSumAfterPartitioning)
27+
{
28+
Solution s;
29+
vector<int> v = {1, 15, 7, 9, 2, 5, 10};
30+
int k = 3;
31+
EXPECT_EQ(s.maxSumAfterPartitioning(v, k), 84);
32+
}
33+
34+
int main(int argc, char **argv)
35+
{
36+
::testing::InitGoogleTest(&argc, argv);
37+
38+
return RUN_ALL_TESTS();
39+
}

0 commit comments

Comments
 (0)