Is It Transitive? X52303


Statement
 

networkx

pdf   zip   main.py

html

Write a Boolean function is_transitive(p) that receives a Boolean binary function p and checks whether it is a transitive relation among the one-digit non-negative integers n, that is, 0 ≤ n < 10.

Sample session
>>> is_transitive(lambda x, y: x < y)
True
>>> is_transitive(lambda x, y: x == y)
True
>>> is_transitive(lambda x, y: x != y)
False
>>> is_transitive(lambda x, y: abs(x-y) == 1)
False
>>> is_transitive(lambda x, y: x+y == x-y)
True
Information
Author
Jordi Delgado and José Luis Balcázar
Language
English
Official solutions
Python
User solutions
Python