[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Computer science question can anyone help
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /sci/ - Science & Math

Thread replies: 19
Thread images: 2
File: 4L_VWKCnxiu.png (2 MB, 1920x1080) Image search: [Google]
4L_VWKCnxiu.png
2 MB, 1920x1080
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 (664 KB, 921x614) Image search: [Google]
political-science.png
664 KB, 921x614
>>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 replies: 19
Thread images: 2

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.