-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rust/armstrong-numbers: 1st iteration
- Loading branch information
Showing
8 changed files
with
636 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
1| 39|pub fn is_armstrong_number(candidate: u32) -> bool { | ||
2| 39| if candidate < 10 { | ||
3| 6| return true; | ||
4| 33| } | ||
5| 33| | ||
6| 33| let digit_count: usize = ((candidate as f64).log10() as usize) + 1; | ||
7| 33| | ||
8| 33| let mut num: u64 = candidate as u64; | ||
9| 33| let mut pow_total: u64 = 0; | ||
10| | | ||
11| 237| while num > 0 { | ||
12| 204| let pow_temp: u64 = num % 10; | ||
13| 204| let mut pow_temp_total = 1; | ||
14| 204| | ||
15| 1.54k| for _ in 0..digit_count { | ||
16| 1.54k| pow_temp_total *= pow_temp; | ||
17| 1.54k| } | ||
18| | | ||
19| 204| pow_total += pow_temp_total; | ||
20| 204| num /= 10; | ||
21| | } | ||
22| | | ||
23| 33| pow_total == (candidate as u64) | ||
24| 39|} | ||
------------------ | ||
| Unexecuted instantiation: armstrong_numbers::is_armstrong_number | ||
------------------ | ||
| armstrong_numbers::is_armstrong_number: | ||
| 1| 39|pub fn is_armstrong_number(candidate: u32) -> bool { | ||
| 2| 39| if candidate < 10 { | ||
| 3| 6| return true; | ||
| 4| 33| } | ||
| 5| 33| | ||
| 6| 33| let digit_count: usize = ((candidate as f64).log10() as usize) + 1; | ||
| 7| 33| | ||
| 8| 33| let mut num: u64 = candidate as u64; | ||
| 9| 33| let mut pow_total: u64 = 0; | ||
| 10| | | ||
| 11| 237| while num > 0 { | ||
| 12| 204| let pow_temp: u64 = num % 10; | ||
| 13| 204| let mut pow_temp_total = 1; | ||
| 14| 204| | ||
| 15| 1.54k| for _ in 0..digit_count { | ||
| 16| 1.54k| pow_temp_total *= pow_temp; | ||
| 17| 1.54k| } | ||
| 18| | | ||
| 19| 204| pow_total += pow_temp_total; | ||
| 20| 204| num /= 10; | ||
| 21| | } | ||
| 22| | | ||
| 23| 33| pow_total == (candidate as u64) | ||
| 24| 39|} | ||
------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Running: cargo llvm-cov --no-clean --all-features --workspace --show-missing-lines | ||
|
||
Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover | ||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
/home/vpayno/git_vpayno/exercism-workspace/rust/armstrong-numbers/src/lib.rs 9 0 100.00% 1 0 100.00% 20 0 100.00% 0 0 - | ||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ||
TOTAL 9 0 100.00% 1 0 100.00% 20 0 100.00% 0 0 - | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
SF:/home/vpayno/git_vpayno/exercism-workspace/rust/armstrong-numbers/src/lib.rs | ||
FN:1,_RNvCslYF4zgzl9EP_17armstrong_numbers19is_armstrong_number | ||
FN:1,_RNvCs88d671SGeHL_17armstrong_numbers19is_armstrong_number | ||
FNDA:0,_RNvCslYF4zgzl9EP_17armstrong_numbers19is_armstrong_number | ||
FNDA:13,_RNvCs88d671SGeHL_17armstrong_numbers19is_armstrong_number | ||
FNF:1 | ||
FNH:1 | ||
DA:1,13 | ||
DA:2,13 | ||
DA:3,2 | ||
DA:4,11 | ||
DA:5,11 | ||
DA:6,11 | ||
DA:7,11 | ||
DA:8,11 | ||
DA:9,11 | ||
DA:11,79 | ||
DA:12,68 | ||
DA:13,68 | ||
DA:14,68 | ||
DA:15,514 | ||
DA:16,514 | ||
DA:17,514 | ||
DA:19,68 | ||
DA:20,68 | ||
DA:23,11 | ||
DA:24,13 | ||
BRF:0 | ||
BRH:0 | ||
LF:20 | ||
LH:20 | ||
end_of_record |
Oops, something went wrong.