| in word cr nCol nRow mat results directions | in := 'リオウウリウ ウオリウオリ オリリオリウ リリオオウオ'. word := 'ウオリ'. cr := Character cr. directions := { #左上 -> (-1@-1). #上 -> (0@-1). #右上 -> (1@-1). #左 -> (-1@0). #右 -> (1@0). #左下 -> (1@-1). #下 -> (0@1). #右下 -> (1@1)}. nCol := (in indexOf: cr) - 1. nRow := (in occurrencesOf: cr) + 1. in := in copyWithout: cr. mat := Matrix rows: nRow columns: nCol contents: in. results := OrderedCollection new. mat indicesDo: [:row :col | | pos delta reader | directions do: [:dirAssoc | pos := col@row. delta := dirAssoc value. reader := word readStream. [(mat at: pos y at: pos x ifInvalid: #NG) = reader peek] whileTrue: [pos := pos + delta. reader next]. reader atEnd ifTrue: [results add: col@row -> dirAssoc key]]]. ^(results collect: [:each | each key: each key - 1 asPoint]) asArray "=> {2@0->#左 . 0@1->#右 . 0@1->#下 . 3@1->#右 . 4@3->#左上} "