[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Computer science question can anyone help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 19
Thread images: 2

File: 4L_VWKCnxiu.png (2MB, 1920x1080px) Image search: [Google]
4L_VWKCnxiu.png
2MB, 1920x1080px
Question 3: Remove All
Implement a function remove_all that takes a Link, and a value, and remove any list node containing that value. You can assume the list already has at least one node containing value and the first element is never removed. Notice that you are not returning anything, so you should mutate the list.

def remove_all(link , value):
"""Remove all the nodes containing value. Assume there exists some
nodes to be removed and the first element is never removed.

>>> l1 = Link(0, Link(2, Link(2, Link(3, Link(1, Link(2, Link(3)))))))
>>> print_link(l1)
<0 2 2 3 1 2 3>
>>> remove_all(l1, 2)
>>> print_link(l1)
<0 3 1 3>
>>> remove_all(l1, 3)
>>> print_link(l1)
<0 1>
"""
"*** YOUR CODE HERE ***"


Use OK to test your code:


python3 ok -q remove_all
>>
I won't make your homework, faggot.
>>
I'm sorry OP, but I only program in assembly via smoke signals, I can't help you there
>>
CS is unfortunately a meme because of people like OP
>>
>>7926064
>doing data structures in anything other than C/C++

Absolutely disgusting.
>>
>>7926064
(define remove_all (lambda (value link)
(if (empty? link) '()
(if (equal? (car link) value)
(remove_all value (cdr link))
(cons (car link) (remove_all value (cdr link)))))))

even works when you remove the head
>>
>not tail recursive

(define remove_all (lambda (value link)
(define remove_all_tail (lambda (value link result)
(if (empty? link) result
(if (equal? (car link) value)
(remove_all_tail value (cdr link) result)
(remove_all_tail value (cdr link) (append result (list (car link)))))))) (remove_all_tail value link '()))
>>
>>7926734
CS was always a meme. It was shit from the very beginning. CS brought nothing of value compared to engineering.
>>
Why are guys not using the best language for list processing in such tasks?

usage: 123123\n1
output: 2323
>>>>,----------[++++++++++[->+>+<<]>[-<+>]>>+>,----------],[-<[<<<-<]>>>>[>>>>]<<<]<[<<<[[-]>+<]>[->[-<<+>>]<]>[-]<<<]>>>>[<<<[.[-]]>>>>>>>]
>>
>>7926064
Is this a joke?
>>
>>7927811
CS is science
>>
>>7927818
No, but that question is like day one programming 101 shit
you may as well ask sci if an electron is positive or negative
also the sticky
>>
>>7927824
what if electron was neutral, and all other particles are actually positive or double-positive
>>
>>7927840
what if python wasn't a piece of shit?
>>
>>7927843
as plausiable as electrons being neutral
>>
i dont think anyone on this board can do CS problems or math problems.

everyone has no confidence. they dont want to be the first person to get it wrong.

math majors dont even have confidence on a fucking anonymously message board.
>>
>>7927870
you are implying that they can solve CS problems.

The reason they are silent is becaust they have no answers
>>
File: political-science.png (664KB, 921x614px) Image search: [Google]
political-science.png
664KB, 921x614px
>>7927818
polsci is science
>>
>>7927870
>dont think anyone on this board can do CS problems

There already are 2 functional solutions ITT: >>7926789 and >>7926843
Thread posts: 19
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.