implement any of following (or all if you're pro) in your favorite language
tree data structure which can have as many child trees as one possibly wants and a function to invert such a tree
fibonacci with linear time complexity (either nth fibonacci or a list of all fibs, your choice)
averaging of a list of numbers (hard mode, list is traversed only once e. g. no summing the list (one traversal) and then dividing by its length (another traversal))
code in language X wins if its >efficient >short >& has hot/pretty syntax
third one is more of a plus
pic unrelated
Elijah Nguyen
We aren't going to do you're homework for you.
Hunter Edwards
>can't do it just as expected >>>/desktop thread/
Jaxon Roberts
if it was homework, I'd say >please do all three in specific language X you nigger faggot
Grayson Morris
just google any of it
Jacob Myers
LOL Is one of those titty mouse pads?
Noah Smith
Python has the 3rd one in a one liner, but I'm on my phone
Also, can't you just use list.length or some equivalent instead of two traversals?
Ryan Reyes
nobody says lol anymore kys
Jeremiah Myers
Answer my question you fucking faggot.
Cooper Turner
>posting homework
>list.length It invokes a function that traveses the list, so even tho you can't see it, it counts as one
Jonathan Smith
>averaging a list is homework stop
Noah Wilson
From what I see about murican cs courses on this site, it could very much be homework desu
Jayden Allen
just admit it, you guys can't implement shit
Easton James
lol
Ethan Nelson
>It invokes a function that traveses the list, so even tho you can't see it, it counts as one no, length is usually a parameter that is in memory for most lists
Luke Smith
lol, whyd that guy delete his average implementation?
Cooper Parker
I don't know about other langs, but in python list objects are implemented as simple c arrays, so to get the length you must iterate at least once
Julian Johnson
I wish I was more like Neil. What a great picture, the man knows what he wants then goes and gets it. He has this memory forever now while I post on Serbian Sudoku boards.
Truly an inspiration to us all.
Kevin Williams
couldn't you just count as you transverse the list once? so like one for loop with a sum and a count.
fibonacci with linear time average complexity would store the numbers.
Parker Lopez
ayy lmaoing @ u
Jonathan Cooper
Why exactly?
Lincoln Powell
You're never gonna make it, Rajeesh. len() is O(1) for lists in CPython.
Joshua Johnson
Then when you initialize the list it automatically counts its own elements and stores it in a parameter. Please explain how the fuck would it "know" its own size without counting it first.
Nathan Adams
I am sorry for your brain damage. Your average function doesn't initialize anything. Also, any initialization of a list would have to traverse itself to copy values (even if it's all zeroes) to it unless you wanted it uninitialized.
Why don't you read the actual implementation and try to educate yourself instead? It's not that hard and I believe a pooinloo could come up with it given some time thinking.
Levi Watson
since gtards aren't smart enough, I'll provide some of my own
>tree data Tree = Leaf a | Node a [Tree a]
invert (Leaf a) = Leaf a invert (Node a trees) = Node a (map invert $ reverse trees)
>linear fibonacci
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
>list average {-# LANGUAGE BangPatterns #-} import Data. List
average xs = (s / b) where (s, b) = sumlen xs
sumlen :: [Float] -> (Float, Float) sumlen = foldl' f (0,0) where f (!s,!l) x = (s+x, l+1)
William Hughes
He didn't say the oneliner would be a hardmode solution
Chase Mitchell
>not data Tree a = Node a [Tree a]
Cooper Bailey
respect with using functional programming
I can't find a reason to apply functional programming so I don't retain anything anytime I learn some
Matthew Parker
Well, here is my attempt at the third problem. Still learning, pls no bully