prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Latvian ssn generator is not correct
  * Faker version: 17.0.0
  * OS: Windows
  
  
  Latvian ssn generator generates ssn in format 'ddd-dd-dddd', which is not correct. 
  
  ### Steps to reproduce
  
  ```
  from faker import Faker
  fake = Faker('lv_LV')
  fake.ssn()
  
  ```
  
  ### Expected behavior
  
  It should be 12 characters long DDMMYY-CZZZQ e.g. 170334-19862
  
  ### Actual behavior
  
  fake.ssn() for latvian locale outputs ssn in format  'ddd-dd-dddd'
  '604-87-6475'
  '824-21-9489'
  '411-57-8156'
  '938-77-8408'
  
  
  </issue>
  <code>
  [start of faker/providers/ssn/lv_LV/__init__.py]
  1 from .. import Provider as BaseProvider
  2 
  3 
  4 class Provider(BaseProvider):
  5     """
  6     A Faker provider for the Latvian VAT IDs
  7     """
  8 
  9     vat_id_formats = ("LV###########",)
  10 
  11     def vat_id(self) -> str:
  12         """
  13         http://ec.europa.eu/taxation_customs/vies/faq.html#item_11
  14         :return: a random Latvian VAT ID
  15         """
  16 
  17         return self.bothify(self.random_element(self.vat_id_formats))
  18
  [end of faker/providers/ssn/lv_LV/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/faker/providers/ssn/lv_LV/__init__.py b/faker/providers/ssn/lv_LV/__init__.py
  --- a/faker/providers/ssn/lv_LV/__init__.py
  +++ b/faker/providers/ssn/lv_LV/__init__.py
  @@ -1,7 +1,56 @@
  -from .. import Provider as BaseProvider
  +import datetime
   
  +from .. import Provider as SsnProvider
  +
  +
  +class Provider(SsnProvider):
  +    def ssn(self, min_age: int = 0, max_age: int = 105) -> str:
  +        """
  +        Returns 11 character Latvian personal identity code (Personas kods).
  +        This function assigns random age to person.
  +
  +        Personal code consists of eleven characters of the form DDMMYYCZZZQ, where
  +        DDMMYY is the date of birth, C the century sign, ZZZ the individual
  +        number and Q the control character (checksum). The number for the
  +        century is either 0 (1800–1899), 1 (1900–1999), or 2 (2000–2099).
  +        """
  +
  +        def _checksum(ssn_without_checksum):
  +            weights = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
  +            weighted_sum = sum(int(digit) * weight for digit, weight in zip(ssn_without_checksum, weights))
  +            reminder = (1 - weighted_sum) % 11
  +            if reminder == 10:
  +                return 0
  +            elif reminder < -1:
  +                return reminder + 11
  +            return reminder
  +
  +        age = datetime.timedelta(days=self.generator.random.randrange(min_age * 365, max_age * 365))
  +        birthday = datetime.date.today() - age
  +        ssn_date = "%02d%02d%s" % (
  +            birthday.day,
  +            birthday.month,
  +            str(birthday.year)[-2:],
  +        )
  +        century = self._get_century_code(birthday.year)  # Century
  +        suffix = self.generator.random.randrange(111, 999)
  +        checksum = _checksum(f"{ssn_date}{century:01d}{suffix:03d}")
  +        ssn = f"{ssn_date}-{century:01d}{suffix:03d}{checksum:01d}"
  +        return ssn
  +
  +    @staticmethod
  +    def _get_century_code(year: int) -> int:
  +        """Returns the century code for a given year"""
  +        if 2000 <= year < 3000:
  +            code = 2
  +        elif 1900 <= year < 2000:
  +            code = 1
  +        elif 1800 <= year < 1900:
  +            code = 0
  +        else:
  +            raise ValueError("SSN do not support people born before the year 1800 or after the year 2999")
  +        return code
   
  -class Provider(BaseProvider):
       """
       A Faker provider for the Latvian VAT IDs
       """
  
verification_info: {"golden_diff": "diff --git a/faker/providers/ssn/lv_LV/__init__.py b/faker/providers/ssn/lv_LV/__init__.py\n--- a/faker/providers/ssn/lv_LV/__init__.py\n+++ b/faker/providers/ssn/lv_LV/__init__.py\n@@ -1,7 +1,56 @@\n-from .. import Provider as BaseProvider\n+import datetime\n \n+from .. import Provider as SsnProvider\n+\n+\n+class Provider(SsnProvider):\n+    def ssn(self, min_age: int = 0, max_age: int = 105) -> str:\n+        \"\"\"\n+        Returns 11 character Latvian personal identity code (Personas kods).\n+        This function assigns random age to person.\n+\n+        Personal code consists of eleven characters of the form DDMMYYCZZZQ, where\n+        DDMMYY is the date of birth, C the century sign, ZZZ the individual\n+        number and Q the control character (checksum). The number for the\n+        century is either 0 (1800\u20131899), 1 (1900\u20131999), or 2 (2000\u20132099).\n+        \"\"\"\n+\n+        def _checksum(ssn_without_checksum):\n+            weights = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2]\n+            weighted_sum = sum(int(digit) * weight for digit, weight in zip(ssn_without_checksum, weights))\n+            reminder = (1 - weighted_sum) % 11\n+            if reminder == 10:\n+                return 0\n+            elif reminder < -1:\n+                return reminder + 11\n+            return reminder\n+\n+        age = datetime.timedelta(days=self.generator.random.randrange(min_age * 365, max_age * 365))\n+        birthday = datetime.date.today() - age\n+        ssn_date = \"%02d%02d%s\" % (\n+            birthday.day,\n+            birthday.month,\n+            str(birthday.year)[-2:],\n+        )\n+        century = self._get_century_code(birthday.year)  # Century\n+        suffix = self.generator.random.randrange(111, 999)\n+        checksum = _checksum(f\"{ssn_date}{century:01d}{suffix:03d}\")\n+        ssn = f\"{ssn_date}-{century:01d}{suffix:03d}{checksum:01d}\"\n+        return ssn\n+\n+    @staticmethod\n+    def _get_century_code(year: int) -> int:\n+        \"\"\"Returns the century code for a given year\"\"\"\n+        if 2000 <= year < 3000:\n+            code = 2\n+        elif 1900 <= year < 2000:\n+            code = 1\n+        elif 1800 <= year < 1900:\n+            code = 0\n+        else:\n+            raise ValueError(\"SSN do not support people born before the year 1800 or after the year 2999\")\n+        return code\n \n-class Provider(BaseProvider):\n     \"\"\"\n     A Faker provider for the Latvian VAT IDs\n     \"\"\"\n", "issue": "Latvian ssn generator is not correct\n* Faker version: 17.0.0\r\n* OS: Windows\r\n\r\n\r\nLatvian ssn generator generates ssn in format 'ddd-dd-dddd', which is not correct. \r\n\r\n### Steps to reproduce\r\n\r\n```\r\nfrom faker import Faker\r\nfake = Faker('lv_LV')\r\nfake.ssn()\r\n\r\n```\r\n\r\n### Expected behavior\r\n\r\nIt should be 12 characters long DDMMYY-CZZZQ e.g. 170334-19862\r\n\r\n### Actual behavior\r\n\r\nfake.ssn() for latvian locale outputs ssn in format  'ddd-dd-dddd'\r\n'604-87-6475'\r\n'824-21-9489'\r\n'411-57-8156'\r\n'938-77-8408'\r\n\n", "before_files": [{"content": "from .. import Provider as BaseProvider\n\n\nclass Provider(BaseProvider):\n    \"\"\"\n    A Faker provider for the Latvian VAT IDs\n    \"\"\"\n\n    vat_id_formats = (\"LV###########\",)\n\n    def vat_id(self) -> str:\n        \"\"\"\n        http://ec.europa.eu/taxation_customs/vies/faq.html#item_11\n        :return: a random Latvian VAT ID\n        \"\"\"\n\n        return self.bothify(self.random_element(self.vat_id_formats))\n", "path": "faker/providers/ssn/lv_LV/__init__.py"}]}