VP 51: Sequential Numbers (15 pts + 15 extra)

What You Need

Any computer with Python 3. You can also use an online Python environment, such as https://colab.research.google.com

Problem Statement

Given a sequence of digits, find the digits that match the next digit in the list. The list is circular, so the digit after the last one is the first digit.

For example, consider this sequence:

112234
In this list, the two digits that match the next digit are 1 and 2.

Consider this sequence:

1111
The answer is 1 1 1 1 -- every digit matches, including the last one.

Consider this sequence:

1234
No digits match.

Consider this sequence:

91212129
The answer is 9 -- only the last digit matches.

VP 51.1: Matching Next Digit (15 pts)

Use this data:
https://samsclass.info/COMSC122/proj/VP51
Find 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/VP50a
Now, 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:

  • 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.
Find the digits that match the digit halfway around the list.
Add them together.
That number is the flag.

Source

Adapted from the Advent of Code.

Posted 8-28-25