-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (58 loc) · 938 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"fmt"
"strconv"
)
func isPalindrome(x int) bool {
palind := x
convAscii := strconv.Itoa(x)
newChar := ""
for i := len(convAscii); i > 0; i-- {
newChar += string(convAscii[i-1])
}
convInt, _ := strconv.Atoi(newChar)
fmt.Println(convInt)
if convInt == palind {
return true
}
return false
}
func romanToInt(s string) int {
sum := 0
for i := 0; i < len(s); i++ {
fmt.Println(string(s[i]))
switch string(s[i]) {
case "I":
sum = sum + 1
continue
case "V":
sum = sum + 5
continue
case "X":
sum = sum + 10
continue
case "L":
sum = sum + 50
continue
case "C":
sum = sum + 100
continue
case "D":
sum = sum + 500
continue
case "M":
sum = sum + 1000
continue
default:
sum = 0
}
}
return sum
}
func main() {
//n := isPalindrome(121)
//fmt.Println(n)
//x := romanToInt("MCMXCIV")
//fmt.Println(x)
//fmt.Println(bits.Add(10, 10, 0))
}