"""simple docstring"""






import json
import os
import pickle
import subprocess
from hashlib import mda
from pathlib import Path
from tempfile import gettempdir
from textwrap import dedent
from types import CodeType, FunctionType
from unittest import TestCase
from unittest.mock import patch

import pytest
from multiprocess import Pool
from packaging import version

import datasets
from datasets.fingerprint import Hasher, fingerprint_transform
from datasets.table import InMemoryTable

from .utils import (
    require_regex,
    require_spacy,
    require_spacy_model,
    require_tiktoken,
    require_torch,
    require_transformers,
)


class 					UpperCAmelCase		:



    """simple docstring"""

    def __init__(     self					,    _UpperCAmelCase							):
       lowercase__:     List[str]      =   foo






    def __call__(     self							):
       return self.foo



class 					UpperCAmelCase		(datasets.Dataset						):



    """simple docstring"""

    @fingerprint_transform(inplace=_UpperCAmelCase							)
    def _snake_case    (     self					,    _UpperCAmelCase					,    *_UpperCAmelCase					,    **_UpperCAmelCase							):
       return DatasetChild(self.data					,    fingerprint=_UpperCAmelCase							)






    @fingerprint_transform(inplace=_UpperCAmelCase							)
    def _snake_case    (     self					,    _UpperCAmelCase					,    *_UpperCAmelCase					,    **_UpperCAmelCase							):
       return DatasetChild(self.data					,    fingerprint=_UpperCAmelCase							)



class 					UpperCAmelCase		:



    """simple docstring"""

    def __init__(     self					,    _UpperCAmelCase							):
       lowercase__:     List[str]      =   callable






    def __call__(     self					,    *_UpperCAmelCase					,    **_UpperCAmelCase							):
       if self.callable is not None:
          return self.callable(*_UpperCAmelCase					,    **_UpperCAmelCase							)






    def __getstate__(     self							):
       raise pickle.PicklingError()



class 					UpperCAmelCase		(_UpperCAmelCase						):



    """simple docstring"""

    @require_transformers
    @pytest.mark.integration
    def _snake_case    (     self							):
       from transformers import AutoTokenizer

       def encode(_UpperCAmelCase							):
          return tokenizer(_UpperCAmelCase							)

       # TODO: add hash consistency tests across sessions
       lowercase__:     Tuple      =   AutoTokenizer.from_pretrained('''bert-base-uncased'''							)
       lowercase__:     Tuple      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     Optional[Any]      =   mda(datasets.utils.py_utils.dumps(lambda _UpperCAmelCase							: tokenizer(_UpperCAmelCase							)							)							).hexdigest()
       lowercase__:     Dict      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     List[str]      =   AutoTokenizer.from_pretrained('''bert-base-cased'''							)
       lowercase__:     Tuple      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     List[Any]      =   mda(datasets.utils.py_utils.dumps(lambda _UpperCAmelCase							: tokenizer(_UpperCAmelCase							)							)							).hexdigest()
       lowercase__:     Optional[int]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     Optional[int]      =   AutoTokenizer.from_pretrained('''bert-base-uncased'''							)
       lowercase__:     List[Any]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     int      =   mda(datasets.utils.py_utils.dumps(lambda _UpperCAmelCase							: tokenizer(_UpperCAmelCase							)							)							).hexdigest()
       lowercase__:     Union[str, Any]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    @require_transformers
    @pytest.mark.integration
    def _snake_case    (     self							):
       from transformers import AutoTokenizer

       lowercase__:     Optional[Any]      =   AutoTokenizer.from_pretrained('''gpt2'''							)
       lowercase__:     Dict      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       tokenizer('''Hello world !'''							)  # call once to change the tokenizer's cache
       lowercase__:     Tuple      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    @require_regex
    def _snake_case    (     self							):
       import regex

       lowercase__:     Any      =   regex.Regex('''foo'''							)
       lowercase__:     Optional[int]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     List[str]      =   regex.Regex('''bar'''							)
       lowercase__:     str      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     str      =   regex.Regex('''foo'''							)
       lowercase__:     Union[str, Any]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)



class 					UpperCAmelCase		(_UpperCAmelCase						):



    """simple docstring"""

    def _snake_case    (     self							):
       def func():
          return foo

       lowercase__:     str      =   [0]
       lowercase__:     List[str]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     Tuple      =   [1]
       lowercase__:     List[Any]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     int      =   [0]
       lowercase__:     Dict      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    def _snake_case    (     self							):
       def func():
          pass

       lowercase__:     str      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()

       def func():
          pass

       lowercase__:     Any      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    def _snake_case    (     self							):
       lowercase__:     str      =   mda(datasets.utils.py_utils.dumps(Foo([0]							)							)							).hexdigest()
       lowercase__:     Dict      =   mda(datasets.utils.py_utils.dumps(Foo([1]							)							)							).hexdigest()
       lowercase__:     str      =   mda(datasets.utils.py_utils.dumps(Foo([0]							)							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    def _snake_case    (     self							):
       lowercase__:     Dict      =   mda(datasets.utils.py_utils.dumps(Foo([0]							).__call__							)							).hexdigest()
       lowercase__:     Optional[Any]      =   mda(datasets.utils.py_utils.dumps(Foo([1]							).__call__							)							).hexdigest()
       lowercase__:     Optional[Any]      =   mda(datasets.utils.py_utils.dumps(Foo([0]							).__call__							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    def _snake_case    (     self							):
       lowercase__:     str      =   (
           '''co_argcount''',
           '''co_kwonlyargcount''',
           '''co_nlocals''',
           '''co_stacksize''',
           '''co_flags''',
           '''co_code''',
           '''co_consts''',
           '''co_names''',
           '''co_varnames''',
           '''co_filename''',
           '''co_name''',
           '''co_firstlineno''',
           '''co_lnotab''',
           '''co_freevars''',
           '''co_cellvars''',
       )

       def _create_code_pyaa(*_UpperCAmelCase							):
          if hasattr(args[-3]					,    '''encode'''							):
             lowercase__:     List[Any]      =   list(_UpperCAmelCase							)
             lowercase__:     Dict      =   args[-3].encode()  # co_lnotab
             lowercase__:     str      =   args[-10].encode()  # co_code
          if hasattr(_UpperCAmelCase					,    '''co_posonlyargcount'''							):
             if len(_UpperCAmelCase							) == 16:
                return CodeType(*_UpperCAmelCase							)
             elif len(_UpperCAmelCase							) == 15:
                return CodeType(args[0]					,    0					,    *args[1:]							)
             return CodeType(args[0]					,    0					,    0					,    *args[1:]							)
          elif hasattr(_UpperCAmelCase					,    '''co_kwonlyargcount'''							):
             if len(_UpperCAmelCase							) == 16:
                return CodeType(args[0]					,    *args[2:]							)
             elif len(_UpperCAmelCase							) == 15:
                return CodeType(*_UpperCAmelCase							)
             return CodeType(args[0]					,    0					,    *args[1:]							)
          if len(_UpperCAmelCase							) == 16:
             return CodeType(args[0]					,    *args[3:]							)
          elif len(_UpperCAmelCase							) == 15:
             return CodeType(args[0]					,    *args[2:]							)
          return CodeType(*_UpperCAmelCase							)

       def create_ipython_func(_UpperCAmelCase					,    _UpperCAmelCase							):
          def func():
             return returned_obj

          lowercase__:     int      =   func.__code__
          # Use _create_code from dill in order to make it work for different python versions
          if datasets.config.PY_VERSION < version.parse('''3.8'''							):
             lowercase__:     List[str]      =   _create_code_pyaa(
                 *[getattr(_UpperCAmelCase					,    _UpperCAmelCase							) if k != '''co_filename''' else co_filename for k in code_args_pyaa]							)
          else:
             lowercase__:     Optional[Any]      =   code.replace(co_filename=_UpperCAmelCase							)
          return FunctionType(_UpperCAmelCase					,    func.__globals__					,    func.__name__					,    func.__defaults__					,    func.__closure__							)

       lowercase__,				lowercase__:     Any      =   '''<ipython-input-2-e0383a102aae>''', [0]
       lowercase__:     int      =   mda(datasets.utils.py_utils.dumps(create_ipython_func(_UpperCAmelCase					,    _UpperCAmelCase							)							)							).hexdigest()
       lowercase__,				lowercase__:     str      =   '''<ipython-input-2-e0383a102aae>''', [1]
       lowercase__:     List[str]      =   mda(datasets.utils.py_utils.dumps(create_ipython_func(_UpperCAmelCase					,    _UpperCAmelCase							)							)							).hexdigest()
       lowercase__,				lowercase__:     List[str]      =   '''<ipython-input-5-713f6613acf3>''', [0]
       lowercase__:     Tuple      =   mda(datasets.utils.py_utils.dumps(create_ipython_func(_UpperCAmelCase					,    _UpperCAmelCase							)							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)

       lowercase__,				lowercase__:     Optional[Any]      =   os.path.join(gettempdir()					,    '''ipykernel_12345'''					,    '''321456789.py'''							), [0]
       lowercase__:     Dict      =   mda(datasets.utils.py_utils.dumps(create_ipython_func(_UpperCAmelCase					,    _UpperCAmelCase							)							)							).hexdigest()
       lowercase__,				lowercase__:     Union[str, Any]      =   os.path.join(gettempdir()					,    '''ipykernel_12345'''					,    '''321456789.py'''							), [1]
       lowercase__:     Union[str, Any]      =   mda(datasets.utils.py_utils.dumps(create_ipython_func(_UpperCAmelCase					,    _UpperCAmelCase							)							)							).hexdigest()
       lowercase__,				lowercase__:     Union[str, Any]      =   os.path.join(gettempdir()					,    '''ipykernel_12345'''					,    '''654123987.py'''							), [0]
       lowercase__:     Optional[Any]      =   mda(datasets.utils.py_utils.dumps(create_ipython_func(_UpperCAmelCase					,    _UpperCAmelCase							)							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    def _snake_case    (     self							):
       lowercase__,				lowercase__:     str      =   [0], [1]

       def func():
          return foo, bar

       lowercase__:     Any      =   '''__main__'''

       def globalvars_mocka_side_effect(_UpperCAmelCase					,    *_UpperCAmelCase					,    **_UpperCAmelCase							):
          return {"foo": foo, "bar": bar}

       def globalvars_mocka_side_effect(_UpperCAmelCase					,    *_UpperCAmelCase					,    **_UpperCAmelCase							):
          return {"bar": bar, "foo": foo}

       with patch('''dill.detect.globalvars'''					,    side_effect=_UpperCAmelCase							) as globalvars_mocka:
          lowercase__:     Tuple      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
          self.assertGreater(globalvars_mocka.call_count					,    0							)
       with patch('''dill.detect.globalvars'''					,    side_effect=_UpperCAmelCase							) as globalvars_mocka:
          lowercase__:     Optional[int]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
          self.assertGreater(globalvars_mocka.call_count					,    0							)
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)



class 					UpperCAmelCase		(_UpperCAmelCase						):



    """simple docstring"""

    def _snake_case    (     self							):
       lowercase__:     List[Any]      =   Hasher.hash('''hello'''							)
       lowercase__:     int      =   Hasher.hash('''hello'''							)
       lowercase__:     List[Any]      =   Hasher.hash('''there'''							)
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    def _snake_case    (     self							):
       lowercase__:     str      =   Hasher.hash(Foo('''hello'''							)							)
       lowercase__:     List[Any]      =   Hasher.hash(Foo('''hello'''							)							)
       lowercase__:     Union[str, Any]      =   Hasher.hash(Foo('''there'''							)							)
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    def _snake_case    (     self							):
       lowercase__:     Tuple      =   Hasher()
       for x in ["hello", Foo('''hello'''							)]:
          hasher.update(_UpperCAmelCase							)
       lowercase__:     Optional[Any]      =   hasher.hexdigest()
       lowercase__:     Optional[Any]      =   Hasher()
       for x in ["hello", Foo('''hello'''							)]:
          hasher.update(_UpperCAmelCase							)
       lowercase__:     Dict      =   hasher.hexdigest()
       lowercase__:     str      =   Hasher()
       for x in ["there", Foo('''there'''							)]:
          hasher.update(_UpperCAmelCase							)
       lowercase__:     int      =   hasher.hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    def _snake_case    (     self							):
       with self.assertRaises(pickle.PicklingError							):
          Hasher.hash(UnpicklableCallable(Foo('''hello'''							)							)							)






    def _snake_case    (     self							):
       lowercase__:     int      =   '''abc'''
       lowercase__:     Optional[int]      =   [string, string]  # two strings have the same ids
       lowercase__:     Optional[int]      =   [string, string]
       lowercase__:     int      =   json.loads(F"""[\"{string}\", \"{string}\"]"""							)  # two strings have different ids
       self.assertIs(obja[0]					,    _UpperCAmelCase							)
       self.assertIs(obja[0]					,    obja[1]							)
       self.assertIs(obja[0]					,    _UpperCAmelCase							)
       self.assertIs(obja[0]					,    obja[1]							)
       self.assertIsNot(obja[0]					,    _UpperCAmelCase							)
       self.assertIsNot(obja[0]					,    obja[1]							)
       lowercase__:     Optional[int]      =   Hasher.hash(_UpperCAmelCase							)
       lowercase__:     int      =   Hasher.hash(_UpperCAmelCase							)
       lowercase__:     Dict      =   Hasher.hash(_UpperCAmelCase							)
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    @require_tiktoken
    def _snake_case    (     self							):
       import tiktoken

       lowercase__:     Optional[int]      =   tiktoken.get_encoding('''gpt2'''							)
       lowercase__:     Tuple      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     int      =   tiktoken.get_encoding('''r50k_base'''							)
       lowercase__:     int      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     Tuple      =   tiktoken.get_encoding('''gpt2'''							)
       lowercase__:     List[str]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    @require_torch
    def _snake_case    (     self							):
       import torch

       lowercase__:     Dict      =   torch.tensor([1.0]							)
       lowercase__:     Tuple      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     Optional[Any]      =   torch.tensor([2.0]							)
       lowercase__:     Tuple      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     Any      =   torch.tensor([1.0]							)
       lowercase__:     Dict      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)






    @require_spacy
    @require_spacy_model('''en_core_web_sm'''							)
    @require_spacy_model('''fr_core_news_sm'''							)
    @pytest.mark.integration
    def _snake_case    (     self							):
       import spacy

       lowercase__:     str      =   spacy.load('''en_core_web_sm'''							)
       lowercase__:     List[str]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     Union[str, Any]      =   spacy.load('''fr_core_news_sm'''							)
       lowercase__:     int      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       lowercase__:     str      =   spacy.load('''en_core_web_sm'''							)
       lowercase__:     Union[str, Any]      =   mda(datasets.utils.py_utils.dumps(_UpperCAmelCase							)							).hexdigest()
       self.assertEqual(_UpperCAmelCase					,    _UpperCAmelCase							)
       self.assertNotEqual(_UpperCAmelCase					,    _UpperCAmelCase							)



@pytest.mark.integration
def SCREAMING_SNAKE_CASE__    (     __UpperCAmelCase				)						->						int:
   lowercase__:     Any      =   tmp_path / '''dir1'''
   lowercase__:     Optional[int]      =   tmp_path / '''dir2'''
   dira.mkdir()
   dira.mkdir()
   lowercase__:     Union[str, Any]      =   '''script.py'''
   lowercase__:     Any      =   dedent(
       '''
    from datasets.fingerprint import Hasher
    def foo():
        pass
    print(Hasher.hash(foo))
    '''				)
   lowercase__:     Tuple      =   dira / script_filename
   lowercase__:     Dict      =   dira / script_filename
   with script_patha.open('''w'''				) as f:
      f.write(__UpperCAmelCase				)
   with script_patha.open('''w'''				) as f:
      f.write(__UpperCAmelCase				)
   lowercase__:     int      =   subprocess.check_output(['''python''', str(__UpperCAmelCase				)]				)
   lowercase__:     Optional[int]      =   subprocess.check_output(['''python''', str(__UpperCAmelCase				)]				)
   assert fingerprinta == fingerprinta



def SCREAMING_SNAKE_CASE__    (     )						->						str:
   lowercase__:     int      =   {'''a''': [0, 1, 2]}
   lowercase__:     Any      =   DatasetChild(InMemoryTable.from_pydict(__UpperCAmelCase				)				)
   lowercase__:     Dict      =   dataset.funca()._fingerprint
   assert expected_fingerprint == dataset.funca()._fingerprint
   assert expected_fingerprint != dataset.funca()._fingerprint

   with Pool(2				) as p:
      assert expected_fingerprint == p.apply_async(dataset.funca				).get()._fingerprint
      assert expected_fingerprint != p.apply_async(dataset.funca				).get()._fingerprint



def SCREAMING_SNAKE_CASE__    (     )						->						List[str]:
   lowercase__:     Tuple      =   {'''a''': [0, 1, 2]}


   class 					UpperCAmelCase		(datasets.Dataset						):



       """simple docstring"""

       @fingerprint_transform(inplace=_UpperCAmelCase							)
       def _snake_case    (     self					,    _UpperCAmelCase							):
          return DummyDatasetChild(self.data					,    fingerprint=_UpperCAmelCase							)



   lowercase__:     Dict      =   DummyDatasetChild(InMemoryTable.from_pydict(__UpperCAmelCase				)				).func()


   class 					UpperCAmelCase		(datasets.Dataset						):



       """simple docstring"""

       @fingerprint_transform(inplace=_UpperCAmelCase					,    version='''1.0.0'''							)
       def _snake_case    (     self					,    _UpperCAmelCase							):
          return DummyDatasetChild(self.data					,    fingerprint=_UpperCAmelCase							)



   lowercase__:     str      =   DummyDatasetChild(InMemoryTable.from_pydict(__UpperCAmelCase				)				).func()


   class 					UpperCAmelCase		(datasets.Dataset						):



       """simple docstring"""

       @fingerprint_transform(inplace=_UpperCAmelCase					,    version='''2.0.0'''							)
       def _snake_case    (     self					,    _UpperCAmelCase							):
          return DummyDatasetChild(self.data					,    fingerprint=_UpperCAmelCase							)



   lowercase__:     Union[str, Any]      =   DummyDatasetChild(InMemoryTable.from_pydict(__UpperCAmelCase				)				).func()

   assert len({fingeprint_no_version, fingeprint_a, fingeprint_a}				) == 3




def SCREAMING_SNAKE_CASE__    (     )						->						Union[str, Any]:
   # AttributeError: module 'dill._dill' has no attribute 'stack'
   lowercase__:     str      =   Hasher()
   hasher.update(lambda __UpperCAmelCase				: x				)

"""simple docstring"""






def SCREAMING_SNAKE_CASE__    (     __UpperCAmelCase = 1_0_0_0				)						->						int:
   lowercase__:     Union[str, Any]      =   0
   lowercase__:     Any      =   0
   while 1:
      num += 3
      if num >= n:
         break
      total += num
      num += 2
      if num >= n:
         break
      total += num
      num += 1
      if num >= n:
         break
      total += num
      num += 3
      if num >= n:
         break
      total += num
      num += 1
      if num >= n:
         break
      total += num
      num += 2
      if num >= n:
         break
      total += num
      num += 3
      if num >= n:
         break
      total += num
   return total


if __name__ == "__main__":
       print(f'''{solution() = }''')
