The solution to the classic "Blockbuster"

In the UK during the 80s and 90s (70 too, I suppose!) There was a classic TV program called “Blockbuster” that showed hexagons in a honeycomb grid, like this (sorry for the blurry image!):

picture from old Blockbuster TV game
(source: ukgameshows.com )

As you can see, there are 5 columns of letters and four rows. 1 person or team is trying to travel horizontally, one is trying to travel vertically. You will win the hexagon by answering the question, and the answer will begin with the letter displayed in that hexagon.

" " - , (, , ), - .

, , , ( , !), , . , , , , , !

, , . , , ! ...

, , , - ? , (, , ).

, , . .

+3
3

, Flood fill, .

- , , - - :

; , , , . , . :

for player in players:
  # those on the starting edge that the player owns get 'marked'
  for cells in cells.start_edge(player):
    if cell.owner = player:
      cell.mark = player
  do:
    count = 0
    for cell in cells:
      if cell.mark == None && cell.owner == player:
        for adjacent in cell.neighbours:
          if adjacent.mark == player
            cell.owner = player
            count += 1
            break
  while count
  for cell in cells.stop_edge(player):
     if cell.mark == player
       player won!!

, - , .

+8

, .

  • "". - , , .
  • ,
  • , ( , )
  • , DFS
+1

.

, 4x4 x 0 4 0 3.

- (1 3) , .

isAdjacent(other) . , : if self.x == other.x & plusmn; 1 self.x == other.x & plusmn; 1. y 8 -1, 0, 1 x, -1, 0, 1.

. self.y == other.y & plusmn; 1 self.x == other.x . x , . x - (0, 2, 4), , self.y == other.y self.y == other.y + 1. , x - (1, 3), . , .

" "? . grid.get(). , . .

, isAdjacent(), , ?

, , . enum_adjacent_vert(y_offset) enum_adjacent_horiz(x_offset). , (self.x-1, self.y+y_offset), (self.x, self.y+y_offset), (self.x+1, self.y+y_offset). , , self.x : (self.x+x_offset, self.y), (self.x+x_offset, self.y+1). self.x : (self.x+x_offset, self.y), (self.x+x_offset, self.y-1).

. , "" "" .

Say you go from left to right (increase x). You want to find a neighboring cell in the list enum_adjacent_horiz. To go from top to bottom (increase y), you will find a neighboring cell in the list enum_adjancent_vert.

+1
source

Source: https://habr.com/ru/post/1715975/


All Articles