• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

What's the best method for removing a random element from a list? I have a list of Scrabble letters and I want to remove a random element of the list and return it. (the list being the bag of letters and removing a letter would be like drawing a letter to put it on your rack) More specifically, are the following two equivalent:
Take a random number from [0, n[ and use it as an index to the list
Shuffle the list (Fisher-Yates shuffle for instance) and return the first element.

The first one is obviously more efficient, but I'm not sure if it's also correct.
 

usea

Member
What's the best method for removing a random element from a list? I have a list of Scrabble letters and I want to remove a random element of the list and return it. (the list being the bag of letters and removing a letter would be like drawing a letter to put it on your rack) More specifically, are the following two equivalent:
Take a random number from [0, n[ and use it as an index to the list
Shuffle the list (Fisher-Yates shuffle for instance) and return the first element.

The first one is obviously more efficient, but I'm not sure if it's also correct.
They're equivalent in behavior, since every element is equally likely in both scenarios.
 

iapetus

Scary Euro Man
They're equivalent in behavior, since every element is equally likely in both scenarios.

They're not equivalent in behaviour, as the second leaves you with a shuffled list. If ordering is important, not only is the first one more performant, it's the only one that doesn't break your list.
 
They're equivalent in behavior, since every element is equally likely in both scenarios.

They're not equivalent in behaviour, as the second leaves you with a shuffled list. If ordering is important, not only is the first one more performant, it's the only one that doesn't break your list.

Okay, that's what I expected. I once tried the first approach (indexing the list with a random number) and for some reason it gave back weird results (always the same pattern of letters removed I think), that's why I was asking. Seems like I just made an implementation error back then.
 

maeh2k

Member
Okay, that's what I expected. I once tried the first approach (indexing the list with a random number) and for some reason it gave back weird results (always the same pattern of letters removed I think), that's why I was asking. Seems like I just made an implementation error back then.

Just to be sure, did you give the random number generator some seed value? If you don't initialize it with a different value each time you use it, the pattern will repeat.
 
How exactly is the first approach more efficient?
Looks pretty much the same to me.
Generating a random number is constant time, shuffling the whole array takes at least O(n).
Just to be sure, did you give the random number generator some seed value? If you don't initialize it with a different value each time you use it, the pattern will repeat.

I used C#'s Random class, which is initialized with a "time-dependent" seed value, which should be fine. I don't remember what exactly the problem was since it's been a few years since I wrote that.
 

Osiris

I permanently banned my 6 year old daughter from using the PS4 for mistakenly sending grief reports as it's too hard to watch or talk to her
I used C#'s Random class, which is initialized with a "time-dependent" seed value, which should be fine. I don't remember what exactly the problem was since it's been a few years since I wrote that.

It's been a while since I did much C#, but i do remember that you have to be careful with Random() in a fast loop situation as the system clock granularity issue can cause the same value to end up being used for the seed, leading to duplicate random number sequences.

Edit:

MSDN Random()
The default seed value is derived from the system clock and has finite resolution. As a result, different Random objects that are created in close succession by a call to the default constructor will have identical default seed values and, therefore, will produce identical sets of random numbers. This problem can be avoided by using a single Random object to generate all random numbers. You can also work around it by modifying the seed value returned by the system clock and then explicitly providing this new seed value to the Random(Int32) constructor. For more information, see the Random(Int32) constructor.
 

Osiris

I permanently banned my 6 year old daughter from using the PS4 for mistakenly sending grief reports as it's too hard to watch or talk to her
Generating the random number may be constant time, but actually traversing the list to get to the random element is O(n).

If he has the element index, why would he traverse?
 

Kansoku

Member
Can someone give me a ink or explain how do we get the complexity of a function? My teacher didn't explain it very well, and I really don't understand it very well.
 

tokkun

Member
If he has the element index, why would he traverse?

He said 'list'. If it is a linked list, then you need to traverse it to get to an element. If you are talking about an array instead, then fine you can get O(1) access to an element, but then the cost of removing the element is O(n).
 
He said 'list'. If it is a linked list, then you need to traverse it to get to an element. If you are talking about an array instead, then fine you can get O(1) access to an element, but then the cost of removing the element is O(n).

Yeah, that's right of course. The C# collections library List<T> has constant time element access (it's like Java's ArrayList)
 
What's the best method for removing a random element from a list? I have a list of Scrabble letters and I want to remove a random element of the list and return it. (the list being the bag of letters and removing a letter would be like drawing a letter to put it on your rack)

If it were me, I would use an array.

Track the effective size of the array/the index of the last element.

Pick a random number between 0 and the last index.

Get the letter at that index to return.

Assign the letter at that index to the last letter in the array, then decrement the effective size.
 

usea

Member
If it were me, I wouldn't even bother. It will not matter at all. This will not be a bottleneck in the game. Do the simplest thing that works and move on.

I'd also make everything immutable, since it's simpler, but to each their own.
 

maeh2k

Member
Generating a random number is constant time, shuffling the whole array takes at least O(n).

Presumably you are going to draw multiple letters. If you play an entire game, successively drawing letters until none are left, it's O(n), too, and you end up with something very similar to the shuffle.
 
If it were me, I wouldn't even bother. It will not matter at all. This will not be a bottleneck in the game. Do the simplest thing that works and move on.

I'd also make everything immutable, since it's simpler, but to each their own.
I've already considered that, but the ImmutableCollections library for C# is kind of a hassle to use. I really do like immutable classes/collections, it makes everything a lot simpler once you're used to it.
Presumably you are going to draw multiple letters. If you play an entire game, successively drawing letters until none are left, it's O(n), too, and you end up with something very similar to the shuffle.
You're right. The difference is most likely negligible and nothing I should spend any more time thinking about.

I don't know if this has been posted already, but this is an amazing article about what it's like to be a systems programmer: http://research.microsoft.com/en-us/people/mickens/thenightwatch.pdf
Very funny and with a lot of insight.
 

usea

Member
I've already considered that, but the ImmutableCollections library for C# is kind of a hassle to use. I really do like immutable classes/collections, it makes everything a lot simpler once you're used to it.
In C# I usually just pretend everything is immutable. I make new lists instead of adding or removing. I make new values instead of changing them. Not always, but most of the time.

I'm not saying everybody should do that, but it's how I do things.
 
I need help in installing Cygwin. Here is what my instructor said, "For Windows, I recommend installing cygwin, which we did in class today. In the installation wizard, when you reach the screen to select features, search for "gcc" in the search field and then select the C/C++ compiler in the "devel" node. Once installation is complete, you can open cygwin and run the "gcc" command to compile your C source code files." I did as he said, but it give me a message stating the download is incomplete. Can anyone help me starting from the beginning?

Edit: nvm
 

Big Chungus

Member
Anyone know anything about bash scripting?

Trying to print out the username, user group and homedirectory but whenever i execute my script it just prints everything out in order instead of in the appropriate columns:

Code:
printf "%-30s %-30s %-50s\n" "User" "Group" "Home Directory"

user_name=`cat /etc/passwd | cut -d: -f1`

#echo $user_name

user_group=`cat /etc/passwd | cut -d: -f4`

#echo $user_group

user_home=`cat /etc/passwd | cut -d: -f6`

#echo $user_home

printf "%-30s %-30s %-50s\n" $user_name $user_group $user_home

echo "Script has ended"

What I see:
Code:
Script has started
User (UID)                     Group                          Home Directory (Size)                             
root                           bin                            daemon                                            
adm                            lp                             sync                                              
shutdown                       halt                           mail                                              
operator                       games                          ftp                                               
nobody                         oprofile                       avahi-autoipd                                     
dbus                           polkitd                        usbmuxd                                           
abrt                           rpc                            colord                                            
rtkit                          chrony                         tss                                               
mysql                          openvpn                        unbound                                           
pulse                          nm-openconnect                 avahi                                             
rpcuser                        nfsnobody                      sshd                                              
tcpdump                        fernando                       0                                                 
1                              2                              4                                                 
7                              0                              0                                                 
0                              12                             0                                                 
100                            50                             99                                                
16                             170                            81                                                
999                            113                            173                                               
32                             997                            172                                               
996                            59                             27                                                
994                            993                            992                                               
990                            70                             29                                                
65534                          74                             72                                                
1000                           /root                          /bin                                              
/sbin                          /var/adm                       /var/spool/lpd                                    
/sbin                          /sbin                          /sbin                                             
/var/spool/mail                /root                          /usr/games                                        
/var/ftp                       /                              /var/lib/oprofile                                 
/var/lib/avahi-autoipd         /                              /                                                 
/                              /etc/abrt                      /var/lib/rpcbind                                  
/var/lib/colord                /proc                          /var/lib/chrony                                   
/dev/null                      /var/lib/mysql                 /etc/openvpn                                      
/etc/unbound                   /var/run/pulse                 /                                                 
/var/run/avahi-daemon          /var/lib/nfs                   /var/lib/nfs                                      
/var/empty/sshd                /                              /home/fernando                                    
Script has ended
 
Java is what they taught when I went to college and I absolutely hated it, too, and my programming experience up to that point in time was just C. Don't give up on programming, though. There are far, far more enjoyable languages to work with.

I'm in college now so pretty much the same situation. I know good programming knowledge can open a lot of doors so I try and keep with it. Thanks.
 
I'd just randomize the list once and take the first element each time you need a new random tile.

How do you handle tiles that are put back in the bag for exchange?

it just prints everything out in order instead of in the appropriate columns:

Code:
printf "%-30s %-30s %-50s\n" $user_name $user_group $user_home

Good news, it's doing exactly what you told it to do ;)

awk is probably a better fit for what you want to do:

Code:
awk -F'[:]' '{ printf "%-30s %-30s %-50s\n", $1, $4, $6 }' /etc/passwd
 

NotBacon

Member
I fucking hate Java. It's me not language but still fuck you Java. I can't wait until I'm done with programming. Props to anyone that can stick with it, it's just not for me.

Java is what they taught when I went to college and I absolutely hated it, too, and my programming experience up to that point in time was just C. Don't give up on programming, though. There are far, far more enjoyable languages to work with.

I loved Java as a first language haha. It feels like there's a built in function for everything you could possibly think of, so it made the learning curve easy for me.

I definitely see it's downfalls now looking back, but it's still my most comfortable language. Good thing i'm an Android dev haha.
 

r1chard

Member
Fuck Java? Fuck Javascript. Seriously, the cargo cult is strong here sometimes:

There is no rocket science in deleting items from array. To delete items from any array you need to use splice: $scope.items.splice(index, 1);

No rocket science. No, that's a perfectly fucking reasonable API there.

Don't get me started on the Date object. No, wait. Do:

function addDays(date, days) {
var result = new Date(date);
result.setDate(date.getDate() + days);
return result;
}

// Don't do it this way!
function addDaysWRONG(date, days) {
var result = new Date();
result.setDate(date.getDate() + days);
return result;
}

Can you see the difference? Do you know what the resultant behaviour difference is?

If you said "oh, in the second one, the time sometimes isn't set correctly" then YOU WIN!

And then there's Date.setHours(). It takes four arguments. Oh yes.

Who designed this API? Monkeys?
 
When you guys/gals where going through undergrad or currently are going through undergrad. With your programming courses, how were your labs constructed? From me as of right now, we sit down at our computers and code. No talking to classmates,the instructor doesn't explain the lab problems. He will answer individual question but that's about it, is this the norm?
 

usea

Member
When you guys/gals where going through undergrad or currently are going through undergrad. With your programming courses, how were your labs constructed? From me as of right now, we sit down at our computers and code. No talking to classmates,the instructor doesn't explain the lab problems. He will answer individual question but that's about it, is this the norm?
My school didn't have labs at all. Every school is different.
 
When you guys/gals where going through undergrad or currently are going through undergrad. With your programming courses, how were your labs constructed? From me as of right now, we sit down at our computers and code. No talking to classmates,the instructor doesn't explain the lab problems. He will answer individual question but that's about it, is this the norm?

I only had labs in the introductory course. The instructor would do some example programming for the first 5-10 minutes, and then we would just code the rest of the time.
 

GaimeGuy

Volunteer Deputy Campaign Director, Obama for America '16
Placement new is weird, amazing, and the use of it to re-initialize pool objects should be supported with the renew keyword in C++. Or something.
 
When you guys/gals where going through undergrad or currently are going through undergrad. With your programming courses, how were your labs constructed? From me as of right now, we sit down at our computers and code. No talking to classmates,the instructor doesn't explain the lab problems. He will answer individual question but that's about it, is this the norm?
For us, the professor described the problem briefly then just sat or walked around waiting for questions. Everyone was usually chatty during lab exercises. If someone finished quickly he can go or hang around. I had labs up to the third year courses (networking, OS, programming languages, etc). I always looked forward to them.
 

Water

Member
When you guys/gals where going through undergrad or currently are going through undergrad. With your programming courses, how were your labs constructed? From me as of right now, we sit down at our computers and code. No talking to classmates,the instructor doesn't explain the lab problems. He will answer individual question but that's about it, is this the norm?
On our basic programming courses, the exercise sessions are intended for asking individual questions, but completely voluntary. If you can do the work from home, you can, and if classmates can help you or the other way around, that's fine too. You do have to code on your own, so going to the extent of copying others' code verbatim is a no.
 

usea

Member
Usually when we were assigned something, the teacher would spend at least 5-10 minutes talking about the assignment and how it related to the current topic in class, just so everybody understood what was expected and could ask questions. Also my school had a CS computer lab for students to socialize and do homework, where there were never any teachers or classes. So it was easy to ask people for help with something since there was always somebody in the lab hanging out between/after class.
 
When you guys/gals where going through undergrad or currently are going through undergrad. With your programming courses, how were your labs constructed? From me as of right now, we sit down at our computers and code. No talking to classmates,the instructor doesn't explain the lab problems. He will answer individual question but that's about it, is this the norm?

It changed based on the class. The very first programming unit completely holds your hand - the instructor would walk the class through/collaboratively write some code, explain the week's assignment then gave every student one-on-one feedback on the last week's work (if they handed anything in). In later classes they would explain the week's work, go through common problems they saw when marking stuff, do one-on-one feedback then help wherever student's needed it for the remainder of the time.

In the second unit it was almost the complete opposite - the instructor showed up, said "read chapter X and do the questions" then sat there. Questions were not particularly encouraged, nor were the answers much help.

In later courses it was closer to the second unit than the first, and we mostly had to show up to get work signed off or if we wanted help or a place to work. Depending on the material the instructors would sometimes give a short overview or example, but mostly they were just there if you wanted to ask any questions.
 

0xCA2

Member
Sup guys, I'm trying to build a resume for my first internship. I've been a self tught programmer for about 2 years and I'm combing through my past projects and programs to see what I should put on my resume. A lot of what I did was CLI and not graphical; would that be acceptable or should I just slap a GUI on those programs?

What type of things would they want to see from a first-time intern?

I've written (and please let me know if this looks unimpressive for my position):
-Several (short) text based games
-A 2 player Tic Tac Toe game
-Simple photo viewer (reads photos in directory, scroll them via back and forward buttons)
-Prototype notepad-esque text editor (just non fuctioning menu bar and large text field :p)
-Prototype IM window UI
-Program that (somewhat) randomly generates a user specified amount of names, assigns them GPAs, stores them in a file and then calculates the valedictorian.
-Sort of visual novel protoype program with scrolling text over a text box over a
background
-File renames, file creators, etc
-Much more that were personal accomplishments that I'm not sure anyone will care about

I know Python and Java, but mostly Java. I'm learning HTML/CSS, and I know a bit about Powershell.

Anyway, just want you alls' feedback on this.

Edit: Wait, I've read that apparently that you won't be able to get a CS internship unless you've taken X amount of classes in the CS track anyway? So if you don't know Data Structures, for example, you'll likely fail the interview? Well then...
 

Exuro

Member
Need some help with an assignment I'm really struggling with. I need to measure the time on a system call and library call and then measurea context switching using pipe(). I'm stuck on the very first part. I was told that there's more overhead on system calls as the OS needs to access kernal space which takes time and so I'm trying to measure some system calls and I can't help but feel I'm doing something wrong.

struct timeval begin, end;

gettimeofday(&begin, NULL);

getpid();

gettimeofday(&end, NULL);

printf("Time: %ld\n", ((end.tv_sec*1000000 + end.tv_usec) - (begin.tv_sec*1000000 + begin.tv_usec)));

So I run gettimeofday before and after a system call and take the difference. One of my issues is I'll run this for 1 and get some number, but then paste getpid a few more times and expect to get a few more times time, but instead I barely get more time than before if that and I can't figure out why. My plan was to make a few calls and take the average but that won't work.

Any ideas?

edit:screw this. I think it has something to do with instruction caching. I'm not liking the reolution on it so I looked up assembly inlining and am using rdtsc instead.

If anyone know, how would I take the cycles that rdtsc returns and convert that to time? Can't seem to find a way to find the frequency of the cpu.
 

tokkun

Member
Need some help with an assignment I'm really struggling with. I need to measure the time on a system call and library call and then measurea context switching using pipe(). I'm stuck on the very first part. I was told that there's more overhead on system calls as the OS needs to access kernal space which takes time and so I'm trying to measure some system calls and I can't help but feel I'm doing something wrong.



So I run gettimeofday before and after a system call and take the difference. One of my issues is I'll run this for 1 and get some number, but then paste getpid a few more times and expect to get a few more times time, but instead I barely get more time than before if that and I can't figure out why. My plan was to make a few calls and take the average but that won't work.

Any ideas?

edit:screw this. I think it has something to do with instruction caching. I'm not liking the reolution on it so I looked up assembly inlining and am using rdtsc instead.

If anyone know, how would I take the cycles that rdtsc returns and convert that to time? Can't seem to find a way to find the frequency of the cpu.

rdtsc can be tricky for that purpose. If your process gets migrated to a new CPU it will give an incorrect result - which is something that could be triggered by a system call depending on your scheduler. You also need to make sure that the rdtsc instruction doesn't get reordered by your out of order processor or you will end up measuring the wrong code segment. As you have discovered, you need to convert from cycles to time via frequency, but if you have dvfs enabled on your cpu, that may not be trivial. rdtscp on supported processors is a little better but still has some of those issues.

My suggestion would be that you can overcome your resolution issue by putting the syscall in a loop, running it thousands of times, and averaging the results. Just remember to measure the loop overhead and subtract it off.
 
When you guys/gals where going through undergrad or currently are going through undergrad. With your programming courses, how were your labs constructed? From me as of right now, we sit down at our computers and code. No talking to classmates,the instructor doesn't explain the lab problems. He will answer individual question but that's about it, is this the norm?

We usually had a lab instructor and TAs and there was a weekly assignment for that lab period that tied in to our most recent assignment. And it was relatively cooperative and questions were welcomed.
 

Exuro

Member
rdtsc can be tricky for that purpose. If your process gets migrated to a new CPU it will give an incorrect result - which is something that could be triggered by a system call depending on your scheduler. You also need to make sure that the rdtsc instruction doesn't get reordered by your out of order processor or you will end up measuring the wrong code segment. As you have discovered, you need to convert from cycles to time via frequency, but if you have dvfs enabled on your cpu, that may not be trivial. rdtscp on supported processors is a little better but still has some of those issues.

My suggestion would be that you can overcome your resolution issue by putting the syscall in a loop, running it thousands of times, and averaging the results. Just remember to measure the loop overhead and subtract it off.
This puts a damper on my progress. Ugh. So I was told that system calls were generally more expensive than library calls due to accessing kernal code. Are there a pair of examples I could use to show the difference?
 

tokkun

Member
This puts a damper on my progress. Ugh. So I was told that system calls were generally more expensive than library calls due to accessing kernal code. Are there a pair of examples I could use to show the difference?

Well, it's not that it's impossible to do with rdtsc, you just need to understand the subtleties. You can overcome the instruction reordering problem by pairing the rdtsc with an instruction that acts as a memory fence, such as cpuid (if your processor supports rdtscp, this combines the two instructions into one). To avoid getting garbage data if a thread migration occurs, you need to read the processor ID returned by cpuid or rdtscp and make sure that it matches for both the start time and end time (this doesn't protect you against garbage data if you migrated multiple times and ended up back where you started, but it reduces the probability of error). You can also 'nice' the process to reduce the chance of getting descheduled during your measurement. To get frequency, you can query the cpu details and just accept that DVFS will make it so you have error bars on your result

So you can definitely do it, I'm just warning you that it took me a couple days of trial and error to get it right the first time I tried doing performance profiling this way. Inline assembly itself is also tricky since it can introduce very subtle bugs if you make a mistake with which registers get clobbered. So don't expect this approach to 'just work'.

The other thing you should keep in mind is that the effect you are trying to measure actually has 2 parts, and you want to make sure you measure them both. The first is the amount of time it takes to run the system call. The second, and often more important part, is the side effects the system call produces on the code that runs after it. The side effect I'm referring to is the impact of the system call on the contents of the instruction cache, data cache, and TLB. When you return from the system call, your program may run slower than normal, because it experiences cache and TLB misses because its data was evicted (or not prefetched) when in the kernel code. This is a topic of research in the OS community, and there have been a few papers published on it in the past few years.

To measure these side effects, it is important that you record not only the time it takes to execute the system call, but also the time it takes to execute the code that runs after the system call.
 
I've got a mid-term exam next Monday (Intro to Programming - c#), and I'm struggling a bit with Loop and if/else structures.

///1. Convert temperature Fahrenheit (F) to Celcius (C)
/// Vary fahrenheit from 32 to 212, compute Celsius aand display both.
/// Formula: C = 5 *(F-32)/9 (use float or double)

///2. Add all the consecutive integers from 100 to 200 except the one that are in the 130 and 170 range.

///3. Use Mod function and division operator
/// Get $ amount from user, determine/display/convert
/// The amount $ amount to quarters and pennies

///4. Use Random and Mod
/// Generate a random value from -100 to 100 then indicate if the value is positive or negative, odd or even

///5. Use while, random
/// Generate 20 random values between 1 and 10, add only the ones that are odd, display sum.

Some of the problems I'm struggling with.
 

Exuro

Member
Well, it's not that it's impossible to do with rdtsc, you just need to understand the subtleties. You can overcome the instruction reordering problem by pairing the rdtsc with an instruction that acts as a memory fence, such as cpuid (if your processor supports rdtscp, this combines the two instructions into one). To avoid getting garbage data if a thread migration occurs, you need to read the processor ID returned by cpuid or rdtscp and make sure that it matches for both the start time and end time (this doesn't protect you against garbage data if you migrated multiple times and ended up back where you started, but it reduces the probability of error). You can also 'nice' the process to reduce the chance of getting descheduled during your measurement. To get frequency, you can query the cpu details and just accept that DVFS will make it so you have error bars on your result

So you can definitely do it, I'm just warning you that it took me a couple days of trial and error to get it right the first time I tried doing performance profiling this way. Inline assembly itself is also tricky since it can introduce very subtle bugs if you make a mistake with which registers get clobbered. So don't expect this approach to 'just work'.

The other thing you should keep in mind is that the effect you are trying to measure actually has 2 parts, and you want to make sure you measure them both. The first is the amount of time it takes to run the system call. The second, and often more important part, is the side effects the system call produces on the code that runs after it. The side effect I'm referring to is the impact of the system call on the contents of the instruction cache, data cache, and TLB. When you return from the system call, your program may run slower than normal, because it experiences cache and TLB misses because its data was evicted (or not prefetched) when in the kernel code. This is a topic of research in the OS community, and there have been a few papers published on it in the past few years.

To measure these side effects, it is important that you record not only the time it takes to execute the system call, but also the time it takes to execute the code that runs after the system call.
Alright. Rdtsc seems a little over the top for what I'm doing then. The professor said to use either that or the get time of day function. He didn't teach us it and rather mentioned that you can use it. We're going to learn about TLB later so I guess I'll have to stick to gettimeofday for now.

I have another question that's related to this. I have to measure a context switch and the professor told us to use a piped read and write. He didn't teach us how to do this but I was able to get the gist of the code but am still confused by how it works and when the context switch actually occurs. I have a piped function that forks and writes from the child and reads in the parent. I also read up on sched_setaffinity to force the process to only run on 1 core but I don't know how to check that that's holding true.
 

Water

Member
Sup guys, I'm trying to build a resume for my first internship. I've been a self tught programmer for about 2 years and I'm combing through my past projects and programs to see what I should put on my resume. A lot of what I did was CLI and not graphical; would that be acceptable or should I just slap a GUI on those programs?
...
I don't know what is expected for the positions you are looking at, but I'll give my perspective on the portfolio in general.

Programming skill is fundamentally about being able to manage complexity. All of the stuff you have sounds too simple (assuming there isn't significant stuff going on under the hood that you didn't mention). It doesn't matter if you have a million trivial programs; they don't prove you can do programming, only that you can look up functionality in documentation and do some copy-pasting.

Suppose you implement some well-known algorithm that has non-trivial complexity - e.g. add some type of minmax AI in the Tic-Tac-Toe game. A minimal implementation of that would take just one page of code, yet this alone would be so much better than the rest of the portfolio, there would be no point in even mentioning the other programs anymore. You shouldn't stop there, of course. You should add more features, e.g. saving and loading games, another type of AI, saving and playing back replays. Note that it's much, much more interesting if features like this are present in the same program instead of separate programs; that's what shows you are actually capable of dealing with complexity.

There are other things besides piling on complexity that will improve your portfolio: making your code high quality (maintainable, efficient, etc.), using reasonable tools (e.g. having your portfolio project in Github), giving the program actual usability and polished UI. But it's for naught if you aren't capable of writing code of interesting complexity to begin with.
 
I've got a mid-term exam next Monday (Intro to Programming - c#), and I'm struggling a bit with Loop and if/else structures.



Some of the problems I'm struggling with.

What particular issues are you having with those problems? Showing us what you've tried already, and what problems it's causing, would make it easier for us to help you.
 

0xCA2

Member
I don't know what is expected for the positions you are looking at, but I'll give my perspective on the portfolio in general.

Programming skill is fundamentally about being able to manage complexity. All of the stuff you have sounds too simple (assuming there isn't significant stuff going on under the hood that you didn't mention). It doesn't matter if you have a million trivial programs; they don't prove you can do programming, only that you can look up functionality in documentation and do some copy-pasting.

Suppose you implement some well-known algorithm that has non-trivial complexity - e.g. add some type of minmax AI in the Tic-Tac-Toe game. A minimal implementation of that would take just one page of code, yet this alone would be so much better than the rest of the portfolio, there would be no point in even mentioning the other programs anymore. You shouldn't stop there, of course. You should add more features, e.g. saving and loading games, another type of AI, saving and playing back replays. Note that it's much, much more interesting if features like this are present in the same program instead of separate programs; that's what shows you are actually capable of dealing with complexity.

There are other things besides piling on complexity that will improve your portfolio: making your code high quality (maintainable, efficient, etc.), using reasonable tools (e.g. having your portfolio project in Github), giving the program actual usability and polished UI. But it's for naught if you aren't capable of writing code of interesting complexity to begin with.

Thanks for the advice. I asked around today and I was told that one can't really get an internship if you haven't done the first 2 programming classes anyway, but also I realize that I'm just not on that level yet. I will just try to push myself more and try to learn and build more complex and robust programs, particularly during the summer.
 
Sup guys, I'm trying to build a resume for my first internship. I've been a self tught programmer for about 2 years and I'm combing through my past projects and programs to see what I should put on my resume. A lot of what I did was CLI and not graphical; would that be acceptable or should I just slap a GUI on those programs?

CLI or not doesn't really matter much. In fact, given where technology is headed I recommend learning how to build web services. Seeing as you have python and java experience.

I'd recommend learning Django on the python side and dropwizard or spring boot on the java side. Most applications involve data base persistence on some level. An ordering system would be good to build such skills. Once you have a handle on that, make sure you learn how to write unit tests. Revisit the ordering system and build unit tests the second time around. Finally, learn how to use build tools ( I like maven for java. For python, I typically just have a makefile that puts in the build version ) and source control.
 

usea

Member
Thanks for the advice. I asked around today and I was told that one can't really get an internship if you haven't done the first 2 programming classes anyway, but also I realize that I'm just not on that level yet. I will just try to push myself more and try to learn and build more complex and robust programs, particularly during the summer.
I'd also like to say that a GUI definitely isn't necessary for things on your resume or in your portfolio.

And the type of things that are relevant depend a lot on the type of company / internship you're going for. A web design place would probably like web projects more than say a traveling salesman search.

Also it depends on the difficulty of landing the internship. In my area showing the initiative to complete any project at all outside of class would put you on the short list. We don't have any prestigious companies around here though.
 
Top Bottom