Created
October 30, 2021 00:02
-
-
Save samkingco/1dbae7db9894b3af05881b81c351fcae to your computer and use it in GitHub Desktop.
Create designs for the T83 NFT project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function gridToPairOfUint160(grid) { | |
| let gridR = grid.map((_, index) => [grid].map((row) => row[index]).reverse()); | |
| let grid2R = gridR[0].map((_, index) => | |
| gridR.map((row) => row[index]).reverse() | |
| )[0]; | |
| let leftPart = 0n; | |
| let rightPart = 0n; | |
| for (let i = 0; i < 14; i++) { | |
| for (let j = 0; j < 22; j++) { | |
| const power = BigInt(13 - i) + 14n * BigInt(j % 11); | |
| const diff = grid2R[i][j] ? 2n ** power : 0n; | |
| if (j < 11) { | |
| leftPart += diff; | |
| } else { | |
| rightPart += diff; | |
| } | |
| } | |
| } | |
| const leftCode = leftPart.toString(); | |
| const rightCode = rightPart.toString(); | |
| return `${leftCode}, ${rightCode}`; | |
| } | |
| const design = [ | |
| [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], | |
| [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], | |
| [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | |
| [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0], | |
| ]; | |
| const grid = design.map((row) => row.map((i) => i === 1)); | |
| console.log(gridToPairOfUint160(grid)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment