diskutil list
sudo dd bs=1m if=2017-11-29-raspbian-stretch-lite.img of=/dev/disk2 conv=sync
| const numberDiamond_1 = function() { | |
| const padding = new Array(9).join(' '); | |
| const numbers = new Array(9) | |
| .fill(0) | |
| .map((v, i) => i + 1) | |
| .join(''); | |
| let halfDiamond = new Array(9).fill(0).map((v, i) => { | |
| let halfRow = padding.slice(0, 8 - i) + numbers.slice(0, i + 1); | |
| return ( | |
| halfRow + |
| // Wrong!!! | |
| self.addEventListener('activate', function(event) { | |
| var cacheWhitelist = ['v2']; | |
| event.waitUntil( | |
| // TODO: remove the old cache | |
| caches.keys().then(function(keyList) { | |
| return Promise.all( | |
| keyList.map(function(key) { | |
| if (cacheWhitelist.indexOf(key) === -1) { |
| /* | |
| Begin in state A. | |
| Perform a diagnostic checksum after 12629077 steps. | |
| In state A: | |
| If the current value is 0: | |
| - Write the value 1. | |
| - Move one slot to the right. | |
| - Continue with state B. | |
| If the current value is 1: |
| const ports = require('./ports'); | |
| let findCompatiblePorts = function(currentPort, portSize, ports, usedPorts) { | |
| ports = ports | |
| .filter(p => p !== currentPort) | |
| .filter(p => usedPorts.indexOf(p) == -1) | |
| .filter(port => { | |
| let [a, b] = port.split('/'); | |
| return a == portSize || b == portSize ? true : false; | |
| }); |
| let coprocessorConflagration = function(instructions, regA = 0) { | |
| let offset = 'a'.charCodeAt(); | |
| let registers = new Array(10).fill(0); | |
| registers[0] = regA; | |
| let multiplied = 0; | |
| let index = 0; | |
| let executeInstruction = function(instruction) { | |
| let [operation, a, b] = instruction.split(' '); |
| let virusGrid = require('./virusGrid'); | |
| let checkGridSize = function(grid, x, y) { | |
| let width = grid[0].length; | |
| if (x < 0) { | |
| grid.unshift(new Array(width).fill(0).map(v => '.')); | |
| x = 0; | |
| } | |
| if (x == grid.length) { |
| let gridRules = require('./gridRules'); | |
| let transposeArray = function(array) { | |
| return array[0].map((col, i) => array.map(row => row[i])); | |
| }; | |
| let permuations = function(square) { | |
| let perms = []; | |
| perms.push(square.slice()); | |
| perms.push(transposeArray(square.slice())); |
| let particles = require('./particles'); | |
| let stepParticles = function(particles) { | |
| return particles.map(p => { | |
| p.v = p.v.map((c, i) => c + p.a[i]); | |
| p.p = p.p.map((c, i) => c + p.v[i]); | |
| return p; | |
| }); | |
| }; |
| const path = require('./path'); | |
| let changeDirection = function(path, x, y, dX, dY) { | |
| let newDirections = [[dY, dX], [-1 * dY, -1 * dX]]; | |
| let direction = -1; | |
| newDirections.forEach((d, i) => { | |
| let location = path[x + d[0]][y + d[1]]; | |
| if (location !== ' ' && location !== undefined) { | |
| direction = i; |