From ff22ef62fadfb1867e499a292ff045ba0708a4a4 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 12:30:24 +0530 Subject: [PATCH 01/17] initial --- Submissions/noname/task5 | 1 + 1 file changed, 1 insertion(+) create mode 100644 Submissions/noname/task5 diff --git a/Submissions/noname/task5 b/Submissions/noname/task5 new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Submissions/noname/task5 @@ -0,0 +1 @@ + From 5d4c41bdc24f878cd6acd949fdade90ada3f2721 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 12:37:52 +0530 Subject: [PATCH 02/17] Create task1 --- Submissions/noname/task1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 Submissions/noname/task1 diff --git a/Submissions/noname/task1 b/Submissions/noname/task1 new file mode 100644 index 0000000..cf5aca3 --- /dev/null +++ b/Submissions/noname/task1 @@ -0,0 +1 @@ +package main import ( "fmt" ) func main() { fmt.Println("Hello, playground") } From a3436b3c24e9fe521af5f946b1e4246b530626f9 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 13:22:10 +0530 Subject: [PATCH 03/17] task2 --- Submissions/noname/task2 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Submissions/noname/task2 diff --git a/Submissions/noname/task2 b/Submissions/noname/task2 new file mode 100644 index 0000000..2a6ee90 --- /dev/null +++ b/Submissions/noname/task2 @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "strconv" +) +func thr(b []int,x int){ + + for i:=0;i<5;i++ { + x = x + b[i] + } + fmt.Println("The sum is - ",x) + +} + +func main() { +var b []int +x:=0 +fmt.Println("-- Enter 5 numbers --") +for i := 1;i<6;i++ { + fmt.Println("Enter ",i,"number :") + var input string + fmt.Scanln(&input) + in,_:= strconv.Atoi(input) + b=append(b,in) +} +go thr(b,x) +fmt.Println("Thread Started") +fmt.Scanln() +} From 03aade63852448ce5fb1af8f2e5e856b03d75078 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 13:51:06 +0530 Subject: [PATCH 04/17] tast3_noname --- Submissions/noname/task3 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Submissions/noname/task3 diff --git a/Submissions/noname/task3 b/Submissions/noname/task3 new file mode 100644 index 0000000..174a27d --- /dev/null +++ b/Submissions/noname/task3 @@ -0,0 +1,29 @@ +package main + +import ( + "io" + "net/http" + "fmt" + ) +func resp(a http.ResponseWriter, b *http.Request){ + io.WriteString(a,"

Welcome

") + } +func resp_2(a http.ResponseWriter, b *http.Request){ + io.WriteString(a,"

Welcome to home page

") + } +func thr(){ + http.HandleFunc("/",resp) + http.ListenAndServe(":8000",nil) + } +func thr_2(){ + http.HandleFunc("/home",resp_2) + http.ListenAndServe(":8000",nil) + } +func main(){ + + go thr() + go thr_2() + fmt.Scanln() + + +} From 5bfbeafc65a7317bcad572a24c2f486c839565bd Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 13:51:52 +0530 Subject: [PATCH 05/17] Update task3 --- Submissions/noname/task3 | 1 + 1 file changed, 1 insertion(+) diff --git a/Submissions/noname/task3 b/Submissions/noname/task3 index 174a27d..7c0aa97 100644 --- a/Submissions/noname/task3 +++ b/Submissions/noname/task3 @@ -23,6 +23,7 @@ func main(){ go thr() go thr_2() + fmt.Println("Press to exit..") fmt.Scanln() From 60ca566844f0336904012d31463269026e17cce1 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 14:00:36 +0530 Subject: [PATCH 06/17] Update task1 --- Submissions/noname/task1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Submissions/noname/task1 b/Submissions/noname/task1 index cf5aca3..489f159 100644 --- a/Submissions/noname/task1 +++ b/Submissions/noname/task1 @@ -1 +1,6 @@ -package main import ( "fmt" ) func main() { fmt.Println("Hello, playground") } +package main +import ( "fmt" ) +func main() { +fmt.Println("Hello World !") +fmt.Scanln("Press to exit") +} From adb657e74a7501fdba212c77fae317ba59220206 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 14:04:28 +0530 Subject: [PATCH 07/17] Update task1 --- Submissions/noname/task1 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Submissions/noname/task1 b/Submissions/noname/task1 index 489f159..fbd3c2e 100644 --- a/Submissions/noname/task1 +++ b/Submissions/noname/task1 @@ -1,6 +1,19 @@ +//denotes main package in which go runs package main + +//import libraries here import ( "fmt" ) + +//main function executes first func main() { + +//Println(input) <- input displays on cmd screen fmt.Println("Hello World !") -fmt.Scanln("Press to exit") + +//Println(input) <-input displays on cmd screen +//[INFO] +fmt.Println("Press to exit") + +//Scanln() <- Waits for raw enter [ Halts the output screen ] +fmt.Scanln() } From 80841a8cc21a15717a9b1dbe3f3aaa1a156210c7 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 14:13:15 +0530 Subject: [PATCH 08/17] Update task2 --- Submissions/noname/task2 | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Submissions/noname/task2 b/Submissions/noname/task2 index 2a6ee90..327b33c 100644 --- a/Submissions/noname/task2 +++ b/Submissions/noname/task2 @@ -1,22 +1,41 @@ +//denotes package main package main +//imports necessary libraries +//fmt -> fast alternative IO operations +//strconv -> numeric convertions from string to int import ( "fmt" "strconv" ) -func thr(b []int,x int){ - for i:=0;i<5;i++ { +//function named thr +//INPUTS <- integer array named b , integer named x +//acts as thread handler +//outputs the sum of 5 integer inputs +func thr(b []int,x int){ +//for loop implementation to loop 5 times in a row + for i:=0;i<5;i++ + { x = x + b[i] } + //prints sum in o/p stream fmt.Println("The sum is - ",x) } +//main function - program entry point +//variables in scope +////-integer array - b +////-integer - x func main() { var b []int x:=0 + +//info update in print fmt.Println("-- Enter 5 numbers --") +//This logic loops for 5 turns , fetches input as string from standare input stream, +//converts string to integer and appends to a slice(a list) for i := 1;i<6;i++ { fmt.Println("Enter ",i,"number :") var input string @@ -24,7 +43,10 @@ for i := 1;i<6;i++ { in,_:= strconv.Atoi(input) b=append(b,in) } +//starts a go threaded subroutine to perform addtion process in background go thr(b,x) +//info update fmt.Println("Thread Started") +//halts output screen to exit fmt.Scanln() } From 1be20fee04a3bc276777768e2b9f7fd397af0866 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 14:21:04 +0530 Subject: [PATCH 09/17] Update task3 --- Submissions/noname/task3 | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/Submissions/noname/task3 b/Submissions/noname/task3 index 7c0aa97..5392d6e 100644 --- a/Submissions/noname/task3 +++ b/Submissions/noname/task3 @@ -1,30 +1,53 @@ -package main +//MADE BY M.BENHUR +//phone : +91-9843184815 +//email : benhurrodriguez98@gmail.com +//refers main package to work on +package main +//import necessary libraries here import ( +//io <- basic IO primitives "io" +//net/http <- http client and server implementations "net/http" +//standard I/O routines "fmt" ) + +//callback function +//input http response w.r.t client , request socket pathway func resp(a http.ResponseWriter, b *http.Request){ io.WriteString(a,"

Welcome

") } + +//callback function +//input http response w.r.t client , request socket pathway func resp_2(a http.ResponseWriter, b *http.Request){ io.WriteString(a,"

Welcome to home page

") } + +//function thread for {/} path +//waits for connection at port 8000 func thr(){ - http.HandleFunc("/",resp) + http.HandleFunc("/",resp) http.ListenAndServe(":8000",nil) } + +//function thread for {/home} path +//waits for connection at port 8000 func thr_2(){ - http.HandleFunc("/home",resp_2) + http.HandleFunc("/home",resp_2) http.ListenAndServe(":8000",nil) } + +//main function - go program entry point func main(){ - + //start go subroutine in path "/" go thr() + //start go subroutine in path "/home" go thr_2() + //info update fmt.Println("Press to exit..") - fmt.Scanln() - - + //halts output screen + fmt.Scanln() } From 7e9538e8438566f4a7247d22c22747a2fd86a476 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 14:21:48 +0530 Subject: [PATCH 10/17] Update task2 --- Submissions/noname/task2 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Submissions/noname/task2 b/Submissions/noname/task2 index 327b33c..376e059 100644 --- a/Submissions/noname/task2 +++ b/Submissions/noname/task2 @@ -1,3 +1,7 @@ +//MADE BY M.BENHUR +//phone : +91-9843184815 +//email : benhurrodriguez98@gmail.com + //denotes package main package main From 6197355ceefc8130663c0b47c9179651b58e5ed0 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 14:22:07 +0530 Subject: [PATCH 11/17] Update task1 --- Submissions/noname/task1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Submissions/noname/task1 b/Submissions/noname/task1 index fbd3c2e..659be7a 100644 --- a/Submissions/noname/task1 +++ b/Submissions/noname/task1 @@ -1,3 +1,7 @@ +//MADE BY M.BENHUR +//phone : +91-9843184815 +//email : benhurrodriguez98@gmail.com + //denotes main package in which go runs package main From 2492e781ae0d35ebafc17b53d6ccfd01db6a47b6 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 18:01:55 +0530 Subject: [PATCH 12/17] Create task4 --- Submissions/noname/task4 | 81 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Submissions/noname/task4 diff --git a/Submissions/noname/task4 b/Submissions/noname/task4 new file mode 100644 index 0000000..3046b48 --- /dev/null +++ b/Submissions/noname/task4 @@ -0,0 +1,81 @@ +//MADE BY M.BENHUR +//phone : +91-9843184815 +//email : benhurrodriguez98@gmail.com + +//main package definition +package main + +//importing libraries +//fmt <- [Standard I/O routines] +//strings <- [in-built string manipulation functions] +import ( + "fmt" + "strings" + ) + +//check_heading(input) - input <- string of input/line in text to parse and check +////output - returns identifier string +func check_heading(m string) string{ + + //method to check Heading 1 + if strings.HasPrefix(m,"#") { + return "H1" + } + //method to check Heading 2 + if strings.HasPrefix(m,"##"){ + return "H2" + } + //method to check bold faced + if strings.HasPrefix(m,"**"){ + if strings.HasSuffix(m,"**"){ + return "BOLD" + } + } + return "NONE" + } +func chkk(check string){ + if check == "H1" { + fmt.Println("Found Heading H1") + } + + if check == "H2" { + fmt.Println("Found Heading H2") + } + + if check == "BOLD" { + fmt.Println("Found BOLD faced string") + } + if check == "NONE" { + fmt.Println("NONE found..") + } + } + +//main function - ENTRY point of go +func main(){ + //string variable declarations for local working + var x,parser_string,parser_string_2,parser_string_3 string + + //sample input data for H1 + parser_string ="# Heading1" + + //sample input data for H2 + parser_string_2 ="## Heading2" + + //sample input data for bold + parser_string_3 = "**bold_font**" + + //Function call and making output - [START] + x = check_heading(parser_string) + chkk(x) + + x = check_heading(parser_string_2) + chkk(x) + + x = check_heading(parser_string_3) + chkk(x) + // - [END] + + //halts output screen + fmt.Scanln() + + } From 5e265ed00a40d0eb9febaa2cfc8597cee174c1ed Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 19:12:26 +0530 Subject: [PATCH 13/17] Update task5 --- Submissions/noname/task5 | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Submissions/noname/task5 b/Submissions/noname/task5 index 8b13789..1d4ad9c 100644 --- a/Submissions/noname/task5 +++ b/Submissions/noname/task5 @@ -1 +1,49 @@ +//MADE BY M.BENHUR +//phone : +91-9843184815 +//email : benhurrodriguez98@gmail.com +//main package definition +package main + +//importing libraries +//fmt <- [Standard I/O routines] +//net/http <- making http request and responses +//io/ioutil <- simple I/O utility functions +import ( + "fmt" + "net/http" + "io/ioutil" + ) + +//main function - ENTRY point of go +func main(){ + //make GET request to API + ////returns response and error response if any + response,error:= http.Get("http://ip.jsontest.com/") + + //check for no errors in making HTTP connection + if error != nil { + //info update + fmt.Println("Error in making HTTP request") + } + //wait in bg until the response closes + defer response.Body.Close() + + //read the content of response in bytes + content,_ := ioutil.ReadAll(response.Body) + + //parse the byte response to string of characters + resp_str := string(content) + + //create a runes(slices/list) + runes :=[]rune(resp_str) + + //display the response in string format + fmt.Println("Your IP from API - ",string(runes[8:23])) + + //info update + fmt.Println("Press to continue") + + //halt O/P screen + fmt.Scanln() + } From 543b3649e2e8960db6fc72128193ffece680f1b9 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 19:18:55 +0530 Subject: [PATCH 14/17] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fae392a..d2b6f45 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -# Instructions +# Completed Go Language Challenge -- All questions/tasks carry 100 points. -- Submit via creating a new folder in Submissions/yourusername/task name/ -- For eg: if user name in annon. Create a new folder named annon in Submissions folder. And suppose you are doing task 5. Create a new folder named task5. Save all the files realted to task5 in that folder and send a Pull request. +## Contact Details + -###NAME: M.Benhur Rodriguez + -###PHONE: +91-9843184815 + -###EMAIL: benhurrodriguez98@gmail.com From da83b6e8c5949d077f6427aad73012cbf3eb1d7b Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 19:19:44 +0530 Subject: [PATCH 15/17] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d2b6f45..4c102bf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Completed Go Language Challenge ## Contact Details - -###NAME: M.Benhur Rodriguez - -###PHONE: +91-9843184815 - -###EMAIL: benhurrodriguez98@gmail.com + ###NAME: M.Benhur Rodriguez + ###PHONE: +91-9843184815 + ###EMAIL: benhurrodriguez98@gmail.com From 3e9699976be3afefd5eef7de3873e93793c34283 Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 19:20:12 +0530 Subject: [PATCH 16/17] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c102bf..d0d1722 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Completed Go Language Challenge ## Contact Details - ###NAME: M.Benhur Rodriguez - ###PHONE: +91-9843184815 - ###EMAIL: benhurrodriguez98@gmail.com + NAME: M.Benhur Rodriguez + PHONE: +91-9843184815 + EMAIL: benhurrodriguez98@gmail.com From 187c9d2d23ab77f6baff0b9aabd6f814ce018c8b Mon Sep 17 00:00:00 2001 From: benhur98 Date: Sat, 17 Mar 2018 19:20:44 +0530 Subject: [PATCH 17/17] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d0d1722..3d50675 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Completed Go Language Challenge ## Contact Details - NAME: M.Benhur Rodriguez - PHONE: +91-9843184815 + NAME: M.Benhur Rodriguez -- + PHONE: +91-9843184815 -- EMAIL: benhurrodriguez98@gmail.com