For example, consider this sequence:
In this list, the two digits that match the next digit are 1 and 2.112234
Consider this sequence:
The answer is 1 1 1 1 -- every digit matches, including the last one.1111
Consider this sequence:
No digits match.1234
Consider this sequence:
The answer is 9 -- only the last digit matches.91212129
VP 51.1: Matching Next Digit (15 pts)
Use this data:https://samsclass.info/COMSC122/proj/VP51Find the digits that match the next digit.
Add them together.
That number is the flag.Hint: for example code, see the previous project: VP 50.
VP 51.2: Matching Opposite Digits (15 pts extra)
Use the same data as in the previous flag:https://samsclass.info/COMSC122/proj/VP50aNow, instead of matching the next digit, match the digit halfway
around the circular list.That is, if your list contains 10 items, only include a digit
if the digit 10/2 = 5 steps forward matches it.Fortunately, your list has an even number of elements.
For example:
Find the digits that match the digit halfway around the list.
- 1212 produces 1 2 1 2: the list contains 4 items, and all four digits match the digit 2 items ahead.
- 1221 -- no digits match, because every comparison is between a 1 and a 2.
- 123425 produces 2 2, because both 2s match each other, but no other digit has a match.
- 123123 produces 1 2 3 1 2 3.
- 12131415 produces 1 1 1 1.
Add them together.
That number is the flag.
Posted 8-28-25