Skip to content

Instantly share code, notes, and snippets.

@haru01
Created May 31, 2017 00:14
Show Gist options
  • Save haru01/aa50ce0b2e8606ffbd0cf467d3d83d66 to your computer and use it in GitHub Desktop.
Save haru01/aa50ce0b2e8606ffbd0cf467d3d83d66 to your computer and use it in GitHub Desktop.
numberの括りだし
package roman
type Arabian uint16
var numbers = []struct {
arabian Arabian
roman string
}{
{5, "V"},
{1, "I"},
}
func (in Arabian) ToRoman() (out string) {
for remain := in; remain != 0; {
for _, n := range numbers {
if remain >= n.arabian {
out += n.roman
remain = remain - n.arabian
}
}
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment