import Foundation
func solution(_ n:Int) -> Int {
var num = n
var sum = 0
var digit = 1
var arr = [Int]()
while (num > 0) {
arr.append(num % 3)
num /= 3
}
for n in arr.reversed() {
sum += n * digit
digit *= 3
}
return sum
}
import Foundation
func solution(_ n:Int) -> Int {
let flipToThree = String(n,radix: 3)
let answer = Int(String(flipToThree.reversed()),radix:3)!
return answer
}
var value = 100
var result = ""
result = String(value, radix: 2)
print(result) // 1100100
var value = "1100100"
var result: Int = Int(value, radix: 2)!
print(result) // 100
var value = "1100100"
var result: Int = Int(value, radix: 2)!
var newResult: String = String(result, radix: 16)
print(newResult) // c9
2진수 -> 10진수 -> 16진수