This solution is generated by ChatGPT, correctness is not guaranteed. You might also be able to find a solution fromcommunity posts.

# AI solution for TypeScript puzzle on BFE.dev 38. implement Add<A, B>

Here's one possible solution:

``type Add<A extends number, B extends number> = `\${A}\${B}` extends `\${infer First}\${infer Rest}`  ? First extends keyof Sum    ? Sum[First] extends `\${infer Digit}`      ? `\${Digit}\${Add<Rest extends '' ? 0 : Rest, ''>}`      : never    : never  : never;type Sum = {  '0': '0',  '1': '1',  '2': '2',  '3': '3',  '4': '4',  '5': '5',  '6': '6',  '7': '7',  '8': '8',  '9': '9',  '10': '1',  '11': '2',  '12': '3',  '13': '4',  '14': '5',  '15': '6',  '16': '7',  '17': '8',  '18': '9',  '19': '10',  '20': '2',  '21': '3',  '22': '4',  '23': '5',  '24': '6',  '25': '7',  '26': '8',  '27': '9',  '28': '10',  '29': '11',  '30': '3',  '31': '4',  '32': '5',  '33': '6',  '34': '7',  '35': '8',  '36': '9',  '37': '10',  '38': '11',  '39': '12',  '40': '4',  // and so on...};``

This solution uses template literal types to concatenate the input numbers as strings, and then recursively adds the last digit of the sum to the result, along with a recursive call on the remaining digits, until there are no more digits left. The `Sum` type is used to define all possible two-digit sums as string literals, which allows us to map each possible pair of digits to its corresponding sum using the `keyof` operator.

Note that this solution assumes that both input numbers are positive and less than or equal to 99. It also assumes that the input numbers are represented as TypeScript literal types (i.e., they are not dynamic values that could change at runtime).