Day 12, a few hints:
1. Array is an object, so you can iterate it as you would iterate mapped types, which doesn't have stack overflow issues
2. The elements are a tuple, so you can quickly access the members by their indexes.
3. You can extract the numerical value by infering the numeric string.
1. Array is an object, so you can iterate it as you would iterate mapped types, which doesn't have stack overflow issues
2. The elements are a tuple, so you can quickly access the members by their indexes.
3. You can extract the numerical value by infering the numeric string.
Comments
To enforce an invariant, we need to apply `out` to enforce contravariance and `in` to enfore covariance to the generic type.
To get the return type, we can `infer` it.
Since I don't want to deal with some funny cases, I just implemented hacky helper functions to deal with it (don't do this 😂)
To avoid type narrowing for string utilities, we can recast it using string utility types.
The trick is to assert whether the generic is provided or not. If it's not provided, access the array element. Otherwise, return the generic as-is.