Skip to content

Commit 9c37cc4

Browse files
authored
Update README.md
1 parent 13ec410 commit 9c37cc4

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# 196-algorithm
22
Implementation of the 196-algorithm to find palindromes in a predetermined sequence of instructions.
33

4-
Inspired by: https://www.youtube.com/watch?v=bN8PE3eljdA&t=374s
4+
Inspired by https://www.youtube.com/watch?v=bN8PE3eljdA&t=374s
5+
56
Implemented here.
67

78
## Execution
@@ -11,3 +12,37 @@ cd 196-algorithm
1112
g++ main.cpp -o main
1213
./main
1314
```
15+
## Approach
16+
Given a number n we iteratively reassign n as the sum of previous n and the reverse of previous n until n is a palindrome.
17+
18+
Example Given:
19+
```
20+
n = 19 // no palindrome, iteration = 0
21+
n = 19 + 91 = 110 // no palindrome, iteration = 1
22+
n = 110 + 11 = 121 // palindrome, iteration = 2
23+
```
24+
25+
## Outcome
26+
27+
|Number|Iterations|Final palindrome|
28+
|------|:--------:|---------------:|
29+
|1| 0| 1|
30+
|2| 0| 2|
31+
|3| 0| 3|
32+
|4| 0| 4|
33+
|5| 0| 5|
34+
|6| 0| 6|
35+
|7| 0| 7|
36+
|8| 0| 8|
37+
|9| 0| 9|
38+
|10| 1| 11|
39+
|11| 0| 11|
40+
|12| 1| 33|
41+
|13| 1| 44|
42+
|14| 1| 55|
43+
|15| 1| 66|
44+
|16| 1| 77|
45+
|17| 1| 88|
46+
|18| 1| 99|
47+
|19| 2| 121|
48+
|20| 1| 22|

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy