File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+ "math"
6
+ "strconv"
7
+ )
8
+
9
+
10
+ func ReverseNumber (number int ) int {
11
+ strNumber := strconv .Itoa (number )
12
+ reverseStrNumber := ""
13
+ for length := len (strNumber ); length > 0 ; length -- {
14
+ reverseStrNumber += string (strNumber [length - 1 ])
15
+ }
16
+ reverseNum , error := strconv .Atoi (reverseStrNumber )
17
+ if error != nil {
18
+ fmt .Println ("Failure to cast String to int" )
19
+ }
20
+ return reverseNum
21
+ }
22
+
23
+ func beautifulDays (i int32 , j int32 , k int32 ) int32 {
24
+ var count = int32 (0 )
25
+ for d := i ; d <= j ; d ++ {
26
+ var result = math .Abs (float64 (d - int32 (ReverseNumber (int (d )))))/ float64 (k )
27
+ if result == float64 (int32 (result )) {
28
+ count += 1
29
+ }
30
+ }
31
+ return count
32
+ }
33
+
34
+
35
+ func main () {
36
+ fmt .Println (beautifulDays (20 , 23 , 6 ))
37
+ }
You can’t perform that action at this time.
0 commit comments