Skip to content

Commit dd7d748

Browse files
Dart armstrong-numbers: Create mentoring.md (#2223)
* Create mentoring.md Added mentoring notes for mentors * Apply suggestions from code review --------- Co-authored-by: Derk-Jan Karrenbeld <[email protected]>
1 parent c3d586f commit dd7d748

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Diff for: tracks/dart/exercises/armstrong-numbers/mentoring.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Mentoring
2+
3+
## Reasonable solutions
4+
5+
Let them know that the most important thing to do here is not to try to code first, but to know how the maths behind this exercise is and how to solve it on paper.
6+
You can use this [website][reference-math-website] to explain it.
7+
Next they can go ahead and take what they wrote down and try to put it in a coding logic.
8+
Lastly, they can go and put their written solution to a code now.
9+
10+
They should always use this approach before start to code, so coding become only a tool for the solution.
11+
12+
```dart
13+
import 'dart:math';
14+
class ArmstrongNumbers{
15+
bool isArmstrongNumber(int number) => number == number.toString()
16+
.split("")
17+
.fold(0,(prev,curr)=> prev + pow(int.parse(curr),number.toString().length));
18+
}
19+
```
20+
21+
[reference-math-website]: https://mathworld.wolfram.com/NarcissisticNumber.html
22+
23+
## Common suggestions
24+
25+
- they already know about [fold-method][reference-fold-method] and how to use it
26+
- math library should be imported here so they can use the [pow-method][reference-pow-method]
27+
- they need to convert String to Integer using the [parse-method][reference-parse-method]
28+
29+
[reference-fold-method]: https://api.dart.dev/stable/1.10.1/dart-core/List/fold.html
30+
[reference-pow-method]: https://api.dart.dev/stable/2.10.5/dart-math/pow.html
31+
[reference-parse-method]: https://api.flutter.dev/flutter/dart-core/int/parse.html
32+
33+
## Solution Video
34+
35+
Step by step [video][youtube-video] guide solution for this exercise
36+
37+
[youtube-video]: https://www.youtube.com/watch?v=0DfS3jM4pLA&t=757s

0 commit comments

Comments
 (0)