From ab3161ba9c74e7c940a6b1682a394b1535e82134 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 13:45:15 +0530 Subject: [PATCH 01/14] chore: remove commented code --- .../doubly_linkedlist/doublylinkedlist.go | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/data_structures/linkedlist/doubly_linkedlist/doublylinkedlist.go b/data_structures/linkedlist/doubly_linkedlist/doublylinkedlist.go index 7df7abcef..71bb49699 100644 --- a/data_structures/linkedlist/doubly_linkedlist/doublylinkedlist.go +++ b/data_structures/linkedlist/doubly_linkedlist/doublylinkedlist.go @@ -141,28 +141,3 @@ func (ll *DoubleLinkedList) DisplayReverse() { fmt.Print("\n") } - -/* -func main() { - ll := DoubleLinkedList{} - - ll.addAtBeg(10) - ll.addAtEnd(20) - ll.display() - ll.addAtBeg(30) - ll.display() - - ll.reverse() - ll.display() - ll.displayReverse() - - fmt.Print(ll.delAtBeg(), "\n") - fmt.Print(ll.delAtEnd(), "\n") - fmt.Print("Display") - ll.display() - fmt.Print(ll.delAtBeg(), "\n") - ll.display() - fmt.Print(ll.delAtBeg(), "\n") - ll.display() -} -*/ From a9427e513288a0cc6d54f9e6849519f3bad2a040 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 13:45:56 +0530 Subject: [PATCH 02/14] chore: remove commented file --- .../singly_linkedlist/singly_linkedlist2.go | 104 ------------------ 1 file changed, 104 deletions(-) delete mode 100644 data_structures/linkedlist/singly_linkedlist/singly_linkedlist2.go diff --git a/data_structures/linkedlist/singly_linkedlist/singly_linkedlist2.go b/data_structures/linkedlist/singly_linkedlist/singly_linkedlist2.go deleted file mode 100644 index fb14fa7b8..000000000 --- a/data_structures/linkedlist/singly_linkedlist/singly_linkedlist2.go +++ /dev/null @@ -1,104 +0,0 @@ -package singly_linkedlist - -// TODO not needed because there is already an implementation of SingleLinkedList - -// import "fmt" - -// /* v is the value of node; next is the pointer to next node */ -// type node struct { -// v int -// next *node -// } - -// /* first node, called head. It points from first node to last node */ -// var head *node = nil - -// func (l *node) pushFront(val int) *node { -// /* if there's no nodes, head points to l (first node) */ -// if head == nil { -// l.v = val -// l.next = nil -// head = l -// return l -// } else { -// /* create a new node equals to head */ -// nnode := new(node) -// nnode = head -// /* create a second node with new value and `next -> nnode` -// * is this way, nnode2 is before nnode -// */ -// nnode2 := &node{ -// v: val, -// next: nnode, -// } -// /* now head is equals nnode2 */ -// head = nnode2 -// return head -// } -// } - -// func (l *node) pushBack(val int) *node { -// /* if there's no nodes, head points to l (first node) */ -// if head == nil { -// l.v = val -// l.next = nil -// head = l -// return l -// } else { -// /* read all list to last node */ -// for l.next != nil { -// l = l.next -// } -// /* allocate a new portion of memory */ -// l.next = new(node) -// l.next.v = val -// l.next.next = nil -// return l -// } -// } - -// func (l *node) popFront() *node { -// if head == nil { -// return head -// } -// /* create a new node equals to first node pointed by head */ -// cpnode := new(node) -// cpnode = head.next - -// /* now head is equals cpnode (second node) */ -// head = cpnode - -// return head -// } - -// func (l *node) popBack() *node { -// if head == nil { -// return head -// } -// /* create a new node equals to head */ -// cpnode := new(node) -// cpnode = head - -// /* read list to the penultimate node */ -// for cpnode.next.next != nil { -// cpnode = cpnode.next -// } -// /* the penultimate node points to null. In this way the last node is deleted */ -// cpnode.next = nil -// return head -// } - -// func main() { -// lista := new(node) -// lista.pushBack(25).pushBack(24).pushBack(32) /* lista: 25 24 32 */ -// lista.pushBack(56) /* lista: 25 24 32 56 */ -// lista.pushFront(36) /* lista: 36 25 24 32 56 */ -// lista.popFront() /* lista: 25 24 32 56 */ -// lista.popBack() /* lista: 25 24 32 */ - -// /* read the list until head is not nil */ -// for head != nil { -// fmt.Printf("%d ", head.v) -// head = head.next /*head points to next node */ -// } -// } From 3977bbc0fafda1f7b291cd57f8d1dc1e627c33a2 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 13:48:29 +0530 Subject: [PATCH 03/14] chore: remove commented code --- dynamic_programming/binomialcoefficient.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/dynamic_programming/binomialcoefficient.go b/dynamic_programming/binomialcoefficient.go index 56682eab6..8bf34df66 100644 --- a/dynamic_programming/binomialcoefficient.go +++ b/dynamic_programming/binomialcoefficient.go @@ -1,20 +1,5 @@ package dynamic_programming -// func main() { -// myArrayOfK := [4]int{5, 6, 7, 8} -// var x int - -// fmt.Println("\nBinomial Coefficient Using Dynamic Programming:", bin2(50, 5)) -// for _, element := range myArrayOfK { -// start := time.Now() -// x = bin2(50, element) -// elapsed := time.Since(start) -// fmt.Println("bin2 (50,", element, ") = ", x, " took ", elapsed) - -// } - -// } - // Bin2 function func Bin2(n int, k int) int { var i, j int From 2638d80049161f44d5937e79eac052095db10a09 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 13:49:06 +0530 Subject: [PATCH 04/14] chore: remove commented code --- dynamic_programming/knapsack.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/dynamic_programming/knapsack.go b/dynamic_programming/knapsack.go index 7ccd64b02..fd2f868fe 100644 --- a/dynamic_programming/knapsack.go +++ b/dynamic_programming/knapsack.go @@ -33,17 +33,3 @@ func Solve(maxWeight int, weights, values []int) int { } return dp[n][m] } - -/* -func main() { - maxWeight := 50 - values := []int{ - 60, 100, 120, - } - weights := []int{ - 10, 20, 30, - } - maxProfit := solve(maxWeight, weights, values) - fmt.Println(maxProfit) -} -*/ From 509589606c8ef5923e83b0aefe84be1889faef8f Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 13:49:37 +0530 Subject: [PATCH 05/14] chore: remove commented code --- dynamic_programming/longestcommonsubsequence.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/dynamic_programming/longestcommonsubsequence.go b/dynamic_programming/longestcommonsubsequence.go index e251b57ad..f6be5ec1b 100644 --- a/dynamic_programming/longestcommonsubsequence.go +++ b/dynamic_programming/longestcommonsubsequence.go @@ -29,12 +29,3 @@ func LongestCommonSubsequence(a string, b string, m int, n int) int { // returning the length of longest common subsequence return lcs[m][n] } - -// func main(){ -// // declaring two strings and asking for input - -// var a,b string -// fmt.Scan(&a, &b) -// // calling the LCS function -// fmt.Println("The length of longest common subsequence is:", longestCommonSubsequence(a,b, len(a), len(b))) -// } From 8b50fdfaca28ef6a7365cabc88c550066b4e3a43 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 13:50:01 +0530 Subject: [PATCH 06/14] chore: remove commented code --- dynamic_programming/longestpalindromicsubsequence.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/dynamic_programming/longestpalindromicsubsequence.go b/dynamic_programming/longestpalindromicsubsequence.go index da783d7f7..867f3df00 100644 --- a/dynamic_programming/longestpalindromicsubsequence.go +++ b/dynamic_programming/longestpalindromicsubsequence.go @@ -45,12 +45,3 @@ func LpsDp(word string) int { return dp[1][N-1] } - -/* -func main() { - // word := "aaabbbbababbabbabbabf" - word := "aaaabbbba" - fmt.Printf("%d\n", lpsRec(word, 0, len(word)-1)) - fmt.Printf("%d\n", lpsDp(word)) -} -*/ From 2d50116e963983900d375a1d9822592dda5698ec Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 13:50:20 +0530 Subject: [PATCH 07/14] chore: remove commented code --- dynamic_programming/matrixmultiplication.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/dynamic_programming/matrixmultiplication.go b/dynamic_programming/matrixmultiplication.go index ff73b1762..84cbae93b 100644 --- a/dynamic_programming/matrixmultiplication.go +++ b/dynamic_programming/matrixmultiplication.go @@ -43,11 +43,3 @@ func MatrixChainDp(D []int) int { return dp[1][N-1] } - -/* -func main() { - D := []int{2, 2, 2, 2, 2} // 4 matrices - fmt.Print(matrixChainRec(D, 1, 4), "\n") - fmt.Print(matrixChainDp(D), "\n") -} -*/ From 12a2fccb848be598ef6756a0bf13273b7f8e51ae Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 13:50:42 +0530 Subject: [PATCH 08/14] chore: remove commented code --- dynamic_programming/rodcutting.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/dynamic_programming/rodcutting.go b/dynamic_programming/rodcutting.go index 733798a39..7950e5793 100644 --- a/dynamic_programming/rodcutting.go +++ b/dynamic_programming/rodcutting.go @@ -32,16 +32,3 @@ func CutRodDp(price []int, length int) int { return r[length] } - -/* -func main() { - length := 10 - price := []int{0, 1, 5, 8, 9, 17, 17, 17, 20, 24, 30} - // price := []int{0, 10, 5, 8, 9, 17, 17, 17, 20, 24, 30} - - // fmt.Print(price[5]+price[length-5], "\n") - - fmt.Print(cutRodRec(price, length), "\n") - fmt.Print(cutRodDp(price, length), "\n") -} -*/ From 8a09d6b51f7c84a1fc37049cad5ef50661887ef8 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 14:20:05 +0530 Subject: [PATCH 09/14] chore: remove commented code --- graphs/depth_first_search/depthfirstsearch.go | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/graphs/depth_first_search/depthfirstsearch.go b/graphs/depth_first_search/depthfirstsearch.go index 07648e17c..c1e1ca66d 100644 --- a/graphs/depth_first_search/depthfirstsearch.go +++ b/graphs/depth_first_search/depthfirstsearch.go @@ -44,27 +44,3 @@ func Dfs(start, end int, nodes []int, edges [][]bool) ([]int, bool) { } return nil, false } - -// func main() { -// nodes := []int{ -// 1, 2, 3, 4, 5, 6, -// } -// /* -// sample graph -// ①-② -// | | -// ③-④-⑤-⑥ -// */ -// edges := [][]bool{ -// {false, true, true, false, false, false}, -// {true, false, false, true, false, false}, -// {true, false, false, true, false, false}, -// {false, true, true, false, true, false}, -// {false, false, false, true, false, true}, -// {false, false, false, false, true, false}, -// } -// start := 1 -// end := 6 -// route, _ := dfs(start, end, nodes, edges) -// fmt.Println(route) -// } From a7bab4a6f3e66159da60a6fb11794100bf9c6016 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 14:20:29 +0530 Subject: [PATCH 10/14] Update floydwarshall.go --- graphs/floyd_warshall/floydwarshall.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/graphs/floyd_warshall/floydwarshall.go b/graphs/floyd_warshall/floydwarshall.go index 0a9f7e7a4..bfc6a32a4 100644 --- a/graphs/floyd_warshall/floydwarshall.go +++ b/graphs/floyd_warshall/floydwarshall.go @@ -42,18 +42,3 @@ func FloydWarshall(graph Matrix) Matrix { return result } - -// func main() { -// var graph Matrix -// graph = Matrix{{0, maxValue, -2, maxValue}, -// {4, 0, 3, maxValue}, -// {maxValue, maxValue, 0, 2}, -// {maxValue, -1, maxValue, 0}} - -// result := FloydWarshall(graph) - -// //Print result -// for i := 0; i < len(result); i++ { -// fmt.Printf("%4g\n", result[i]) -// } -// } From 5047420d71ac68b9643b1fc1c74b4aa04646e118 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 14:26:45 +0530 Subject: [PATCH 11/14] chore: remove commented code --- other/max_subarray_sum/maxsubarraysum.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/other/max_subarray_sum/maxsubarraysum.go b/other/max_subarray_sum/maxsubarraysum.go index 9101c4e6e..76e375638 100644 --- a/other/max_subarray_sum/maxsubarraysum.go +++ b/other/max_subarray_sum/maxsubarraysum.go @@ -21,8 +21,3 @@ func MaxSubarraySum(array []int) int { } return maxTillNow } - -// func main() { -// array := []int{-2, -5, 6, 0, -2, 0, -3, 1, 0, 5, -6} -// fmt.Println("Maximum contiguous sum: ", maxSubarraySum(array)) -// } From c16f37456e1b577b715562cc1244f246ba51adc7 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 14:28:33 +0530 Subject: [PATCH 12/14] chore: remove commented code --- other/password_generator/passwordgenerator.go | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/other/password_generator/passwordgenerator.go b/other/password_generator/passwordgenerator.go index f795c16a1..24798b724 100644 --- a/other/password_generator/passwordgenerator.go +++ b/other/password_generator/passwordgenerator.go @@ -37,17 +37,3 @@ func GeneratePassword(minLength int, maxLength int) string { } } } - -// func main() { -// rand.Seed(time.Now().Unix()) - -// fmt.Print("Please specify a minimum length: ") -// var minLength int -// fmt.Scanf("%d", &minLength) - -// fmt.Print("Please specify a maximum length: ") -// var maxLength int -// fmt.Scanf("%d", &maxLength) - -// fmt.Printf("Your generated password is %v\n", generatePassword(minLength, maxLength)) -// } From 2908a2a632cc54c96d76749b9930f9515bb52926 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 14:30:26 +0530 Subject: [PATCH 13/14] chore: remove commented code --- sort/heapsort.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sort/heapsort.go b/sort/heapsort.go index 698c7610f..dbb838810 100644 --- a/sort/heapsort.go +++ b/sort/heapsort.go @@ -23,7 +23,6 @@ func (h maxHeap) MaxHeapify(i int) { if r < h.size() && h.slice[r] > h.slice[max] { max = r } - //log.Printf("MaxHeapify(%v): l,r=%v,%v; max=%v\t%v\n", i, l, r, max, h.slice) if max != i { h.slice[i], h.slice[max] = h.slice[max], h.slice[i] h.MaxHeapify(max) @@ -34,17 +33,10 @@ func (h maxHeap) size() int { return h.heapSize } // ??? func HeapSort(slice []int) []int { h := buildMaxHeap(slice) - //log.Println(slice) for i := len(h.slice) - 1; i >= 1; i-- { h.slice[0], h.slice[i] = h.slice[i], h.slice[0] h.heapSize-- h.MaxHeapify(0) - /*if i == len(h.slice)-1 || i == len(h.slice)-3 || i == len(h.slice)-5 { - element := (i - len(h.slice)) * -1 - fmt.Println("Heap after removing ", element, " elements") - fmt.Println(h.slice) - - }*/ } return h.slice } From e9245a6961c424c91af1003f166b1631052973a0 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Sun, 5 Sep 2021 14:41:43 +0530 Subject: [PATCH 14/14] chore: fix directories --- .../cyclicallylinkedlist/Linked_Cyclic_List.jpg | Bin .../cyclicallylinkedlist/Readme.md | 0 .../cyclicallylinkedlist/cyclicallylinkedlist.go | 0 .../cyclicallylinkedlist_test.go | 0 .../genetic_algorithm}/geneticalgorithm.go | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {datastructures/linkedlist => data_structures}/cyclicallylinkedlist/Linked_Cyclic_List.jpg (100%) rename {datastructures/linkedlist => data_structures}/cyclicallylinkedlist/Readme.md (100%) rename {datastructures/linkedlist => data_structures}/cyclicallylinkedlist/cyclicallylinkedlist.go (100%) rename {datastructures/linkedlist => data_structures}/cyclicallylinkedlist/cyclicallylinkedlist_test.go (100%) rename {genetic_algorithm => other/genetic_algorithm}/geneticalgorithm.go (100%) diff --git a/datastructures/linkedlist/cyclicallylinkedlist/Linked_Cyclic_List.jpg b/data_structures/cyclicallylinkedlist/Linked_Cyclic_List.jpg similarity index 100% rename from datastructures/linkedlist/cyclicallylinkedlist/Linked_Cyclic_List.jpg rename to data_structures/cyclicallylinkedlist/Linked_Cyclic_List.jpg diff --git a/datastructures/linkedlist/cyclicallylinkedlist/Readme.md b/data_structures/cyclicallylinkedlist/Readme.md similarity index 100% rename from datastructures/linkedlist/cyclicallylinkedlist/Readme.md rename to data_structures/cyclicallylinkedlist/Readme.md diff --git a/datastructures/linkedlist/cyclicallylinkedlist/cyclicallylinkedlist.go b/data_structures/cyclicallylinkedlist/cyclicallylinkedlist.go similarity index 100% rename from datastructures/linkedlist/cyclicallylinkedlist/cyclicallylinkedlist.go rename to data_structures/cyclicallylinkedlist/cyclicallylinkedlist.go diff --git a/datastructures/linkedlist/cyclicallylinkedlist/cyclicallylinkedlist_test.go b/data_structures/cyclicallylinkedlist/cyclicallylinkedlist_test.go similarity index 100% rename from datastructures/linkedlist/cyclicallylinkedlist/cyclicallylinkedlist_test.go rename to data_structures/cyclicallylinkedlist/cyclicallylinkedlist_test.go diff --git a/genetic_algorithm/geneticalgorithm.go b/other/genetic_algorithm/geneticalgorithm.go similarity index 100% rename from genetic_algorithm/geneticalgorithm.go rename to other/genetic_algorithm/geneticalgorithm.go