LeetCode 552: Student Attendance Record II I'm posting my code for a LeetCode problem copied here. If you have time and would like to golf for a short solution, please do so.
Requirement

It has to only pass the LeetCode's Online Judge, if the language would be available.

If the language is not available, simply we should possibly keep the class Solution as well as the function name.


Languages and Version Notes
Available languages are:

C++ clang 9 Uses the C++17 standard.
Java    13.0.1
Python  2.7.12
Python3 3.8
C   gcc 8.2
C#  8.0
JavaScript 14.3.0
Ruby    2.4.5
Bash    4.3.30
Swift   5.0.1
Go  1.13
Scala   2.13
Kotlin  1.3.10
Rust    1.40.0
PHP 7.2

Thank you!
Problem

Given a positive integer n, return the number of all possible
attendance records with length n, which will be regarded as
rewardable. The answer may be very large, return it after mod 10 ^ 9 + 7.
A student attendance record is a string that only contains the
following three characters:

'A' : Absent.
'L' : Late.
'P' : Present.

A record is regarded as rewardable if it doesn't contain more than one
'A' (absent) or more than two continuous 'L' (late).
Example 1:

Input: n = 2
Output: 8

Explanation:
There are 8 records with length 2 will be regarded as rewardable:

&quot;PP&quot; , &quot;AP&quot;, &quot;PA&quot;, &quot;LP&quot;, &quot;PL&quot;, &quot;AL&quot;, &quot;LA&quot;, &quot;LL&quot;

Only &quot;AA&quot; won't be regarded as rewardable owing to more than one absent times.

Note: The value of n won't exceed 100,000.



Accepted Code
class Solution:
    def checkRecord(self, n):
        MOD = 1000000007
        a = b = d = 1
        c = e = f = 0
        for _ in range(n - 1):
            a, b, c, d, e, f = (a + b + c) % MOD, a, b, (a + b + c + d + e + f) % MOD, d, e

        return (a + b + c + d + e + f) % MOD

Accepted Golf Attempt in Python 3 - 185 bytes - I
class Solution:
    def checkRecord(self,n):
        M=1000000007;a=b=d=1;c=e=f=0
        for _ in range(n-1):a,b,c,d,e,f=(a+b+c)%M,a,b,(a+b+c+d+e+f)%M,d,e
        return(a+b+c+d+e+f)%M

Accepted Golf Attempt in Python 3 - 185 bytes - II
class Solution:
    def checkRecord(self,n):
        M=int(1e9+7);a=b=d=1;c=e=f=0
        for _ in range(n-1):a,b,c,d,e,f=(a+b+c)%M,a,b,(a+b+c+d+e+f)%M,d,e
        return(a+b+c+d+e+f)%M

Reference
In LeetCode's answer template, there is a class usually named Solution with one or more public functions which we are not allowed to rename.

Problem

Discuss

Languages

I guess the solution was originally designed by Stefan Pochmann
Tips:

The first argument self can be renamed to something shorter.
Use while n:n-=1 to loop n times
(Python 2 specific) You can use a single tab for the second level of indentation, instead of 2 spaces.
For this problem, it's sufficiently fast to just mod b every loop, instead of having to mod both a and d.
The part a,b,c,d,e,f=... can be broken into a,b,c=...;d,e,f=..., which allows reusing the updated value a=a+b+c
c,e,f can be initialized to 10**9+7 instead of 0 (found by @xnor).

Python 2, 136 134 131 127 125 bytes

class Solution:
 def checkRecord(_,n):
&#9;a=b=d=1;c=e=f=M=10**9+7
&#9;while n:n-=1;a,b,c=a+b+c,a%M,b;d,e,f=a+d+e+f,d,e
&#9;return d%M

Try it online!