Divide and conquer algorithim

What is the AppleScript equivalent of the divide and conquer algorithm? The examples I see are for other program languages. Trying to divide out small PDFs from a large PDF.

Your question is very vague. D&C is a style of recursive algorithm; there is not just one. Be more specific as to what the problem and goal are so that any would-be respondent doesn’t have to guess at your intention.

Hope this is more specific:



--5026 total pages in the pdf.
--divide in half, save as new pdf, repeat till done
--new pdfs to have about 1000 pages each.

set x to ""
set myfile to choose file with prompt "Select your PDF file."
tell application "Adobe Acrobat Pro"
	open myfile
	
	tell document 1
		set thecount to count of pages
		set breakcount to thecount div 1000 as integer
	end tell
	
	repeat with x from 1 to breakcount
		
		set fx to path to desktop
		set savefile to fx & "_Parts_" & x as text
		
		set halfcount to thecount div 2 as integer
		delete pages document 1 first halfcount last thecount --delete from this line to end.
		save document 1 to file savefile
		close document 1
		
		set savefile to fx & "_Parts_" & (x + 1) as text
		open myfile
		delete pages document 1 first 1 last (halfcount - 1) --delete from this line to end.
		save document 1 to file savefile
		close document 1
	end repeat
	
end tell

So far my result is 2 PDFs split in half; the script does not know how to grab the new PDFs to split them.
Looking for the most efficient way to tag and open the subsequent halved pdfs to split in half before I start working thru it. That is what I refer to by calling it a D&C problem. Excuse my terminology if that is not correct.

My goal is to keep splitting the subsequent pdf’s into further halves until the are all approx. 1000 pages each.

Hi. I don’t have that app installed and have never attempted to script it, but this will arrive at semi-equal break points. One document may have extra pages, to make up for rounding errors.


set {span, totesPage} to {1000, 5026} --desired sectioned and actual total sizes
set divisible to totesPage div span
set roughly to span + (round ((totesPage mod span) / (divisible)) rounding down)
--set EPatEorB to totesPage - (roughly * divisible) --extra pages at end or beginning  (of source doc)