Match Results | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Match Results

Here package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} var a int var b string fmt.Scanln(&b) //results = append (results, results[(len(results)-1)]) results = append (results, b) for _, v := range results { switch { case v == "w": a += 3 case v == "l": a += 0 case v == "d": a += 1 } } fmt.Println(a) }

12th Sep 2021, 4:53 PM
Schawnnara Jiri Jeena-Myrr
Schawnnara Jiri Jeena-Myrr - avatar
5 Answers
+ 4
And why is there a case for lost? This gives no points. There is no reason to do this.
12th Sep 2021, 6:10 PM
Coding Cat
Coding Cat - avatar
+ 1
What's your problem or question here. Please specify it firstly. Happy coding!
12th Sep 2021, 5:05 PM
mesarthim
mesarthim - avatar
+ 1
Schawnnara Jiri Jeena-Myrr What is the problem here? It is working fine.
12th Sep 2021, 5:33 PM
A͢J
A͢J - avatar
+ 1
package main import "fmt" func main() { var ( lastRes []rune total uint8 ) results := []rune{'w', 'l', 'w', 'd', 'w', 'l', 'l', 'l', 'd', 'd', 'w', 'l', 'w', 'd'} var tmp string fmt.Scanln(&tmp) lastRes = []rune(tmp) results = append(results, lastRes...) for _, v := range results { switch { case v == 119: total += 3 case v == 100: total += 1 } } fmt.Println(total) }
22nd Mar 2022, 8:23 PM
max
max - avatar
+ 1
package main import "fmt" func main() { results := []string{"w", "l", "w", "d", "w", "l", "l", "l", "d", "d", "w", "l", "w", "d"} var a int var b string fmt.Scanln(&b) results = append (results, b) for _, v := range results { if v=="w"{ a+=3 } if v=="d"{ a+=1 } if v=="l"{ a+=0 } } fmt.Println(a) }
6th Dec 2022, 11:49 PM
Samba Sy
Samba Sy - avatar