You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/practice/atbash-cipher/.docs/instructions.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Instructions
2
2
3
-
Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.
3
+
Create an implementation of the Atbash cipher, an ancient encryption system created in the Middle East.
4
4
5
5
The Atbash cipher is a simple substitution cipher that relies on transposing all the letters in the alphabet such that the resulting alphabet is backwards.
6
6
The first letter is replaced with the last letter, the second with the second-last, and so on.
Copy file name to clipboardExpand all lines: exercises/practice/circular-buffer/.docs/instructions.md
+32-16Lines changed: 32 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,39 +4,55 @@ A circular buffer, cyclic buffer or ring buffer is a data structure that uses a
4
4
5
5
A circular buffer first starts empty and of some predefined length.
6
6
For example, this is a 7-element buffer:
7
-
<!-- prettier-ignore -->
8
-
[ ][ ][ ][ ][ ][ ][ ]
7
+
8
+
```text
9
+
[ ][ ][ ][ ][ ][ ][ ]
10
+
```
9
11
10
12
Assume that a 1 is written into the middle of the buffer (exact starting location does not matter in a circular buffer):
11
-
<!-- prettier-ignore -->
12
-
[ ][ ][ ][1][ ][ ][ ]
13
+
14
+
```text
15
+
[ ][ ][ ][1][ ][ ][ ]
16
+
```
13
17
14
18
Then assume that two more elements are added — 2 & 3 — which get appended after the 1:
15
-
<!-- prettier-ignore -->
16
-
[ ][ ][ ][1][2][3][ ]
19
+
20
+
```text
21
+
[ ][ ][ ][1][2][3][ ]
22
+
```
17
23
18
24
If two elements are then removed from the buffer, the oldest values inside the buffer are removed.
19
25
The two elements removed, in this case, are 1 & 2, leaving the buffer with just a 3:
20
-
<!-- prettier-ignore -->
21
-
[ ][ ][ ][ ][ ][3][ ]
26
+
27
+
```text
28
+
[ ][ ][ ][ ][ ][3][ ]
29
+
```
22
30
23
31
If the buffer has 7 elements then it is completely full:
24
-
<!-- prettier-ignore -->
25
-
[5][6][7][8][9][3][4]
32
+
33
+
```text
34
+
[5][6][7][8][9][3][4]
35
+
```
26
36
27
37
When the buffer is full an error will be raised, alerting the client that further writes are blocked until a slot becomes free.
28
38
29
39
When the buffer is full, the client can opt to overwrite the oldest data with a forced write.
30
40
In this case, two more elements — A & B — are added and they overwrite the 3 & 4:
31
-
<!-- prettier-ignore -->
32
-
[5][6][7][8][9][A][B]
41
+
42
+
```text
43
+
[5][6][7][8][9][A][B]
44
+
```
33
45
34
46
3 & 4 have been replaced by A & B making 5 now the oldest data in the buffer.
35
47
Finally, if two elements are removed then what would be returned is 5 & 6 yielding the buffer:
36
-
<!-- prettier-ignore -->
37
-
[ ][ ][7][8][9][A][B]
48
+
49
+
```text
50
+
[ ][ ][7][8][9][A][B]
51
+
```
38
52
39
53
Because there is space available, if the client again uses overwrite to store C & D then the space where 5 & 6 were stored previously will be used not the location of 7 & 8.
40
54
7 is still the oldest element and the buffer is once again full.
0 commit comments