Skip to content

Commit 2564014

Browse files
committed
Example comments for the rest of the problems
1 parent 6a8ff85 commit 2564014

File tree

5 files changed

+62
-8
lines changed

5 files changed

+62
-8
lines changed

strings/longest_substring_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ TestLongestSubstrings tests solution(s) with the following signature and problem
77
88
func LongestSubstringOfTwoChars(input string) string
99
10-
Given a string like "aabbc" return the longest substring of two unique characters like "aabb".
10+
Given a string return the longest substring of two unique characters.
11+
12+
For example given "aabbc", return "aabb" because it's the longest substring that has two unique
13+
characters "a" and "b".
14+
15+
Other substrings of "aabc" include:
16+
17+
* "aabbc", contains more than 2 unique characters.
18+
* "bbc", shorter than "aabb".
1119
*/
1220
func TestLongestSubstrings(t *testing.T) {
1321
tests := []struct {
@@ -21,7 +29,7 @@ func TestLongestSubstrings(t *testing.T) {
2129
{"aabbc", "aabb"},
2230
{"ada", "ada"},
2331
{"dafff", "afff"},
24-
{"assdeeeddfffha", "deeedd"},
32+
{"abbdeeeddfffha", "deeedd"},
2533
}
2634

2735
for i, test := range tests {

strings/look_and_tell_test.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,27 @@ TestFindDuplicate tests solution(s) with the following signature and problem des
77
88
func LookAndTell(depth int) []string
99
10-
Given a depth, return the output of look and tell an algorithm where each line reads the
11-
last line. For example "1" is read as "11" (one one), and "11" is read as "21" (two ones).
10+
Given a positive integer n, return the output of the Look and Tell algorithm until the nth depth.
11+
12+
The Look and Tell algorithm starts by outputting 1 at first level, then at each subsequent level
13+
it reads the previous line by counting the number of times a digit is repeated and then writes
14+
the count and the digit.
15+
16+
For example given 4, return:
17+
18+
1
19+
11
20+
21
21+
1211
22+
23+
Which reads:
24+
one
25+
one one
26+
two ones
27+
one two one one.
28+
29+
The third output (two ones) reads the level before it which is 11. Two ones means repeat
30+
1 two times i.e. 11.
1231
*/
1332
func TestFindDuplicate(t *testing.T) {
1433
tests := []struct {

strings/number_in_english_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ TestReadNumberInEnglish tests solution(s) with the following signature and probl
77
88
func NumberInEnglish(num int) string
99
10-
Given a number like 34, return how the number would be read in English e.g. (Thirty Four) for
11-
integers smaller than one Trillion.
10+
Given n a positive integer smaller than a Trillion, return the number in English words.
11+
12+
For example given 0, return "Zero".
13+
For example given 34, return "Thirty Four".
14+
For example given 10, return "Ten".
15+
For example given 900000000001, return "Nine Hundred Billion One".
1216
*/
1317
func TestReadNumberInEnglish(t *testing.T) {
1418
tests := []struct {
@@ -18,10 +22,12 @@ func TestReadNumberInEnglish(t *testing.T) {
1822
{0, "Zero"},
1923
{1, "One"},
2024
{2, "Two"},
25+
{10, "Ten"},
2126
{34, "Thirty Four"},
2227
{123456789, "One Hundred Twenty Three Million Four Hundred Fifty Six Thousand Seven Hundred Eighty Nine"},
2328
{1000000000, "One Billion"},
2429
{100000000000, "One Hundred Billion"},
30+
{900000000001, "Nine Hundred Billion One"},
2531
}
2632

2733
for i, test := range tests {

strings/reverse_vowels_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ TestReverseVowels tests solution(s) with the following signature and problem des
77
88
func ReverseVowels(str string) (string, error)
99
10-
Given a string e.g. "coat", reverse the order in which vowels appear e.g. "caot".
10+
Given a string, return the same string while reversing the vowels {"a", "e", "i", "o", "u"}
11+
appear in it.
12+
13+
For example given "coat", return "caot", because the vowels are "o" and "a" and their positions
14+
are reversed.
1115
*/
1216
func TestReverseVowels(t *testing.T) {
1317
tests := []struct {

strings/roman_numerals_test.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,24 @@ TestIntToRoman tests solution(s) with the following signature and problem descri
77
88
func IntToRoman(input int) string
99
10-
Given a positive integer like 1917 return the Roman numeral like MCMXVII.
10+
Given a positive integer like return the equivalent inRoman numerals:
11+
12+
For example:
13+
14+
* Given 1, return I
15+
* Given 4, return IV
16+
* Given 5, return V
17+
* Given 9, return IX
18+
* Given 10, return X
19+
* Given 40, return XL
20+
* Given 50, return L
21+
* Given 90, return XC
22+
* Given 100, return C
23+
* Given 400, return CD
24+
* Given 500, return D
25+
* Given 900, return CM
26+
* Given 1000, return M
27+
* Given 1917, return MCMXVII.
1128
*/
1229
func TestIntToRoman(t *testing.T) {
1330
tests := []struct {

0 commit comments

Comments
 (0)