aboutsummaryrefslogtreecommitdiff
path: root/rust/saddle-points/README.md
diff options
context:
space:
mode:
authorFederico Igne <git@federicoigne.com>2020-12-26 17:48:38 +0000
committerFederico Igne <git@federicoigne.com>2021-11-03 18:55:08 +0000
commit02481656966b0a8dfc95cf3c22bcc049660ff7d4 (patch)
tree8e39798fcaf27931d91c2088423fd4e97adcfc2d /rust/saddle-points/README.md
parent4e2052c4d792540c2f742b2c2a081b11117ed41d (diff)
downloadexercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.tar.gz
exercism-02481656966b0a8dfc95cf3c22bcc049660ff7d4.zip
Move Rust exercises in a subdirectory
Diffstat (limited to 'rust/saddle-points/README.md')
-rw-r--r--rust/saddle-points/README.md132
1 files changed, 132 insertions, 0 deletions
diff --git a/rust/saddle-points/README.md b/rust/saddle-points/README.md
new file mode 100644
index 0000000..84647d0
--- /dev/null
+++ b/rust/saddle-points/README.md
@@ -0,0 +1,132 @@
1# Saddle Points
2
3Detect saddle points in a matrix.
4
5So say you have a matrix like so:
6
7```text
8 1 2 3
9 |---------
101 | 9 8 7
112 | 5 3 2 <--- saddle point at column 1, row 2, with value 5
123 | 6 6 7
13```
14
15It has a saddle point at column 1, row 2.
16
17It's called a "saddle point" because it is greater than or equal to
18every element in its row and less than or equal to every element in
19its column.
20
21A matrix may have zero or more saddle points.
22
23Your code should be able to provide the (possibly empty) list of all the
24saddle points for any given matrix.
25
26The matrix can have a different number of rows and columns (Non square).
27
28Note that you may find other definitions of matrix saddle points online,
29but the tests for this exercise follow the above unambiguous definition.
30
31## Rust Indices Start At 0
32
33By convention, ordered sequences of values in Rust have their contents numbered
34("indexed") starting from 0. This applies regardless of what the rest of the
35exercise description in this README says, such as references to indices that
36start at 1, so you will have to subtract 1 to translate those index numbers
37to Rust index numbers.
38
39## Efficiency Notice
40
41This exercise uses a _vector of vectors_ to store the content of matrices. While
42this exercise is designed to help students understand basic concepts about
43vectors, such as indexing, and that nested data types are legal, _vector of
44vectors_ is a suboptimal choice for high-performance matrix algebra and any
45similar efficient processing of larger amounts of data.
46
47The detailed explanation of this inefficiency is beyond the scope of this
48exercise and this learning track in general. This aspect is known as
49[cache locality](https://stackoverflow.com/questions/12065774/why-does-cache-locality-matter-for-array-performance)
50and you can find a good introduction to it by clicking that link if you'd like
51to learn more about details of a modern computer architecture.
52
53
54## Rust Installation
55
56Refer to the [exercism help page][help-page] for Rust installation and learning
57resources.
58
59## Writing the Code
60
61Execute the tests with:
62
63```bash
64$ cargo test
65```
66
67All but the first test have been ignored. After you get the first test to
68pass, open the tests source file which is located in the `tests` directory
69and remove the `#[ignore]` flag from the next test and get the tests to pass
70again. Each separate test is a function with `#[test]` flag above it.
71Continue, until you pass every test.
72
73If you wish to run all ignored tests without editing the tests source file, use:
74
75```bash
76$ cargo test -- --ignored
77```
78
79To run a specific test, for example `some_test`, you can use:
80
81```bash
82$ cargo test some_test
83```
84
85If the specific test is ignored use:
86
87```bash
88$ cargo test some_test -- --ignored
89```
90
91To learn more about Rust tests refer to the [online test documentation][rust-tests]
92
93Make sure to read the [Modules][modules] chapter if you
94haven't already, it will help you with organizing your files.
95
96## Further improvements
97
98After you have solved the exercise, please consider using the additional utilities, described in the [installation guide](https://exercism.io/tracks/rust/installation), to further refine your final solution.
99
100To format your solution, inside the solution directory use
101
102```bash
103cargo fmt
104```
105
106To see, if your solution contains some common ineffective use cases, inside the solution directory use
107
108```bash
109cargo clippy --all-targets
110```
111
112## Submitting the solution
113
114Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer.
115
116## Feedback, Issues, Pull Requests
117
118The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help!
119
120If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
121
122[help-page]: https://exercism.io/tracks/rust/learning
123[modules]: https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html
124[cargo]: https://doc.rust-lang.org/book/ch14-00-more-about-cargo.html
125[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html
126
127## Source
128
129J Dalbey's Programming Practice problems [http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html](http://users.csc.calpoly.edu/~jdalbey/103/Projects/ProgrammingPractice.html)
130
131## Submitting Incomplete Solutions
132It's possible to submit an incomplete solution so you can see how others have completed the exercise.