Skip to main content
Commonmark migration
Source Link

#CJam, 26 bytes

CJam, 26 bytes

l~_,,:T.-_T\ff&Tf.e&.|:e_p 

Not very short...

###Explanation

Explanation

l~ e# Read the input. _,,:T e# Get the graph size and store in T. .- e# Remove self-loops from the original input. _T\ff& e# Check if each vertex is in each list, and e# return truthy if yes, or empty list if no. Tf.e& e# Convert truthy to vertex numbers. .| e# Merge with the original graph. :e_ e# Remove empty lists. p e# Format and print. 

#CJam, 26 bytes

l~_,,:T.-_T\ff&Tf.e&.|:e_p 

Not very short...

###Explanation

l~ e# Read the input. _,,:T e# Get the graph size and store in T. .- e# Remove self-loops from the original input. _T\ff& e# Check if each vertex is in each list, and e# return truthy if yes, or empty list if no. Tf.e& e# Convert truthy to vertex numbers. .| e# Merge with the original graph. :e_ e# Remove empty lists. p e# Format and print. 

CJam, 26 bytes

l~_,,:T.-_T\ff&Tf.e&.|:e_p 

Not very short...

Explanation

l~ e# Read the input. _,,:T e# Get the graph size and store in T. .- e# Remove self-loops from the original input. _T\ff& e# Check if each vertex is in each list, and e# return truthy if yes, or empty list if no. Tf.e& e# Convert truthy to vertex numbers. .| e# Merge with the original graph. :e_ e# Remove empty lists. p e# Format and print. 
added 639 characters in body
Source Link
jimmy23013
  • 37.4k
  • 6
  • 79
  • 154

#CJam, 26 bytes

l~_,,:T.-_T\ff&Tf.e&.|:e_p 

Not very short...

###Explanation

l~ e# Read the input. _,,:T e# Get the graph size and store in T. .- e# Remove self-loops from the original input. _T\ff& e# Check if each vertex is in each list, and e# return truthy if yes, or empty list if no. Tf.e& e# Convert truthy to vertex numbers. .| e# Merge with the original graph. :e_ e# Remove empty lists. p e# Format and print. 

#CJam, 26 bytes

l~_,,:T.-_T\ff&Tf.e&.|:e_p 

Not very short...

#CJam, 26 bytes

l~_,,:T.-_T\ff&Tf.e&.|:e_p 

Not very short...

###Explanation

l~ e# Read the input. _,,:T e# Get the graph size and store in T. .- e# Remove self-loops from the original input. _T\ff& e# Check if each vertex is in each list, and e# return truthy if yes, or empty list if no. Tf.e& e# Convert truthy to vertex numbers. .| e# Merge with the original graph. :e_ e# Remove empty lists. p e# Format and print. 
Source Link
jimmy23013
  • 37.4k
  • 6
  • 79
  • 154

#CJam, 26 bytes

l~_,,:T.-_T\ff&Tf.e&.|:e_p 

Not very short...