Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { logger as console } from '../../../logger';
function arrayManipulation(n: number, queries: number[][]): number {
const LENGTH = n + 1;
const SURROGATE_VALUE = 0;
const result: number[] = Array<number>(LENGTH).fill(SURROGATE_VALUE);
const result: number[] = new Array<number>(LENGTH).fill(SURROGATE_VALUE);
let maximum = 0;

queries.forEach((query) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function arrayManipulation(n: number, queries: number[][]): number {
// last slot for storing accumSum result
const LENGTH = n + 2;
const INITIAL_VALUE = 0;
const result = Array(LENGTH).fill(INITIAL_VALUE);
const result = new Array(LENGTH).fill(INITIAL_VALUE);
let maximum = 0;

queries.forEach((query) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import { logger as console } from '../../../logger';

function extraLongFactorials(n: number): bigint {
const rs = [...Array<number>(n)].reduce((a, b, i) => a * BigInt(i + 1), 1n);
const rs = new Array<bigint>(n)
.fill(1n)
.reduce((a, _b, i) => a * BigInt(i + 1), 1n);
return rs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function flippingBits(n: number): number {
}
});

return parseInt(resultBinStr, __BINARY_BASE__);
return Number.parseInt(resultBinStr, __BINARY_BASE__);
}

export default { flippingBits };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ const __RADIX__ = 10;

function superDigitCompute(n: string): number {
if (n.length === 1) {
return parseInt(n, __RADIX__);
return Number.parseInt(n, __RADIX__);
}

let partial = 0;
for (const digit of n) {
partial += parseInt(digit, __RADIX__);
partial += Number.parseInt(digit, __RADIX__);
}

return superDigitCompute(`${partial}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function whatFlavorsCompute(cost: number[], money: number): number[] | null {
const cache: Record<number, number> = {};

for (const [key, price] of Object.entries(cost)) {
const i = parseInt(key, __RADIX__);
const i = Number.parseInt(key, __RADIX__);
const diff = money - price;

if (Number.isInteger(cache?.[diff])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function whatFlavorsBruteforceCompute(cost: number[], money: number): number[] {
const RADIX = 10;

for (const key of Object.keys(cost)) {
const i: number = parseInt(key, RADIX);
const i: number = Number.parseInt(key, RADIX);
const x: number = cost[i];

const budget = money - x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function whatFlavorsCompute(cost: number[], money: number): number[] {
}

for (const key of Object.keys(cost)) {
const i = parseInt(key, __RADIX__);
const i = Number.parseInt(key, __RADIX__);

const v1 = cost[i];
const v2 = money - v1;
Expand All @@ -35,7 +35,7 @@ function whatFlavorsCompute(cost: number[], money: number): number[] {

const result = new Set<number>();
for (const key of Object.keys(cost)) {
const x = parseInt(key, __RADIX__);
const x = Number.parseInt(key, __RADIX__);

if (cost[x] === ans1 || cost[x] === ans2) {
result.add(x + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ function swapNodes(indexes: number[][], queries: number[]): number[][] {

nodeCollector = Object.fromEntries(
Object.entries(nodeCollector).sort(
([a], [b]) => parseInt(a, __RADIX__) - parseInt(b, __RADIX__)
([a], [b]) =>
Number.parseInt(a, __RADIX__) - Number.parseInt(b, __RADIX__)
)
);

for (const query of queries) {
for (const [level, nodeList] of Object.entries(nodeCollector)) {
const tLevel: number = parseInt(level, __RADIX__);
const tLevel: number = Number.parseInt(level, __RADIX__);

if (tLevel % query === 0) {
for (const node of nodeList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function isValidCompute(s: string): boolean {
);
const __RADIX__ = 10;
const __TOLERANCE__ = 1;
const minorFreq: number = parseInt(frequenciesList[0][0], __RADIX__);
const majorFreq: number = parseInt(frequenciesList[1][0], __RADIX__);
const minorFreq: number = Number.parseInt(frequenciesList[0][0], __RADIX__);
const majorFreq: number = Number.parseInt(frequenciesList[1][0], __RADIX__);

if (
frequencies[minorFreq] === __TOLERANCE__ &&
Expand Down
2 changes: 1 addition & 1 deletion src/hackerrank/warmup/solveMeFirst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function solveMeFirst(inputLines: string[]): number {
let result = 0;

inputLines.forEach((v) => {
result += parseInt(v, __RADIX__);
result += Number.parseInt(v, __RADIX__);
});

return result;
Expand Down
2 changes: 1 addition & 1 deletion src/hackerrank/warmup/timeConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function timeConversion(s: string): string {

const timeStr = s.substring(0, s.length - 2);
const time = timeStr.split(':');
let hour = parseInt(time[0], 10);
let hour = Number.parseInt(time[0], 10);

if (hour >= 12) {
hour = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/projecteuler/problem0013-alt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function problem0013alt(

console.debug(`Sum: ${sum}`);

const firstDigits = parseInt(
const firstDigits = Number.parseInt(
sum.toString().slice(0, numberOfFirstDigits),
radix
);
Expand Down
2 changes: 1 addition & 1 deletion src/projecteuler/problem0013.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function problem0013(arrayOfNumbers: string[], _firtsDigits: number): number {

console.debug(`Sum: ${sum}`);

const first = parseInt(sum.slice(0, _firtsDigits), radix);
const first = Number.parseInt(sum.slice(0, _firtsDigits), radix);

console.log(`First ${_firtsDigits} digits of huge sume are ${first}`);

Expand Down
2 changes: 1 addition & 1 deletion src/projecteuler/problem0016-alt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function problem0016alt(base: string, exponent: number): string {

let result = 0;
digits.forEach((num: string) => {
result += parseInt(num, __RADIX__);
result += Number.parseInt(num, __RADIX__);
});

console.log(`Sum of Digits: (${result})`);
Expand Down