Skip to content

Instantly share code, notes, and snippets.

@in1yan
Created February 13, 2025 04:49
Show Gist options
  • Save in1yan/34704967c6aeafb9dbf631065c265b58 to your computer and use it in GitHub Desktop.
Save in1yan/34704967c6aeafb9dbf631065c265b58 to your computer and use it in GitHub Desktop.
sloth bytes challenge
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(remove_virus("PC Files: spotifysetup.exe, virus.exe, dog.jpg"))
fmt.Println(remove_virus("PC Files: antivirus.exe, cat.pdf, lethalmalware.exe, dangerousvirus.exe "))
fmt.Println(remove_virus("PC Files: notvirus.exe, funnycat.gif"))
}
func remove_virus(str string) string {
words := strings.Split(strings.ReplaceAll(str[9:], " ", ""), ",")
var clean[] string
for _, file := range words{
if strings.Contains(file, "notvirus") ||strings.Contains(file, "antivirus"){
clean = append(clean, file)
}
if strings.Contains(file, "virus") ||strings.Contains(file, "malware"){
continue
}
clean = append(clean, file)
}
if len(clean) == 0 {
return "PC Files: Empty"
}
return "PC Files: " + strings.Join(clean, ", ")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment