Skip to content

Commit f2b7889

Browse files
committed
Automate of generation and formatting README file
1 parent 6d55179 commit f2b7889

File tree

476 files changed

+600
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

476 files changed

+600
-33
lines changed

.DS_Store

0 Bytes
Binary file not shown.

README.md

Lines changed: 475 additions & 3 deletions

readme-generator.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <cstdio>
2+
#include <fstream>
3+
#include <string>
4+
#include <cstring>
5+
#include <cassert>
6+
#include <dirent.h>
7+
using namespace std;
8+
9+
int main(void) {
10+
freopen("../README.md", "w", stdout);
11+
puts("## Solutions to LeetCode Programming Problems\n\n");
12+
DIR *dir;
13+
char *directoryPath = "/Users/kaidul/Documents/LeetCode_problems_solution/source-code/";
14+
struct dirent *ent;
15+
if ((dir = opendir (directoryPath)) != NULL) {
16+
while ((ent = readdir (dir)) != NULL) {
17+
int n = strlen(ent->d_name);
18+
if(n < 4) {
19+
continue;
20+
}
21+
char filename[260];
22+
for(int i = 0; i < n; ++i) {
23+
if(ent->d_name[i] == '_')
24+
filename[i] = ' ';
25+
else filename[i] = ent->d_name[i];
26+
}
27+
filename[strlen(ent->d_name)] = '\0';
28+
string sFileName = string(filename);
29+
int dot = sFileName.find('.');
30+
assert(dot != string::npos);
31+
sFileName = sFileName.substr(0, dot);
32+
printf("+ [%s](source-code/%s)\n", sFileName.c_str(), ent->d_name);
33+
// int result = rename(ent->d_name, filename);
34+
// if(result == 0) puts ( "File successfully renamed" );
35+
// else perror( "Error renaming file" );
36+
// printf ("%s, %s\n", ent->d_name, filename); // foo bar, foo_bar
37+
}
38+
closedir (dir);
39+
} else {
40+
/* could not open directory */
41+
perror ("");
42+
return EXIT_FAILURE;
43+
}
44+
return 0;
45+
}

rename_file.cpp

Lines changed: 0 additions & 30 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

source-code/Arithmetic_Slices.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
class Solution {
2+
public:
3+
/*
4+
int numberOfArithmeticSlices(vector<int>& arr) {
5+
int n = arr.size();
6+
if(n == 0) return 0;
7+
vector<int> interval(n - 1);
8+
for(int i = 0; i < n - 1; ++i) {
9+
interval[i] = arr[i + 1] - arr[i];
10+
}
11+
int result = 0;
12+
for(int i = 0; i < n - 1; ++i) {
13+
int len = 1;
14+
while(i + 1 < n - 1 and interval[i] == interval[i + 1]) {
15+
++i;
16+
len++;
17+
}
18+
int elem = len + 1;
19+
result += ((elem - 2) * (elem - 1)) / 2;
20+
}
21+
return result;
22+
}
23+
*/
24+
int numberOfArithmeticSlices(vector<int>& arr) {
25+
int n = arr.size();
26+
if(n < 3) return 0;
27+
vector<int> dp(n, 0);
28+
if(arr[2] - arr[1] == arr[1] - arr[0]) {
29+
dp[2] = 1;
30+
}
31+
int result = dp[2];
32+
for(int i = 3; i < n; ++i) {
33+
if(arr[i] - arr[i - 1] == arr[i - 1] - arr[i - 2]) {
34+
dp[i] = dp[i - 1] + 1;
35+
}
36+
result += dp[i];
37+
}
38+
return result;
39+
}
40+
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)