import Data.List
soljushen [] [] = [[]]
soljushen predmeti birki = [(birka,predmet):solushn |
(levo
,predmet:pravo
) <- zip (inits predmeti
) (tails predmeti
), sort predmet == sort birka,
solushn <- soljushen (levo++pravo) (birki\\birka)]
aW1wb3J0IERhdGEuTGlzdAoKbWFpbiA9IGZtYXAgbGluZXMgZ2V0Q29udGVudHMgPj49IFxbcHJlZG1ldGksYmlya2ldIC0+IGxldAoJKHByZWRtZXRpJyxiaXJraScpID0gdW56aXAgJCBoZWFkICQgc29sanVzaGVuICh3b3JkcyBwcmVkbWV0aSkgYmlya2kKCWluIG1hcE1fIChwdXRTdHJMbiAuIHVud29yZHMpIFtwcmVkbWV0aScsYmlya2knXQoJCnNvbGp1c2hlbiBbXSBbXSA9IFtbXV0Kc29sanVzaGVuIHByZWRtZXRpIGJpcmtpID0gWyhiaXJrYSxwcmVkbWV0KTpzb2x1c2huIHwgCgkobGV2byxwcmVkbWV0OnByYXZvKSA8LSB6aXAgKGluaXRzIHByZWRtZXRpKSAodGFpbHMgcHJlZG1ldGkpLAoJbGV0IGJpcmthID0gemlwV2l0aCBjb25zdCBiaXJraSBwcmVkbWV0LAoJc29ydCBwcmVkbWV0ID09IHNvcnQgYmlya2EsCglzb2x1c2huIDwtIHNvbGp1c2hlbiAobGV2bysrcHJhdm8pIChiaXJraVxcYmlya2EpXQ==