Back
Close

Find the words

Statement

 Goal

Given a list of W words, concatenate them together to form an NxN grid and return the two words on the main diagonals (top to bottom) in alphabetical order.
Input
Line 1: The size N of the grid.
Line 2: The number of words W.
Next W lines: The word list.
Output
One line with the two diagonal words, space separated and in alphabetical order.
Constraints
3 ≤ N ≤ 20
W ≤ 100
Example
Input
3
3
cow
bat
rat
Output
cat war

Game modes
Fastest, Shortest

Test cases
N=3 Test
Input
3 3 cow bat rat
Output
cat war

N=3 validator Validator
Input
3 3 pig rat bat
Output
gab pat

N=5 Test
Input
5 5 sack cute harbour skull elite
Output
choke stole

N=5 validator Validator
Input
5 5 eager infant stab fever donor
Output
enter rated

N=8 Test
Input
8 10 magical academy bail reasoning golden alliance auto negotiate alert angel
Output
absolute marginal

N=8 validator Validator
Input
8 13 jail amend unify icon noon absence abuse attain alert imagery blow nest dawn
Output
junction nineteen

N=10 Test
Input
10 19 sack absent atrocity eager acid cabin bail habitat ownership globe absorb lane abuse odds arena gallon prey acre array
Output
strawberry technology

N=10 validator Validator
Input
10 18 undergo legend abuse ease dairy naked beam teens gear ladder accessible bench temple eager accused absent sack absurd
Output
gentleness understand

N=15 Test
Input
15 36 tackle absent fake racial absurd icon ultimate annually sack abundance abstract challenging wander abuse acid domain academy accordance accelerate tactic accent ease habitat amid acre aide accountable banner adequate acute aids absorb adverse sacred alert bass
Output
kindheartedness trustworthiness

N=15 Validator Validator
Input
15 35 ultimate absent sanction abortion absence abuse unacceptable activate adoption habitat alert dawn absorb acid teens abstract aids absurd academy temple accent lawn adaptation amateur analogy acre accomplish addiction anxiety ladder aide fake yell abolish bare
Output
southwestwardly unsportsmanlike

N=20 Test
Input
20 57 backdrop abortion accumulate absence abuse nest cabin absent acid canal sketch absorb adhere accommodate acre abstract alien absurd racial abundance aide academy accent aside accelerate accused tactic acceptance aids deed accessible adjust array accidentally aspire fabric accomplish sack auction accumulation adolescent activist accomplishment accordance adverse alliance accuracy archive ladder activate beam albeit abolish amusing yell accountable badge
Output
buckminsterfullerene uncharacteristically

N=20 Validator Validator
Input
20 53 packet abortion absence sack absent absorb boast eager abstract abuse absurd abundance analogy addiction acid tackle acre obesity adequate accent habitat racial academy beam agricultural accelerate acceptance aide boom vacuum accidentally coalition accommodate leap accomplish accumulate hail accordance tactic arbitrary acquisition adolescent adoption accordingly annually accounting adjacent accountant tenure accomplishment pity accountability civic
Output
counterrevolutionary pseudohermaphroditic

Solution language

Solution

Stub generator input