Skip to content

Commit

Permalink
Merge pull request #30 from vishalmishraa/29-add-problems-tags
Browse files Browse the repository at this point in the history
29 add problems tags
  • Loading branch information
vishalmishraa authored Aug 10, 2024
2 parents 6cceaab + 94ce76c commit aefdfde
Show file tree
Hide file tree
Showing 18 changed files with 324 additions and 108 deletions.
47 changes: 0 additions & 47 deletions .github/workflows/meshmap.yml

This file was deleted.

105 changes: 105 additions & 0 deletions apps/boilerplate-generator/test/directory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,80 @@ dotenv.config();

const problemsPath: string = process.env.PROBLEMS_DIR_PATH || '';

const tags = [
'ARRAY',
'STRING',
'HASH_TABLE',
'DYNAMIC_PROGRAMMING',
'MATH',
'SORTING',
'GREEDY',
'DEPTH_FIRST_SEARCH',
'DATABASE',
'BINARY_SEARCH',
'BREADTH_FIRST_SEARCH',
'TREE',
'MATRIX',
'BIT_MANIPULATION',
'TWO_POINTERS',
'BINARY_TREE',
'HEAP',
'PREFIX_SUM',
'STACK',
'SIMULATION',
'GRAPH',
'COUNTING',
'DESIGN',
'SLIDING_WINDOW',
'BACKTRACKING',
'ENUMERATION',
'UNION_FIND',
'LINKED_LIST',
'ORDERED_SET',
'MONOTONIC_STACK',
'NUMBER_THEORY',
'TRIE',
'SEGMENT_TREE',
'DIVIDE_AND_CONQUER',
'QUEUE',
'RECURSION',
'BITMASK',
'BINARY_SEARCH_TREE',
'GEOMETRY',
'MEMOIZATION',
'BINARY_INDEXED_TREE',
'HASH_FUNCTION',
'COMBINATORICS',
'TOPOLOGICAL_SORT',
'STRING_MATCHING',
'SHORTEST_PATH',
'ROLLING_HASH',
'GAME_THEORY',
'INTERACTIVE',
'DATA_STREAM',
'BRAINTEASER',
'MONOTONIC_QUEUE',
'RANDOMIZED',
'MERGE_SORT',
'ITERATOR',
'DOUBLY_LINKED_LIST',
'CONCURRENCY',
'PROBABILITY_AND_STATISTICS',
'QUICKSELECT',
'SUFFIX_ARRAY',
'COUNTING_SORT',
'BUCKET_SORT',
'MINIMUM_SPANNING_TREE',
'SHELL',
'LINE_SWEEP',
'RESERVOIR_SAMPLING',
'STRONGLY_CONNECTED_COMPONENT',
'EULERIAN_CIRCUIT',
'RADIX_SORT',
'REJECTION_SAMPLING',
'INCONSISTENT_COMPARISON',
];

// check if problem directory exist or not
describe('Problem folder exist', () => {
it('should have problems folder', () => {
Expand Down Expand Up @@ -61,6 +135,37 @@ describe('Problem folder exist', () => {
});
})
});

fs.readdirSync(problemsPath).filter(file => {
it(`${file} should have tags.md file`, () => {
const problemFolderPath = path.join(problemsPath, file);
const tagsPath = path.join(problemFolderPath, 'tags.md');
expect(fs.existsSync(tagsPath)).toBe(true);
});
});

fs.readdirSync(problemsPath).filter(file => {
it(`${file} tags should belong to predefined tags`, () => {
const problemFolderPath = path.join(problemsPath, file);
const tagsPath = path.join(problemFolderPath, 'tags.md');
const tagsContent = fs.readFileSync(tagsPath, 'utf8');
const fetchedTags = tagsContent.split('\n').map(tag => tag.trim());
fetchedTags.forEach(tag => {
expect(tags.includes(tag)).toBe(true);
});
});
//there should be no empty spaces && one line should have only one word which is predefined
it(`${file} tags should not have empty spaces`, () => {
const problemFolderPath = path.join(problemsPath, file);
const tagsPath = path.join(problemFolderPath, 'tags.md');
const tagsContent = fs.readFileSync(tagsPath, 'utf8');
const fetchedTags = tagsContent.split('\n').map(tag => tag.trim());
fetchedTags.forEach(tag => {
expect(tag).not.toBe('');
});
});
});

});


3 changes: 3 additions & 0 deletions apps/problems/Broken-SubArray/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARRAY
STRING
HASH_TABLE
2 changes: 2 additions & 0 deletions apps/problems/Calculate-Fibonacci/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ARRAY
GREEDY
5 changes: 5 additions & 0 deletions apps/problems/Check-Palindrome/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARRAY
STRING
MATH
SORTING
GREEDY
3 changes: 3 additions & 0 deletions apps/problems/Find-Median/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARRAY
STRING
GREEDY
7 changes: 7 additions & 0 deletions apps/problems/Find-Prime-Numbers/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARRAY
STRING
HASH_TABLE
DYNAMIC_PROGRAMMING
MATH
SORTING
GREEDY
5 changes: 5 additions & 0 deletions apps/problems/Intersting-Arrays/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARRAY
STRING
HASH_TABLE
SORTING
GREEDY
5 changes: 5 additions & 0 deletions apps/problems/Kth-Smallest/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARRAY
STRING
MATH
SORTING
GREEDY
5 changes: 5 additions & 0 deletions apps/problems/Matrix-Paths/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARRAY
STRING
HASH_TABLE
DYNAMIC_PROGRAMMING
MATH
5 changes: 5 additions & 0 deletions apps/problems/Max-Element/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ARRAY
DYNAMIC_PROGRAMMING
MATH
SORTING
GREEDY
7 changes: 7 additions & 0 deletions apps/problems/Merge-Sorted-Arrays/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARRAY
STRING
HASH_TABLE
DYNAMIC_PROGRAMMING
MATH
SORTING
GREEDY
7 changes: 7 additions & 0 deletions apps/problems/Reverse-String/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARRAY
STRING
HASH_TABLE
DYNAMIC_PROGRAMMING
MATH
SORTING
GREEDY
7 changes: 7 additions & 0 deletions apps/problems/Software-Dev/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARRAY
STRING
HASH_TABLE
DYNAMIC_PROGRAMMING
MATH
SORTING
GREEDY
7 changes: 7 additions & 0 deletions apps/problems/Sort-Array/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARRAY
STRING
HASH_TABLE
DYNAMIC_PROGRAMMING
MATH
SORTING
GREEDY
4 changes: 4 additions & 0 deletions apps/problems/Two-Sum/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ARRAY
MATH
SORTING
GREEDY
7 changes: 7 additions & 0 deletions packages/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ model Problem {
contests ContestProblem[]
submissions Submission[]
defaultCode DefaultCode[]
tags Tag[]
}

model Tag {
id String @id @default(cuid())
name String @unique
problems Problem[]
}

model DefaultCode {
Expand Down
Loading

0 comments on commit aefdfde

Please sign in to comment.