diff --git a/challenges/look-and-say-sequence-conway/README.md b/challenges/look-and-say-sequence-conway/README.md new file mode 100644 index 0000000..138edc1 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/README.md @@ -0,0 +1,55 @@ +# look-and-say-sequence-conway + +Created by [@Divlo](https://github.com/Divlo) on 30 November 2021. + +## Instructions + +In mathematics, the **look-and-say sequence** is the sequence of integers beginning as follows: `1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, ...`. + +The look-and-say sequence was introduced and analyzed by John **Conway**. + +To generate a member of the sequence from the previous member, read off the digits of the previous member, counting the number of digits in groups of the same digit. For example: + +- `1` is read off as "one 1" or 11. +- `11` is read off as "two 1s" or 21. +- `21` is read off as "one 2, then one 1" or 1211. +- `1211` is read off as "one 1, one 2, then two 1s" or 111221. +- `111221` is read off as "three 1s, two 2s, then one 1" or 312211. + +Write a program that prints the next term of the **look-and-say sequence**. + +## Source + +- [Look-and-say sequence - Wikipedia](https://en.wikipedia.org/wiki/Look-and-say_sequence) + +## Examples + +### Example 1 + +#### Input + +```txt +11 +``` + +#### Output + +```txt +21 +``` + +### Example 2 + +#### Input + +```txt +1211 +``` + +#### Output + +```txt +111221 +``` + +See the `test` folder for examples of input/output. diff --git a/challenges/look-and-say-sequence-conway/solutions/.gitkeep b/challenges/look-and-say-sequence-conway/solutions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/challenges/look-and-say-sequence-conway/test/1/input.txt b/challenges/look-and-say-sequence-conway/test/1/input.txt new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/1/input.txt @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/1/output.txt b/challenges/look-and-say-sequence-conway/test/1/output.txt new file mode 100644 index 0000000..b5045cc --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/1/output.txt @@ -0,0 +1 @@ +21 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/10/input.txt b/challenges/look-and-say-sequence-conway/test/10/input.txt new file mode 100644 index 0000000..87de368 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/10/input.txt @@ -0,0 +1 @@ +98765421 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/10/output.txt b/challenges/look-and-say-sequence-conway/test/10/output.txt new file mode 100644 index 0000000..62256d3 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/10/output.txt @@ -0,0 +1 @@ +1918171615141211 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/2/input.txt b/challenges/look-and-say-sequence-conway/test/2/input.txt new file mode 100644 index 0000000..02be51a --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/2/input.txt @@ -0,0 +1 @@ +1211 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/2/output.txt b/challenges/look-and-say-sequence-conway/test/2/output.txt new file mode 100644 index 0000000..1324ce7 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/2/output.txt @@ -0,0 +1 @@ +111221 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/3/input.txt b/challenges/look-and-say-sequence-conway/test/3/input.txt new file mode 100644 index 0000000..f65edad --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/3/input.txt @@ -0,0 +1 @@ +1312211231131112311211232221121321132132211331121321231231121113112221121321133112132112312321123113112221121113122113121113123112112322111213 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/3/output.txt b/challenges/look-and-say-sequence-conway/test/3/output.txt new file mode 100644 index 0000000..9cc7662 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/3/output.txt @@ -0,0 +1 @@ +111311222112132113311213211221121332211211131221131211132221232112111312111213111213211231132132211211131221232112111312211213111213122112132113213221123113112221131112311311121321122112132231121113 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/4/input.txt b/challenges/look-and-say-sequence-conway/test/4/input.txt new file mode 100644 index 0000000..56a6051 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/4/input.txt @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/4/output.txt b/challenges/look-and-say-sequence-conway/test/4/output.txt new file mode 100644 index 0000000..9d60796 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/4/output.txt @@ -0,0 +1 @@ +11 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/5/input.txt b/challenges/look-and-say-sequence-conway/test/5/input.txt new file mode 100644 index 0000000..930ba36 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/5/input.txt @@ -0,0 +1 @@ +3113112221232112111312211312113211 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/5/output.txt b/challenges/look-and-say-sequence-conway/test/5/output.txt new file mode 100644 index 0000000..1b264de --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/5/output.txt @@ -0,0 +1 @@ +1321132132111213122112311311222113111221131221 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/6/input.txt b/challenges/look-and-say-sequence-conway/test/6/input.txt new file mode 100644 index 0000000..39724cf --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/6/input.txt @@ -0,0 +1 @@ +1113213211 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/6/output.txt b/challenges/look-and-say-sequence-conway/test/6/output.txt new file mode 100644 index 0000000..c3af407 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/6/output.txt @@ -0,0 +1 @@ +31131211131221 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/7/input.txt b/challenges/look-and-say-sequence-conway/test/7/input.txt new file mode 100644 index 0000000..c4e6a16 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/7/input.txt @@ -0,0 +1 @@ +11189 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/7/output.txt b/challenges/look-and-say-sequence-conway/test/7/output.txt new file mode 100644 index 0000000..525d8d2 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/7/output.txt @@ -0,0 +1 @@ +311819 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/8/input.txt b/challenges/look-and-say-sequence-conway/test/8/input.txt new file mode 100644 index 0000000..a1dda08 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/8/input.txt @@ -0,0 +1 @@ +111895647 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/8/output.txt b/challenges/look-and-say-sequence-conway/test/8/output.txt new file mode 100644 index 0000000..c885b68 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/8/output.txt @@ -0,0 +1 @@ +31181915161417 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/9/input.txt b/challenges/look-and-say-sequence-conway/test/9/input.txt new file mode 100644 index 0000000..e2e107a --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/9/input.txt @@ -0,0 +1 @@ +123456789 \ No newline at end of file diff --git a/challenges/look-and-say-sequence-conway/test/9/output.txt b/challenges/look-and-say-sequence-conway/test/9/output.txt new file mode 100644 index 0000000..6b59d04 --- /dev/null +++ b/challenges/look-and-say-sequence-conway/test/9/output.txt @@ -0,0 +1 @@ +111213141516171819 \ No newline at end of file