Skip to content

Commit bc69c4a

Browse files
authored
Merge branch 'main' into tweak/fix-loading-state-blinking-arrow
2 parents 78c4d83 + d9bdf59 commit bc69c4a

File tree

77 files changed

+2230
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2230
-347
lines changed

package-lock.json

Lines changed: 125 additions & 101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"prismjs": "^1.29.0",
2424
"react": "^18.3.1",
2525
"react-dom": "^18.3.1",
26-
"react-router-dom": "^6.27.0",
26+
"react-router-dom": "^7.1.1",
2727
"react-syntax-highlighter": "^15.6.1"
2828
},
2929
"devDependencies": {

public/_redirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* /index.html 200
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Clear ith bit
3+
description: Clear the ith bit of a number and returns the resulting number
4+
tags: bit-manipulation, number, clear
5+
author: aelshinawy
6+
---
7+
8+
```c
9+
int clear_ith_bit(int n, int i) {
10+
return n & ~(1 << i);
11+
}
12+
13+
14+
// Usage:
15+
clear_ith_bit(10, 1); // Returns: 8
16+
clear_ith_bit(10, 3); // Returns: 2
17+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Count Set Bits
3+
description: Counts the number of set bits in an int
4+
tags: bit-manipulation, count
5+
author: aelshinawy
6+
---
7+
8+
```c
9+
int count_set_bits(int n) {
10+
int count = 0;
11+
while (n) {
12+
n &= (n - 1);
13+
count++;
14+
}
15+
return count;
16+
}
17+
18+
19+
// Usage:
20+
count_set_bits(5); // Returns: 2
21+
count_set_bits(255); // Returns: 8
22+
count_set_bits(8); // Returns: 1
23+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Get ith bit
3+
description: Get the i-th bit of a number
4+
tags: bit-manipulation, number, get
5+
author: aelshinawy
6+
---
7+
8+
```c
9+
int get_ith_bit(int n, int i) {
10+
return (n >> i) & 1;
11+
}
12+
13+
14+
// Usage:
15+
get_ith_bit(10, 0); // Returns: 0
16+
get_ith_bit(10, 1); // Returns: 1
17+
get_ith_bit(10, 2); // Returns: 0
18+
get_ith_bit(10, 3); // Returns: 1
19+
```

snippets/c/bit-manipulation/is-odd.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Is Odd
3+
description: Check if a number is odd
4+
tags: bit-manipulation, number, is-odd
5+
author: aelshinawy
6+
---
7+
8+
```c
9+
bool is_odd(int n) {
10+
return n & 1;
11+
}
12+
13+
14+
// Usage:
15+
is_odd(10); // Returns: false
16+
is_odd(11); // Returns: true
17+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Set ith bit
3+
description: Set the i-th bit of a number and returns the resulting number
4+
tags: bit-manipulation, number, set
5+
author: aelshinawy
6+
---
7+
8+
```c
9+
int set_ith_bit(int n, int i) {
10+
return n | (1 << i);
11+
}
12+
13+
14+
// Usage:
15+
set_ith_bit(10, 0); // Returns: 11
16+
set_ith_bit(10, 2); // Returns: 14
17+
set_ith_bit(1, 8); // Returns: 257
18+
set_ith_bit(1, 3); // Returns: 9
19+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Swap Numbers
3+
description: Swap two numbers without a temporary variable
4+
tags: bit-manipulation, number, swap
5+
author: aelshinawy
6+
---
7+
8+
```c
9+
void swap(int *a, int *b) {
10+
*a ^= *b;
11+
*b ^= *a;
12+
*a ^= *b;
13+
}
14+
15+
16+
// Usage:
17+
int x = 5, y = 10;
18+
swap(&x, &y);
19+
printf("x = %d, y = %d\n", x, y); // x = 10, y = 5
20+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: Toggle ith bit
3+
description: Toggle the i-th bit of a number and returns the resulting number
4+
tags: bit-manipulation, number, toggle
5+
author: aelshinawy
6+
---
7+
8+
```c
9+
int toggle_ith_bit(int n, int i) {
10+
return n ^ (1 << i);
11+
}
12+
13+
14+
// Usage:
15+
toggle_ith_bit(10, 0); // Returns: 11
16+
toggle_ith_bit(10, 1); // Returns: 8
17+
toggle_ith_bit(8, 1); // Returns: 10
18+
```

0 commit comments

Comments
 (0)