Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7561 - Subtract #14578

Open
Sliect opened this issue Aug 17, 2022 · 0 comments
Open

7561 - Subtract #14578

Sliect opened this issue Aug 17, 2022 · 0 comments
Labels
7561 answer Share answers/solutions to a question en in English

Comments

@Sliect
Copy link

Sliect commented Aug 17, 2022

// your answers
type Rang<T extends Number = 0, P extends 1[] = []> =
  P['length'] extends T ?
    P : Rang<T, [1, ...P]>
type Shift<T extends 1[]> = T extends [infer F, ...infer Rest] ? Rest : []
type Subtract<M extends number, S extends number, L extends 1[] = Rang<M>, R extends 1[] = Rang<S>> = 
  L['length'] extends 0
    ? R['length'] extends 0
      ? 0
      : never
    : R['length'] extends 0
      ? L['length']
      : Subtract<M, S, Shift<L>, Shift<R>>
@Sliect Sliect added answer Share answers/solutions to a question en in English labels Aug 17, 2022
@github-actions github-actions bot added the 7561 label Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7561 answer Share answers/solutions to a question en in English
Projects
None yet
Development

No branches or pull requests

1 participant