-
-
Save raghavgarg1257/ba28f1b035dea18c8a53e6d87be0975d to your computer and use it in GitHub Desktop.
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
(() => { | |
const GRID_SIZE = 31; | |
const instructions = [ | |
{ | |
moveX: -Math.floor(GRID_SIZE / 2), | |
moveY: -Math.floor(GRID_SIZE / 2), | |
}, | |
]; | |
for (let x=0; x<GRID_SIZE - 1; x++) { | |
instructions.push({moveX: 1, moveY: 0}); | |
} | |
for (let x=0; x<GRID_SIZE - 1; x++) { | |
instructions.push({moveX: 0, moveY: 1}); | |
} | |
for (let x=GRID_SIZE - 1; x > 0; x--) { | |
instructions.push({moveX: -1, moveY: 0}); | |
} | |
for (let x=GRID_SIZE - 1; x > 0; x--) { | |
instructions.push({moveX: 0, moveY: -1}); | |
} | |
return instructions; | |
})(); |
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
(() => { | |
const GRID_SIZE = 31; | |
const instructions = [ | |
{ | |
moveX: -Math.floor(GRID_SIZE / 2) + 1, | |
moveY: -Math.floor(GRID_SIZE / 2), | |
}, | |
]; | |
for (let y=0; y < GRID_SIZE-1; y++) { | |
for (let x=0; x < Math.floor(GRID_SIZE/2)-((y+1)%2); x++) { | |
instructions.push({moveX: 2, moveY: 0}); | |
} | |
instructions.push({moveX: -GRID_SIZE+2, moveY: 1}); | |
} | |
return instructions; | |
})(); |
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 spiral(instructions, m, n) { | |
const loop = n - (m - n); | |
for (let x = 0; x < loop; x++) { | |
instructions.push({moveX: 0, moveY: 1}); | |
} | |
for (let x = loop; x > 0; x--) { | |
instructions.push({moveX: -1, moveY: 0}); | |
} | |
for (let x = loop; x > 0; x--) { | |
instructions.push({moveX: 0, moveY: -1}); | |
} | |
for (let x = 0; x < loop - 1; x++) { | |
instructions.push({moveX: 1, moveY: 0}); | |
} | |
} | |
(() => { | |
const GRID_SIZE = 31; | |
const instructions = [ | |
{ | |
moveX: Math.floor(GRID_SIZE / 2), | |
moveY: -Math.floor(GRID_SIZE / 2), | |
}, | |
]; | |
for (let x = 0; x < Math.floor(GRID_SIZE / 2); x++) { | |
spiral(instructions, GRID_SIZE-1, GRID_SIZE-x-1); | |
instructions.push({moveX: 0, moveY: 1}); | |
} | |
return instructions; | |
})(); |
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 spiral(instructions, m, n) { | |
const loop = n - (m - n); | |
for (let x = 0; x < loop; x++) { | |
instructions.push({moveX: 1, moveY: 0}); | |
} | |
for (let x = loop; x > 0; x--) { | |
instructions.push({moveX: 0, moveY: -1}); | |
} | |
for (let x = loop; x > 0; x--) { | |
instructions.push({moveX: -1, moveY: 0}); | |
} | |
for (let x = 0; x < loop - 1; x++) { | |
instructions.push({moveX: 0, moveY: 1}); | |
} | |
} | |
(() => { | |
const GRID_SIZE = 31; | |
const instructions = [ | |
{ | |
moveX: -Math.floor(GRID_SIZE / 2), | |
moveY: Math.floor(GRID_SIZE / 2), | |
}, | |
]; | |
for (let x = 0; x < Math.floor(GRID_SIZE / 2); x++) { | |
spiral(instructions, GRID_SIZE-1, GRID_SIZE-x-1); | |
instructions.push({moveX: 1, moveY: 0}); | |
} | |
return instructions; | |
})(); |
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
(() => { | |
const GRID_SIZE = 31; | |
const instructions = [ | |
{ | |
moveX: 0, | |
moveY: Math.floor(GRID_SIZE / 2), | |
}, | |
]; | |
for (let y = 0; y < 100; y++) { | |
for (let x = 0; x < 15; x++) { | |
instructions.push({moveX: 1, moveY: -1}); | |
} | |
for (let x = 0; x < 15; x++) { | |
instructions.push({moveX: -1, moveY: -1}); | |
} | |
for (let x = 0; x < 15; x++) { | |
instructions.push({moveX: -1, moveY: 1}); | |
} | |
for (let x = 0; x < 15; x++) { | |
instructions.push({moveX: 1, moveY: 1}); | |
} | |
} | |
return instructions; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment