Carlo Teo Pedretti
Carlo Teo Pedretti
They both work, I've just changed the directions. ``` blank: '0' start state: A table: A: 0: {write: 1, R: B} 1: {write: 0, L: C} B: 0: {write: 1,...
Thanks to @delfimpandiani for the patience and the help (you're a very good teacher): ``` def test_my_enumerate(input_list, expected): result = my_enumerate(input_list) if expected == result: return True else: return False...
This solution is based on the approach that if the first (or the second) value '1' is followed by the value '0' in the next cell, then it couldn't be...
``` def test_my_reversed(input_list, expected): result = my_reversed(input_list) if expected == result: return True else: return False def my_reversed(input_list): reverse_list = [] max_value = len(input_list) - 1 for position, item in...
I've found this recursive algorithm very resource-consuming because it has to calculate each previous number for every number, so I've used low inputs to mitigate the effect. I guess there's...
``` from networkx import Graph cs_bib = Graph() #add nodes cs_bib.add_node("Tim Berners-Lee") cs_bib.add_node("Christian Bizer") cs_bib.add_node("Tom Heath") cs_bib.add_node("Sören Auer") cs_bib.add_node("Lalana Kagal") cs_bib.add_node("James A. Hendler") #add edges with 'weight' attribute cs_bib.add_edge("Tim Berners-Lee",...
``` set_hobbit = set({"Frodo", "Sam", "Pippin", "Merry"}) set_magician = set({"Saruman", "Gandalf"}) a_day_may_come_when_the_courage_of_men_fails = dict() a_day_may_come_when_the_courage_of_men_fails ["hobbits"] = set_hobbit a_day_may_come_when_the_courage_of_men_fails ["magicians"] = set_magician print(a_day_may_come_when_the_courage_of_men_fails) ```
Provided that in recursion x y = x * x y-1, that's my idea: ``` def test_exponentiation(base_number, exponent, expected): result = exponentiation(base_number, exponent) if expected == result: return True else:...
``` def test_stack_from_list(input_list, expected): result = stack_from_list(input_list) if expected == result: return True else: return False from collections import deque def stack_from_list(input_list): output_stack = deque() # the stack to create...
Thank you @SeverinJB for your feedback, it was really helpful. ``` def test_multiplication(int_1, int_2, d, expected): result = multiplication(int_1, int_2, d) if expected == result: return True else: return False...