Skip to content

Commit

Permalink
chore: update index
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Mar 26, 2024
1 parent 821d739 commit 503c1b4
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.ja.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.ko.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.pt-BR.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.zh-CN.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions questions/32532-hard-binary-addition/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--info-header-start--><h1>Binary Addition <img src="https://img.shields.io/badge/-hard-de3d37" alt="hard"/> <img src="https://img.shields.io/badge/-%23recursion-999" alt="#recursion"/> <img src="https://img.shields.io/badge/-%23array-999" alt="#array"/></h1><blockquote><p>by Finley Garton <a href="https://github.com/finleygn" target="_blank">@finleygn</a></p></blockquote><p><a href="https://tsch.js.org/32532/play" target="_blank"><img src="https://img.shields.io/badge/-Take%20the%20Challenge-3178c6?logo=typescript&logoColor=white" alt="Take the Challenge"/></a> </p><!--info-header-end-->

Implement `BinaryAdd` to add two binary numbers together. The numbers should not be translated out of binary at any point.

Note the two inputs will always have the same length.


<!--info-footer-start--><br><a href="../../README.md" target="_blank"><img src="https://img.shields.io/badge/-Back-grey" alt="Back"/></a> <a href="https://tsch.js.org/32532/answer" target="_blank"><img src="https://img.shields.io/badge/-Share%20your%20Solutions-teal" alt="Share your Solutions"/></a> <a href="https://tsch.js.org/32532/solutions" target="_blank"><img src="https://img.shields.io/badge/-Check%20out%20Solutions-de5a77?logo=awesome-lists&logoColor=white" alt="Check out Solutions"/></a> <!--info-footer-end-->
1 change: 0 additions & 1 deletion questions/32532-hard-binary-addition/info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ tags: recursion, array
author:
github: finleygn
name: Finley Garton

4 changes: 2 additions & 2 deletions questions/32532-hard-binary-addition/template.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
type Bit = 1 | 0;
type Bit = 1 | 0

type BinaryAdd<A extends Bit[], B extends Bit[]> = any;
type BinaryAdd<A extends Bit[], B extends Bit[]> = any
20 changes: 10 additions & 10 deletions questions/32532-hard-binary-addition/test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import type { Equal, Expect } from '@type-challenges/utils'

type cases = [
Expect<Equal<
BinaryAdd<[1],[1]>,
[1,0]
BinaryAdd<[1], [1]>,
[1, 0]
>>,
Expect<Equal<
BinaryAdd<[0],[1]>,
BinaryAdd<[0], [1]>,
[1]
>>,
Expect<Equal<
BinaryAdd<[1,1,0],[0,0,1]>,
[1,1,1]
BinaryAdd<[1, 1, 0], [0, 0, 1]>,
[1, 1, 1]
>>,
Expect<Equal<
BinaryAdd<[1,1,1,1,1,1,1,1,1,1,1,1,1],[1,1,1,1,1,1,1,1,1,1,1,1,1]>,
[1,1,1,1,1,1,1,1,1,1,1,1,1,0]
BinaryAdd<[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]>,
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]
>>,
Expect<Equal<
BinaryAdd<[1,0,1,0,1,1,1,0],[1,0,0,0,1,1,0,0]>,
[1,0,0,1,1,1,0,1,0]
>>,
BinaryAdd<[1, 0, 1, 0, 1, 1, 1, 0], [1, 0, 0, 0, 1, 1, 0, 0]>,
[1, 0, 0, 1, 1, 1, 0, 1, 0]
>>,
]

0 comments on commit 503c1b4

Please sign in to comment.