


"""simple docstring"""

def lowerCAmelCase_      (				UpperCamelCase__	: int ):






 """simple docstring"""







 if bit_count < 0:
  raise ValueError("""The given input must be positive""" )

 # get the generated string sequence
 __lowercase									=	gray_code_sequence_string(UpperCamelCase__ )
 #
 # convert them to integers
 for i in range(len(UpperCamelCase__ ) ):
  __lowercase									=	int(sequence[i]				,   2 )

 return sequence


def lowerCAmelCase_      (				UpperCamelCase__	: int ):






 """simple docstring"""







 if bit_count == 0:
  return ["0"]

 if bit_count == 1:
  return ["0", "1"]

 __lowercase									=	1 << bit_count  # defines the length of the sequence
 # 1<< n is equivalent to 2^n

 # recursive answer will generate answer for n-1 bits
 __lowercase									=	gray_code_sequence_string(bit_count - 1 )

 __lowercase									=	[]

 # append 0 to first half of the smaller sequence generated
 for i in range(seq_len // 2 ):
  __lowercase									=	"""0""" + smaller_sequence[i]
  sequence.append(UpperCamelCase__ )

 # append 1 to second half ... start from the end of the list
 for i in reversed(range(seq_len // 2 ) ):
  __lowercase									=	"""1""" + smaller_sequence[i]
  sequence.append(UpperCamelCase__ )

 return sequence


if __name__ == "__main__":
       import doctest

       doctest.testmod()




"""simple docstring"""

import random


def lowerCAmelCase_      (				UpperCamelCase__	: int				,   UpperCamelCase__	: float				,   UpperCamelCase__	: bool = False ):






 """simple docstring"""







 __lowercase									=	{i: [] for i in range(UpperCamelCase__ )}

 # if probability is greater or equal than 1, then generate a complete graph
 if probability >= 1:
  return complete_graph(UpperCamelCase__ )
 # if probability is lower or equal than 0, then return a graph without edges
 if probability <= 0:
  return graph

 # for each couple of nodes, add an edge from u to v
 # if the number randomly generated is greater than probability probability
 for i in range(UpperCamelCase__ ):
  for j in range(i + 1				,   UpperCamelCase__ ):
   if random.random() < probability:
    graph[i].append(UpperCamelCase__ )
    if not directed:
     # if the graph is undirected, add an edge in from j to i, either
     graph[j].append(UpperCamelCase__ )
 return graph


def lowerCAmelCase_      (				UpperCamelCase__	: int ):






 """simple docstring"""







 return {
     i: [j for j in range(UpperCamelCase__ ) if i != j] for i in range(UpperCamelCase__ )
 }


if __name__ == "__main__":
       import doctest

       doctest.testmod()
