From 4c7fa8188fb42cab394adc61491c15d9a43d2acb Mon Sep 17 00:00:00 2001
From: Udeshya Dhungana <075bct095.udeshya@pcampus.edu.np>
Date: Wed, 24 Sep 2025 16:33:31 +0545
Subject: [PATCH 1/6] Add quantifiers as a new extension in grep
---
stage_descriptions/quantifiers-01-qu1.md | 20 ++++++++++++++++++++
stage_descriptions/quantifiers-02-qu2.md | 20 ++++++++++++++++++++
stage_descriptions/quantifiers-03-qu3.md | 20 ++++++++++++++++++++
stage_descriptions/quantifiers-04-qu4.md | 20 ++++++++++++++++++++
4 files changed, 80 insertions(+)
create mode 100644 stage_descriptions/quantifiers-01-qu1.md
create mode 100644 stage_descriptions/quantifiers-02-qu2.md
create mode 100644 stage_descriptions/quantifiers-03-qu3.md
create mode 100644 stage_descriptions/quantifiers-04-qu4.md
diff --git a/stage_descriptions/quantifiers-01-qu1.md b/stage_descriptions/quantifiers-01-qu1.md
new file mode 100644
index 0000000..67d0b51
--- /dev/null
+++ b/stage_descriptions/quantifiers-01-qu1.md
@@ -0,0 +1,20 @@
+In this stage, we'll add support for `*`, the [zero or more](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-zero-or-more-times-) quantifier.
+
+The `*` quantifier matches the preceding element zero or more times. This means the element can be absent entirely or repeated any number of times.
+
+**Examples**:
+- `ca*t` should match "ct", "cat", and "caaat", but not "dog".
+- `k\d*t` should match "kt", "k1t", "k123t", and "k999t", but not "kabct".
+- `k[abc]*t` should match "kt", "kat", "kabct", and "kcccbbbt", but not "kaxyzt" or "kxyzt".
+
+Your program will be executed like this:
+
+```bash
+$ echo -n "ct" | ./your_program.sh -E "ca*t"
+```
+
+Your program must exit with 0 if the input matches the given pattern, and 1 if not.
+
+{{#reader_is_bot}}
+Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
+{{/reader_is_bot}}
diff --git a/stage_descriptions/quantifiers-02-qu2.md b/stage_descriptions/quantifiers-02-qu2.md
new file mode 100644
index 0000000..b120cf2
--- /dev/null
+++ b/stage_descriptions/quantifiers-02-qu2.md
@@ -0,0 +1,20 @@
+In this stage, we'll add support for `{n}`, the [exact repetition](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-exactly-n-times-n) quantifier.
+
+The `{n}` quantifier matches the preceding element exactly n times. The element must appear the exact number of times specified.
+
+**Examples**:
+- `ca{3}t` should match "caaat", but not "caat" or "caaaat".
+- `d\d{2}g` should match "d42g" and "d99g", but not "d1g" or "d123g".
+- `c[xyz]{4}w` should match "cyyyyw" and "czyxzw", but not "cxyzw" or "xyzzzw".
+
+Your program will be executed like this:
+
+```bash
+$ echo -n "caaat" | ./your_program.sh -E "ca{3}t"
+```
+
+Your program must exit with 0 if the input matches the given pattern, and 1 if not.
+
+{{#reader_is_bot}}
+Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
+{{/reader_is_bot}}
diff --git a/stage_descriptions/quantifiers-03-qu3.md b/stage_descriptions/quantifiers-03-qu3.md
new file mode 100644
index 0000000..e8b9da3
--- /dev/null
+++ b/stage_descriptions/quantifiers-03-qu3.md
@@ -0,0 +1,20 @@
+In this stage, we'll add support for `{n,}`, the [at least n times](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-at-least-n-times-n) quantifier.
+
+The `{n,}` quantifier matches the preceding element at least n times. The element must appear n or more times, with no upper limit.
+
+**Examples**:
+- `ca{2,}t` should match "caat", "caaat", and "caaaaat", but not "cat".
+- `x\d{3,}y` should match "x123y", "x9999y", and "x12345y", but not "x42y".
+- `b[aeiou]{2,}r` should match "baer", "baeiour", and "beeeeer", but not "bar".
+
+Your program will be executed like this:
+
+```bash
+$ echo -n "caat" | ./your_program.sh -E "ca{2,}t"
+```
+
+Your program must exit with 0 if the input matches the given pattern, and 1 if not.
+
+{{#reader_is_bot}}
+Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
+{{/reader_is_bot}}
diff --git a/stage_descriptions/quantifiers-04-qu4.md b/stage_descriptions/quantifiers-04-qu4.md
new file mode 100644
index 0000000..4e3de79
--- /dev/null
+++ b/stage_descriptions/quantifiers-04-qu4.md
@@ -0,0 +1,20 @@
+In this stage, we'll add support for `{n,m}`, the [between n and m times](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-between-n-and-m-times-nm) quantifier.
+
+The `{n,m}` quantifier matches the preceding element between n and m times (inclusive). The element must appear at least n times but no more than m times.
+
+**Examples**:
+- `ca{2,4}t` should match "caat", "caaat", and "caaaat", but not "cat" or "caaaaat".
+- `n\d{1,3}m` should match "n1m", "n42m", and "n123m", but not "n1234m".
+- `p[xyz]{2,3}q` should match "pxyq", "pxyzq", and "pzzzq", but not "pxq" or "pxyzyq".
+
+Your program will be executed like this:
+
+```bash
+$ echo -n "caaat" | ./your_program.sh -E "ca{2,4}t"
+```
+
+Your program must exit with 0 if the input matches the given pattern, and 1 if not.
+
+{{#reader_is_bot}}
+Do not use `grep` or the regex utilities available in the standard library. Implement the regex matcher yourself.
+{{/reader_is_bot}}
From e9f203422207c4e50b232e13a46518e4ea9148e5 Mon Sep 17 00:00:00 2001
From: Udeshya Dhungana <075bct095.udeshya@pcampus.edu.np>
Date: Wed, 24 Sep 2025 16:38:12 +0545
Subject: [PATCH 2/6] Use new slugs
---
.../{quantifiers-01-qu1.md => quantifiers-01-ai9.md} | 0
.../{quantifiers-02-qu2.md => quantifiers-02-wy9.md} | 0
.../{quantifiers-03-qu3.md => quantifiers-03-hk3.md} | 0
.../{quantifiers-04-qu4.md => quantifiers-04-ug0.md} | 0
4 files changed, 0 insertions(+), 0 deletions(-)
rename stage_descriptions/{quantifiers-01-qu1.md => quantifiers-01-ai9.md} (100%)
rename stage_descriptions/{quantifiers-02-qu2.md => quantifiers-02-wy9.md} (100%)
rename stage_descriptions/{quantifiers-03-qu3.md => quantifiers-03-hk3.md} (100%)
rename stage_descriptions/{quantifiers-04-qu4.md => quantifiers-04-ug0.md} (100%)
diff --git a/stage_descriptions/quantifiers-01-qu1.md b/stage_descriptions/quantifiers-01-ai9.md
similarity index 100%
rename from stage_descriptions/quantifiers-01-qu1.md
rename to stage_descriptions/quantifiers-01-ai9.md
diff --git a/stage_descriptions/quantifiers-02-qu2.md b/stage_descriptions/quantifiers-02-wy9.md
similarity index 100%
rename from stage_descriptions/quantifiers-02-qu2.md
rename to stage_descriptions/quantifiers-02-wy9.md
diff --git a/stage_descriptions/quantifiers-03-qu3.md b/stage_descriptions/quantifiers-03-hk3.md
similarity index 100%
rename from stage_descriptions/quantifiers-03-qu3.md
rename to stage_descriptions/quantifiers-03-hk3.md
diff --git a/stage_descriptions/quantifiers-04-qu4.md b/stage_descriptions/quantifiers-04-ug0.md
similarity index 100%
rename from stage_descriptions/quantifiers-04-qu4.md
rename to stage_descriptions/quantifiers-04-ug0.md
From bb1e1f5716482e8d91614633d923a468ab468e2a Mon Sep 17 00:00:00 2001
From: Udeshya Dhungana <075bct095.udeshya@pcampus.edu.np>
Date: Wed, 24 Sep 2025 16:39:59 +0545
Subject: [PATCH 3/6] Update course definition
---
course-definition.yml | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/course-definition.yml b/course-definition.yml
index 88ce8a8..3808f1c 100644
--- a/course-definition.yml
+++ b/course-definition.yml
@@ -68,6 +68,14 @@ extensions:
Along the way, you'll learn about how to implement efficient file I/O, directory traversal and pattern matching on file contents.
+ - slug: "quantifiers"
+ name: "Quantifiers"
+ description_markdown: |
+ In this challenge extension, you'll add support for [quantifiers][1] to your Grep implementation.
+
+ Along the way, you'll learn about how to implement the `*` quantifier (zero or more), and bounded quantifiers.
+ [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Quantifier
+
stages:
- slug: "cq2"
name: "Match a literal character"
@@ -266,4 +274,33 @@ stages:
name: "Recursive search"
difficulty: hard
marketing_md: |-
- In this stage, you'll add support for searching through files in a given directory and its subdirectories recursively with the -r flag.
\ No newline at end of file
+ In this stage, you'll add support for searching through files in a given directory and its subdirectories recursively with the -r flag.
+
+ # Quantifiers
+ - slug: "ai9"
+ primary_extension_slug: "quantifiers"
+ name: "Zero or more times"
+ difficulty: hard
+ marketing_md: |-
+ In this stage, we'll add support for `*`, the [zero or more](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-zero-or-more-times-) quantifier.
+
+ - slug: "wy9"
+ primary_extension_slug: "quantifiers"
+ name: "Exact repetition"
+ difficulty: hard
+ marketing_md: |-
+ In this stage, we'll add support for `{n}`, the [exact repetition](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-exactly-n-times-n) quantifier.
+
+ - slug: "hk3"
+ primary_extension_slug: "quantifiers"
+ name: "Minimum repetition"
+ difficulty: hard
+ marketing_md: |-
+ In this stage, we'll add support for `{n,}`, the [at least m times](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-at-least-n-times-n) quantifier.
+
+ - slug: "ug0"
+ primary_extension_slug: "quantifiers"
+ name: "Range repetition"
+ difficulty: hard
+ marketing_md: |-
+ In this stage, we'll add support for `{n,m}`, the [between n and m times](https://docs.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions#match-between-n-and-m-times-nm) quantifier.
\ No newline at end of file
From 084797d23c27101887a64758fbc68fce5efd31aa Mon Sep 17 00:00:00 2001
From: Udeshya Dhungana <075bct095.udeshya@pcampus.edu.np>
Date: Wed, 24 Sep 2025 16:42:32 +0545
Subject: [PATCH 4/6] Include tests section
---
stage_descriptions/quantifiers-01-ai9.md | 4 +++-
stage_descriptions/quantifiers-02-wy9.md | 4 +++-
stage_descriptions/quantifiers-03-hk3.md | 4 +++-
stage_descriptions/quantifiers-04-ug0.md | 4 +++-
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/stage_descriptions/quantifiers-01-ai9.md b/stage_descriptions/quantifiers-01-ai9.md
index 67d0b51..54c0833 100644
--- a/stage_descriptions/quantifiers-01-ai9.md
+++ b/stage_descriptions/quantifiers-01-ai9.md
@@ -7,10 +7,12 @@ The `*` quantifier matches the preceding element zero or more times. This means
- `k\d*t` should match "kt", "k1t", "k123t", and "k999t", but not "kabct".
- `k[abc]*t` should match "kt", "kat", "kabct", and "kcccbbbt", but not "kaxyzt" or "kxyzt".
+## Tests
+
Your program will be executed like this:
```bash
-$ echo -n "ct" | ./your_program.sh -E "ca*t"
+$ echo -n "" | ./your_program.sh -E ""
```
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
diff --git a/stage_descriptions/quantifiers-02-wy9.md b/stage_descriptions/quantifiers-02-wy9.md
index b120cf2..9f55a0d 100644
--- a/stage_descriptions/quantifiers-02-wy9.md
+++ b/stage_descriptions/quantifiers-02-wy9.md
@@ -7,10 +7,12 @@ The `{n}` quantifier matches the preceding element exactly n times. The element
- `d\d{2}g` should match "d42g" and "d99g", but not "d1g" or "d123g".
- `c[xyz]{4}w` should match "cyyyyw" and "czyxzw", but not "cxyzw" or "xyzzzw".
+## Tests
+
Your program will be executed like this:
```bash
-$ echo -n "caaat" | ./your_program.sh -E "ca{3}t"
+$ echo -n "" | ./your_program.sh -E ""
```
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
diff --git a/stage_descriptions/quantifiers-03-hk3.md b/stage_descriptions/quantifiers-03-hk3.md
index e8b9da3..3b98d3c 100644
--- a/stage_descriptions/quantifiers-03-hk3.md
+++ b/stage_descriptions/quantifiers-03-hk3.md
@@ -7,10 +7,12 @@ The `{n,}` quantifier matches the preceding element at least n times. The elemen
- `x\d{3,}y` should match "x123y", "x9999y", and "x12345y", but not "x42y".
- `b[aeiou]{2,}r` should match "baer", "baeiour", and "beeeeer", but not "bar".
+## Tests
+
Your program will be executed like this:
```bash
-$ echo -n "caat" | ./your_program.sh -E "ca{2,}t"
+$ echo -n "" | ./your_program.sh -E ""
```
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
diff --git a/stage_descriptions/quantifiers-04-ug0.md b/stage_descriptions/quantifiers-04-ug0.md
index 4e3de79..9149ba7 100644
--- a/stage_descriptions/quantifiers-04-ug0.md
+++ b/stage_descriptions/quantifiers-04-ug0.md
@@ -7,10 +7,12 @@ The `{n,m}` quantifier matches the preceding element between n and m times (incl
- `n\d{1,3}m` should match "n1m", "n42m", and "n123m", but not "n1234m".
- `p[xyz]{2,3}q` should match "pxyq", "pxyzq", and "pzzzq", but not "pxq" or "pxyzyq".
+## Tests
+
Your program will be executed like this:
```bash
-$ echo -n "caaat" | ./your_program.sh -E "ca{2,4}t"
+$ echo -n "" | ./your_program.sh -E ""
```
Your program must exit with 0 if the input matches the given pattern, and 1 if not.
From dd1356018282b3a1731ada4b0cba02121a190056 Mon Sep 17 00:00:00 2001
From: Udeshya Dhungana <075bct095.udeshya@pcampus.edu.np>
Date: Wed, 24 Sep 2025 16:44:54 +0545
Subject: [PATCH 5/6] Change mozilla link to microsoft
---
course-definition.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/course-definition.yml b/course-definition.yml
index 3808f1c..6d0aae6 100644
--- a/course-definition.yml
+++ b/course-definition.yml
@@ -74,7 +74,7 @@ extensions:
In this challenge extension, you'll add support for [quantifiers][1] to your Grep implementation.
Along the way, you'll learn about how to implement the `*` quantifier (zero or more), and bounded quantifiers.
- [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Quantifier
+ [1]: https://learn.microsoft.com/en-us/dotnet/standard/base-types/quantifiers-in-regular-expressions
stages:
- slug: "cq2"
From f21facde55e2d662e9466f1e8e3a104feffd7444 Mon Sep 17 00:00:00 2001
From: Udeshya Dhungana <075bct095.udeshya@pcampus.edu.np>
Date: Wed, 24 Sep 2025 16:48:07 +0545
Subject: [PATCH 6/6] Hadolint ignore line
---
dockerfiles/go-1.21.Dockerfile | 1 +
dockerfiles/go-1.22.Dockerfile | 1 +
dockerfiles/go-1.24.Dockerfile | 1 +
3 files changed, 3 insertions(+)
diff --git a/dockerfiles/go-1.21.Dockerfile b/dockerfiles/go-1.21.Dockerfile
index 59934f5..43c29d0 100644
--- a/dockerfiles/go-1.21.Dockerfile
+++ b/dockerfiles/go-1.21.Dockerfile
@@ -8,6 +8,7 @@ COPY go.mod go.sum ./
# Starting from Go 1.20, the go standard library is no loger compiled
# setting the GODEBUG environment to "installgoroot=all" restores the old behavior
+# hadolint ignore=DL3062
RUN GODEBUG="installgoroot=all" go install std
RUN go mod download
diff --git a/dockerfiles/go-1.22.Dockerfile b/dockerfiles/go-1.22.Dockerfile
index f74d49a..8984d4b 100644
--- a/dockerfiles/go-1.22.Dockerfile
+++ b/dockerfiles/go-1.22.Dockerfile
@@ -11,6 +11,7 @@ COPY --exclude=.git --exclude=README.md . /app
# Starting from Go 1.20, the go standard library is no loger compiled.
# Setting GODEBUG to "installgoroot=all" restores the old behavior
+# hadolint ignore=DL3062
RUN GODEBUG="installgoroot=all" go install std
RUN go mod download
diff --git a/dockerfiles/go-1.24.Dockerfile b/dockerfiles/go-1.24.Dockerfile
index fa98f0f..d08d151 100644
--- a/dockerfiles/go-1.24.Dockerfile
+++ b/dockerfiles/go-1.24.Dockerfile
@@ -11,6 +11,7 @@ COPY --exclude=.git --exclude=README.md . /app
# Starting from Go 1.20, the go standard library is no loger compiled.
# Setting GODEBUG to "installgoroot=all" restores the old behavior
+# hadolint ignore=DL3062
RUN GODEBUG="installgoroot=all" go install std
RUN go mod download