[nb] Sync

This commit is contained in:
Aerex 2022-02-20 21:55:27 -06:00
parent f9c2c88398
commit 3551467ef9
17 changed files with 38 additions and 0 deletions
cmd/leetcode
exercises
all-elements-in-two-binary-search-tree/nodejs
dynamic-programming
.index
22-generate-parenthesis
5-longest-palindromic-substring/golang
group-anagrams/nodejs
integer-to-roman/nodejs
permutations/nodejs
pow-x-n/nodejs
rec-permute/nodejs
reverse-integer/nodejs
roman-to-integer/nodejs
string-to-integer-aoi/nodejs
util/js
zig-zag-conversion/nodejs

38
cmd/leetcode/main.go Normal file
View File

@ -0,0 +1,38 @@
// package is like namespace. Every file has one
package main
// HINT: To import just file you can the format import "<package-name">
import (
"github.com/spf13/cobra"
"io/ioutil"
"log"
"fmt"
)
// Like in C/C++/Java there is a main function
func main() {
var listExer = &cobra.Command {
Use: "leetcode",
Short: "list all exercises",
Long: "leetcode ls",
Run: func(cmd *cobra.Command, args []string) {
leet_code_dir := "/home/aerex/.nb/leetcode/exercises"
files, err := ioutil.ReadDir(leet_code_dir)
if err != nil {
log.Fatal(err)
}
for _, file := range files {
fmt.Println(file.Name())
}
},
}
var rootCmd = &cobra.Command{
Use: "leetcode <command>",
}
rootCmd.AddCommand(listExer)
}