mirror of
https://gitlab.rlp.net/mobitar/julia_course.git
synced 2024-11-16 13:28:10 +00:00
Add new task
This commit is contained in:
parent
dde727f0a2
commit
414f6ccf18
1 changed files with 94 additions and 40 deletions
|
@ -21,11 +21,70 @@ begin
|
||||||
using PlutoUI
|
using PlutoUI
|
||||||
|
|
||||||
function check_reverse_string()
|
function check_reverse_string()
|
||||||
if @isdefined reverse_string
|
if !@isdefined reverse_string
|
||||||
test_str = "BlablaHahaOKLOL"
|
return md"""
|
||||||
|
🔴 The function `reverse_string` is not implemented yet 🤨
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
test_str = "BlablaHahaOKLOL"
|
||||||
|
|
||||||
|
try
|
||||||
|
if reverse_string(test_str) != reverse(test_str)
|
||||||
|
return md"""
|
||||||
|
🔴 Your function delivers wrong results 😢
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
catch err
|
||||||
|
return md"""
|
||||||
|
🔴 Something is wrong with your function 😵
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
return md"""
|
||||||
|
🟢 Nice, all is fine 👌
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
function check_string_extraction()
|
||||||
|
if !@isdefined extracted
|
||||||
|
return md"""
|
||||||
|
🔴 The variable `extracted` is not defined yet 🤨
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
test_str = "Hello World"
|
||||||
|
|
||||||
|
try
|
||||||
|
if lowercase(extracted) != lowercase(test_str)
|
||||||
|
return md"""
|
||||||
|
🔴 "Hello world" is not extracted well yet 😢
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
catch err
|
||||||
|
return md"""
|
||||||
|
🔴 Something is wrong with your variable `extracted` 😵
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
return md"""
|
||||||
|
🟢 Nice, all is fine 👌
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
function check_squaring_difference()
|
||||||
|
if !@isdefined squaring_difference
|
||||||
|
return md"""
|
||||||
|
🔴 The function `squaring_difference` is not implemented yet 🤨
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
random_numbers = (331, 236, 69, 738, 949, 631, 761, 119, 729, 280)
|
||||||
|
results_to_random_numbers = (3006919850, 777687850, 5720330, 74226126612, 202912760050, 39674819100, 83918590100, 50410780, 70671821220, 1540279020)
|
||||||
|
|
||||||
|
for i in 1:length(random_numbers)
|
||||||
try
|
try
|
||||||
if reverse_string(test_str) != reverse(test_str)
|
if squaring_difference(random_numbers[i]) != results_to_random_numbers[i]
|
||||||
return md"""
|
return md"""
|
||||||
🔴 Your function delivers wrong results 😢
|
🔴 Your function delivers wrong results 😢
|
||||||
"""
|
"""
|
||||||
|
@ -35,44 +94,11 @@ begin
|
||||||
🔴 Something is wrong with your function 😵
|
🔴 Something is wrong with your function 😵
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
return md"""
|
|
||||||
🟢 Nice, all is fine 👌
|
|
||||||
"""
|
|
||||||
else
|
|
||||||
return md"""
|
|
||||||
🔴 The function `reverse_string` is not implemented yet 🤨
|
|
||||||
"""
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function check_squaring_difference()
|
|
||||||
if @isdefined squaring_difference
|
|
||||||
random_numbers = (331, 236, 69, 738, 949, 631, 761, 119, 729, 280)
|
|
||||||
results_to_random_numbers = (3006919850, 777687850, 5720330, 74226126612, 202912760050, 39674819100, 83918590100, 50410780, 70671821220, 1540279020)
|
|
||||||
|
|
||||||
for i in 1:length(random_numbers)
|
|
||||||
try
|
|
||||||
if squaring_difference(random_numbers[i]) != results_to_random_numbers[i]
|
|
||||||
return md"""
|
|
||||||
🔴 Your function delivers wrong results 😢
|
|
||||||
"""
|
|
||||||
end
|
|
||||||
catch err
|
|
||||||
return md"""
|
|
||||||
🔴 Something is wrong with your function 😵
|
|
||||||
"""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return md"""
|
return md"""
|
||||||
🟢 Nice, all is fine 👌
|
🟢 Nice, all is fine 👌
|
||||||
"""
|
"""
|
||||||
else
|
|
||||||
return md"""
|
|
||||||
🔴 The function `squaring_difference` is not implemented yet 🤨
|
|
||||||
"""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
md""
|
md""
|
||||||
|
@ -148,6 +174,30 @@ Example: "string" would get "gnirts".
|
||||||
# ╔═╡ d5bff992-e8b2-4f72-8943-db8ac4a671eb
|
# ╔═╡ d5bff992-e8b2-4f72-8943-db8ac4a671eb
|
||||||
check_reverse_string()
|
check_reverse_string()
|
||||||
|
|
||||||
|
# ╔═╡ be7120b3-3dbe-4af7-b7b9-a4ede45f6cf3
|
||||||
|
md"""
|
||||||
|
# String extraction
|
||||||
|
|
||||||
|
Extract the string "Hello world" out of the string variable `mess` defined below.
|
||||||
|
|
||||||
|
The space between the two words must be included!
|
||||||
|
|
||||||
|
The extracted string should be contained in a variable named `extracted`.
|
||||||
|
|
||||||
|
Hint: Remember that strings are a chain of characters. So you can use a lot of what you have learned about vectors on strings.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# ╔═╡ c5c5ac69-6167-4078-8b8c-ac46a6d0be58
|
||||||
|
# 12345678901234567890123456789
|
||||||
|
mess = "OHLENLNLMUIOQ WNHSIDWNOURLDSD"
|
||||||
|
|
||||||
|
# ╔═╡ 9f4d8332-5814-4625-9f5c-1056ee095428
|
||||||
|
# Your code starts here
|
||||||
|
|
||||||
|
|
||||||
|
# ╔═╡ 35bcd481-acec-4c29-bfe6-732d3c4d09b0
|
||||||
|
check_string_extraction()
|
||||||
|
|
||||||
# ╔═╡ be22832f-2004-49ec-911c-96e7e790ba5a
|
# ╔═╡ be22832f-2004-49ec-911c-96e7e790ba5a
|
||||||
md"""
|
md"""
|
||||||
# Squaring difference
|
# Squaring difference
|
||||||
|
@ -416,6 +466,10 @@ uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0"
|
||||||
# ╟─f71b0085-8185-4d3f-b29e-90af6ac8957a
|
# ╟─f71b0085-8185-4d3f-b29e-90af6ac8957a
|
||||||
# ╠═2de65e70-661c-40c1-8fdb-03fd5b25b7e2
|
# ╠═2de65e70-661c-40c1-8fdb-03fd5b25b7e2
|
||||||
# ╟─d5bff992-e8b2-4f72-8943-db8ac4a671eb
|
# ╟─d5bff992-e8b2-4f72-8943-db8ac4a671eb
|
||||||
|
# ╟─be7120b3-3dbe-4af7-b7b9-a4ede45f6cf3
|
||||||
|
# ╠═c5c5ac69-6167-4078-8b8c-ac46a6d0be58
|
||||||
|
# ╠═9f4d8332-5814-4625-9f5c-1056ee095428
|
||||||
|
# ╟─35bcd481-acec-4c29-bfe6-732d3c4d09b0
|
||||||
# ╟─be22832f-2004-49ec-911c-96e7e790ba5a
|
# ╟─be22832f-2004-49ec-911c-96e7e790ba5a
|
||||||
# ╠═53b585dd-aa13-44c1-a3de-988e027ab0c4
|
# ╠═53b585dd-aa13-44c1-a3de-988e027ab0c4
|
||||||
# ╟─b08055c9-b6de-4495-9788-ff79928a85ef
|
# ╟─b08055c9-b6de-4495-9788-ff79928a85ef
|
||||||
|
|
Loading…
Reference in a new issue