CODEBASE: Expand lint rules, and Aliases are stored as maps (#501)

This commit is contained in:
Snarling
2023-05-05 03:55:59 -04:00
committed by GitHub
parent d25254caf1
commit ebae35b1fb
202 changed files with 905 additions and 1110 deletions
+19 -15
View File
@@ -3,7 +3,6 @@ import { MinHeap } from "../utils/Heap";
import { comprGenChar, comprLZGenerate, comprLZEncode, comprLZDecode } from "../utils/CompressionContracts";
import { HammingEncode, HammingDecode, HammingEncodeProperly } from "../utils/HammingCodeTools";
/* tslint:disable:completed-docs no-magic-numbers arrow-return-shorthand */
/* Function that generates a valid 'data' for a contract type */
export type GeneratorFunc = () => unknown;
@@ -270,14 +269,16 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
let l = 0;
let r: number = n - 1;
let k = 0;
while (true) {
let done = false;
while (!done) {
// Up
for (let col: number = l; col <= r; col++) {
spiral[k] = data[u][col];
++k;
}
if (++u > d) {
break;
done = true;
continue;
}
// Right
@@ -286,7 +287,8 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
++k;
}
if (--r < l) {
break;
done = true;
continue;
}
// Down
@@ -295,7 +297,8 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
++k;
}
if (--d < u) {
break;
done = true;
continue;
}
// Left
@@ -304,7 +307,8 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
++k;
}
if (++l > r) {
break;
done = true;
continue;
}
}
@@ -1333,7 +1337,7 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
},
gen: (): string => {
const _alteredBit = Math.round(Math.random());
const _buildArray: Array<string> = HammingEncodeProperly(
const _buildArray: string[] = HammingEncodeProperly(
getRandomInt(Math.pow(2, 4), Math.pow(2, getRandomInt(1, 57))),
).split("");
if (_alteredBit) {
@@ -1423,21 +1427,21 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
return [n + m, edges];
},
solver: (_data: unknown, ans: string): boolean => {
//Helper function to get neighbourhood of a vertex
function neighbourhood(vertex: number): number[] {
const adjLeft = data[1].filter(([a]) => a == vertex).map(([, b]) => b);
const adjRight = data[1].filter(([, b]) => b == vertex).map(([a]) => a);
return adjLeft.concat(adjRight);
}
const data = _data as [number, [number, number][]];
//Sanitize player input
const sanitizedPlayerAns: string = removeBracketsFromArrayString(ans);
const sanitizedPlayerAns = removeBracketsFromArrayString(ans);
//Case where the player believes there is no solution.
//Attempt to construct one to check if this is correct.
if (sanitizedPlayerAns === "") {
//Helper function to get neighbourhood of a vertex
function neighbourhood(vertex: number): number[] {
const adjLeft = data[1].filter(([a]) => a == vertex).map(([, b]) => b);
const adjRight = data[1].filter(([, b]) => b == vertex).map(([a]) => a);
return adjLeft.concat(adjRight);
}
//Verify that there is no solution by attempting to create a proper 2-coloring.
const coloring: (number | undefined)[] = Array(data[0]).fill(undefined);
while (coloring.some((val) => val === undefined)) {