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 queueTime(customers, n) { | |
| var sorted = customers.sort((a,b)=>b-a); | |
| var max = Math.max(...sorted); | |
| var tills = Array(n).fill(0); | |
| while(sorted.length>0){ | |
| for(var i=0;i<n && i<sorted.length;i++) | |
| { | |
| tills[i] += sorted.shift(); | |
| } |
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 primeFactors(n){ | |
| var list = []; | |
| var maxi=9999999; | |
| var maxk=99; | |
| for(var i=2;n>1;i++){ | |
| var m = null; | |
| for(var k=1;;k++){ | |
| var d = n/Math.pow(i,k); |
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 Perceptron { | |
| constructor(layers, inputs) { | |
| if (layers[0] !== inputs.length) | |
| throw new Error("Invalid number of inputs"); | |
| this.l = layers; | |
| this.activation = val => (val >= 0.5 ? 1 : 0); | |
| this.learningRate = 0.1; | |
| this.initWeights(); |
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 draco3d = require('draco3d'); | |
| const js2obj = require('./js2obj'); | |
| const decoderModule = draco3d.createDecoderModule({}); | |
| const encoderModule = draco3d.createEncoderModule({}); | |
| var data = fs.readFileSync('./testdata/bunny.drc'); |
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 optimizeGeometry(geometry) { | |
| var saveVerts = []; | |
| geometry.vertices.forEach((vert, i) => { | |
| var present = geometry.faces.some(face => { | |
| return face[0] === i || face[1] === i || face[2] === i | |
| }); | |
| if (present) | |
| saveVerts.push(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
| function calcNormal( normals, normal, angle ){ | |
| let allowed = normals.filter( n => n.angleTo( normal ) < angle * Math.PI / 180 ); | |
| return allowed.reduce( (a, b) => a.clone().add( b ) ).normalize(); | |
| } | |
| THREE.GeometryUtils.computeVertexNormals = function(geometry, angle){ | |
| geometry.computeFaceNormals(); | |
| var vertices = geometry.vertices.map( () => [] ); // vertices with normals array |
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
| import * as THREE from 'three'; | |
| export class RealZoom { | |
| constructor({ width, height }, diag) { | |
| var diagPX = Math.sqrt(width ** 2 + height ** 2); | |
| var screenWidthInch = width / diagPX * diag; | |
| var screenWidthCM = 2.54 * screenWidthInch; | |
| var viewWidthPX = window.innerWidth; | |
| this.viewWidthCM = viewWidthPX / width * screenWidthCM; | |
| } |
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
| snail = function(array) { | |
| var side = 'top'; | |
| var result = []; | |
| while(array.length > 0){ | |
| switch(side){ | |
| case 'top': | |
| result.push(...cutRow(0, array)); | |
| side = 'right'; |
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
| .alert { | |
| position: absolute; | |
| left: 0; | |
| top: 0; | |
| width: 100%; | |
| background: rgba(255, 30,3, 0.7); | |
| color: white; | |
| padding: 1%; | |
| font-size: 120%; | |
| font-family: monospace; |
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 LabMath = { | |
| "маточікування": function avarage(arr) { | |
| return arr.reduce((a, b) => a + b, 0) / arr.length; | |
| }, | |
| "медіана": function(arr) { | |
| return arr.sort((a, b) => a - b)[Math.floor(arr.length / 2)]; | |
| }, | |
| "напівсума «крайніх» спостережень": function(arr) { | |
| return (Math.min(...arr) + Math.max(...arr)) / 2; | |
| }, |