Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Subleq/Julia/subleq-1.julia
Normal file
30
Task/Subleq/Julia/subleq-1.julia
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
module Subleq
|
||||
|
||||
using OffsetArrays
|
||||
|
||||
function interpret(allwords::AbstractVector{Int})
|
||||
words = OffsetArray(allwords, -1)
|
||||
buf = IOBuffer()
|
||||
ip = 0
|
||||
while true
|
||||
a, b, c = words[ip:ip+2]
|
||||
ip += 3
|
||||
if a < 0
|
||||
print("Enter a character: ")
|
||||
words[b] = parse(Int, readline(stdin))
|
||||
elseif b < 0
|
||||
print(buf, Char(words[a]))
|
||||
else
|
||||
words[b] -= words[a]
|
||||
if words[b] ≤ 0
|
||||
ip = c
|
||||
end
|
||||
ip < 0 && break
|
||||
end
|
||||
end
|
||||
return String(take!(buf))
|
||||
end
|
||||
|
||||
interpret(src::AbstractString) = interpret(parse.(Int, split(src)))
|
||||
|
||||
end # module Subleq
|
||||
4
Task/Subleq/Julia/subleq-2.julia
Normal file
4
Task/Subleq/Julia/subleq-2.julia
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
using .Subleq
|
||||
|
||||
print(Subleq.interpret("15 17 -1 17 -1 -1 16 1 -1 16 3 -1 15 15 0 0 -1 72 101
|
||||
108 108 111 44 32 119 111 114 108 100 33 10 0"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue