We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f38e77b commit e25809bCopy full SHA for e25809b
Check if The Number is Fascinating/kata.go
@@ -0,0 +1,33 @@
1
+package kata
2
+
3
+func isFascinating(n int) bool {
4
+ var stats = [9]int{}
5
+ for i := 1; i <= 3; i++ {
6
+ ok := countDigits(n*i, &stats)
7
+ if !ok {
8
+ return false
9
+ }
10
11
+ return assert(&stats)
12
+}
13
14
+func countDigits(n int, stats *[9]int) bool {
15
+ for n > 0 {
16
+ var digit = n % 10
17
+ n = n / 10
18
+ if digit == 0 {
19
20
21
+ stats[digit-1]++
22
23
+ return true
24
25
26
+func assert(stats *[9]int) bool {
27
+ for _, count := range stats {
28
+ if count == 0 || count > 1 {
29
30
31
32
33
0 commit comments