Posts

4 queen

N = 4 ld = [0] * 30 rd = [0] * 30 cl = [0] * 30 def printSolution(board):     for i in range(N):         for j in range(N):             print(" Q " if board[i][j] == 1 else " . ", end="")         print() def solveNQUtil(board, col):     if col >= N:         return True     for i in range(N):         if (ld[i - col + N - 1] != 1 and rd[i + col] != 1) and cl[i] != 1:             board[i][col] = 1             ld[i - col + N - 1] = rd[i + col] = cl[i] = 1             if solveNQUtil(board, col + 1):                 return True             board[i][col] = 0 # BACKTRACK             ld[i - col + N - 1] = rd[i + col] = cl[i] = 0     return False def solveNQ():     board = [[0 for _ in range(N)] for _ in range(N)]     if not solveNQUtil(board, 0):         print("Solution does not exist")         return False     printSolution(board)     return True if __name__ == "__main__":     solveNQ()

alpha beta

 tree = [[[5, 1, 2], [8, -8, -9]], [[9, 4, 5], [-3, 4, 3]]] root = 0 pruned = 0 def children(branch, depth, alpha, beta):  global tree  global root  global pruned  i = 0  for child in branch:  if type(child) is list:  (nalpha, nbeta) = children(child, depth + 1, alpha, beta)  if depth % 2 == 1:  beta = nalpha if nalpha < beta else beta  else:  alpha = nbeta if nbeta > alpha else alpha  branch[i] = alpha if depth % 2 == 0 else beta  i += 1  else:  if depth % 2 == 0 and alpha < child:  alpha = child  if depth % 2 == 1 and beta > child:  beta = child  if alpha >= beta:  pruned += 1  break  if depth == root:  tree = alpha if root == 0 else beta  return (alpha, beta) def alphabeta(in_tree=tree, start=root, upper=-15, lower=15):  global tree global pruned  global root  (alpha, beta) = children(tree, start, upper, lower)  if __name__ == "__main__":  print ("(alpha, beta): ", alpha, beta)  print ("Result: ", tree)  print ("Times pruned: ",

water jug

 from collections import deque def water_jug_bfs(capacity_a, capacity_b, target):     visited = set()     queue = deque([(0, 0)])     while queue:         current_state = queue.popleft()         a, b = current_state         if current_state in visited:             continue         visited.add(current_state)         if a == target or b == target:             print("Target amount reached:", current_state)             return         queue.append((0, b))         queue.append((a, 0))         queue.append((capacity_a, b))         queue.append((a, capacity_b))         queue.append((a - min(a, capacity_b - b), b + min(a, capacity_b - b)))         queue.append((a + min(b, capacity_a - a), b - min(b, capacity_a - a)))     print("Target amount not reachable with the given jug capacities.") # Example usage: jug_capacity_a = 4 jug_capacity_b = 3 target_amount = 2 print(f"Solving Water Jug problem for capacities ({jug_capacity_a}, {jug_capacity_b}) to measure {target_amount}

6 Most Historical Places In India | detail information |

Image
                                मेरा भारत #6 Most Historical Places In India. 1. Taj Mahal. Best time to visit:   October to March.   Entry fees:  For foreigners INR 1100 and for Indians  INR 50.         About:       The Taj Mahal is one of the seven wonders of the world  and is considered to be the most popular tourist attraction in the country. The symbol of love, The Taj was built by Mughal emperor Shah Jahan for his Queen Mumtaz.  Tagore  described the Taj as a  "teardrop on the cheek of eternity".   The monuments attracts a lots of tourists all around the year.    2. Red fort.        Best time to visit:   October to February. Entry fees:   for foreigners INR  500 and for Indians INR 20. About:    The Red Fort was the official seat of Mughal rule and authority from 1648 onwards, when the 5th Mughal emperor, Shah Jahan, decided to move the capital of the empire from Agra to Delhi. Constructed using red sandstone, it remains one of the architectural marvels of the Mughal e

Letest upcoming Hollywood movies in 2021 | superhit Hollywood movies 2021 upcoming |

Image
  Letest upcoming Hollywood movies in 2021. 1. BLACK WIDOW. Initial release date. 29, march, 2021. Cast of the movie. 1.Scarlett Johansson. 2.Florence pugh. 3.Robert Downey Jr. 4.David harbour. 2. Venom: let there be carnage.    Initial release date. 24, june, 2021. Cast of the movie. 1.Tom Hardy. 2.Woody Harrelson. 3.Amber Sienna. 4.Michelle Williams. 3. Godzilla vs. Kong.                        Initial release date. 25, march, 2021. Cast of the movie. 1. Millie Bobby Brown. 2. Julian Dennison. 3. Alexander Skarsgard. 4. Kyle Chandler. 4. Fast and Furious 9.                       Initial release date. 28, May, 2021. Cast of the movie. 1. Vin Diesel. 2. John Cena. 3. Cardi.B. 4. Paul Walker. 5. Dwayne Johnson.   5. The Eternals.                                                                                                         Initial release date. 12, February, 2021. Cast of the movie. 1. Harry styles. 2. Kit Harington. 3. Richard Madden. 4. Angelina Jolie.                        

7 wonders of India

Image
    7. wonders of India     In our India, there are so many ancient architects are present, where so many foreigners and also Indians come to visit. It increases the beauty of India. 1 st.    Taj Mahal.         P erhaps there are only a few people in the world who have not   heard about the Taj Mahal, the famous symbol of love. It is an ivory white mausoleum built by mughal emperor Shah jahan for his beloved wife Mumtaz  Mahal after her demise.          The Taj Mahal today is the resting place of both Mumtaz mahal and Shah jahan. Taj Mahal construction started 1632 and  was probably  completely built by 1653. The Taj Mahal a UNESCO world heritage site is today admired by the million of visitor who has visit the site.          The Taj Mahal was designated as a UNESCO world heritage site in 1983 for being the jewel of Muslim art in India. It is not only one of the 7 wonders of India but also the world. 2 nd.    The Golden Temple in Amritsar.     T he harmandar sahib also known as golden

Biggest, longest, highest, and largest things in India

Image
5 biggest, longest, highest and largest things in India. In our India, there are many things, which is largest, biggest and longest in India and sometimes in all over world. 1. The longest road in India. NH-44 I t is the longest national highway in India. The length of NH-44 is 3,745 km. It covers the North-South corridor of NHDP. It starts from Shrinagar and end in kanyakumari in the south. 2. The longest river in India. Ganga river I t is the longest and largest river in india, which worshipped by the Hindus as Goddess Ganga. The river originates in the Western Himalayas and flows through the Gangetic plains before entering Bangladesh where it falls into the Bay of Bengal. 3. The highest mountain in India. Kanchenjunga I t is the highest mountain peak in India and ranked 3rd highest peak in the world with 28,169 ft. It is located at the border of India and Nepal in Sikkim. 4. The biggest stedium in India. Eden gardens  I t is the India's biggest and oldest stedium, which is locat