Question
Write a predicate named split3(N,L) that has two arguments: N, a positive integer, and L, a list of positive integers. You may assume that the
Write a predicate named split3(N,L) that has two arguments: N, a positive integer, and L, a list of positive integers. You may assume that the list L is flat, i.e., it does not contain sublists. The predicate split3/2 returns true (or yes) if the list L can be partitioned into three sublists (with elements in the same order), such that the sum of the integers in each subset is less than or equal to N. Otherwise, it returns false (or no). Examples:
?-split3(5,[]).
false
?-split3(6,[5, 5, 12]).
false
?-split3(14,[6, 5, 10, 1, 1, 1, 14]).
true
?-split3(5,[3, 1, 4, 1, 2]).
true
?-split3(6,[4, 3, 5, 2, 1]).
false
?-split3(7,[4, 5, 7, 2, 3]).
false
?-split3(8,[3,5,4,2,7,1]).
true
?-split3(3,[1, 2, 2, 2, 1, 1]).
false
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started