Skip to content

Conversation

@akaushika
Copy link

No description provided.

@akaushika
Copy link
Author

This is my Handin for MP2

one = ['x','y']
function = ['x','y','cos_pi','sin_pi','prod','square','average','square_root']
if max_depth == 1:
return one[random.randint(0,1)]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use random.choice(one), that grabs a random element from the list and is (in my opinion, at least) a slightly cleaner way to handle it. That said, it's entirely your call!

import math


def build_random_function(min_depth, max_depth):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I don't believe that the function, as you've written it, actually uses min_depth for anything - it always makes a function of max_depth. That said, it still works, and I suppose that it's technically correct.

For what it's worth, there's a handful of different ways you could handle min_ and max_depth - one option is to just randomly pick one if they're not the same, and another would be to start allowing the 'one' functions as soon as min_depth hits 1, but not force them until max_depth is 1.

#check reversed input range
reverseInput = False
oldMin = min( input_interval_start, input_interval_end )
# print(oldMin)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, before turning things in it's best to remove these debugging print statements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants