Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "strconv"
- )
- func main() {
- //var num int64
- //fmt.Println(getSpreadsheetNotation(num))
- fmt.Println(getSpreadsheetNotation(27))
- fmt.Println(getSpreadsheetNotation(1405))
- }
- func getSpreadsheetNotation(a int64) string {
- var div702 int64 = a / 702
- var mod702 int64 = a % 702
- if mod702 != 0 {
- div702++
- } else {
- mod702 = 702
- }
- var div26 int64 = mod702 / 26
- var mod26 int64 = mod702 % 26
- if mod26 == 0 {
- mod26 = 26
- div26--
- }
- var firstLetter = string('A' - 1 + div26)
- var secondLetter = string('A' - 1 + mod26)
- if div26 == 0 {
- return strconv.FormatInt(div702, 10) + secondLetter
- } else {
- return strconv.FormatInt(div702, 10) + firstLetter + secondLetter
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement