ghaiklor / type-challenges-solutions

Solutions for the collection of TypeScript type challenges with explanations
https://ghaiklor.github.io/type-challenges-solutions/
Creative Commons Attribution 4.0 International
470 stars 56 forks source link

type-challenges-solutions/en/medium-minusone #210

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

MinusOne

This project is aimed at helping you better understand how the type system works, writing your own utilities, or just having fun with the challenges.

https://ghaiklor.github.io/type-challenges-solutions/en/medium-minusone.html

cigui commented 2 years ago

Instead of appending a single element to the tuple on each recursive call, we can append more on each recursive call, which results in fewer recursive calls and passes the test. Check my solution for details: https://github.com/type-challenges/type-challenges/issues/10727

mefengl commented 1 year ago

https://github.com/type-challenges/type-challenges/issues/18456#issue-1432554106 use Tail recursion

zhaoyao91 commented 1 year ago

I wrote a short and long versions of solutions for this challenge with more explanation: https://github.com/type-challenges/type-challenges/issues/19437

中文笔记:https://juejin.cn/post/7167664060547203108/

gaac510 commented 1 year ago

Came up with two solutions. One works up to 9999, the other works up to 9_007_199_254_740_992. https://github.com/type-challenges/type-challenges/issues/21030#issue-1509235310