Some solutions for the julia path

This commit is contained in:
2025-08-04 19:44:03 +02:00
parent 5c52e8e34d
commit 8296c79f68
104 changed files with 4373 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
function get_item(stack, position)
if position < 1 || position > length(stack)
error("Position out of bounds")
end
return stack[position]
end
function set_item!(stack, position, replacement_card)
if position < 1 || position > length(stack)
error("Position out of bounds")
end
stack[position] = replacement_card
return stack
end
function insert_item_at_top!(stack, new_card)
push!(stack, new_card)
return stack
end
function remove_item!(stack, position)
if position < 1 || position > length(stack)
error("Position out of bounds")
end
deleteat!(stack, position)
end
function remove_item_from_top!(stack)
if isempty(stack)
error("Stack is empty")
end
return deleteat!(stack, length(stack))
end
function insert_item_at_bottom!(stack, new_card)
pushfirst!(stack, new_card)
return stack
end
function remove_item_at_bottom!(stack)
if isempty(stack)
error("Stack is empty")
end
popfirst!(stack)
return stack
end
function check_size_of_stack(stack, stack_size)
return length(stack) == stack_size
end