% https://open.kattis.com/problems/set % 1s % 2.1 Easy % Picat % Indices: % 1 2 3 % 4 5 6 % 7 8 9 % 10 11 12 % % 384 chars import util. main :- S = chunks_of(read_file_lines().map(split).flatten,4), Len = S.len, CC = 0, foreach(A in 1..Len, B in A+1..Len, C in B+1..Len, once(t(S[A],S[B],S[C]))) printf("%w %w %w%n",A,B,C),CC:=CC+1 end, (CC==0->println("no sets");true). t([],[],[]). t([A|As],[B|Bs],[C|Cs]) :- (a([A,B,C]) ; d([A,B,C])), t(As,Bs,Cs). a([A,A,A]). d([A,B,C]):-A!=B,A!=C,B!=C.