COS4861
Assignment 1
2026
[Unique No.: 285354]
Due: Monday, 11 May 2026 at 11pm
,Disclaimer
The study notes provided herein are intended to assist students in their academic
endeavours and provide guidance based on assignments. However, it is important to
understand and acknowledge the following points before utilizing these study notes:
1. Educational Aid: These study notes are designed to serve as educational aids and
should not be considered as a substitute for individual research, critical thinking, or
professional guidance. Students are encouraged to conduct their own extensive
research and consult with their instructors or academic advisors for specific
assignment requirements.
2. Personal Responsibility: While every effort has been made to ensure the accuracy
and reliability of the information provided in these study notes, the seller cannot
guarantee the completeness or correctness of all the content. It is the responsibility of
the buyer to verify the accuracy of the information and use their own judgment when
applying it to their assignments.
3. Academic Integrity: It is crucial for students to uphold academic integrity and adhere
to their institution's policies and guidelines regarding plagiarism, citation, and
referencing. These study notes should be used as a tool for learning and inspiration, but
any direct reproduction of the content without proper acknowledgment and citation
may constitute academic misconduct.
4. Subject Variation: The study notes may not cover all possible variations or
interpretations of a subject matter. Different institutions, professors, or courses may
have specific requirements or perspectives that are not addressed in these notes.
Therefore, it is essential for students to tailor their assignments according to their
unique academic environment.
5. Limited Liability: The seller of these study notes shall not be held liable for any direct
or indirect damages, losses, or consequences arising from the use of the notes. This
includes, but is not limited
to, poor grades, academic penalties, or any other negative outcomes resulting from the
application or misuse of the information provided.
By purchasing and utilizing these study notes, you acknowledge that you have read,
understood, and
agreed to the above disclaimer. It is recommended to review the disclaimer periodically,
as it may be subject to updates or revisions without prior notice.
,
,
, Question 1
1.1. ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])\s([01]\d|2[0-3]):[0-5]\d:[0-5]\d$
▪ ^ and $ are anchors preventing partial matches
▪ \d{4} — matches exactly 4 digits for the year (e.g., 2024)
▪ - — literal hyphen separator
▪ (0[1-9]|1[0-2]) — matches the month: 01–09 or 10–12
▪ - — literal hyphen separator
▪ (0[1-9]|[12]\d|3[01]) — matches the day: 01–09, 10–29, or 30–31
▪ \s — matches the single space between date and time
▪ ([01]\d|2[0-3]) — matches the hour: 00–19 (using [01]\d) or 20–23
▪ : — literal colon separator
▪ [0-5]\d — matches minutes 00–59
▪ : — literal colon separator
▪ [0-5]\d — matches seconds 00–59
1.2. (a) This regular expression matches South African Rand (R) currency amounts,
including thousands separators and optional cents.
Examples:
R10 — matches (a simple amount with no thousands separator)
R1,500 — matches (thousands separated amount)
R12,345.99 — matches (with decimal cents)
R 250.00 — matches (with optional space after R)
(b)
▪ R — matches the literal Rand symbol 'R'
▪ \s? — optionally matches a single whitespace character (space) between R
and the number
▪ \d{1,3} — matches between 1 and 3 digits (the leading digit group before any
thousands separator), e.g., '1', '12', or '999'
▪ (?:[,]\d{3})* — a non-capturing group (?:…) that matches a comma followed
by exactly 3 digits, zero or more times. This handles thousands separators:
',000', ',000,000', etc.
▪ (?:\.\d{2})? — a non-capturing group that optionally matches a decimal point
followed by exactly 2 digits (cents). The ? makes the whole group optional.
1.3. A Finite State Transducer (FST) is an extension of a Finite State Automaton that
produces output as well as recognising input. An FST has:
• States — a finite set Q
• An input alphabet Σ