From 7330e81ad2c2acaaba84d22631907babed57d0c7 Mon Sep 17 00:00:00 2001 From: daviddoji Date: Fri, 8 May 2026 17:21:46 +0200 Subject: [PATCH] Iguales al siguiente en Go --- src/Go/001.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/Go/001.go diff --git a/src/Go/001.go b/src/Go/001.go new file mode 100644 index 0000000..e39ef13 --- /dev/null +++ b/src/Go/001.go @@ -0,0 +1,21 @@ +package main + +import "fmt" + +func same_to_next(lst []int) []int { + _lst := []int{} + for i := 0; i+1 < len(lst); i++ { + if lst[i] == lst[i+1] { + _lst = append(_lst, lst[i]) + } + } + return _lst +} + +func main() { + check := []int{1, 2, 2, 2, 3, 3, 4} + fmt.Println(same_to_next(check)) // [2 2 3] + + check = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + fmt.Println(same_to_next(check)) // [] +} \ No newline at end of file