All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Attendance Records (Posted on 2018-08-10) Difficulty: 3 of 5
A certain school rewards students for superior attendance and punctuality. The prize is received if there is no more than one lateness and no absence has lasted more than two consecutive days. If a student is late more than once in the specified duration of the award period or is absent three or more days in a row, the student is not eligible for a prize.

Note that multiple latenesses need not be on consecutive days to disentitle an award, but the three disqualifying absences need to be successive to cancel the award.

To keep track of attendance and punctuality for one student, a string of letters is used. For example:

PPPAAPAPPPAALAPPPPAP represents a sequence of Punctual days, Absence days and Lateness days that does qualify for the award, as none of the A's come in a group of three and there is only one lateness.

PPPAAPAPPPAAAPPPPAPL disqualifies the student because of the three absences in a row.

PPPAAPAPPPAALAPPPPAL disqualifies based on two latenesses.

A recent such prize period lasted 12 days. How many strings of 12 are there that would qualify for an award? There are obviously 3^12 possible strings altogether, many of which would not qualify; but how many do qualify?


Adapted from a Project Euler puzzle on-line.

  Submitted by Charlie    
No Rating
Solution: (Hide)
As the string is being built up, two things could happen that would instantly prevent the string from qualifying: a second lateness (L) is added, or an absence (A) is added to a string that already ended with two absences, so that this would be the third in a row.

There are six states that a given string could be in as it's in the process of being built up to length 12: it can have zero latenesses or one lateness; and within these categories, have zero, one or two absences at the end.

Punctuality or Lateness reset the Absence counter to zero, but Latenesses are never reset.

Each addition of a character, A, P or L, multiplies the possibilities by 3, but some of these fall off the valid set as explained above.

The sets of figures below show, in the left hand column numbers of strings with no latenesses, and in column two those with one lateness. The three numbers in each group refer to zero, one or two trailing A's (absences). You can see how the initial single A, P or L tally in the first set.

When a second letter is added, the possibility of an A creates a 1 in the one-A category in each column in the next set by carryover from zero A's, and a 1 in the two-A category as a carryover from the one-A category in the previous set. It also creates a 1 in the one-A category in the right column (one L becomes LA). The possibility of a P changes the 1 to a 2 in the top left entry as the sum of PP and AP as the absences get reset. The same happens in the right column as the 3 accounts for LP, PL or AL.

The numbers in the second group add to 8, as LL immediately becomes a disqualified branch.

The transitions from

       A       D
       B       E
       C       F
make the next set:
     A+B+C   A+B+C+D+E+F
       A       D
       B       E
Note that while A and B apprear three times in the next group, C, D and E appear only once each, as state C, ending in two Absences, is lost to validity with a third Absence; D and E are lost via an L; F appears only once, as only a Puncutality will keep it valid, as an Absence would be the third in a row, and a Lateness would be a second lateness. The table:
       1       1
       1       0
       0       0

       2       3
       1       1
       1       0

       4       8
       2       3
       1       1

       7      19
       4       8
       2       3

      13      43
       7      19
       4       8

      24      94
      13      43
       7      19

      44     200
      24      94
      13      43

      81     418
      44     200
      24      94

     149     861
      81     418
      44     200

     274    1753
     149     861
      81     418

     504    3536
     274    1753
     149     861

     927    7077
     504    3536
     274    1753

The numbers in the last (12th) set add up to 14071, making that the answer.

Comments: ( You must be logged in to post comments.)
  Subject Author Date
The three disqualifyingverma ruby2018-08-22 04:17:55
re: SolutionCharlie2018-08-13 14:30:16
SolutionSolutionBrian Smith2018-08-11 17:57:31
quick searchDaniel2018-08-10 09:18:28
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (15)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information