Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
57
Task/Four-is-magic/11l/four-is-magic.11l
Normal file
57
Task/Four-is-magic/11l/four-is-magic.11l
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
V Small = [‘zero’, ‘one’, ‘two’, ‘three’, ‘four’,
|
||||
‘five’, ‘six’, ‘seven’, ‘eight’, ‘nine’,
|
||||
‘ten’, ‘eleven’, ‘twelve’, ‘thirteen’, ‘fourteen’,
|
||||
‘fifteen’, ‘sixteen’, ‘seventeen’, ‘eighteen’, ‘nineteen’]
|
||||
|
||||
V Tens = [‘’, ‘’, ‘twenty’, ‘thirty’, ‘forty’, ‘fifty’, ‘sixty’, ‘seventy’, ‘eighty’, ‘ninety’]
|
||||
|
||||
V Illions = [‘’, ‘ thousand’, ‘ million’, ‘ billion’, ‘ trillion’, ‘ quadrillion’, ‘ quintillion’]
|
||||
|
||||
F say(Int64 =n) -> String
|
||||
V result = ‘’
|
||||
I n < 0
|
||||
result = ‘negative ’
|
||||
n = -n
|
||||
|
||||
I n < 20
|
||||
result ‘’= Small[Int(n)]
|
||||
|
||||
E I n < 100
|
||||
result ‘’= Tens[Int(n I/ 10)]
|
||||
V m = n % 10
|
||||
I m != 0
|
||||
result ‘’= ‘-’Small[Int(m)]
|
||||
|
||||
E I n < 1000
|
||||
result ‘’= Small[Int(n I/ 100)]‘ hundred’
|
||||
V m = n % 100
|
||||
I m != 0
|
||||
result ‘’= ‘ ’say(m)
|
||||
|
||||
E
|
||||
V sx = ‘’
|
||||
V i = 0
|
||||
L n > 0
|
||||
V m = n % 1000
|
||||
n I/= 1000
|
||||
I m != 0
|
||||
V ix = say(m)‘’Illions[i]
|
||||
I sx.len > 0
|
||||
ix ‘’= ‘ ’sx
|
||||
sx = ix
|
||||
i++
|
||||
result ‘’= sx
|
||||
|
||||
R result
|
||||
|
||||
F fourIsMagic(=n)
|
||||
V s = say(n).capitalize()
|
||||
V result = s
|
||||
L n != 4
|
||||
n = s.len
|
||||
s = say(n)
|
||||
result ‘’= ‘ is ’s‘, ’s
|
||||
R result‘ is magic.’
|
||||
|
||||
L(n) [Int64(0), 4, 6, 11, 13, 75, 100, 337, -164, 7FFF'FFFF'FFFF'FFFF]
|
||||
print(fourIsMagic(n))
|
||||
Loading…
Add table
Add a link
Reference in a new issue