How to use solved method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

ps.ts

Source:ps.ts Github

copy

Full Screen

1type SomeType =2 | {3 maze: Array<Array<string>>;4 direction: "^" | "<" | "v" | ">";5 from: [number, number];6 movements: Array<string>;7 }8 | false;9function checker(maze: Array<Array<string>>, from: [number, number]) {10 if (from[0] === 0) {11 return true;12 } else if (from[1] === 0) {13 return true;14 } else if (from[0] === maze.length - 1) {15 return true;16 } else if (from[1] === maze[0].length - 1) {17 return true;18 }19 return false;20}21const handleClick = (solvedMaze: Array<Array<string>>) => {22 // solvedMaze=([...maze]);23 function handlingMaze(24 direction: "^" | "<" | "v" | ">" = "<",25 directions: ["^", "<", "v", ">"] = ["^", "<", "v", ">"],26 from: [number, number],27 movements: Array<string> = [],28 memo: { [key: string]: Array<string> | boolean } = {}29 ): SomeType {30 let z = 0;31 while (from !== [0, 0]) {32 if (z > 3) {33 if (checker(solvedMaze, from))34 return { from, movements, direction, maze: solvedMaze };35 return false;36 }37 if (38 from[0] >= 0 &&39 from[0] < solvedMaze.length &&40 from[1] >= 0 &&41 from[1] < solvedMaze[from[0]].length &&42 direction === "^"43 ) {44 if (solvedMaze[from[0]][from[1]] === " ") {45 if (46 from[0] >= 0 &&47 from[0] < solvedMaze.length &&48 from[1] >= 0 &&49 from[1] < solvedMaze[from[0]].length50 ) {51 solvedMaze[from[0]][from[1]] = direction;52 solvedMaze = [...solvedMaze];53 }54 }55 if (from[0] - 1 >= 0 && solvedMaze[from[0] - 1][from[1]] === " ") {56 from[0] -= 1;57 if (58 from[0] >= 0 &&59 from[0] < solvedMaze.length &&60 from[1] >= 0 &&61 from[1] < solvedMaze[from[0]].length62 ) {63 solvedMaze[from[0]][from[1]] = direction;64 solvedMaze = [...solvedMaze];65 }66 movements.push("F");67 z = 0;68 if (from[1] - 1 >= 0 && solvedMaze[from[0]][from[1] - 1] === " ") {69 if (!(JSON.stringify(solvedMaze) in memo)) {70 const res: SomeType = handlingMaze(71 directions[1],72 directions,73 [from[0], from[1] - 1],74 [...movements, "L", "F"],75 memo76 );77 if (res) {78 movements = res.movements;79 solvedMaze = [...res.maze];80 if (81 from[0] >= 0 &&82 from[0] < solvedMaze.length &&83 from[1] >= 0 &&84 from[1] < solvedMaze[from[0]].length85 ) {86 solvedMaze[from[0]][from[1]] = direction;87 solvedMaze = [...solvedMaze];88 }89 memo[JSON.stringify(solvedMaze)] = movements;90 direction = res.direction;91 from = res.from;92 } else {93 memo[JSON.stringify(solvedMaze)] = false;94 }95 }96 }97 if (98 from[1] + 1 < solvedMaze[0].length &&99 solvedMaze[from[0]][from[1] + 1] === " "100 ) {101 if (!(JSON.stringify(solvedMaze) in memo)) {102 const res: SomeType = handlingMaze(103 directions[3],104 directions,105 [from[0], from[1] + 1],106 [...movements, "R", "F"],107 memo108 );109 if (res) {110 movements = res.movements;111 solvedMaze = [...res.maze];112 if (113 from[0] >= 0 &&114 from[0] < solvedMaze.length &&115 from[1] >= 0 &&116 from[1] < solvedMaze[from[0]].length117 ) {118 solvedMaze[from[0]][from[1]] = direction;119 solvedMaze = [...solvedMaze];120 }121 memo[JSON.stringify(solvedMaze)] = movements;122 direction = res.direction;123 from = res.from;124 } else {125 memo[JSON.stringify(solvedMaze)] = false;126 }127 }128 }129 if (130 from[0] + 1 < solvedMaze.length &&131 solvedMaze[from[0] + 1][from[1]] === " "132 ) {133 if (!(JSON.stringify(solvedMaze) in memo)) {134 const res: SomeType = handlingMaze(135 directions[2],136 directions,137 [from[0] + 1, from[1]],138 [...movements, "B", "F"],139 memo140 );141 if (res) {142 movements = res.movements;143 solvedMaze = [...res.maze];144 if (145 from[0] >= 0 &&146 from[0] < solvedMaze.length &&147 from[1] >= 0 &&148 from[1] < solvedMaze[from[0]].length149 ) {150 solvedMaze[from[0]][from[1]] = direction;151 solvedMaze = [...solvedMaze];152 }153 memo[JSON.stringify(solvedMaze)] = movements;154 direction = res.direction;155 from = res.from;156 } else {157 memo[JSON.stringify(solvedMaze)] = false;158 }159 }160 }161 } else if (162 from[1] - 1 >= 0 &&163 solvedMaze[from[0]][from[1] - 1] === " "164 ) {165 from[1] -= 1;166 direction = directions[1];167 movements = [...movements, "L", "F"];168 } else if (169 from[1] + 1 < solvedMaze[0].length &&170 solvedMaze[from[0]][from[1] + 1] === " "171 ) {172 from[1] += 1;173 direction = directions[3];174 movements = [...movements, "R", "F"];175 z = 0;176 } else if (177 from[0] + 1 < solvedMaze.length &&178 solvedMaze[from[0] + 1][from[1]] === " "179 ) {180 from[0] += 1;181 direction = directions[2];182 movements = [...movements, "B", "F"];183 z = 0;184 }185 }186 if (187 from[0] >= 0 &&188 from[0] < solvedMaze.length &&189 from[1] >= 0 &&190 from[1] < solvedMaze[from[0]].length &&191 direction === ">"192 ) {193 if (solvedMaze[from[0]][from[1]] === " ") {194 if (195 from[0] >= 0 &&196 from[0] < solvedMaze.length &&197 from[1] >= 0 &&198 from[1] < solvedMaze[from[0]].length199 ) {200 solvedMaze[from[0]][from[1]] = direction;201 solvedMaze = [...solvedMaze];202 }203 }204 if (205 from[1] + 1 < solvedMaze[0].length &&206 solvedMaze[from[0]][from[1] + 1] === " "207 ) {208 from[1] += 1;209 if (210 from[0] >= 0 &&211 from[0] < solvedMaze.length &&212 from[1] >= 0 &&213 from[1] < solvedMaze[from[0]].length214 ) {215 solvedMaze[from[0]][from[1]] = direction;216 solvedMaze = [...solvedMaze];217 }218 movements.push("F");219 z = 0;220 if (from[0] - 1 >= 0 && solvedMaze[from[0] - 1][from[1]] === " ") {221 if (!(JSON.stringify(solvedMaze) in memo)) {222 const res: SomeType = handlingMaze(223 directions[0],224 directions,225 [from[0] - 1, from[1]],226 [...movements, "L", "F"],227 memo228 );229 if (res) {230 movements = res.movements;231 solvedMaze = [...res.maze];232 if (233 from[0] >= 0 &&234 from[0] < solvedMaze.length &&235 from[1] >= 0 &&236 from[1] < solvedMaze[from[0]].length237 ) {238 solvedMaze[from[0]][from[1]] = direction;239 solvedMaze = [...solvedMaze];240 }241 memo[JSON.stringify(solvedMaze)] = movements;242 direction = res.direction;243 from = res.from;244 } else {245 memo[JSON.stringify(solvedMaze)] = false;246 }247 }248 }249 if (250 from[0] + 1 < solvedMaze.length &&251 solvedMaze[from[0] + 1][from[1]] === " "252 ) {253 if (!(JSON.stringify(solvedMaze) in memo)) {254 const res: SomeType = handlingMaze(255 directions[2],256 directions,257 [from[0] + 1, from[1]],258 [...movements, "R", "F"],259 memo260 );261 if (res) {262 movements = res.movements;263 solvedMaze = [...res.maze];264 if (265 from[0] >= 0 &&266 from[0] < solvedMaze.length &&267 from[1] >= 0 &&268 from[1] < solvedMaze[from[0]].length269 ) {270 solvedMaze[from[0]][from[1]] = direction;271 solvedMaze = [...solvedMaze];272 }273 memo[JSON.stringify(solvedMaze)] = movements;274 direction = res.direction;275 from = res.from;276 } else {277 memo[JSON.stringify(solvedMaze)] = false;278 }279 }280 }281 if (from[1] - 1 >= 0 && solvedMaze[from[0]][from[1] - 1] === " ") {282 if (!(JSON.stringify(solvedMaze) in memo)) {283 const res: SomeType = handlingMaze(284 directions[1],285 directions,286 [from[0], from[1] - 1],287 [...movements, "B", "F"],288 memo289 );290 if (res) {291 movements = res.movements;292 solvedMaze = [...res.maze];293 if (294 from[0] >= 0 &&295 from[0] < solvedMaze.length &&296 from[1] >= 0 &&297 from[1] < solvedMaze[from[0]].length298 ) {299 solvedMaze[from[0]][from[1]] = direction;300 solvedMaze = [...solvedMaze];301 }302 memo[JSON.stringify(solvedMaze)] = movements;303 direction = res.direction;304 from = res.from;305 } else {306 memo[JSON.stringify(solvedMaze)] = false;307 }308 }309 }310 } else if (311 from[0] - 1 >= 0 &&312 solvedMaze[from[0] - 1][from[1]] === " "313 ) {314 from[0] -= 1;315 direction = directions[0];316 movements = [...movements, "L", "F"];317 } else if (318 from[0] + 1 < solvedMaze.length &&319 solvedMaze[from[0] + 1][from[1]] === " "320 ) {321 from[0] += 1;322 direction = directions[2];323 movements = [...movements, "R", "F"];324 z = 0;325 } else if (326 from[1] - 1 >= 0 &&327 solvedMaze[from[0]][from[1] - 1] === " "328 ) {329 from[1] -= 1;330 direction = directions[1];331 movements = [...movements, "B", "F"];332 z = 0;333 }334 }335 if (336 from[0] >= 0 &&337 from[0] < solvedMaze.length &&338 from[1] >= 0 &&339 from[1] < solvedMaze[from[0]].length &&340 direction === "v"341 ) {342 // ! ["^", "<", "v", ">"]343 if (solvedMaze[from[0]][from[1]] === " ") {344 if (345 from[0] >= 0 &&346 from[0] < solvedMaze.length &&347 from[1] >= 0 &&348 from[1] < solvedMaze[from[0]].length349 ) {350 solvedMaze[from[0]][from[1]] = direction;351 solvedMaze = [...solvedMaze];352 }353 }354 if (355 from[0] + 1 < solvedMaze.length &&356 solvedMaze[from[0] + 1][from[1]] === " "357 ) {358 from[0] += 1;359 if (360 from[0] >= 0 &&361 from[0] < solvedMaze.length &&362 from[1] >= 0 &&363 from[1] < solvedMaze[from[0]].length364 ) {365 solvedMaze[from[0]][from[1]] = direction;366 solvedMaze = [...solvedMaze];367 }368 movements.push("F");369 z = 0;370 if (371 from[1] + 1 < solvedMaze[0].length &&372 solvedMaze[from[0]][from[1] + 1] === " "373 ) {374 if (!(JSON.stringify(solvedMaze) in memo)) {375 const res: SomeType = handlingMaze(376 directions[3],377 directions,378 [from[0], from[1] + 1],379 [...movements, "L", "F"],380 memo381 );382 if (res) {383 movements = res.movements;384 solvedMaze = [...res.maze];385 if (386 from[0] >= 0 &&387 from[0] < solvedMaze.length &&388 from[1] >= 0 &&389 from[1] < solvedMaze[from[0]].length390 ) {391 solvedMaze[from[0]][from[1]] = direction;392 solvedMaze = [...solvedMaze];393 }394 memo[JSON.stringify(solvedMaze)] = movements;395 direction = res.direction;396 from = res.from;397 } else {398 memo[JSON.stringify(solvedMaze)] = false;399 }400 }401 }402 if (from[1] - 1 >= 0 && solvedMaze[from[0]][from[1] - 1] === " ") {403 if (!(JSON.stringify(solvedMaze) in memo)) {404 const res: SomeType = handlingMaze(405 directions[1],406 directions,407 [from[0], from[1] - 1],408 [...movements, "R", "F"],409 memo410 );411 if (res) {412 movements = res.movements;413 solvedMaze = [...res.maze];414 if (415 from[0] >= 0 &&416 from[0] < solvedMaze.length &&417 from[1] >= 0 &&418 from[1] < solvedMaze[from[0]].length419 ) {420 solvedMaze[from[0]][from[1]] = direction;421 solvedMaze = [...solvedMaze];422 }423 memo[JSON.stringify(solvedMaze)] = movements;424 direction = res.direction;425 from = res.from;426 } else {427 memo[JSON.stringify(solvedMaze)] = false;428 }429 }430 }431 if (from[0] - 1 >= 0 && solvedMaze[from[0] - 1][from[1]] === " ") {432 if (!(JSON.stringify(solvedMaze) in memo)) {433 const res: SomeType = handlingMaze(434 directions[0],435 directions,436 [from[0] - 1, from[1]],437 [...movements, "B", "F"],438 memo439 );440 if (res) {441 movements = res.movements;442 solvedMaze = [...res.maze];443 if (444 from[0] >= 0 &&445 from[0] < solvedMaze.length &&446 from[1] >= 0 &&447 from[1] < solvedMaze[from[0]].length448 ) {449 solvedMaze[from[0]][from[1]] = direction;450 solvedMaze = [...solvedMaze];451 }452 memo[JSON.stringify(solvedMaze)] = movements;453 direction = res.direction;454 from = res.from;455 } else {456 memo[JSON.stringify(solvedMaze)] = false;457 }458 }459 }460 } else if (461 from[1] + 1 < solvedMaze[0].length &&462 solvedMaze[from[0]][from[1] + 1] === " "463 ) {464 from[1] += 1;465 direction = directions[3];466 movements = [...movements, "L", "F"];467 } else if (468 from[1] - 1 >= 0 &&469 solvedMaze[from[0]][from[1] - 1] === " "470 ) {471 from[1] -= 1;472 direction = directions[1];473 movements = [...movements, "R", "F"];474 z = 0;475 } else if (476 from[0] - 1 >= 0 &&477 solvedMaze[from[0] - 1][from[1]] === " "478 ) {479 from[0] -= 1;480 direction = directions[0];481 movements = [...movements, "B", "F"];482 z = 0;483 }484 }485 if (486 from[0] >= 0 &&487 from[0] < solvedMaze.length &&488 from[1] >= 0 &&489 from[1] < solvedMaze[from[0]].length &&490 direction === "<"491 ) {492 // ! ["^", "<", "v", ">"]493 if (solvedMaze[from[0]][from[1]] === " ") {494 if (495 from[0] >= 0 &&496 from[0] < solvedMaze.length &&497 from[1] >= 0 &&498 from[1] < solvedMaze[from[0]].length499 ) {500 solvedMaze[from[0]][from[1]] = direction;501 solvedMaze = [...solvedMaze];502 }503 }504 if (from[1] - 1 >= 0 && solvedMaze[from[0]][from[1] - 1] === " ") {505 from[1] -= 1;506 if (507 from[0] >= 0 &&508 from[0] < solvedMaze.length &&509 from[1] >= 0 &&510 from[1] < solvedMaze[from[0]].length511 ) {512 solvedMaze[from[0]][from[1]] = direction;513 solvedMaze = [...solvedMaze];514 }515 movements.push("F");516 z = 0;517 if (518 from[0] + 1 < solvedMaze.length &&519 solvedMaze[from[0] + 1][from[1]] === " "520 ) {521 if (!(JSON.stringify(solvedMaze) in memo)) {522 const res: SomeType = handlingMaze(523 directions[2],524 directions,525 [from[0] + 1, from[1]],526 [...movements, "L", "F"],527 memo528 );529 if (res) {530 movements = res.movements;531 solvedMaze = [...res.maze];532 if (533 from[0] >= 0 &&534 from[0] < solvedMaze.length &&535 from[1] >= 0 &&536 from[1] < solvedMaze[from[0]].length537 ) {538 solvedMaze[from[0]][from[1]] = direction;539 solvedMaze = [...solvedMaze];540 }541 memo[JSON.stringify(solvedMaze)] = movements;542 direction = res.direction;543 from = res.from;544 } else {545 memo[JSON.stringify(solvedMaze)] = false;546 }547 }548 }549 if (from[0] - 1 >= 0 && solvedMaze[from[0] - 1][from[1]] === " ") {550 if (!(JSON.stringify(solvedMaze) in memo)) {551 const res: SomeType = handlingMaze(552 directions[0],553 directions,554 [from[0] - 1, from[1]],555 [...movements, "R", "F"],556 memo557 );558 if (res) {559 movements = res.movements;560 solvedMaze = [...res.maze];561 if (562 from[0] >= 0 &&563 from[0] < solvedMaze.length &&564 from[1] >= 0 &&565 from[1] < solvedMaze[from[0]].length566 ) {567 solvedMaze[from[0]][from[1]] = direction;568 solvedMaze = [...solvedMaze];569 }570 memo[JSON.stringify(solvedMaze)] = movements;571 direction = res.direction;572 from = res.from;573 } else {574 memo[JSON.stringify(solvedMaze)] = false;575 }576 }577 }578 if (579 from[1] + 1 < solvedMaze[0].length &&580 solvedMaze[from[0]][from[1] + 1] === " "581 ) {582 if (!(JSON.stringify(solvedMaze) in memo)) {583 const res: SomeType = handlingMaze(584 directions[3],585 directions,586 [from[0], from[1] + 1],587 [...movements, "B", "F"],588 memo589 );590 if (res) {591 movements = res.movements;592 solvedMaze = [...res.maze];593 if (594 from[0] >= 0 &&595 from[0] < solvedMaze.length &&596 from[1] >= 0 &&597 from[1] < solvedMaze[from[0]].length598 ) {599 solvedMaze[from[0]][from[1]] = direction;600 solvedMaze = [...solvedMaze];601 }602 memo[JSON.stringify(solvedMaze)] = movements;603 direction = res.direction;604 from = res.from;605 } else {606 memo[JSON.stringify(solvedMaze)] = false;607 }608 }609 }610 } else if (611 from[0] + 1 < solvedMaze.length &&612 solvedMaze[from[0] + 1][from[1]] === " "613 ) {614 from[0] += 1;615 direction = directions[2];616 movements = [...movements, "L", "F"];617 } else if (618 from[0] - 1 >= 0 &&619 solvedMaze[from[0] - 1][from[1]] === " "620 ) {621 from[0] -= 1;622 direction = directions[0];623 movements = [...movements, "R", "F"];624 z = 0;625 } else if (626 from[1] + 1 < solvedMaze[0].length &&627 solvedMaze[from[0]][from[1] + 1] === " "628 ) {629 from[1] += 1;630 direction = directions[3];631 movements = [...movements, "B", "F"];632 z = 0;633 }634 }635 z++;636 }637 return handlingMaze(direction, directions, from, movements, memo);638 }639 let direction: "^" | "<" | "v" | ">" = "<";640 let from: [number, number] = [0, 0];641 let movements: Array<string> = [];642 let memo: { [key: string]: Array<string> | boolean } = {};643 // Have a nice sleep ;)644 const directions: ["^", "<", "v", ">"] = ["^", "<", "v", ">"];645 for (let x = 0; x < solvedMaze.length; x++) {646 let y = -1;647 for (let i = 0; i < directions.length; i++) {648 y = solvedMaze[x].indexOf(directions[i]);649 if (y > -1) {650 from[0] = x;651 from[1] = y;652 break;653 }654 }655 if (y > -1) {656 from = [x, y];657 direction = solvedMaze[x][y] as typeof direction;658 break;659 }660 }661 let z = 0;662 while (from !== [0, 0]) {663 if (!(JSON.stringify(solvedMaze) in memo)) {664 const res: SomeType = handlingMaze(665 direction,666 directions,667 [from[0], from[1]],668 [...movements],669 memo670 );671 if (res) {672 movements = res.movements;673 solvedMaze = res.maze;674 direction = res.direction;675 from = res.from;676 if (677 from[0] >= 0 &&678 from[0] < solvedMaze.length &&679 from[1] >= 0 &&680 from[1] < solvedMaze[from[0]].length681 )682 solvedMaze[from[0]][from[1]] = direction;683 memo[JSON.stringify(solvedMaze)] = movements;684 if (checker(res.maze, res.from)) {685 return movements;686 }687 } else {688 memo[JSON.stringify(solvedMaze)] = true;689 }690 }691 if (z > 3) {692 if (checker(solvedMaze, from)) {693 return movements;694 }695 return;696 }697 z++;698 }699 return movements;700};...

Full Screen

Full Screen

solve.js

Source:solve.js Github

copy

Full Screen

1function checker(maze, from) {2 if (from[0] === 0) {3 return true;4 } else if (from[1] === 0) {5 return true;6 } else if (from[0] === maze.length - 1) {7 return true;8 } else if (from[1] === maze[0].length - 1) {9 return true;10 }11 return false;12}13const handleClick = (solvedMaze) => {14 // solvedMaze=([...maze]);15 function handlingMaze(16 direction = "<",17 directions = ["^", "<", "v", ">"],18 from,19 movements = [],20 memo = {}21 ) {22 let z = 0;23 while (from !== [0, 0]) {24 if (z > 1) {25 if (checker(solvedMaze, from))26 return { from, movements, direction, maze: solvedMaze };27 return false;28 }29 if (30 from[0] >= 0 &&31 from[0] < solvedMaze.length &&32 from[1] >= 0 &&33 from[1] < solvedMaze[from[0]].length &&34 direction === "^"35 ) {36 if (solvedMaze[from[0]][from[1]] === " ") {37 if (38 from[0] >= 0 &&39 from[0] < solvedMaze.length &&40 from[1] >= 0 &&41 from[1] < solvedMaze[from[0]].length42 ) {43 solvedMaze[from[0]][from[1]] = direction;44 solvedMaze = [...solvedMaze];45 }46 }47 if (from[0] - 1 >= 0 && solvedMaze[from[0] - 1][from[1]] === " ") {48 from[0] -= 1;49 if (50 from[0] >= 0 &&51 from[0] < solvedMaze.length &&52 from[1] >= 0 &&53 from[1] < solvedMaze[from[0]].length54 ) {55 solvedMaze[from[0]][from[1]] = direction;56 solvedMaze = [...solvedMaze];57 }58 movements.push("F");59 z = 0;60 if (from[1] - 1 >= 0 && solvedMaze[from[0]][from[1] - 1] === " ") {61 if (!(JSON.stringify(solvedMaze) in memo)) {62 const res = handlingMaze(63 directions[1],64 directions,65 [from[0], from[1] - 1],66 [...movements, "L", "F"],67 memo68 );69 if (res) {70 movements = res.movements;71 solvedMaze = [...res.maze];72 if (73 from[0] >= 0 &&74 from[0] < solvedMaze.length &&75 from[1] >= 0 &&76 from[1] < solvedMaze[from[0]].length77 ) {78 solvedMaze[from[0]][from[1]] = direction;79 solvedMaze = [...solvedMaze];80 }81 memo[JSON.stringify(solvedMaze)] = movements;82 direction = res.direction;83 from = res.from;84 } else {85 memo[JSON.stringify(solvedMaze)] = false;86 }87 }88 }89 if (90 from[1] + 1 < solvedMaze[0].length &&91 solvedMaze[from[0]][from[1] + 1] === " "92 ) {93 if (!(JSON.stringify(solvedMaze) in memo)) {94 const res = handlingMaze(95 directions[3],96 directions,97 [from[0], from[1] + 1],98 [...movements, "R", "F"],99 memo100 );101 if (res) {102 movements = res.movements;103 solvedMaze = [...res.maze];104 if (105 from[0] >= 0 &&106 from[0] < solvedMaze.length &&107 from[1] >= 0 &&108 from[1] < solvedMaze[from[0]].length109 ) {110 solvedMaze[from[0]][from[1]] = direction;111 solvedMaze = [...solvedMaze];112 }113 memo[JSON.stringify(solvedMaze)] = movements;114 direction = res.direction;115 from = res.from;116 } else {117 memo[JSON.stringify(solvedMaze)] = false;118 }119 }120 }121 if (122 from[0] + 1 < solvedMaze.length &&123 solvedMaze[from[0] + 1][from[1]] === " "124 ) {125 if (!(JSON.stringify(solvedMaze) in memo)) {126 const res = handlingMaze(127 directions[2],128 directions,129 [from[0] + 1, from[1]],130 [...movements, "B", "F"],131 memo132 );133 if (res) {134 movements = res.movements;135 solvedMaze = [...res.maze];136 if (137 from[0] >= 0 &&138 from[0] < solvedMaze.length &&139 from[1] >= 0 &&140 from[1] < solvedMaze[from[0]].length141 ) {142 solvedMaze[from[0]][from[1]] = direction;143 solvedMaze = [...solvedMaze];144 }145 memo[JSON.stringify(solvedMaze)] = movements;146 direction = res.direction;147 from = res.from;148 } else {149 memo[JSON.stringify(solvedMaze)] = false;150 }151 }152 }153 } else if (154 from[1] - 1 >= 0 &&155 solvedMaze[from[0]][from[1] - 1] === " "156 ) {157 from[1] -= 1;158 direction = directions[1];159 movements = [...movements, "L", "F"];160 } else if (161 from[1] + 1 < solvedMaze[0].length &&162 solvedMaze[from[0]][from[1] + 1] === " "163 ) {164 from[1] += 1;165 direction = directions[3];166 movements = [...movements, "R", "F"];167 z = 0;168 } else if (169 from[0] + 1 < solvedMaze.length &&170 solvedMaze[from[0] + 1][from[1]] === " "171 ) {172 from[0] += 1;173 direction = directions[2];174 movements = [...movements, "B", "F"];175 z = 0;176 }177 }178 if (179 from[0] >= 0 &&180 from[0] < solvedMaze.length &&181 from[1] >= 0 &&182 from[1] < solvedMaze[from[0]].length &&183 direction === ">"184 ) {185 if (solvedMaze[from[0]][from[1]] === " ") {186 if (187 from[0] >= 0 &&188 from[0] < solvedMaze.length &&189 from[1] >= 0 &&190 from[1] < solvedMaze[from[0]].length191 ) {192 solvedMaze[from[0]][from[1]] = direction;193 solvedMaze = [...solvedMaze];194 }195 }196 if (197 from[1] + 1 < solvedMaze[0].length &&198 solvedMaze[from[0]][from[1] + 1] === " "199 ) {200 from[1] += 1;201 if (202 from[0] >= 0 &&203 from[0] < solvedMaze.length &&204 from[1] >= 0 &&205 from[1] < solvedMaze[from[0]].length206 ) {207 solvedMaze[from[0]][from[1]] = direction;208 solvedMaze = [...solvedMaze];209 }210 movements.push("F");211 z = 0;212 if (from[0] - 1 >= 0 && solvedMaze[from[0] - 1][from[1]] === " ") {213 if (!(JSON.stringify(solvedMaze) in memo)) {214 const res = handlingMaze(215 directions[0],216 directions,217 [from[0] - 1, from[1]],218 [...movements, "L", "F"],219 memo220 );221 if (res) {222 movements = res.movements;223 solvedMaze = [...res.maze];224 if (225 from[0] >= 0 &&226 from[0] < solvedMaze.length &&227 from[1] >= 0 &&228 from[1] < solvedMaze[from[0]].length229 ) {230 solvedMaze[from[0]][from[1]] = direction;231 solvedMaze = [...solvedMaze];232 }233 memo[JSON.stringify(solvedMaze)] = movements;234 direction = res.direction;235 from = res.from;236 } else {237 memo[JSON.stringify(solvedMaze)] = false;238 }239 }240 }241 if (242 from[0] + 1 < solvedMaze.length &&243 solvedMaze[from[0] + 1][from[1]] === " "244 ) {245 if (!(JSON.stringify(solvedMaze) in memo)) {246 const res = handlingMaze(247 directions[2],248 directions,249 [from[0] + 1, from[1]],250 [...movements, "R", "F"],251 memo252 );253 if (res) {254 movements = res.movements;255 solvedMaze = [...res.maze];256 if (257 from[0] >= 0 &&258 from[0] < solvedMaze.length &&259 from[1] >= 0 &&260 from[1] < solvedMaze[from[0]].length261 ) {262 solvedMaze[from[0]][from[1]] = direction;263 solvedMaze = [...solvedMaze];264 }265 memo[JSON.stringify(solvedMaze)] = movements;266 direction = res.direction;267 from = res.from;268 } else {269 memo[JSON.stringify(solvedMaze)] = false;270 }271 }272 }273 if (from[1] - 1 >= 0 && solvedMaze[from[0]][from[1] - 1] === " ") {274 if (!(JSON.stringify(solvedMaze) in memo)) {275 const res = handlingMaze(276 directions[1],277 directions,278 [from[0], from[1] - 1],279 [...movements, "B", "F"],280 memo281 );282 if (res) {283 movements = res.movements;284 solvedMaze = [...res.maze];285 if (286 from[0] >= 0 &&287 from[0] < solvedMaze.length &&288 from[1] >= 0 &&289 from[1] < solvedMaze[from[0]].length290 ) {291 solvedMaze[from[0]][from[1]] = direction;292 solvedMaze = [...solvedMaze];293 }294 memo[JSON.stringify(solvedMaze)] = movements;295 direction = res.direction;296 from = res.from;297 } else {298 memo[JSON.stringify(solvedMaze)] = false;299 }300 }301 }302 } else if (303 from[0] - 1 >= 0 &&304 solvedMaze[from[0] - 1][from[1]] === " "305 ) {306 from[0] -= 1;307 direction = directions[0];308 movements = [...movements, "L", "F"];309 } else if (310 from[0] + 1 < solvedMaze.length &&311 solvedMaze[from[0] + 1][from[1]] === " "312 ) {313 from[0] += 1;314 direction = directions[2];315 movements = [...movements, "R", "F"];316 z = 0;317 } else if (318 from[1] - 1 >= 0 &&319 solvedMaze[from[0]][from[1] - 1] === " "320 ) {321 from[1] -= 1;322 direction = directions[1];323 movements = [...movements, "B", "F"];324 z = 0;325 }326 }327 if (328 from[0] >= 0 &&329 from[0] < solvedMaze.length &&330 from[1] >= 0 &&331 from[1] < solvedMaze[from[0]].length &&332 direction === "v"333 ) {334 // ! ["^", "<", "v", ">"]335 if (solvedMaze[from[0]][from[1]] === " ") {336 if (337 from[0] >= 0 &&338 from[0] < solvedMaze.length &&339 from[1] >= 0 &&340 from[1] < solvedMaze[from[0]].length341 ) {342 solvedMaze[from[0]][from[1]] = direction;343 solvedMaze = [...solvedMaze];344 }345 }346 if (347 from[0] + 1 < solvedMaze.length &&348 solvedMaze[from[0] + 1][from[1]] === " "349 ) {350 from[0] += 1;351 if (352 from[0] >= 0 &&353 from[0] < solvedMaze.length &&354 from[1] >= 0 &&355 from[1] < solvedMaze[from[0]].length356 ) {357 solvedMaze[from[0]][from[1]] = direction;358 solvedMaze = [...solvedMaze];359 }360 movements.push("F");361 z = 0;362 if (363 from[1] + 1 < solvedMaze[0].length &&364 solvedMaze[from[0]][from[1] + 1] === " "365 ) {366 if (!(JSON.stringify(solvedMaze) in memo)) {367 const res = handlingMaze(368 directions[3],369 directions,370 [from[0], from[1] + 1],371 [...movements, "L", "F"],372 memo373 );374 if (res) {375 movements = res.movements;376 solvedMaze = [...res.maze];377 if (378 from[0] >= 0 &&379 from[0] < solvedMaze.length &&380 from[1] >= 0 &&381 from[1] < solvedMaze[from[0]].length382 ) {383 solvedMaze[from[0]][from[1]] = direction;384 solvedMaze = [...solvedMaze];385 }386 memo[JSON.stringify(solvedMaze)] = movements;387 direction = res.direction;388 from = res.from;389 } else {390 memo[JSON.stringify(solvedMaze)] = false;391 }392 }393 }394 if (from[1] - 1 >= 0 && solvedMaze[from[0]][from[1] - 1] === " ") {395 if (!(JSON.stringify(solvedMaze) in memo)) {396 const res = handlingMaze(397 directions[1],398 directions,399 [from[0], from[1] - 1],400 [...movements, "R", "F"],401 memo402 );403 if (res) {404 movements = res.movements;405 solvedMaze = [...res.maze];406 if (407 from[0] >= 0 &&408 from[0] < solvedMaze.length &&409 from[1] >= 0 &&410 from[1] < solvedMaze[from[0]].length411 ) {412 solvedMaze[from[0]][from[1]] = direction;413 solvedMaze = [...solvedMaze];414 }415 memo[JSON.stringify(solvedMaze)] = movements;416 direction = res.direction;417 from = res.from;418 } else {419 memo[JSON.stringify(solvedMaze)] = false;420 }421 }422 }423 if (from[0] - 1 >= 0 && solvedMaze[from[0] - 1][from[1]] === " ") {424 if (!(JSON.stringify(solvedMaze) in memo)) {425 const res = handlingMaze(426 directions[0],427 directions,428 [from[0] - 1, from[1]],429 [...movements, "B", "F"],430 memo431 );432 if (res) {433 movements = res.movements;434 solvedMaze = [...res.maze];435 if (436 from[0] >= 0 &&437 from[0] < solvedMaze.length &&438 from[1] >= 0 &&439 from[1] < solvedMaze[from[0]].length440 ) {441 solvedMaze[from[0]][from[1]] = direction;442 solvedMaze = [...solvedMaze];443 }444 memo[JSON.stringify(solvedMaze)] = movements;445 direction = res.direction;446 from = res.from;447 } else {448 memo[JSON.stringify(solvedMaze)] = false;449 }450 }451 }452 } else if (453 from[1] + 1 < solvedMaze[0].length &&454 solvedMaze[from[0]][from[1] + 1] === " "455 ) {456 from[1] += 1;457 direction = directions[3];458 movements = [...movements, "L", "F"];459 } else if (460 from[1] - 1 >= 0 &&461 solvedMaze[from[0]][from[1] - 1] === " "462 ) {463 from[1] -= 1;464 direction = directions[1];465 movements = [...movements, "R", "F"];466 z = 0;467 } else if (468 from[0] - 1 >= 0 &&469 solvedMaze[from[0] - 1][from[1]] === " "470 ) {471 from[0] -= 1;472 direction = directions[0];473 movements = [...movements, "B", "F"];474 z = 0;475 }476 }477 if (478 from[0] >= 0 &&479 from[0] < solvedMaze.length &&480 from[1] >= 0 &&481 from[1] < solvedMaze[from[0]].length &&482 direction === "<"483 ) {484 // ! ["^", "<", "v", ">"]485 if (solvedMaze[from[0]][from[1]] === " ") {486 if (487 from[0] >= 0 &&488 from[0] < solvedMaze.length &&489 from[1] >= 0 &&490 from[1] < solvedMaze[from[0]].length491 ) {492 solvedMaze[from[0]][from[1]] = direction;493 solvedMaze = [...solvedMaze];494 }495 }496 if (from[1] - 1 >= 0 && solvedMaze[from[0]][from[1] - 1] === " ") {497 from[1] -= 1;498 if (499 from[0] >= 0 &&500 from[0] < solvedMaze.length &&501 from[1] >= 0 &&502 from[1] < solvedMaze[from[0]].length503 ) {504 solvedMaze[from[0]][from[1]] = direction;505 solvedMaze = [...solvedMaze];506 }507 movements.push("F");508 z = 0;509 if (510 from[0] + 1 < solvedMaze.length &&511 solvedMaze[from[0] + 1][from[1]] === " "512 ) {513 if (!(JSON.stringify(solvedMaze) in memo)) {514 const res = handlingMaze(515 directions[2],516 directions,517 [from[0] + 1, from[1]],518 [...movements, "L", "F"],519 memo520 );521 if (res) {522 movements = res.movements;523 solvedMaze = [...res.maze];524 if (525 from[0] >= 0 &&526 from[0] < solvedMaze.length &&527 from[1] >= 0 &&528 from[1] < solvedMaze[from[0]].length529 ) {530 solvedMaze[from[0]][from[1]] = direction;531 solvedMaze = [...solvedMaze];532 }533 memo[JSON.stringify(solvedMaze)] = movements;534 direction = res.direction;535 from = res.from;536 } else {537 memo[JSON.stringify(solvedMaze)] = false;538 }539 }540 }541 if (from[0] - 1 >= 0 && solvedMaze[from[0] - 1][from[1]] === " ") {542 if (!(JSON.stringify(solvedMaze) in memo)) {543 const res = handlingMaze(544 directions[0],545 directions,546 [from[0] - 1, from[1]],547 [...movements, "R", "F"],548 memo549 );550 if (res) {551 movements = res.movements;552 solvedMaze = [...res.maze];553 if (554 from[0] >= 0 &&555 from[0] < solvedMaze.length &&556 from[1] >= 0 &&557 from[1] < solvedMaze[from[0]].length558 ) {559 solvedMaze[from[0]][from[1]] = direction;560 solvedMaze = [...solvedMaze];561 }562 memo[JSON.stringify(solvedMaze)] = movements;563 direction = res.direction;564 from = res.from;565 } else {566 memo[JSON.stringify(solvedMaze)] = false;567 }568 }569 }570 if (571 from[1] + 1 < solvedMaze[0].length &&572 solvedMaze[from[0]][from[1] + 1] === " "573 ) {574 if (!(JSON.stringify(solvedMaze) in memo)) {575 const res = handlingMaze(576 directions[3],577 directions,578 [from[0], from[1] + 1],579 [...movements, "B", "F"],580 memo581 );582 if (res) {583 movements = res.movements;584 solvedMaze = [...res.maze];585 if (586 from[0] >= 0 &&587 from[0] < solvedMaze.length &&588 from[1] >= 0 &&589 from[1] < solvedMaze[from[0]].length590 ) {591 solvedMaze[from[0]][from[1]] = direction;592 solvedMaze = [...solvedMaze];593 }594 memo[JSON.stringify(solvedMaze)] = movements;595 direction = res.direction;596 from = res.from;597 } else {598 memo[JSON.stringify(solvedMaze)] = false;599 }600 }601 }602 } else if (603 from[0] + 1 < solvedMaze.length &&604 solvedMaze[from[0] + 1][from[1]] === " "605 ) {606 from[0] += 1;607 direction = directions[2];608 movements = [...movements, "L", "F"];609 } else if (610 from[0] - 1 >= 0 &&611 solvedMaze[from[0] - 1][from[1]] === " "612 ) {613 from[0] -= 1;614 direction = directions[0];615 movements = [...movements, "R", "F"];616 z = 0;617 } else if (618 from[1] + 1 < solvedMaze[0].length &&619 solvedMaze[from[0]][from[1] + 1] === " "620 ) {621 from[1] += 1;622 direction = directions[3];623 movements = [...movements, "B", "F"];624 z = 0;625 }626 }627 z++;628 }629 return handlingMaze(direction, directions, from, movements, memo);630 }631 let direction = "<";632 let from = [0, 0];633 let movements = [];634 let memo = {};635 // Have a nice sleep ;)636 const directions = ["^", "<", "v", ">"];637 for (let x = 0; x < solvedMaze.length; x++) {638 let y = -1;639 for (let i = 0; i < directions.length; i++) {640 y = solvedMaze[x].indexOf(directions[i]);641 if (y > -1) {642 from[0] = x;643 from[1] = y;644 break;645 }646 }647 if (y > -1) {648 from = [x, y];649 direction = solvedMaze[x][y];650 break;651 }652 }653 let z = 0;654 while (from !== [0, 0]) {655 if (!(JSON.stringify(solvedMaze) in memo)) {656 const res = handlingMaze(657 direction,658 directions,659 [from[0], from[1]],660 [...movements],661 memo662 );663 if (res) {664 movements = res.movements;665 solvedMaze = res.maze;666 direction = res.direction;667 from = res.from;668 if (669 from[0] >= 0 &&670 from[0] < solvedMaze.length &&671 from[1] >= 0 &&672 from[1] < solvedMaze[from[0]].length673 )674 solvedMaze[from[0]][from[1]] = direction;675 memo[JSON.stringify(solvedMaze)] = movements;676 if (checker(res.maze, res.from)) {677 return movements;678 }679 } else {680 break;681 }682 }683 if (z > 1) {684 if (checker(solvedMaze, from)) {685 return movements;686 }687 return [];688 }689 z++;690 }691 return movements;692};...

Full Screen

Full Screen

typeCastingToAsm.ts

Source:typeCastingToAsm.ts Github

copy

Full Screen

1import { DECLARATION_TYPES } from '../../typings/syntaxTypes'2import { GENCODE_AUXVARS, GENCODE_SOLVED_OBJECT } from '../codeGeneratorTypes'3import utils from '../utils'4import { createSimpleInstruction, toRegister } from './createInstruction'5export function typeCasting (6 AuxVars: GENCODE_AUXVARS, InSolved: GENCODE_SOLVED_OBJECT, toType: DECLARATION_TYPES, line: number7) : GENCODE_SOLVED_OBJECT {8 const fromType = utils.getDeclarationFromMemory(InSolved.SolvedMem)9 if (fromType === toType) {10 return InSolved11 }12 function typeCastingMain () : GENCODE_SOLVED_OBJECT {13 switch (toType) {14 case 'void':15 // From anything to void16 AuxVars.freeRegister(InSolved.SolvedMem.address)17 InSolved.SolvedMem = utils.createVoidMemObj()18 return InSolved19 case 'long':20 return toLong()21 case 'fixed':22 return toFixed()23 case 'void_ptr':24 case 'long_ptr':25 case 'fixed_ptr':26 case 'struct_ptr':27 return toPointer()28 case 'struct':29 default:30 throw new Error('Internal error')31 }32 }33 function toFixed () : GENCODE_SOLVED_OBJECT {34 switch (fromType) {35 case 'long':36 // From long to fixed37 InSolved = toRegister(AuxVars, InSolved, line)38 InSolved.asmCode += createSimpleInstruction('LongToFixed', InSolved.SolvedMem.asmName)39 utils.setMemoryDeclaration(InSolved.SolvedMem, 'fixed')40 return InSolved41 case 'void':42 // From void to fixed43 InSolved.SolvedMem = AuxVars.getNewRegister(line)44 InSolved.asmCode += `CLR @${InSolved.SolvedMem.asmName}\n`45 utils.setMemoryDeclaration(InSolved.SolvedMem, 'fixed')46 return InSolved47 case 'struct':48 case 'void_ptr':49 case 'long_ptr':50 case 'fixed_ptr':51 case 'struct_ptr':52 throw new Error(`At line: ${line}. It is not possible to cast ${fromType} to fixed number.`)53 default:54 throw new Error('Internal error')55 }56 }57 function toLong () : GENCODE_SOLVED_OBJECT {58 switch (fromType) {59 case 'void':60 // From void to long61 InSolved.SolvedMem = AuxVars.getNewRegister(line)62 InSolved.asmCode += `CLR @${InSolved.SolvedMem.asmName}\n`63 utils.setMemoryDeclaration(InSolved.SolvedMem, 'long')64 return InSolved65 case 'fixed':66 InSolved = toRegister(AuxVars, InSolved, line)67 InSolved.asmCode += createSimpleInstruction('FixedToLong', InSolved.SolvedMem.asmName)68 utils.setMemoryDeclaration(InSolved.SolvedMem, 'long')69 return InSolved70 case 'struct':71 throw new Error(`At line: ${line}. It is not possible to cast ${fromType} to long number.`)72 case 'void_ptr':73 case 'long_ptr':74 case 'fixed_ptr':75 case 'struct_ptr':76 utils.setMemoryDeclaration(InSolved.SolvedMem, 'long')77 return InSolved78 default:79 throw new Error('Internal error')80 }81 }82 function toPointer () : GENCODE_SOLVED_OBJECT {83 switch (fromType) {84 case 'void':85 // From void to pointer (NULL)86 InSolved.SolvedMem = utils.createConstantMemObj(0)87 utils.setMemoryDeclaration(InSolved.SolvedMem, toType)88 return InSolved89 case 'fixed':90 // From fixed to any pointer91 throw new Error(`At line: ${line}. It is not possible to cast ${fromType} to a pointer type.`)92 case 'struct':93 // From struct to pointer (address of first value in struct)94 InSolved.SolvedMem = utils.createConstantMemObj(InSolved.SolvedMem.hexContent)95 utils.setMemoryDeclaration(InSolved.SolvedMem, toType)96 return InSolved97 case 'long':98 case 'void_ptr':99 case 'long_ptr':100 case 'fixed_ptr':101 case 'struct_ptr':102 // From long to any pointer103 // From any pointer to any pointer104 utils.setMemoryDeclaration(InSolved.SolvedMem, toType)105 return InSolved106 default:107 throw new Error('Internal error')108 }109 }110 return typeCastingMain()...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { solve } = require('@fast-check/solver');3const fc = require('fast-check');4const { solve } = require('@fast-check/solver');5const fc = require('fast-check');6const { solve } = require('@fast-check/solver');7const fc = require('fast-check');8const { solve } = require('@fast-check/solver');9{10 "scripts": {11 }12}13function solve<ArbitraryType, ModelType, PropertyType>(14 model: (m: ModelType, a: ArbitraryType) => ModelType,15 property: (m: ModelType) => PropertyType,16): void;

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const {solved} = require('fast-check-monorepo');3fc.assert(4 fc.property(5 fc.integer(),6 fc.integer(),7 (a, b) => {8 return solved(a, b) === a + b;9 }10);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const {some, none} = require('fp-ts/lib/Option');3const {pipe} = require('fp-ts/lib/pipeable');4const {fold} = require('fp-ts/lib/Either');5const {isString} = require('util');6 .array(fc.string())7 .chain(arr => fc.tuple(fc.constant(arr), fc.integer(0, arr.length - 1)))8 .chain(([arr, index]) => fc.tuple(fc.constant(arr), fc.constant(index), fc.constant(arr[index])));9describe('fc.array', () => {10 it('should generate a value', () => {11 fc.assert(fc.property(gen, ([arr, index, val]) => {12 expect(arr[index]).toBe(val);13 }));14 });15});16This project is a fork of the [fast-check](

Full Screen

Using AI Code Generation

copy

Full Screen

1import fc from "fast-check";2import { solved } from "@fast-check/solved";3import fc from "fast-check";4import { solved } from "@fast-check/solved";5import fc from "fast-check";6import { solved } from "@fast-check/solved";7import fc from "fast-check";8import { solved } from "@fast-check/solved";9import fc from "fast-check";10import { solved } from "@fast-check/solved";11import fc from "fast-check";12import { solved } from "@fast-check/solved";13import fc from "fast-check";14import { solved } from "@fast-check/solved";15import fc from "fast-check";16import { solved } from "@fast-check/solved";17import fc from "fast-check";18import { solved } from "@fast-check/solved";19import fc from "fast-check";20import { solved } from "@fast-check/solved";

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { solve } = require('fast-check-monorepo');3const f = (x, y) => x + y;4const prop = fc.property(5 fc.integer(),6 fc.integer(),7 (x, y) => f(x, y) === x + y8);9solve(prop);10function solve<Ts>(prop: fc.IProperty<Ts>): void11function solveWith<Ts>(12function solveWithSeed<Ts>(

Full Screen

Using AI Code Generation

copy

Full Screen

1const { check, property } = require('fast-check');2const { isSorted } = require('./test3');3check(4 property([Number], arr => {5 return isSorted(arr);6 })7);8const { check, property } = require('fast-check');9const { isSorted } = require('./test4');10check(11 property([Number], arr => {12 return isSorted(arr);13 })14);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { solved } = require('fast-check-monorepo');3const { isEven } = require('./test1');4it('should check that isEven is a function', () =>5 fc.assert(6 fc.property(fc.integer(), (n) => {7 solved(isEven(n));8 })9 ));

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful