Skip to content

Commit 1b79e2c

Browse files
author
Abhijit Sarkar
committed
Complete up to P69
1 parent 2b96bae commit 1b79e2c

File tree

126 files changed

+814
-153
lines changed

Some content is hidden

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

126 files changed

+814
-153
lines changed

.github/run.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ done
3434
if (( no_test == 0 )); then
3535
if [[ -z "$1" ]]; then
3636
./mill __.test
37-
elif ./mill resolve problems["$1"].__.test &>/dev/null; then
38-
./mill problems["$1"].__.test
37+
elif ./mill resolve modules["$1"].__.test &>/dev/null; then
38+
./mill modules["$1"].__.test
3939
else
4040
red='\033[0;31m'
4141
no_color='\033[0m'
@@ -45,8 +45,8 @@ fi
4545

4646
if (( no_lint == 0 )); then
4747
if [[ -z "${CI}" ]]; then
48-
./mill mill.scalalib.scalafmt.ScalafmtModule/reformatAll problems[_].sources
48+
./mill mill.scalalib.scalafmt.ScalafmtModule/reformatAll modules[_].__.sources
4949
else
50-
./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll problems[_].sources
50+
./mill mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll modules[_].__.sources
5151
fi
5252
fi

.scalafmt.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ version = "3.8.3"
22
align.preset = more
33
maxColumn = 120
44
runner.dialect = scala3
5-
assumeStandardLibraryStripMargin = true
5+
assumeStandardLibraryStripMargin = true
6+
project.excludePaths = [
7+
"glob:**/bintree/test/src/package.scala",
8+
]

README.md

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -4,135 +4,135 @@
44

55
## Working with lists
66

7-
[P01](src/main/scala/list/P01.scala) (*) Find the last element of a list.
7+
[P01](list/src/P01.scala) (*) Find the last element of a list.
88

9-
[P02](src/main/scala/list/P02.scala) (*) Find the last but one element of a list.
9+
[P02](list/src/P02.scala) (*) Find the last but one element of a list.
1010

11-
[P03](src/main/scala/list/P03.scala) (*) Find the Kth element of a list.
11+
[P03](list/src/P03.scala) (*) Find the Kth element of a list.
1212

13-
[P04](src/main/scala/list/P04.scala) (*) Find the number of elements of a list.
13+
[P04](list/src/P04.scala) (*) Find the number of elements of a list.
1414

15-
[P05](src/main/scala/list/P05.scala) (*) Reverse a list.
15+
[P05](list/src/P05.scala) (*) Reverse a list.
1616

17-
[P06](src/main/scala/list/P06.scala) (*) Find out whether a list is a palindrome.
17+
[P06](list/src/P06.scala) (*) Find out whether a list is a palindrome.
1818

19-
[P07](src/main/scala/list/P07.scala) (**) Flatten a nested list structure.
19+
[P07](list/src/P07.scala) (**) Flatten a nested list structure.
2020

21-
[P08](src/main/scala/list/P08.scala) (**) Eliminate consecutive duplicates of list elements.
21+
[P08](list/src/P08.scala) (**) Eliminate consecutive duplicates of list elements.
2222

23-
[P09](src/main/scala/list/P09.scala) (**) Pack consecutive duplicates of list elements into sublists.
23+
[P09](list/src/P09.scala) (**) Pack consecutive duplicates of list elements into sublists.
2424

25-
[P10](src/main/scala/list/P10.scala) (*) Run-length encoding of a list.
25+
[P10](list/src/P10.scala) (*) Run-length encoding of a list.
2626

27-
[P11](src/main/scala/list/P11.scala) (*) Modified run-length encoding.
27+
[P11](list/src/P11.scala) (*) Modified run-length encoding.
2828

29-
[P12](src/main/scala/list/P12.scala) (**) Decode a run-length encoded list.
29+
[P12](list/src/P12.scala) (**) Decode a run-length encoded list.
3030

31-
[P13](src/main/scala/list/P13.scala) (**) Run-length encoding of a list (direct solution).
31+
[P13](list/src/P13.scala) (**) Run-length encoding of a list (direct solution).
3232

33-
[P14](src/main/scala/list/P14.scala) (*) Duplicate the elements of a list.
33+
[P14](list/src/P14.scala) (*) Duplicate the elements of a list.
3434

35-
[P15](src/main/scala/list/P15.scala) (**) Duplicate the elements of a list a given number of times.
35+
[P15](list/src/P15.scala) (**) Duplicate the elements of a list a given number of times.
3636

37-
[P16](src/main/scala/list/P16.scala) (**) Drop every Nth element from a list.
37+
[P16](list/src/P16.scala) (**) Drop every Nth element from a list.
3838

39-
[P17](src/main/scala/list/P17.scala) (*) Split a list into two parts.
39+
[P17](list/src/P17.scala) (*) Split a list into two parts.
4040

41-
[P18](src/main/scala/list/P18.scala) (**) Extract a slice from a list.
41+
[P18](list/src/P18.scala) (**) Extract a slice from a list.
4242

43-
[P19](src/main/scala/list/P19.scala) (**) Rotate a list N places to the left.
43+
[P19](list/src/P19.scala) (**) Rotate a list N places to the left.
4444

45-
[P20](src/main/scala/list/P20.scala) (*) Remove the Kth element from a list.
45+
[P20](list/src/P20.scala) (*) Remove the Kth element from a list.
4646

47-
[P21](src/main/scala/list/P21.scala) (*) Insert an element at a given position into a list.
47+
[P21](list/src/P21.scala) (*) Insert an element at a given position into a list.
4848

49-
[P22](src/main/scala/list/P22.scala) (*) Create a list containing all integers within a given range.
49+
[P22](list/src/P22.scala) (*) Create a list containing all integers within a given range.
5050

51-
[P23](src/main/scala/list/P23.scala) (**) Extract a given number of randomly selected elements from a list.
51+
[P23](list/src/P23.scala) (**) Extract a given number of randomly selected elements from a list.
5252

53-
[P24](src/main/scala/list/P24.scala) (*) Lotto: Draw N different random numbers from the set 1..M.
53+
[P24](list/src/P24.scala) (*) Lotto: Draw N different random numbers from the set 1..M.
5454

55-
[P25](src/main/scala/list/P25.scala) (*) Generate a random permutation of the elements of a list.
55+
[P25](list/src/P25.scala) (*) Generate a random permutation of the elements of a list.
5656

57-
[P26](src/main/scala/list/P26.scala) (**) Generate the combinations of K distinct objects chosen from the N elements of a list.
57+
[P26](list/src/P26.scala) (**) Generate the combinations of K distinct objects chosen from the N elements of a list.
5858

59-
[P27](src/main/scala/list/P27.scala) (**) Group the elements of a set into disjoint subsets.
59+
[P27](list/src/P27.scala) (**) Group the elements of a set into disjoint subsets.
6060

61-
[P28](src/main/scala/list/P28.scala) (**) Sorting a list of lists according to length of sublists.
61+
[P28](list/src/P28.scala) (**) Sorting a list of lists according to length of sublists.
6262

6363
## Arithmetic
6464

65-
[P31](src/main/scala/arithmetic/P31.scala) (**) Determine whether a given integer number is prime.
65+
[P31](arithmetic/src/P31.scala) (**) Determine whether a given integer number is prime.
6666

67-
[P32](src/main/scala/arithmetic/P32.scala) (**) Determine the greatest common divisor of two positive integer numbers.
67+
[P32](arithmetic/src/P32.scala) (**) Determine the greatest common divisor of two positive integer numbers.
6868

69-
[P33](src/main/scala/arithmetic/P33.scala) (*) Determine whether two positive integer numbers are coprime.
69+
[P33](arithmetic/src/P33.scala) (*) Determine whether two positive integer numbers are coprime.
7070

71-
[P34](src/main/scala/arithmetic/P34.scala) (**) Calculate Euler’s totient function ϕ(m).
71+
[P34](arithmetic/src/P34.scala) (**) Calculate Euler’s totient function ϕ(m).
7272

73-
[P35](src/main/scala/arithmetic/P35.scala) (**) Determine the prime factors of a given positive integer.
73+
[P35](arithmetic/src/P35.scala) (**) Determine the prime factors of a given positive integer.
7474

75-
[P36](src/main/scala/arithmetic/P36.scala) (**) Determine the prime factors of a given positive integer (2).
75+
[P36](arithmetic/src/P36.scala) (**) Determine the prime factors of a given positive integer (2).
7676

7777
P37 (**) Calculate Euler’s totient function ϕ(m) (improved).
7878

7979
P38 (*) Compare the two methods of calculating Euler’s totient function.
8080

81-
[P39](src/main/scala/arithmetic/P39.scala) (*) A list of prime numbers.
81+
[P39](arithmetic/src/P39.scala) (*) A list of prime numbers.
8282

83-
[P40](src/main/scala/arithmetic/P40.scala) (**) Goldbach's conjecture.
83+
[P40](arithmetic/src/P40.scala) (**) Goldbach's conjecture.
8484

85-
[P41](src/main/scala/arithmetic/P41.scala) (**) A list of Goldbach compositions.
85+
[P41](arithmetic/src/P41.scala) (**) A list of Goldbach compositions.
8686

8787
## Logic and Codes
8888

89-
[P46](src/main/scala/logic/P46.scala) (**) Truth tables for logical expressions.
89+
[P46](logic/src/P46.scala) (**) Truth tables for logical expressions.
9090

91-
[P47](src/main/scala/logic/P47.scala) (*) Truth tables for logical expressions (2).
91+
[P47](logic/src/P47.scala) (*) Truth tables for logical expressions (2).
9292

9393
P48 (**) Truth tables for logical expressions (3).
9494

95-
[P49](src/main/scala/logic/P49.scala) (**) Gray code.
95+
[P49](logic/src/P49.scala) (**) Gray code.
9696

97-
[P50](src/main/scala/logic/P50.scala) (***) Huffman code.
97+
[P50](logic/src/P50.scala) (***) Huffman code.
9898

9999
## Binary Trees
100100

101101
P54 Omitted; our tree representation will only allow well-formed trees.
102102

103-
[P55](src/main/scala/bintree/P55.scala) (**) Construct completely balanced binary trees.
103+
[P55](bintree/src/P55.scala) (**) Construct completely balanced binary trees.
104104

105-
[P56](src/main/scala/bintree/P56.scala) (**) Symmetric binary trees.
105+
[P56](bintree/src/P56.scala) (**) Symmetric binary trees.
106106

107-
[P57](src/main/scala/bintree/P57.scala) (**) Binary search trees (dictionaries).
107+
[P57](bintree/src/P57.scala) (**) Binary search trees (dictionaries).
108108

109-
[P58](src/main/scala/bintree/P58.scala) (**) Generate-and-test paradigm.
109+
[P58](bintree/src/P58.scala) (**) Generate-and-test paradigm.
110110

111-
[P59](src/main/scala/bintree/P59.scala) (**) Construct height-balanced binary trees.
111+
[P59](bintree/src/P59.scala) (**) Construct height-balanced binary trees.
112112

113-
P60 (**) Construct height-balanced binary trees with a given number of nodes.
113+
[P60](bintree/src/P60.scala) (**) Construct height-balanced binary trees with a given number of nodes.
114114

115-
P61 (*) Count the leaves of a binary tree.
115+
[P61](bintree/src/P61.scala) (*) Count the leaves of a binary tree.
116116

117-
P61A (*) Collect the leaves of a binary tree in a list.
117+
[P61A](bintree/P61A.scala) (*) Collect the leaves of a binary tree in a list.
118118

119-
P62 (*) Collect the internal nodes of a binary tree in a list.
119+
[P62](bintree/src/P62.scala) (*) Collect the internal nodes of a binary tree in a list.
120120

121-
P62B (*) Collect the nodes at a given level in a list.
121+
[P62B](bintree/P62B.scala) (*) Collect the nodes at a given level in a list.
122122

123-
P63 (**) Construct a complete binary tree.
123+
[P63](bintree/src/P63.scala) (**) Construct a complete binary tree.
124124

125-
P64 (**) Layout a binary tree (1).
125+
[P64](bintree/src/P64.scala) (**) Layout a binary tree (1).
126126

127-
P65 (**) Layout a binary tree (2).
127+
[P65](bintree/src/P65.scala) (**) Layout a binary tree (2).
128128

129129
P66 (***) Layout a binary tree (3).
130130

131-
P67 (**) A string representation of binary trees.
131+
[P67](bintree/src/P67.scala) (**) A string representation of binary trees.
132132

133-
P68 (**) Preorder and inorder sequences of binary trees.
133+
[P68](bintree/src/P68.scala) (**) Preorder and inorder sequences of binary trees.
134134

135-
P69 (**) Dotstring representation of binary trees.
135+
[P69](bintree/src/P69.scala) (**) Dotstring representation of binary trees.
136136

137137
## Multiway Trees
138138

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)