27
4
The idea of this challenge is to find all the words from a dictionary on a grid of letters. Your input should come from stdin or function arg and will come in the following format:
[your dictionary as a list of space sep words]
[a grid of letters]
Example:
The cool car
looc
thea
jopr
Rules for finding a match
A match is valid if it is found diagonally, horizontally, or vertically on the board (case insensitive). The direction doesn't matter (e.g. look
matches kool
). If there are multiple matches of the same word, mark all of them.
Output:
Your output will be the grid you were given - with the minor change that the letters will be space separated and the lines will be double spaced. Example:
Input:
looc
thea
jopr
Output:
l o o c
t h e a
j o p r
To represent a match you will put an arrow between letters that go together. The arrows (/\-|X
) will point to each pair of letters that are grouped in a match. X
is used if /\
intersect.
Examples:
Input:
The cool car
looc
thea
jopr
Output:
l-o-o-c
|
t-h-e a
|
j o p r
Input:
Atomic chess is cool
achess
btoikm
bloosi
nowmlp
hewiir
asdfec
Output:
a c-h-e-s-s
\ \ /
b t o i k m
\ \ \
b l o o s-i
\ \
n o w m l p
\
h e w i i r
\
a s d f e c
Input:
This is very neat words var are fun rob bot robot
wotsdsearn
siiewfvery
chheruoawd
tetoennore
asbdrgrehe
aobyedycab
tweosttgwt
Output:
w o t s d s e a r n
/
s-i i e w f v-e-r-y
/ | \
c h h e r u o a w d
/ / | X
t e t o e n n o r e
/ X \
a s b d r g r e h e
/ / \
a o b y e d y c a b
/ / \
t w e o s t t g w t
Related: http://codegolf.stackexchange.com/q/37940/42963
– AdmBorkBork – 2015-12-22T19:25:07.3405I can't imagine this going under 30 bytes. – Martijn – 2015-12-23T15:10:30.073
how much time did you spend writing the test inputs? it seems like a lot of work – cat – 2015-12-24T17:57:39.740
About 10-15 min. It wasn't to hard, even by hand (though is is quite error prone). – J Atkin – 2015-12-24T18:25:28.237
This seems actually very challenging to program, even without golfing it. – Codefun64 – 2015-12-31T07:55:41.467
I don't know if it's worth changing with two answers already on the board, but we usually allow a more flexible input format here. – lirtosiast – 2016-01-02T21:43:55.897
Drat, I didn't think about that. I forgot to include that you could write a function that takes a string... – J Atkin – 2016-01-02T21:53:15.137
@ThomasKwa What other formats would be considered common? – J Atkin – 2016-01-02T21:55:05.270
1I'm still waiting for that
Pyth
orCJam
answer that will be under 40 bytes... – J Atkin – 2016-01-03T14:57:25.520Uh, reviewing the text of the challenge I see that I should get a single string as input, my fuction has 2 parameters instead. I'll fix it later – edc65 – 2016-01-03T15:32:24.647
Some questions ... is the grid always lowercase as in the example? And if not, the casing should be kept in output? – edc65 – 2016-01-03T15:56:50.877
... and
(case intensive)
should be read(case insensitive)
or plainly the contrary? – edc65 – 2016-01-03T15:59:30.490Darn, I didn't think of that. Well its a little late to change it so I just go ahead and ignore casing. – J Atkin – 2016-01-03T16:00:12.920