Compare commits

...

6 Commits

Author SHA1 Message Date
Satyam Singh
3985835aa5
Merge 20070c23e5 into f3f32ae3ca 2024-11-22 14:07:16 +01:00
pre-commit-ci[bot]
f3f32ae3ca
[pre-commit.ci] pre-commit autoupdate (#12385)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.7.3 → v0.7.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.3...v0.7.4)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-11-18 22:07:12 +01:00
Christian Clauss
e3bd7721c8
validate_filenames.py Shebang python for Windows (#12371) 2024-11-15 14:59:14 +01:00
pre-commit-ci[bot]
e3f3d668be
[pre-commit.ci] pre-commit autoupdate (#12370)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.7.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.2...v0.7.3)
- [github.com/abravalheri/validate-pyproject: v0.22 → v0.23](https://github.com/abravalheri/validate-pyproject/compare/v0.22...v0.23)

* Update sudoku_solver.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>
2024-11-11 21:05:50 +01:00
pre-commit-ci[bot]
20070c23e5 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-10-13 19:35:06 +00:00
satyxm
15658bfe12 Single Number Algo Added 2024-10-14 01:01:58 +05:30
4 changed files with 34 additions and 4 deletions

View File

@ -16,7 +16,7 @@ repos:
- id: auto-walrus
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.7.4
hooks:
- id: ruff
- id: ruff-format
@ -42,7 +42,7 @@ repos:
pass_filenames: false
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.22
rev: v0.23
hooks:
- id: validate-pyproject

View File

@ -0,0 +1,30 @@
def single_number(nums: list[int]) -> int:
"""
Find the single number in an array where every other number appears twice.
Args:
nums: List of integers where every integer appears twice except for one.
Returns:
The single integer that appears once.
Example:
>>> single_number([4, 1, 2, 1, 2])
4
>>> single_number([2, 2, 1])
1
>>> single_number([1])
1
"""
result = 0
for num in nums:
result ^= num # Applying XOR operation
return result
if __name__ == "__main__":
# Test cases
print(single_number([4, 1, 2, 1, 2])) # Output: 4
print(single_number([2, 2, 1])) # Output: 1
print(single_number([1])) # Output: 1
print(single_number([5, 3, 5, 7, 3])) # Output: 7

View File

@ -172,7 +172,7 @@ def solved(values):
def from_file(filename, sep="\n"):
"Parse a file into a list of strings, separated by sep."
return open(filename).read().strip().split(sep) # noqa: SIM115
return open(filename).read().strip().split(sep)
def random_puzzle(assignments=17):

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!python
import os
try: