From 840d79ec4c7d49516b1847e3fc00b45be8dec806 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 15:05:14 +0000 Subject: [PATCH] [Sync Iteration] go/series/1 --- solutions/go/series/1/series.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 solutions/go/series/1/series.go diff --git a/solutions/go/series/1/series.go b/solutions/go/series/1/series.go new file mode 100644 index 0000000..9328f72 --- /dev/null +++ b/solutions/go/series/1/series.go @@ -0,0 +1,25 @@ +package series + +func All(n int, s string) []string { + if n > len(s) { + return nil + } + + l := make([]string, 0, len(s)-n+1) + for i := 0; i+n <= len(s); i++ { + l = append(l, s[i:i+n]) + } + + return l +} + +func UnsafeFirst(n int, s string) string { + return s[:n] +} + +func First(n int, s string) (string, bool) { + if n > len(s) { + return "", false + } + return s[:n], true +}