Commit Graph

43 Commits

Author SHA1 Message Date
Vishal Kumar Gupta
edee8e644b
use format to remove '0b' (#11307)
* use format to remove '0b'

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix: error message for float input

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-01 18:41:40 -07:00
Maxim Smolskiy
4700297b3e
Enable ruff RUF002 rule (#11377)
* Enable ruff RUF002 rule

* Fix

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-04-22 21:51:47 +02:00
Rahid Zeynalov
5898b9603b
Typo deicmal -> decimal (#11169) 2023-11-25 12:25:46 +01:00
Abílio Azevedo
2531f8e221
test: adding more tests to missing number algorithm (#10394)
* test: adding more tests to missing number algorithm

* Update missing_number.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-29 22:43:32 +01:00
Tapas Singhal
8217f9bd35
Create find_previous_power_of_two.py (#11004)
* Create find_previous_power_of_two.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update find_previous_power_of_two.py

This change avoids the unnecessary left shift operation

* Update find_previous_power_of_two.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-29 11:25:39 +01:00
Manmita Das
1e1ee00782
Excess 3 code (#11001)
* added excess-3 code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated with fixes

* updated with fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update excess_3_code.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-27 23:48:15 +02:00
NikhithaBandari
be94690dec
Create swap_all_odd_and_even_bits.py (#10692)
* Create swap_all_odd_and_even_bits.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update swap_all_odd_and_even_bits.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* 6: 00000110 --> 9: 00001001

* Update swap_all_odd_and_even_bits.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-19 19:49:47 +02:00
Manmita Das
9da6f48b46
Add binary_coded_decimal.py (#10656)
* added decimal to bcd sequence

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated with fixes

* Update and rename bcd_sequence.py to binary_coded_decimal.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update binary_coded_decimal.py

* Update binary_coded_decimal.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-18 00:37:57 +02:00
ivan53
5a1305b6fe
Fix benchmark to test with the provided number instead on 25 (#10587) 2023-10-16 10:48:26 -04:00
Manpreet Singh
3ecad36f92
fix: incorrect range detection in find_missing_number (#10361)
* Fix incorrect range detection in find_missing_number

* Support consecutive decreasing numbers

Added support for consecutive decreasing numbers in the find_missing_number function.

* Support unordered numbers
2023-10-15 00:45:44 -04:00
Siddharth Warrier
c8f6f79f80
Power of 4 (#9505)
* added power_of_4

* updated power_of_4

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated power_of_4

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated power_of_4

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated power_of_4

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated power_of_4

* added type check

* added tescase

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-10-09 08:40:14 +13:00
Naman
f3be0ae9e6
Added largest pow of 2 le num (#9374) 2023-10-05 21:37:23 +13:00
Shreya Bhalgat
cfabd91a8b
Add missing number algorithm (#9203)
* Added missing_number algorithm using bit manipulation

* Update bit_manipulation/missing_number.py

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2023-10-01 13:28:20 +02:00
Tianyi Zheng
f9b8759ba8
Move bitwise add (#9097)
* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* Move and rename maths/sum_of_two_positive_numbers_bitwise.py

* updating DIRECTORY.md

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-09-27 15:54:40 +02:00
pre-commit-ci[bot]
421ace81ed
[pre-commit.ci] pre-commit autoupdate (#9013)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.285 → v0.0.286](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.285...v0.0.286)
- [github.com/tox-dev/pyproject-fmt: 0.13.1 → 1.1.0](https://github.com/tox-dev/pyproject-fmt/compare/0.13.1...1.1.0)

* updating DIRECTORY.md

* Fis ruff rules PIE808,PLR1714

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2023-08-29 15:18:10 +02:00
Christian Clauss
4b79d771cd
Add more ruff rules (#8767)
* Add more ruff rules

* Add more ruff rules

* pre-commit: Update ruff v0.0.269 -> v0.0.270

* Apply suggestions from code review

* Fix doctest

* Fix doctest (ignore whitespace)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-05-26 09:34:17 +02:00
Alexander Pantyukhin
30277f8590
add numbers different signs algorithm. (#8008) 2022-12-15 17:11:32 +13:00
Roberto Garcia
af8d520922
Update is_even.py (#8028) 2022-12-15 17:10:09 +13:00
Alexander Pantyukhin
47bf3f58e0
fix validation condition and add tests (#7997)
* fix validation condition and add tests

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-11-29 19:07:27 +01:00
Alexander Pantyukhin
a25c53e8b0
Fix argument validation for count_1s_brian_kernighan_method (#7994)
* Fix argument validation for count_1s_brian_kernighan_method

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-11-20 23:59:25 +13:00
Alexander Pantyukhin
4e6c1c049d
Is power of two (#7936)
* add is power of two

* fix comment

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Deal with negative numbers

* Spelling: negative

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-11-01 18:43:03 +01:00
Gautam Chaurasia
11e6c6fcc4
Added algorithm for finding index of rightmost set bit (#7234)
* Added algorithm for finding index of rightmost set bit

* applied suggested changes

* applied suggested changes

* Fixed failing Testcases

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-30 14:28:27 +01:00
Arjit Arora
b46b92a916
Add function for highest set bit location (#7586)
* Add function for highest set bit location

* Address review comments
2022-10-26 22:09:23 +02:00
JatinR05
bb078541dd
Update count_number_of_one_bits.py (#7589)
* Update count_number_of_one_bits.py

removed the modulo operator as it is very time consuming in comparison to the and operator

* Update count_number_of_one_bits.py

Updated with the timeit library to compare. Moreover I have updated my code which helps us in reaching the output comparatively faster.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update bit_manipulation/count_number_of_one_bits.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update count_number_of_one_bits.py

Updated the code

* Update count_number_of_one_bits.py

Updated code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Run the tests before running the benchmarks

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* consistently

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-24 12:13:39 +02:00
Laukik Chahande
39a99b46f5
check whether integer is even or odd using bit manupulation (#7099)
* even_or_not file added

* Updated DIRECTORY.md

* modified DIRECTORY.md

* Update bit_manipulation/even_or_not.py

* updating DIRECTORY.md

* Rename even_or_not.py to is_even.py

* updating DIRECTORY.md

Co-authored-by: luciferx48 <laukik.22010776@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-23 19:26:22 +02:00
Sagar Giri
b5b1eb2f00
Fix broken links by PR #7277 (#7319) 2022-10-16 15:45:25 +02:00
Leoriem-code
47dd31f4a1
Add README files 1/7 (#5754)
* Added 5 README files

* corrected arithmetic_analysis README

* Update audio_filters/README.md

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update backtracking/README.md

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update bit_manipulation/README.md

Co-authored-by: John Law <johnlaw.po@gmail.com>

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-11-04 18:49:36 +08:00
krishchopra02
0124b73484
Add a gray_code_sequence.py file to the bit_manipulation folder (#5038)
* Added a gray_code_sequence.py file to the bit_manipulation folder

* Added a descriptive name for variable n changing it to bit count

* Update gray_code_sequence.py

Co-authored-by: krishchopra02 <krishchopra02@gmail.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-11-02 18:13:49 +08:00
Manan Rathi
50485f7c8e
Fix typos in Sorts and Bit_manipulation (#4949)
* Fix several typos

* Update bit_manipulation/README.md

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Update double_sort.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-20 16:42:32 +08:00
Jainendra Mandavi
d28463c75d
Create count_1s_brian_kernighan_method (#5385)
Ref - http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetKernighan
2021-10-18 18:53:10 +02:00
Cere Blanco
8d173438c3
Bit manipulation: get the bit at a given position (#4438) 2021-05-18 20:24:34 +05:30
Elisha Hollander
0992498a10
refactor: Remove unnecessary if else condition (#4307)
All the operation is being done in an else condition for "if number >= 0"
2021-04-04 09:30:17 +05:30
Leyza
02d9bc66c1
Added binary shifts and twos complement functions to bit manipulation (#4068)
* Added binary shifts and twos complement functions to bit manipulation package

* Fixed problem representing 0 wrong

* More testing

* Fixed problems

* Fixed formatting

* More format fixes

* Format fixes

* Fixed docstrings and added url

* Minor change to url
2021-02-23 11:45:00 +05:30
Ayush Bisht
d3ac521b63
add count_number_of_one_bits.py (#4195)
* count-bits

* update
2021-02-12 07:59:24 +05:30
ayushbisht2001
3f1e376bbc
add reverse_bits.py (#4120)
* add reverse_bits.py

* check

* Delete binary_xor_operator_new.py

* Fix All the errors

Co-authored-by: xcodz-dot <xcodz-dot@users.noreply.github.com>
2021-01-27 15:54:57 +05:30
Dhruv Manilawala
8f47d9f807
Fix type annotations for bit manipulation algorithms (#4056) 2020-12-24 18:16:44 +05:30
Vivek
ac6a160f1b
added binary_count_trailing_zeros.py (#2557)
* added binary_count_trailing_zeros.py

* updated binary_count_trailing_zeros.py file

* changed file name to count_trailing_zeros.py

* updated count_trailing_zeros.py

* resolved flake8 error

* renamed to binary_count_trailing_zeros.py

* added required changes

* resolved pre-commit error

* added count_setbits.py

* resolved errors

* changed name to binary_count_setbits.py

* updated file

* reformated file
2020-11-26 09:27:00 +08:00
Phil Bazun
1b5c1b8344
Add single bit manipulation operations. (#3284)
* Add single bit manipuation operations.

* fixup! Add single bit manipuation operations.

* Change wording.
2020-10-25 10:24:35 +01:00
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Du Yuanchao
902fe1c907
Fixed reverse words algorithm (#2469)
* updated reversed words

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-24 19:12:52 +08:00
Vivek
4a3b8d682e
Added binary_xor_operator.py and binary_and_operator.py (#2433)
* Added binary_and_operator.py & binary_xor_operator.py

* Updated binary_and_operator.py

* Updated binary_xor_operator.py

* Updated binary_xor_operator.py
2020-09-24 09:30:22 +02:00
Firejay3
61dde44434
Added binery_or_operator.py to bit manipulation file (#2331)
* added bitwise binary OR operator

* Rename binary_OR_operator.py to binary_or_operator.py

* Update binary_or_operator.py

* Update binary_or_operator.py

* Update bit_manipulation/binary_or_operator.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update binary_or_operator.py

* Update binary_or_operator.py

* Nice!!

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-27 09:09:42 +02:00
Christian Clauss
24b2aecef3
Create Python/bit_manipulation/README.md (#1897)
* Create Python/bit_manipulation/README.md

To open up a new area of algorithms...

@Shrutikabansal I hope that you will contribute some of your work here.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-04-20 20:19:27 +02:00