Problem:
Score : 200 points

Problem Statement

Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller?

Constraints

1 \leq a \leq 9

1 \leq b \leq 9

a and b are integers.

Input

Input is given from Standard Input in the following format:

a b

Output

Print the lexicographically smaller of the two strings. (If the two strings are equal, print one of them.)

Sample Input 1

4 3

Sample Output 1

3333

We have two strings 444 and 3333. Between them, 3333 is the lexicographically smaller.

Sample Input 2

7 7

Sample Output 2

7777777

Solution in Go (1.6) (judge verdict: Wrong Answer)

package main

import (
	"fmt"
	"sort"
	"strconv"
	"strings"
)

func solution(a, b int) int {
	ab := make([]int, b)
	ba := make([]int, a)

	// aをb回
	for i := 0; i < b; i++ {
		ab[i] = a
	}
	// bをa回
	for i := 0; i < a; i++ {
		ba[i] = b
	}

	if dictionaryOrder(ab) < dictionaryOrder(ba) {
		return ints2int(ab)
	}
	return ints2int(ba)
}

func ints2int(nums []int) int {
	strs := make([]string, len(nums))

	for i := range nums {
		strs[i] = strconv.Itoa(nums[i])
	}
	ans, _ := strconv.Atoi(strings.Join(strs, ""))
	return ans
}

func dictionaryOrder(nums []int) int {
	var ans int
	l := len(nums)
	for i := 0; i < l; i++ {
		n := nums[i]
		arr := make([]int, len(nums)-i)
		copy(arr, nums[i:])
		a := ascNumber(arr, n) - 1
		if a == 0 {
			ans += 0
		} else {
			ans += a * factorical(l-i-1)
		}
	}
	ans++
	return ans
}

func ascNumber(nums []int, n int) int {
	sort.Ints(nums)
	var i int = 1
	for _, v := range nums {
		if v == n {
			break
		}
		i++
	}
	return i
}

func factorical(n int) int {
	if n == 0 || n == 1 {
		return 1
	}
	return n * factorical(n-1)
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(solution(a, b))
}