Posts

Showing posts from March 30, 2019

Keep lines containing “list of different words” like pattern [duplicate]

Image
0 This question already has an answer here: How to make sed remove lines not matched by a substitution 4 answers Boolean OR in sed regex 4 answers How can I keep all lines matching all those words toto OR titi OR clic OR SOMETHING and delete any other lines? If I do sed '/toto/ p ' file I cannot select titi for example. What I am looking for is something similar to a Perl Regular expression as ^ (word1|word2|word3|andsoon).* . However, I need it for sed because it will be integrated into a bigger sed script. The goal is to keep all lines starting with word where word is any word from a set of word...

Keeping a ball lost forever

Image
13 $begingroup$ Suppose you can make a rectangular maze, where each cell (apart from the bottom-right) can contain an arrow in one of the four directions (up, down, left or right) of your choosing, except for those on an edge or corner, which must not point out of the maze. A ball is then placed into the top-left square and begins to move. It will move in the direction of the arrow in the cell that it is currently in. Then, that arrow will rotate 90 degrees clockwise. If an arrow is pointing out of the maze, it will continue rotating clockwise until it points in a valid direction. A valid maze is one in which the ball will never reach the bottom-right corner. Prove or disprove the existence of such a maze. If it exists, find the smallest possible maze (in terms of number of squares). Here is an examp...