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
public class Main { | |
public static void main(String[] args) { | |
assert oddSquareSum(1) == 0; | |
assert oddSquareSum(2) == 1; | |
assert oddSquareSum(9) == 1; | |
assert oddSquareSum(10) == 10; | |
assert oddSquareSum(44) == 35; | |
assert oddSquareSum(0) == 0; | |
assert oddSquareSum(7569) == 105995; | |
assert oddSquareSum(Integer.MAX_VALUE) == 16585052009610L; |
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 { equal } from "https://deno.land/x/equal/mod.ts"; | |
function getArrayWithZeroesRemoved(arr, startIndex, endIndex) { | |
const arrayWithZeroesRemoved = new Array(endIndex - startIndex + 1); | |
let i = 0; | |
while (startIndex <= endIndex) { | |
arrayWithZeroesRemoved[i] = arr[startIndex]; | |
i++; | |
startIndex++; | |
} |
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 getAllDigits(arr) { | |
const digits = []; | |
for (const number of arr) { | |
if (number === 0) { | |
digits.push(0); | |
continue; | |
} | |
let remainingOfNumber = Math.abs(number); | |
while (remainingOfNumber > 0) { | |
const digit = remainingOfNumber % 10; |
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 maxPointsOnLine(points: number[][]): number { | |
if (points.length === 1) { | |
return 1; | |
} | |
const pointPairs = []; | |
for (let i = 0; i < points.length; i++) { | |
for (let j = i + 1; j < points.length; j++) { | |
pointPairs.push([points[i][0], points[i][1], points[j][0], points[j][1]]); | |
} | |
} |