-2 base
How do I make an -2 base?
What is a -2 base? How do you make a -2 base? This script and codes were developed by Piotr Kozanecki on 15 January 2023, Sunday.
-2 base - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>-2 base</title>
</head>
<body> <script src="js/index.js"></script>
</body>
</html>
-2 base - Script Codes JS Codes
function resolve(S) { let result = S.slice(0); S.map(function(element, index, array) { if (index === array.length - 1) { result.push(element); } else { result[index + 1] += element; } }); result.map(function(element, index, array) { if (element > 1) { array[index] %= 2; if (array[index] === 0) { if (typeof array[index + 1] !== 'undefined') { array[index + 1]? array[index + 1] = 0: array[index +1 ] = 1; } else { array.push(1); } } } }); while (result[result.length - 1] === 0) { result.pop(); } return result;
}
function calculateNeg2(array) { let result = 0, base = 1; array.map(function(element, index, array) { result += element * base; base *= -2; }); return result;
}
let a = [1, 0, 0, 1, 1];
console.log(calculateNeg2(a));
console.log(resolve(a));
console.log(calculateNeg2(resolve(a)));
// resolve(a);
Developer | Piotr Kozanecki |
Username | kozanecki_p |
Uploaded | January 15, 2023 |
Rating | 3 |
Size | 1,641 Kb |
Views | 10,120 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Netguru Frontend recruitement task | 8,602 Kb |
A Pen by Piotr Kozanecki | 3,329 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Mini Profile | Frytyler | 3,828 Kb |
Countdown Timer | Massiebn | 3,001 Kb |
Transitioning application screens with semantically named classes | Djgrant | 3,697 Kb |
Animated rainbow wave on canvas | Icodeforlove | 2,777 Kb |
3D-box | Parthviroja | 2,346 Kb |
Responsive slide | Thorien | 2,400 Kb |
Spin | Elalemanyo | 8,262 Kb |
Resize image | Happyhj | 1,892 Kb |
Modal Dialog | Gigaleet | 2,251 Kb |
Tooltip in table | Roine | 3,713 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!