420chan now has a web-based IRC client available, right here
Leave these fields empty (spam trap):
You can leave this blank to post anonymously, or you can create a Tripcode by using the float Name#Password
A subject is required when posting a new thread
[*]Italic Text[/*]
[**]Bold Text[/**]
[~]Taimapedia Article[/~]
[%]Spoiler Text[/%]
>Highlight/Quote Text
[pre]Preformatted & Monospace text[/pre]
1. Numbered lists become ordered lists
* Bulleted lists become unordered lists


Community Updates

420chan now supports HTTPS! If you find any issues, you may report them in this thread
C++ Design: Too Many Arguments!! by Alice Sezzlehed - Sat, 12 May 2018 13:28:25 EST ID:ooXJl0td No.37530 Ignore Report Reply Quick Reply
File: 1526146105683.jpg -(970836B / 948.08KB, 3048x2432) Thumbnail displayed, click image for full size. 970836
Hi guys and gals,
My C++ program (a roguelike game with lots of lists) is becoming pretty large. As I try to clean things up, I’m noticing I’m creating huge ass functions with many arguments (since I’m passing so much data sets around).

I think I’m pretty meticulous about keeping track of everything, so it’s not that I’m running out of computer memory, it’s just the code is impossibly long and ugly. Is it normal to have functions with 10+ pointers to different datasets, etc.?? Or am I dokng somethig wrong - any idea how to fix it?

Id love to hear your ideas!!
6 posts omitted. Click Reply to view.
Fucking Sidgedin - Mon, 14 May 2018 02:00:31 EST ID:naT3gKNs No.37540 Ignore Report Quick Reply
Note that in this answer, I'm assuming you're some kind of a beginner. Also, what you're probably asking for is help on writing a "state machine" which I'm certainly not an expert in. What follows is general advice on function design. And sorry for the wall of text...

Imagine the following: tomorrow you're going on a trip for 1 year and you don't take your project with you. After you come back, will you still be able to read/understand your thing?
So the question probably becomes: "What can I do to make my code easily navigatable, understandable, and workable?"
And I have to tell you that some things are probably just experience. Here are some tips though:
  • Comment your code well. This doesn't mean lots of comments, it means commenting anything that is not obvious. Note that things like variable/function names are also comments in a sense, so use those to your advantage (e.g. trying to encode the type of a var inside its name is mostly useless. Rather, you could name a var after its intent.). Above every function goes a comment that at least describes what goes/can go in it and what can come/comes out of it and roughly what it does; probably also useful for things like structs/data types.
  • Group things together that belong together. This can mean to make use of stuff like structs (or sth similar, depending on language) but also to e.g. have functions only do a specific thing that "belongs to its territory" rather than do things that have nothing to do with it. If you have the impression that a function shouldn't be doing a specific thing which is still necessary to do at this point, you should probably split that part off into a new function.

I guess what I really want to say is that you should't necessarily look (or even worry) at things like "line count in a function" or "number of parameters" -- such metrics don't often say much about actual maintainability (or performance) of code. Make your code understandable: a function should follow a single train of thought and you should be able to follow a function in a single train of thought. And sometimes (though admittedly rarely) that can mean hav…
Comment too long. Click here to view the full text.
Jarvis Bemmerbury - Mon, 14 May 2018 19:00:49 EST ID:r5si74OP No.37541 Ignore Report Quick Reply
Oh it would be so cool if the outdated university curriculum included stuff like that in it.
Doris Cradgelot - Fri, 18 May 2018 04:12:24 EST ID:+joVuqaF No.37544 Ignore Report Quick Reply
If you're using a lot of default values you can initialize them with a lambda (an anonymous function) like:

int foo( int n ) {
auto bar = [](int n, int constant) { return n + constant; };
return bar( n, 2 );

This is an extremely contrived example of the partial application pattern, but the important thing to note is that the `foo` function only takes one argument, then `bar` is called from inside with both the default argument and the argument passed to `foo`.
Esther Pullerforth - Mon, 21 May 2018 02:44:25 EST ID:Xm/W+3lL No.37545 Ignore Report Quick Reply
I personally find lambda function usage in C++ more complicated than standard explicit named function usage most of the time.
Hedda Turveywater - Mon, 21 May 2018 15:20:05 EST ID:+joVuqaF No.37546 Ignore Report Quick Reply
The lambda expression comes in handy for partial application because you can't nest standard functions in C++. Plus, if the lambda is only meant to be a helper for one particular function, you wouldn't want it to pollute the global name space anyway.

javascript by Lydia Gudgedale - Sat, 12 May 2018 20:10:25 EST ID:r5si74OP No.37533 Ignore Report Reply Quick Reply
File: 1526170225292.png -(863168B / 842.94KB, 1452x2208) Thumbnail displayed, click image for full size. 863168
just sharing this enjoyable picture image with a text post
Rebecca Blebblelock - Sat, 12 May 2018 23:20:04 EST ID:lP7MCiRB No.37536 Ignore Report Quick Reply
1526181604017.gif -(34345B / 33.54KB, 600x450) Thumbnail displayed, click image for full size.
Isabella Gimmerhall - Sun, 13 May 2018 06:14:36 EST ID:Xm/W+3lL No.37537 Ignore Report Quick Reply
I liked that. Thanks for sharing, OP.
Doris Cradgelot - Fri, 18 May 2018 03:26:20 EST ID:+joVuqaF No.37543 Ignore Report Quick Reply
1526628380219.jpg -(46819B / 45.72KB, 330x512) Thumbnail displayed, click image for full size.
That behavior's not actually a bug. Loose equals (`==`) just means that type coercion is allowed. Section 11.9.3 of the ES5 specification says if both things being compared have the same type, they're compared via identity; if they have different types, perform the following steps are until both things have the same type (then they're compared via identity).

for x == y:

2) If x is null and y is undefined, return true.

3) If x is undefined and y is null, return true.

4) If Type(x) is Number and Type(y) is String, return the result of the comparison x == ToNumber(y).

5) If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y.

6) If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.

7) If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).
Comment too long. Click here to view the full text.

Mini multiplayer server instance by Jenny Wezzlechet - Tue, 08 May 2018 12:02:54 EST ID:S/rykYgn No.37528 Ignore Report Reply Quick Reply
File: 1525795374104.gif -(562047B / 548.87KB, 200x200) Thumbnail displayed, click image for full size. 562047
This is a hard question to explain because English is not my first language.

I have a game coded with socket.io that uses a persistent world. When a player clicks play, he enters the world and can manipulate it like singleplayer Minecraft. However, many other users can access the server at the same time and modify the world so that the first player sees modification, but none of the players can see each other. All enemies, bullets, etc are only for each individual player. Players only can see world modifications of other players.

I want to make it so groups of 2 players can player simultaneously. So these 2 players can see each other as well as world modifications of all other players. Would I just have to have multiple servers? I want to just use the 1 server to let groups of 2 players to play the game like how solo players play the game now. I can't afford to host many small servers.
Sidney Surringwock - Fri, 11 May 2018 01:19:59 EST ID:Xm/W+3lL No.37529 Ignore Report Quick Reply
Since your game is like Minecraft, you could simply have one very large procedurally generated world that was so big that it's highly unlikely that any group of 2 players would ever run into one of their neighboring groups of players.

C++ by Hugh Cevingwater - Mon, 09 Apr 2018 09:00:46 EST ID:9B4LusOJ No.37498 Ignore Report Reply Quick Reply
File: 1523278846948.jpg -(24430B / 23.86KB, 576x768) Thumbnail displayed, click image for full size. 24430
I'm looking for something a bit like std::map, except that I don't care about a <key, value> pair; I just want to be able to say to the thing, "here, keep this integer". And "hey, have you got that integer, yes or no?"

Something tells me a hashmap isn't the right tool for the job, but I can't seem to figure out what is. Any ideas?
Albert Hingerdat - Mon, 09 Apr 2018 09:33:39 EST ID:8hwK1pxu No.37499 Ignore Report Quick Reply
You probably want std::hash

It's like std::map, except it only takes a key and instead of having to implement less than, you have to implement a hash function for the type you are using if it doesn't have one
Hamilton Drallerson - Tue, 10 Apr 2018 15:06:39 EST ID:9B4LusOJ No.37509 Ignore Report Quick Reply
Oh that did the trick. Thanks.
Doris Clubblesedge - Sat, 05 May 2018 15:20:32 EST ID:w/eFrgQ5 No.37526 Ignore Report Quick Reply
Why not set or multiset? http://www.cplusplus.com/reference/set/
Shitting Gumbleman - Sun, 06 May 2018 03:33:29 EST ID:Xm/W+3lL No.37527 Ignore Report Quick Reply
If all you care about is "could this item potentially be in this set?", then you might want to look into using a Bloom filter datastructure (not the kind used in graphics, but the other kind used in general computer science).
Jarvis Bemmerbury - Mon, 14 May 2018 19:02:15 EST ID:r5si74OP No.37542 Ignore Report Quick Reply
y not just a set

C++ from Java by James Badgeham - Mon, 30 Apr 2018 11:44:50 EST ID:uuXCv622 No.37523 Ignore Report Reply Quick Reply
File: 1525103090443.jpg -(131910B / 128.82KB, 900x750) Thumbnail displayed, click image for full size. 131910
Alright boys, I just finished my first year of Applied Computer Science, we were taught Java extensively and had one class on VB in the second semester (god I hope I never have to work with that) Anyways, apparently next year we continue on the programming concepts we learned expanding into things like multi-threading which we haven't learnt yet, except we switch to C++. The thing is, we don't actually get taught C++, we're just taught IN C++. The advice from the second years I got was teach yourself C++ over the summer and that will be the easiest class you take next year, otherwise it will be the hardest. So, what resources could you recommend to make that transition? What are specific Java-to-C++ quirks I might need to know?
Fucking Wublingbanks - Mon, 30 Apr 2018 18:38:08 EST ID:jPnU+Gop No.37524 Ignore Report Quick Reply
Download and spend a weekend on A Tour of C++. Then make a toy project to feel out your compiler and workflow. You'll be way ahead of the curve.
Phyllis Gingerway - Wed, 02 May 2018 02:36:17 EST ID:Xm/W+3lL No.37525 Ignore Report Quick Reply
Learning C++ without learning C might be the largest part of the hurdle for you. Otherwise, many of the object-oriented paradigms of Java carry over into C++. For a very high-level view, read Wikipedia's entry on the differences and similarities between C++ and Java:

Also the sooner you download Visual Studio (it's free now, so there's no excuses!) and learn how to use an interactive debugger, the better off your entire life will be.

There are some large differences that you'll have to learn between the languages. Most of them fall under the category of "things Java does for you that C++ makes you do manually". Things like this include:
  • Memory management. Garbage collection is *not* a thing in C or C++, so you have to manage the creation and deletion of your objects manually (using new/delete or malloc/free or placing the objects on the stack as automatic variables).
  • Pointers, references, and by-value passing of variables. This is pretty important in C and C++ (C doesn't support references). Pointers are a new concept of a variable that can "point" to arbitrary locations in memory (or to "null"). References are really just pointers with a nicer syntax that can only point to one thing. So much stuff in C/C++ is pointers and this is a really important language concept, so make sure to try to learn it well!
  • Strings are not really a built-in type. You can use std::string for ease of use, but you really should get comfortable with C-strings (character arrays or char*).
  • Operator overloading is possible in C++. This is not necessarily a required feature, but the ability to redefine operators is useful for various purposes.
  • "const" is a special keyword in C and C++ and it marks a variable as being non-modifiable after the first time it is written. This is a lot like Java's "final" keyword for variables.
  • The built-in types are mostly the same: short, int, float, and double all mean the same things between the two languages. Also both languages have a type for boolean logic ("bool" in C/C++ and "boolean" in Java). C/C++ also support "unsig…
Comment too long. Click here to view the full text.

Game dev live stream by Otay - Sat, 28 Apr 2018 12:36:33 EST ID:/kCdQ+UW No.37520 Ignore Report Reply Quick Reply
File: 1524933393357.jpg -(52501B / 51.27KB, 500x471) Thumbnail displayed, click image for full size. 52501
im writing a game in an out dated version of the unreal engine and streaming it :] https://www.twitch.tv/otayzilla
Lillian Simmlebeck - Sat, 28 Apr 2018 23:10:42 EST ID:2j3uquS6 No.37521 Ignore Report Quick Reply
Aw yeah dog let me waste my life by watching you waste your life.
David Tillingfuck - Sun, 29 Apr 2018 03:43:43 EST ID:Xm/W+3lL No.37522 Ignore Report Quick Reply
Have fun, OP!

JS Canvas Laser Light 3D FX by Eugene Pabblecocke - Fri, 05 Jan 2018 16:22:23 EST ID:E0anbCqO No.37255 Ignore Report Reply Quick Reply
File: 1515187343914.png -(58209B / 56.84KB, 1000x1000) Thumbnail displayed, click image for full size. 58209
<body onload="setInterval(doit,101);" bgcolor="black">

<canvas id="myCanvas" width="1000" height="1000" style="border:1px solid #black;">
Your browser does not support the HTML5 canvas tag.</canvas>

function doit(){
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");

var gradient = ctx.createLinearGradient(Math.random()*5000,Math.random()*4000, Math.random()*235, Math.random()*235);
gradient.addColorStop("10", "black");
gradient.addColorStop("0.5", "red");
gradient.addColorStop("1.0", "black");
Comment too long. Click here to view the full text.
173 posts and 4 images omitted. Click Reply to view.
JS NV SRC Full Spec Bright - Fri, 30 Mar 2018 13:33:49 EST ID:ogZT6wC7 No.37487 Ignore Report Quick Reply

<label for="hue"><p><input type="range" min="0" max="43360" value="33440" id="hue" hidden></label><p> <output id="target"></output>
<video id="main" muted loop autoplay>
<canvas id="source"></canvas>
Comment too long. Click here to view the full text.
JS Pink NV New - Mon, 09 Apr 2018 21:40:39 EST ID:ogZT6wC7 No.37503 Ignore Report Quick Reply
<body bgcolor=black>


Comment too long. Click here to view the full text.
Ian Clayshaw - Tue, 10 Apr 2018 20:08:02 EST ID:5ed0HJE6 No.37510 Ignore Report Quick Reply
Man who was that guy who would constantly post JS/html code? Lol. Cant remember his name.
NV G4 Revised - Wed, 25 Apr 2018 14:26:39 EST ID:+nAZg0Fw No.37518 Ignore Report Quick Reply
<body bgcolor=black>


Comment too long. Click here to view the full text.
NV Full Spec Inverted - Wed, 25 Apr 2018 14:39:17 EST ID:+nAZg0Fw No.37519 Ignore Report Quick Reply
<body bgcolor=black>


Comment too long. Click here to view the full text.

Hax by Phyllis Cubblenot - Sat, 31 Mar 2018 16:15:54 EST ID:W1v5J6Mb No.37489 Ignore Report Reply Quick Reply
File: 1522527354600.png -(135420B / 132.25KB, 720x1280) Thumbnail displayed, click image for full size. 135420
Hello, we are a grey and blackhat hacking group called Go7nSec (Guardians Of 7he Net security) we are an equality hacktivist group we also have an interest in anti-government, we also strongly enforce the idea "take from the rich give to the poor" and we are currently recruiting for people who are professional in hacking, programing, cryptography, and stegnography. We operate on kik for new memmbers (#404blacklist ). Send a list of your skills, why you want to join, any other serious hacking groups/people your associated with in the group above. we will reveiw your submission. If you do not get a reply in 1 week you have not been accepted. We look forward to seeing you during our operations!

Reuben Beblingstock - Sat, 31 Mar 2018 19:52:29 EST ID:k++VoPQ4 No.37490 Ignore Report Quick Reply
Hello fellow hackerman. Can you recommend an Android and Whonix configuration for to set up anonymous kik account?
Clara Dartlock - Tue, 24 Apr 2018 15:09:52 EST ID:e23ty+oc No.37517 Ignore Report Quick Reply
than go ahead and proof it first
nobody will take you serious acting like that

Pose estimation and rigging by Priscilla Singerstedging - Sun, 08 Apr 2018 05:39:32 EST ID:xDpPYEfL No.37493 Ignore Report Reply Quick Reply
File: 1523180372573.jpg -(42267B / 41.28KB, 889x500) Thumbnail displayed, click image for full size. 42267
facebook released a new method to detect multiple bodies in a video. Some poeple already made their own attempts on github to do the same, and the algorithm will detect human movements and infer a skeleton out of it (you may have seen it, th eone with different colored limbs). What is the best pipeline to use this algorithm to extract movements from people in videos and place their sksletons into say anime figures in a video rendering software so the figure can follow the pose extracted form the human?

just asking for which software / language is best for this. i already know the theory, just need the practicalities of it (mostly model rigging and video stuff)

trying to make a hatsune miku x donald trump dance video but too lazy to rig it myself so i want to use AI for that.
Polly Worthingforth - Sun, 08 Apr 2018 16:33:19 EST ID:Xm/W+3lL No.37495 Ignore Report Quick Reply
You'd need a way to convert from the automatically-inferred skeleton to the target skeleton. I'm not sure which software would be best for this, but most of the skeletal rigging code I've seen was in a C-like language (C++, Java, C#, etc.) and used in videogames.
Phoebe Mucklespear - Tue, 10 Apr 2018 11:31:22 EST ID:9QSfnS0r No.37507 Ignore Report Quick Reply
Your best bet is python imho

  • You have tensorflow, the status quo on deep learning neural network.
Most probably any existing pose estimation networks you'd find on github will be done in tensorflow.
  • You can use python scripting in blender.
Although it uses it's own interpreter installation and it's not straightforward to use it in an outside application the things you can do in regards to animation and scripting in blender are second to none.
  • Makehuman
An application written in python to create humanoid meshes. It has the usual sliders to change the model attributes. You might try to get your network to come up with the sliders for a similar mesh based on an input video.

The advantage of this approach: You can at any point edit anything by hand and go beyond scripting.
The disadvantage: Many components and you pretty much have to at least adapt an existing tensorflow model.
Phoebe Mucklespear - Tue, 10 Apr 2018 11:39:39 EST ID:9QSfnS0r No.37508 Ignore Report Quick Reply
That said:

>too lazy to rig it myself so i want to use AI for that.
At current time there is no ready to use end user application that can do this.
And writing such application yourself is certainly more work that animating by hand.
A_Wizard !cMZsY.BCnU!!vVWR8L52 - Wed, 11 Apr 2018 20:43:18 EST ID:mJDH+xt3 No.37514 Ignore Report Quick Reply
This is actually a bit disturbing. An amazing toy, but the ability to log this kind of biometric data can be used for some pretty damned nefarious ends.
Samuel Berringtit - Fri, 13 Apr 2018 12:02:59 EST ID:9QSfnS0r No.37516 Ignore Report Quick Reply
I disagree, at least in an ideological sense.
I think it's disturbing that the law still regards video as hard, tamper-proof evidence. This should have been fixed in the early 00s not now when it's becoming a trivial exercise in terms of labor.
And if you find that scary see what can be done in conjunction with statistics.
For instance they demonstrated an algorithm that can guess a persons sexual orientation with 90%+ accuracy....
Just based on the intricacies of a facial expression on one photograph.

Friendly crypto community by William Smallham - Thu, 12 Apr 2018 16:48:08 EST ID:UqUR/YN3 No.37515 Ignore Report Reply Quick Reply
File: 1523566088427.jpg -(14380B / 14.04KB, 310x162) Thumbnail displayed, click image for full size. 14380
New and fast growing friendly community that provides exclusive cryptocurrency signals, newsletters, magazines, trading indicators, tools, and more based on advanced analytics and professional graph analysis techniques. Best server for providing users with evidence-based buy and sell signals for cryptocurrency trading and shorting!

A ridiculous sequence of courses by Doris Blatherstock - Sun, 04 Jun 2017 02:38:16 EST ID:HC1vVHLz No.37033 Ignore Report Reply Quick Reply
File: 1496558296564.jpg -(18091B / 17.67KB, 480x360) Thumbnail displayed, click image for full size. 18091
Hello, I made and actually did all this (including the 'grad level' research electives, except for the coding theory book)

It's easier than it looks, it took me 3 years to do that. I did it about 3-4 hrs a day at first but then everything kind of snowballed and I finished it with only 1hr a day after the first year. These days I'm finishing The Art of Computer Programming series, I'm done up to book 4A and doing 4B draft at the same time. I just do it 20-30mins a day.

I cannot shill TAOCP enough, it totally changed me from amateur to professional computer scientist by just doing hundreds and hundreds of exercises. 20mins a day, for one year, it's all you need for the first book. Anyway, pick and choose what you want from this list and enjoy

I make money from cloning shopify apps, and I work P/T on https://turtle.ai/ though much more infrequently these days. I started out shilling myself on elance (now "upwork") as a jr developer and literally taking jobs from 3rd world countries for less than I would spend on lunch. I also work 2 days a week at my local university doing "ML" (statistics) for a cancer research lab making peanuts but it's research, and fun to do, and I don't need the money. The book in that above link, "Parallel and Sequential Algorithms" was directly responsible for the lab hiring me. Anyway anons I'm here to tell you to try this have a good day.
26 posts omitted. Click Reply to view.
Sophie Hocklefield - Mon, 05 Mar 2018 04:09:18 EST ID:HH6lED9y No.37463 Ignore Report Quick Reply
OP, do you have any tips on starting out freelancing? I am three quarters out from graduating with a CS degree so I have some knowledge but I haven't been able to secure an internship and for various reasons I need to work. I don't want to go back to crappy jobs if I can help it, so I wanted to pick your brain on freelancing. Is upwork worth it if I just needed to make say 300 bucks a week or so?
Sidney Crommlededge - Fri, 30 Mar 2018 21:56:04 EST ID:Tfi7s7JZ No.37488 Ignore Report Quick Reply
will you stop removing things you double jolly african-american
A_Wizard !cMZsY.BCnU!!vVWR8L52 - Wed, 04 Apr 2018 18:33:40 EST ID:mJDH+xt3 No.37492 Ignore Report Quick Reply
Just hang out in all the crypto chatrooms. Done.
Ian Clayshaw - Tue, 10 Apr 2018 21:30:41 EST ID:5ed0HJE6 No.37511 Ignore Report Quick Reply
I thought you were b& m8
A_Wizard !cMZsY.BCnU!!vVWR8L52 - Wed, 11 Apr 2018 20:41:16 EST ID:mJDH+xt3 No.37513 Ignore Report Quick Reply
1523493676068.png -(110901B / 108.30KB, 595x746) Thumbnail displayed, click image for full size.
Spardot doesn't even remember me...

Would someone mind checking my work? by Isaac Yankem D.D.S. !!dPPr4Oxe - Mon, 09 Apr 2018 22:15:27 EST ID:PRg+vC3B No.37504 Ignore Report Reply Quick Reply
File: 1523326527669.jpg -(1821032B / 1.74MB, 4128x2322) Thumbnail displayed, click image for full size. 1821032
I'm using the site PracticePython.org to learn some python and one of the challenges is list overlap comprehension. My solution seems WAY different than what they have but it also seems to be working which seems, wrong. Would one of you kind people mind having a look and telling me if this is ferkakt? Here's a picture of my Jack Russel Terrier as a show of my gratitude.

import random

al = random.randint(5, 25)
bl = random.randint(5, 25)
a = random.sample(range(100), al)
b = random.sample(range(100), bl)
c = []

if len(a) > len(b):
c = [i for i in a if i in b and not c]
if len(b) > len(a):
c = [i for i in b if i in a and not c]
Comment too long. Click here to view the full text.
Isaac Yankem D.D.S. !!dPPr4Oxe - Mon, 09 Apr 2018 22:17:51 EST ID:PRg+vC3B No.37505 Ignore Report Quick Reply
Here's the challenge itself if that helps you understand what I was trying to do with it: (https://www.practicepython.org/solution/2014/04/16/10-list-overlap-comprehensions-solutions.html)

This week’s exercise is going to be revisiting an old exercise (see Exercise 5), except require the solution in a different way.

Take two lists, say for example these two:

a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

and write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your program works on two lists of different sizes. Write this using at least one list comprehension. (Hint: Remember list comprehensions from Exercise 7).


Randomly generate two lists to test this
Nathaniel Pittwell - Tue, 10 Apr 2018 01:19:26 EST ID:k++VoPQ4 No.37506 Ignore Report Quick Reply
  1. Stop using bullshit variable names. Is c common? Then call it common. Names matter.
  2. It doesn't matter which list is longer or which list you iterate over. If you were trying to optimize, all you did was waste time and create a bug.
  3. List comprehensions are always introduced as being the same thing as a list appending loop, but it isn't true. You can't reference the resulting list from within the comprehension so what you're trying to do will never work. To get unique items, either make the input or output unique.
  4. Randomly generating lists and manually checking the result is a bad joke. Instead, organize code into small functions and write test cases:

def make_common_list(a, b):
common = [i for i in a if i in b]
return make_unique_list(common)

def make_unique_list(seq):
unique_list = []
for i in seq:
if i not in unique_list:
return unique_list
Comment too long. Click here to view the full text.
Isaac Yankem D.D.S. !!dPPr4Oxe - Tue, 10 Apr 2018 22:00:49 EST ID:PRg+vC3B No.37512 Ignore Report Quick Reply

Firstly, thinks for responding and giving advice. I appreciate it immensely.

Let me address each of your comments individually to give and get clarification.

  1. The list names are used from the exercise given. Also, I didn't think they would matter much because they aren't being used in any real world code. Just as an exercise to learn how things work. I get that if I were building something that would be used for anything other than completing this coding exercise naming the lists something useful would be important. I have a little tiny bit of knowledge of JavaScript and have dicked around with creating things in it and I know to always make sure an array has a useful name so that I know what data it's storing.

2. Ok. I was thinking that because the lists weren't sorted in my code (Remember they're generated randomly) that I would always want to check the longer one against the shorter one so it wouldn't get to the end of the short one and stop. That wasn't made clear in the source material I was reading that it wouldn't be a problem. In fact, they made it seem like it would be a problem if one was longer than the other and you didn't do something for it.

3. I'm not completely sure I understand but IF I do, you're saying that I cannot check against the list I'm creating inside of the list comprehension? That makes sense sort of and working around that is definitely something I'll keep in mind. TBH: I kind of like using the for loops more than list comprehension. The whole things feels like voodoo to me and the for loops make more sense in my head.

4. I see. Randomly generating and then testing it is dumb because who knows what kind of results you'll get if they're random. I should have started with known lists, made sure it works and then generated them randomly.

Pages Next>>
0 1 2 3 4 5 6 7 8 9 10 11
Report Post
Please be descriptive with report notes,
this helps staff resolve issues quicker.