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
| // TXT Shuffler by FelicitusNeko is marked with CC0 1.0. | |
| // To view a copy of this license, visit https://creativecommons.org/publicdomain/zero/1.0/ | |
| #include <dirent.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <time.h> | |
| typedef struct listing_t { |
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
| // Copyright (c) 2022 FelicitusNeko | |
| // | |
| // This software is released under the MIT License. | |
| // https://opensource.org/licenses/MIT | |
| const { readdirSync, writeFileSync, unlinkSync } = require("fs"); | |
| const { spawn } = require("child_process"); | |
| const { join, basename } = require("path"); | |
| const convertTarget = "C:\\Path\\To\\ConvertedFiles"; |
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 FFT = (input, maxPhase) => { | |
| let data = input.split('').map(i => parseInt(i)); | |
| for (let phase = 0; phase < maxPhase; phase++) { | |
| let newData = []; | |
| for (let X = 0; X < input.length; X++) { | |
| let newVal = 0; | |
| for (let Y = X; Y < input.length; Y++) { | |
| switch (~~((Y + 1) / (X + 1)) % 4) { |
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 fs = require('fs'); | |
| const DIR_NORTH = 1, DIR_SOUTH = 2, DIR_WEST = 3, DIR_EAST = 4; | |
| const TURN_LEFT = 0, TURN_NO = 1, TURN_RIGHT = 2, TURN_BACK = 3; | |
| const STAT_WALL = 0, STAT_STEP = 1, STAT_OXY = 2; | |
| const MAP_WALL = 0, MAP_OPEN = 1, MAP_FINISH = 2, MAP_START = 3, MAP_LHR = 4, MAP_RHR = 5, MAP_BOTH = 6; | |
| class IntOpcodeMachine { | |
| constructor(pgm) { | |
| this.pgm = pgm.split(',').map(i => parseInt(i)); |
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
| class IntOpcodeMachine { | |
| constructor(pgm) { | |
| this.pgm = pgm.split(',').map(i => parseInt(i)); | |
| this.originalPgm = this.pgm.slice(0); | |
| this.position = 0; | |
| this.relBase = 0; | |
| this.cmdSize = { 1: 4, 2: 4, 3: 2, 4: 2, 5: 3, 6: 3, 7: 4, 8: 4, 9: 2, 99: 1 } | |
| this.input = []; this.output = []; | |
| } |
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 pos3d = { x: 0, y: 0, z: 0 } | |
| const gravObject = { pos: { x: 0, y: 0, z: 0 }, vel: { x: 0, y: 0, z: 0 } }; | |
| const gravMachine = (data, cycles) => { | |
| let gravObjects = data.split(/[\r\n\<\>]+/).filter(i => i.length).map(i => { | |
| let retval = { pos: Object.assign({}, pos3d), vel: Object.assign({}, pos3d) }; | |
| i.split(', ').map(ii => ii.split('=')).forEach(ii => retval.pos[ii[0]] = parseInt(ii[1])); | |
| return retval; | |
| }); |
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
| class IntOpcodeMachine { | |
| constructor(pgm) { | |
| this.pgm = pgm.split(',').map(i => parseInt(i)); | |
| this.originalPgm = this.pgm.slice(0); | |
| this.position = 0; | |
| this.relBase = 0; | |
| this.cmdSize = { 1: 4, 2: 4, 3: 2, 4: 2, 5: 3, 6: 3, 7: 4, 8: 4, 9: 2, 99: 1 } | |
| this.input = []; this.output = []; | |
| } |
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
| class Point { | |
| constructor(x, y) { | |
| this.X = x; this.Y = y; | |
| } | |
| distanceTo(rhs) { | |
| if (!(rhs instanceof Point)) throw new Error('Parameter is not a Point'); | |
| return Math.abs(Math.sqrt(Math.pow(rhs.Y - this.Y, 2) + Math.pow(rhs.X - this.X, 2))); | |
| } |
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
| // Day 9 part 2 is literally the exact same code except the input is 2 instead of 1 | |
| class IntOpcodeMachine { | |
| constructor(pgm) { | |
| this.pgm = pgm.split(',').map(i => parseInt(i)); | |
| this.originalPgm = this.pgm.slice(0); | |
| this.position = 0; | |
| this.relBase = 0; | |
| this.cmdSize = { 1: 4, 2: 4, 3: 2, 4: 2, 5: 3, 6: 3, 7: 4, 8: 4, 9: 2, 99: 1 } | |
| this.input = []; this.output = []; |
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 imagizer = (data, w, h) => { | |
| const layerSize = w * h; | |
| let retval = []; | |
| for (let z = 0; z * layerSize < data.length; z++) { | |
| let layer = []; | |
| for (let y = 0; y < h; y++) | |
| layer.push(data.substr((layerSize * z) + (w * y), w).split('').map(i => parseInt(i))); | |
| retval.push(layer); | |
| } |
NewerOlder