Skip to content

Commit 8ab61c6

Browse files
authored
Merge pull request #29 from csvistool/extras-row
Add DP & Extras section
2 parents 1775c51 + e2ba41e commit 8ab61c6

2 files changed

Lines changed: 36 additions & 28 deletions

File tree

src/AlgoList.js

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as algos from './algo';
2+
const isAprilFools = new Date().getMonth() === 3 && new Date().getDate() <= 2; // April 1st or 2nd
23

34
// After adding the export in algos/index.js, add new algorithms in the following format:
45
// AlgorithmName: ['Menu Display Name', algos.ClassName, hasPseudoCode, 'Verbose Display Name (optional)', 'Rainbow Color (optional)'],
@@ -10,12 +11,12 @@ export const algoMap = {
1011
'Non-Linear Probing',
1112
true,
1213
],
13-
LVA: ['LVA', algos.LVA, false, 'Landis-Velsky-Adelson Tree', true],
14-
BogoSort: ['Bogo Sort', algos.BogoSort, false, 'Bogo Sort', true],
15-
DropSort: ['Drop Sort', algos.DropSort, false, 'Drop Sort', true],
16-
SleepSort: ['Sleep Sort', algos.SleepSort, false, 'Sleep Sort', true],
17-
MiracleSort: ['Miracle Sort', algos.MiracleSort, false, 'Miracle Sort', true],
18-
FredSort: ['Fred Sort', algos.FredSort, false, 'Fred Sort', true],
14+
LVA: ['LVA', algos.LVA, false, 'Landis-Velsky-Adelson Tree', isAprilFools],
15+
BogoSort: ['Bogo Sort', algos.BogoSort, false, 'Bogo Sort', isAprilFools],
16+
DropSort: ['Drop Sort', algos.DropSort, false, 'Drop Sort', isAprilFools],
17+
SleepSort: ['Sleep Sort', algos.SleepSort, false, 'Sleep Sort', isAprilFools],
18+
MiracleSort: ['Miracle Sort', algos.MiracleSort, false, 'Miracle Sort', isAprilFools],
19+
FredSort: ['Fred Sort', algos.FredSort, false, 'Fred Sort', isAprilFools],
1920
ArrayList: ['ArrayList', algos.ArrayList, true],
2021
LinkedList: ['Singly LinkedList', algos.LinkedList, true],
2122
DoublyLinkedList: ['Doubly LinkedList', algos.DoublyLinkedList, true],
@@ -60,13 +61,7 @@ export const algoMap = {
6061
const aprilFoolsAlgos = [
6162
'LVA',
6263
'NonLinearProbing',
63-
'DropSort',
64-
'SleepSort',
65-
'MiracleSort',
66-
'BogoSort',
67-
'FredSort',
6864
];
69-
const isAprilFools = new Date().getMonth() === 3 && new Date().getDate() <= 2; // April 1st or 2nd
7065
export const algoList = [
7166
...(isAprilFools ? aprilFoolsAlgos : []),
7267
'Lists',
@@ -86,7 +81,6 @@ export const algoList = [
8681
'Heap',
8782
'AVL',
8883
'BTree',
89-
'SplayTree',
9084
'SkipList',
9185
'HashMaps',
9286
'ClosedHash',
@@ -107,15 +101,22 @@ export const algoList = [
107101
'KMP',
108102
'RabinKarp',
109103
'Graph Algorithms',
110-
'CreateGraph',
111104
'BFS',
112105
'DFS',
113106
'Dijkstra',
114107
'Prim',
115108
'Kruskal',
116-
'Dynamic Programming',
117109
'LCS',
110+
'---',
111+
'DP & Extras',
112+
'CreateGraph',
113+
'SplayTree',
118114
'Floyd',
115+
'DropSort',
116+
'SleepSort',
117+
'MiracleSort',
118+
'BogoSort',
119+
'FredSort',
119120
];
120121

121122
export const relatedSearches = {
@@ -244,10 +245,6 @@ export const algoFilter = [
244245
id: 'BTree',
245246
category: 'Trees and SkipList',
246247
},
247-
{
248-
id: 'SplayTree',
249-
category: 'Trees and SkipList',
250-
},
251248
{
252249
id: 'SkipList',
253250
category: 'Trees and SkipList',
@@ -334,26 +331,34 @@ export const algoFilter = [
334331
},
335332
{
336333
id: 'LCS',
337-
category: 'Dynamic Programming',
334+
category: 'DP & Extras',
338335
},
339336
{
340337
id: 'Floyd',
341-
category: 'Dynamic Programming',
338+
category: 'DP & Extras',
339+
},
340+
{
341+
id: 'CreateGraph',
342+
category: 'DP & Extras',
343+
},
344+
{
345+
id: 'SplayTree',
346+
category: 'DP & Extras',
342347
},
343348
{
344349
id: 'FredSort',
345-
category: 'Sorting and Quickselect',
350+
category: 'DP & Extras',
346351
},
347352
{
348353
id: 'SleepSort',
349-
category: 'Sorting and Quickselect',
354+
category: 'DP & Extras',
350355
},
351356
{
352357
id: 'MiracleSort',
353-
category: 'Sorting and Quickselect',
358+
category: 'DP & Extras',
354359
},
355360
{
356361
id: 'DropSort',
357-
category: 'Sorting and Quickselect',
362+
category: 'DP & Extras',
358363
},
359364
];

src/components/HomeScreen/SearchFilter.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { algoMap } from '../../AlgoList';
44

55
const SearchFilter = React.memo(function SearchFilter({ filteredAlgoList }) {
66
return filteredAlgoList.length ? (
7-
filteredAlgoList.map(
8-
(name, idx) =>
7+
filteredAlgoList.map((name, idx) =>
8+
name === '---' ? (
9+
<hr key={`divider-${idx}`} style={{ width: '90%', border: '3px solid #ccc', margin: '10px auto', marginBottom: '2%', marginRight: '2%' }} />
10+
) : (
911
algoMap[name] && (
1012
<Link to={`/${name}`} key={idx} style={{ textDecoration: 'none' }}>
1113
<button
@@ -42,7 +44,8 @@ const SearchFilter = React.memo(function SearchFilter({ filteredAlgoList }) {
4244
</div>
4345
</button>
4446
</Link>
45-
),
47+
)
48+
),
4649
)
4750
) : (
4851
<span className="no-results">No results found. Please try a different search term.</span>

0 commit comments

Comments
 (0)