You are on page 1of 4

FA1.

2 ASYNCHRONOUS – AM3
General Instructions/rules:
1. Submit cpp files only. Unacceptable format – 0 pt
2. Write the programmer’s name, date and time creation before writing your code. Missing developer’s
details – (minus) 5 pts each file
3. Filename format – FA1-2-SECTION-SUBJECTCODE-FIRSTNAMEINITIAL-LASTNAME-PROGNUM.
example FA1-2-AM1-CSS122L-M-BAUTISTA-PROG1. Not following the filename format – (minus) 5 pts
each file.
4. Turnitin check from 10% - (minus) 40 pts each file
5. Copied from classmates, outsource from resources outside the working area (emails, messenger,
dropbox, other drives etc) – 0 pts / retake f2f coding, maximum of 60% of the grade.
6. Comments within the code that explains the purpose or use of the function or block of statement –
(add, max) 5 pts each file.
7. Use of <vector> - (minus) 30 pts in each file
8. Developers may use their favorite sites to verify and confirm syntax and concepts but not to search
for answer or codes related to the problem. If developer found guilty – 0 pts / retake f2f coding,
maximum of 60 percent of the grade.

Advise: Initialize all arrays with values first for testing purposes. If
the sample values satisfy both positive and negative returns, then
proceed with the codes that ask the users to enter contents of an
array.

PROBLEM 1: 50 PTS

Requirements: Apply the following


1. Error Handling -10 pts
2. Pointer – 10 pts
3. Arrays – 10 pts
4. Function – 10 pts
5. With code, no application of Requirements 1-4 – 10pts
6. Error during compile time – 0 pt
7. Logical error – Maximum of 50% pts

1|Page
Problem statement: Student Numbers ends with 1,3,5,7,9
Create a function that takes an array and determines whether it's strictly increasing,
strictly decreasing, or neither.

Examples

check([1, 2, 3]) ➞ "increasing"

check([3, 2, 1]) ➞ "decreasing"

check([1, 2, 1]) ➞ "neither"

check([1, 1, 2]) ➞ "neither"

Notes

• The last example does NOT count as strictly increasing, since 1-indexed 1 is
not strictly greater than the 0-indexed 1 .
• Input arrays have a minimum length of 2.

Problem statement: Student Numbers ends with 0,2,4,6,8

A boomerang is a V-shaped sequence that is either upright or upside down.


Specifically, a boomerang can be defined as: sub-array of length 3, with the first
and last digits being the same and the middle digit being different.

Some boomerang examples:


[3, 7, 3], [1, -1, 1], [5, 6, 5]
Create a function that returns the total number of boomerangs in an array.

To illustrate:
[3, 7, 3, 2, 1, 5, 1, 2, 2, -2, 2]
// 3 boomerangs in this sequence: [3, 7, 3], [1, 5, 1], [2, -2, 2]
Be aware that boomerangs can overlap, like so:
[1, 7, 1, 7, 1, 7, 1]
// 5 boomerangs (from left to right): [1, 7, 1], [7, 1, 7], [1, 7, 1],
[7, 1, 7], and [1, 7, 1]

2|Page
Examples

countBoomerangs([9, 5, 9, 5, 1, 1, 1]) ➞ 2

countBoomerangs([5, 6, 6, 7, 6, 3, 9]) ➞ 1

countBoomerangs([4, 4, 4, 9, 9, 9, 9]) ➞ 0

Notes

[5, 5, 5] (triple identical digits) is NOT considered a boomerang because the


middle digit is identical to the first and last.

PROBLEM 2: 50 PTS

Requirements: Apply the following


1. Error Handling -10 pts
2. Pointer – 10 pts
3. Arrays – 10 pts
4. Function – 10 pts
5. With code, no application of Requirements 1-4 – 10pts
6. Error during compile time – 0 pt
7. Logical error – Maximum of 50% pts

Problem statement: Student Numbers ends with 1,3,5,7,9

Write a function that reverses the subarray between the start and end index
(inclusive). The rest of the array should be kept the same.

Examples

rangedReversal([1, 2, 3, 4, 5, 6], 1, 3) ➞ [1, 4, 3, 2, 5, 6]

rangedReversal([1, 2, 3, 4, 5, 6], 0, 4) ➞ [5, 4, 3, 2, 1, 6]

rangedReversal([9, 8, 7, 4], 0, 0) ➞ [9, 8, 7, 4]

Notes

3|Page
• Arrays will be zero-indexed.
• The start and end indices will always be valid in context of the array.
• The end index will always be greater than or equal to the starting index.
• Return the array itself if the starting and ending index are the same

Problem statement: Student Numbers ends with 0,2,4,6,8

Create a function that divides an array into chunks of size n, where n is the length of
each chunk.

Examples

chunkify([2, 3, 4, 5], 2) ➞ [[2, 3], [4, 5]]

chunkify([2, 3, 4, 5, 6], 2) ➞ [[2, 3], [4, 5], [6]]

chunkify([2, 3, 4, 5, 6, 7], 3) ➞ [[2, 3, 4], [5, 6, 7]]

chunkify([2, 3, 4, 5, 6, 7], 1) ➞ [[2], [3], [4], [5], [6], [7]]

chunkify([2, 3, 4, 5, 6, 7], 7) ➞ [[2, 3, 4, 5, 6, 7]]

Notes

• It's O.K. if the last chunk is not completely filled (see example #2).
• Integers will always be single-digit.

/mnbautista

4|Page

You might also like