Skip to content

Commit 415b7f1

Browse files
committed
Create beautiful_days_at_the_movies.go
1 parent 3ea3492 commit 415b7f1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy