Last active
January 1, 2020 05:37
-
-
Save ilius/f8e98f44f809d169ea91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc PlayNumber { amount } { | |
# _200+.au _30+.au _4.au _1000+.au _1.au | |
#puts "\nDEBUGGING : PlayNumber: amount=$amount" | |
set result {} | |
####################### | |
if { $amount <= 20 } { | |
lappend result "_$amount.au" | |
return $result | |
} | |
####################### | |
if { $amount > 1000000000 } { | |
set b10 1000000000 | |
} elseif { $amount > 1000000 } { | |
set b10 1000000 | |
} elseif { $amount > 1000 } { | |
set b10 1000 | |
} elseif { $amount > 100 } { | |
set b10 100 | |
} elseif { $amount > 10 } { | |
set b10 10 | |
} else { | |
set b10 1 | |
} | |
####################### | |
set head [expr $amount / $b10] | |
set headAll [expr $head * $b10] | |
set rest [expr $amount % $headAll] | |
######### | |
if { $b10 >= 1000 } { | |
if { $head > 1 } { | |
foreach a [PlayNumber $head] {lappend result $a} | |
} | |
if { $rest > 0 } { | |
lappend result "_$b10+.au" | |
foreach a [PlayNumber $rest] {lappend result $a} | |
} else { | |
lappend result "_$b10.au" | |
} | |
} else { | |
if { $rest > 0 } { | |
lappend result "_$headAll+.au" | |
foreach a [PlayNumber $rest] {lappend result $a} | |
} else { | |
lappend result "_$headAll.au" | |
} | |
} | |
####################### | |
return $result | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment