-
Distruct Number Into Sum Of Distinct Cubes Using Bitwise Operators
Hello, checkiomates🐱👤!
Here we are again! This digest is strongly dedicated to implementation of some math intsruments in JS: bitwise operators, different symbols, presenting a number as sum of cubes. Yor are welcome to reading and commenting!
💡TIP
You may click on any mission tag and see all missions, where this tag is present! If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
🏁MISSION
Sum of Distinct Cubes by freeman_lex -
Positive integers can be broken down into sums of distinct cubes of positive integers, sometimes in multiple different ways. Your function should find and return the descending array of distinct cubes whose sum equals the given positive integer n. If it is impossible to express n as a sum of distinct cubes, return null. If n allows several breakdowns into sums of distinct cubes, the function must return the lexicographically highest solution that starts with the largest possible first number, followed by the lexicographically highest representation of the rest of the number n-a*a*a. For example, called with n = 1729, this function should return [12, 1] instead of [10, 9].
assert.deepStrictEqual(sumOfCubes(1729), [12, 1]); assert.deepStrictEqual(sumOfCubes(8), [2]); assert.deepStrictEqual(sumOfCubes(11), null);
📖ARTICLE
A guide to destructuring in JavaScript -
A destructuring assignment allows you to extract individual values from an array or object and assign them to a set of identifiers without needing to access the values of each element the old-fashioned way—one at a time, by index or key.
Mathematical Symbols and JavaScript Equivalents -
For your attention is a list of common and rare math symbols with their implementation is JS.
Bitwise Operators in JavaScript and When to Use Them -
Bitwise operators in JavaScript are fundamental to the language. These operators apply logical operations to each bit of the operands. They consist of bitwise NOT (~), bitwise AND (&), bitwise OR (|), and bitwise XOR (^), as well as their assignment variations &=, |=, and ^=. This post discusses what they are and the best practices around them.
👩💻CODE SHOT
It's a very simple task! Dont be shy) How do you think, what the following code does?
function ?????????(word: string, first: string, second: string): boolean { return word.indexOf(second) - (word + first).indexOf(first) === 1; }
🙌 Thanks for your attention! Hope to meet you at CheckiO, as well as at our Instagram and Twitter! We are really interested in your thoughts! Please, leave a comment below! ⤵
Welcome to CheckiO - games for coders where you can improve your codings skills.
The main idea behind these games is to give you the opportunity to learn by exchanging experience with the rest of the community. Every day we are trying to find interesting solutions for you to help you become a better coder.
Join the Game