Created
June 15, 2016 18:38
-
-
Save narenaryan/668d7a1830dbacd874e8c9233c6fdf65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ("fmt" | |
| "bufio" | |
| "os" | |
| "strconv" | |
| "strings" | |
| ) | |
| func cleanString(stream string, seperator string) []int{ | |
| // Trims the stream and then splits | |
| trimmed_stream := strings.TrimSpace(stream) | |
| split_arr := strings.Split(trimmed_stream, seperator) | |
| // convert strings to integers and store them in a slice | |
| clean_arr := make([]int, len(split_arr)) | |
| for index,val := range split_arr{ | |
| clean_arr[index], _ = strconv.Atoi(val) | |
| } | |
| return clean_arr | |
| } | |
| func main() { | |
| inputreader := bufio.NewReader(os.Stdin) | |
| input, _ := inputreader.ReadString('\n') | |
| noOfTestCases, _ := strconv.Atoi(strings.TrimSpace(input)) | |
| for i := 0; i < noOfTestCases; i++ { | |
| lineInput, _ := inputreader.ReadString('\n') | |
| fmt.Println(cleanString(lineInput, " ")) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment