Here you have the challenge for the software engineer position. You can find in this branch two different challenges, an algorithm one another one to see how you can refactor a dirty code. If you think that you can solve it using some design patters, feel free and apply them. Let's go! ๐
Given an integer, n, we want to know the following:
- How many 1-bits are in its binary representation?
- Let's say n's binary representation has k significant bits indexed from 1 to k. What are the respective positions (i.e., in ascending order) of each 1-bit?
- The performance is really important in this challenge.
Complete Count function in PositiveBitCounter class. It has one parameter: an integer, n. It must return an integer enumerable with the following 1 + k values:
- The first index (0) must contain the total number of 1 bits in n's binary representation.
- The subsequent indices must contain the respective positions of the one-indexed 1-bits in n's binary representation.
Return an enumerable of integers where the first element is the total number of 1-bits in n's binary representation and the subsequent elements are the respective one-indexed locations of each 1-bit from most to least significant.
The integer n = 161 converts to binary.
1 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
---|
Reverse the binary representation.
1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 |
---|
Count number of positive bits: 3 Search the position: 0, 5, 7 Return { 3, 0, 5, 7 }
Refactor the FraudRadar class. You can make any changes you see that are needed in code or tests. See the tests for more information.
- All the tests must pass.
- The code should fulfil OOP and SOLID principles.
- The code should be maintainable.
- The code should be extensible.
- You should apply defensive programming practices.
- Receive the file path is not nice. Think and change the signature and make it cooler.# payvision-recruitment-challenges-software-engineer-js