Skip to content

Commit 2b86fac

Browse files
committed
Stalwart's birthday party turned computer science lesson. PowerShell Scientific notation parsing and the Swisscom problem.
1 parent 499c2e4 commit 2b86fac

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$sciNotation = "1E+306"
2+
$bigNumber = [System.Numerics.BigInteger]::new($sciNotation)
3+
Write-Host $bigNumber
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function compute(intArray, target) {
2+
let best = intArray[0]
3+
for (let candidate of intArray) {
4+
if (calcDist(candidate, target) < calcDist(best, target)) {
5+
best = candidate
6+
}
7+
}
8+
return best
9+
}
10+
11+
function calcDist(input, target) {
12+
return Math.abs(input - target)
13+
}
14+
15+
let ints = [-7, 5, 2, -1, 9]
16+
console.log(compute(ints, 0))

0 commit comments

Comments
 (0)