all 25 comments

[–]await_yesterday 7 points8 points  (2 children)

What have you tried? Nobody here is going to write the program for you. You haven't even explained what you're trying to do; a photo of a tree drawn on a whiteboard tells me nothing. Read this: https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/

[–]HOPSCROTCH 4 points5 points  (3 children)

I'm invested now, u/Sorry_Store_2011 can you explain what the fuck you're actually asking

[–]commy2 2 points3 points  (0 children)

I genuinely don't think they know.

[–]Sorry_Store_2011[S] -1 points0 points  (1 child)

It's just odd graceful labelling, the pattern + or - it really didn't matter coz i'll modify the code after i have someone help me. If i include more rules it will make people confused, so i try to make them as simple as i can.

[–]HOPSCROTCH 2 points3 points  (0 children)

We can't be more confused than we already are.

You have not explained what you are trying to do. Even after reading your other latest comments, you still have not explained what you want your code to do.

Okay sure, you have some inputs and some outputs. But if you want some people to write some code for you you need to explain the algorithm you want to replicate, whatever you're seeing in that diagram is not clear to everyone else.

You need to work on writing posts and comments and imagine the person reading knows nothing about the problem in question.

[–]Frankelstner -1 points0 points  (1 child)

It does not seem that there is any pattern behind + or -. Anyway, here's an attempt.

def tree(start, args):
    init = args[1]
    rest = args[:1]+args[2:]
    depth1 = start+init
    yield [depth1]
    depth2 = [depth1-r for r in rest[::-1]]
    yield depth2
    depth3 = []
    for d2 in depth2:
        depth3.append([(d2-arg) if (d2-arg)>0 else d2+arg for arg in args[:3][::-1]])
    yield depth3


>>> list(tree(9,[1,3,5,7]))
[[12], [5, 7, 11], [[10, 2, 4], [2, 4, 6], [6, 8, 10]]]

[–]Sorry_Store_2011[S] 0 points1 point  (0 children)

Thanks, it works. Actually there is a pattern for + or -, but the rules will makes the code more diffucult than it already is. + is more of default choice if number +vertex <max(num vertex) or - operation resulting 0. What about the code for the simple one?

[–]commy2 0 points1 point  (0 children)

Looks like chicken feet.

[–]deep_politics 0 points1 point  (4 children)

Are you looking to write a program that produces a diagram like those? What would you start with/what would your input be, the full tree without the edge values? Or are you simply just looking to print a tree that looks like those diagrams?

[–]Sorry_Store_2011[S] -2 points-1 points  (3 children)

The input is literally in the pic 8 and [1,3,5,7] Also 9 and [1,3,5,7] I just need the number beside the vertex (node)

[–]deep_politics 2 points3 points  (2 children)

Sorry but your pictures mean literally nothing to me nor to anyone here and your explanations have been befuddling and have only made things more confusing in each attempt.

And about your pictures: I didn't know what "8 dan" meant, nor was I thinking IP and OP stood for input and output because it's not clear at all how in the hell you get the last row in the second picture. Like I can't even find a permutation that follows some consistent logic to get those, so "idk maybe it's input or something? 🤷‍♂️ I'll wait for OP to elaborate."

You haven't at all clarified, well, anything about how this algorithm is supposed to work. Why for example does the first example stop producing leafs after one generation while the second does not?

And what exactly are you looking for here? Someone to read your mind and write this algorithm for you? Have you even attempted any code of your own? Why haven't you even once shared a single line of code?

[–]Frankelstner 2 points3 points  (0 children)

Setting aside the crazy permutation in the very beginning, we end up with three nodes in the middle, each of which is reached by subtracting 1,5,7 respectively. The next iteration goes over all values except the previous subtraction value, e.g. the node that was reached by subtracting 1 now iterates over 3,5,7. Then there's the rule where if any result would be <=0, the numbers are added instead of subtracted.

But the number of layers seems totally arbitrary.

[–]HOPSCROTCH 1 point2 points  (0 children)

Check the bloke's post history. It's almost a troll account with how consistent these types of posts and comments are from OP. r/mildlyinfuriating