/dpt/ - Daily Programming Thread

What have you been working on, Sup Forums?

Previous thread:

Other urls found in this thread:

natureofcode.com/
ideone.com/ZStICn
pastebin.com/yHQVkG6g
youtube.com/watch?v=lyZQPjUT5B4
github.com/swenson/sort
twitter.com/NSFWRedditVideo

This website is 18+

Have you read your SICP today?

Which is why you need to stop posting Korean cartoons. Cartoons are for children.

Is there someone who develops to android in kotlin? How do you like it?

>3dpd

How do I declare attributes to achieve a drop down grouped list that takes dimension values like the margins, padding ones?

I didn't remember 3D grills could be so pretty. Did you know that most people meet their girlfriends at school or work? Hint: don't study computer science.

Which is the best to wear during programming?
>Full suit with tuxedo
>Shirt and jeans
>Casual outfit
>Naked

fairly sure there's some pretty important articles of clothing /dpt/ will tell you that you're missing

is it ok to use global variables like mouseX and mouseY for the mouse position? my mum says global variables are bad practice.

...

I usually wear at least socks. If my feet get cold, I find it harder to concentrate.

>my mum says global variables are bad practice
Her original intention of that word is "You are a result of bad practice"

because she got pregnant in the first time she had sex?

what colour

how's the weather in UK?

nice

Don't you fucking lie to me

>What language is it written in?

C++


>What text editor are you using, and did you make your own syntax highlighting file for your DSL?

Notepad++, and yes. It's very easy to make your own syntax highlighting using it.

>how long have you been working on that?

4-5 years very on-and-off since I have full-time commitments.

>I remember seeing screenshots of something very similar being posted in an original content thread on /jp/ a year ago or maybe more.

/jp/ was the original place I ever posted the game. Their OC threads + /vg/'s amateur gamedev threads have been my main 2 places for posting progress.

Welcome back Simloli-dev. How is your day?

This kind of action seems like it should be point and click

stop being a paedo you mexican fuck and make a normal game

Why is this town full of lolis and where are their parents?

fuck you what colour are the socks

>Her original intention of that word
Your mum's "original intention of that word" is "You are a result of bad English classes."

Mmmm gat damn I miss high school
It's been so long I can barely remember what all that awkward sex was like

What are some general programming books I can read to be a better programmer? If I only had time for one at the moment which one is a must?

So far I only read language strict books.

>forget phone
>teacher writes code on the board
>ask friend next to me if she could send them to me
>she does
>remember that she never got up to get close
>she took the photos from her seat
>photos arent good enough to even read the code from
t-thanks

fuck me, the one time i forget my phone

friendly reminder that a queue and stack of size 1 are both a LIFO and a FIFO and therefore referring to either as a 'LIFO' or a 'FIFO' exclusively is wrong

>Download Tinder
>Fuck high school seniors and college freshmen
>tfw you keep getting older, but they stay the same age

>tfw you get called a pedo because you're attracted to women aged 21-25 and you're above 30

They're in the game too. I just debug-spawned a group of them for that gif. In normal gameplay every house has 1-2 parents and 1 child (none of the interiors for the houses I've done can fit enough bedrooms - but when I do the interiors to the bigger house they will). so there's actually more adults in the town than kids, and that's excluding police officers.

Pic related, it's the actual approximate density (granted I drove slightly to where I saw more dots on the minimap) of adults vs children (ie more adults)

Well, that menu allows you to bind those actions to keys so you can just hotkey the stuff you want to use before an encounter, then not have to open up that menu. (I think I'll make it pause afterwards?)

Tiring, but I'm hoping now I can get some work done on the game. I'm programming some stuff to make the procedural town generation better. I added in dumpsters to dump bodies in yesterday and then added in paths from the doorsteps of most houses to the sidewalks (it will BFS to find the shortest path, and then if there's multiple buildings with path sources in the yard, will also let those join up to existing paths if that is closer than the sidewalk is.).

I think I'll continue on that and make it so that some blocks are simply forests to add some variety to the city. Or maybe add in gardens and playgrounds to the yards. Or have there be a "central park" in every town with a big statue or something to provide additional orientation.

(that and the adding choice/option structure to LoliScript as seen in )

natureofcode.com/

They're both correct, fucktard.

Will you put shotas in your game?

I don't have the time or patience to play games with girls these days

Working on cs group project and all my members contribute the shittiest code but don't wanna be a dick and rewrite their stuff. How do I deal with normies Sup Forums?!

/*This program loads a file into an array of structs,
and is able to sort that array by name and salary size.
*/

#include
#include
#include
#include
#include
#include

using namespace std;

struct Employee
{
int id;
string firstName;
string lastName;
int salary;
};

void opener(ifstream &reader);
void getEmployees(ifstream &reader, Employee allEmployees[], int count);
void empPrintByName(Employee allEmployees[], Employee nameSorted[], Employee salSorted[], int count);
int empSortByName(const Employee allEmployees[], int count, int i);
void sorter(Employee allEmployees[], Employee nameSorted[], Employee salSorted[], int count);

int main()
{
Employee allEmployees[6];
ifstream empReader;
Employee nameSorted[6];
Employee salSorted[6];

opener(empReader);

for (int count = 0; count < 6; count++)
{
getEmployees(empReader, allEmployees, count);
sorter(allEmployees, nameSorted, salSorted, count);
empPrintByName(allEmployees, nameSorted, salSorted, count);
}
}


void opener(ifstream &reader)
{
reader.open("employees.txt");
if (reader.fail())
{
cout

IIRC, there was some study of OKCupid data that showed that the "ideal" age women look best to men is like 21 or 22.
Women generally prefer guys about 4 years older, until they get to be 31, then they prefer about 2 years younger.

Not sure how far above 30 you are, but your age alone is going to be attractive to girls in their mid 20s. Even moreso if you're doing OK for yourself, girls find a put together guy attractive.

There's also the rule of thumb: half your age + 7. So as a 32 year old guy, 23 is the conventional lower limit of your dating pool.

Then get yourself a long term gf.

so your saying when i turn 100 i can date a 57 year old?

hell yeah

void getEmployees(ifstream &reader, Employee allEmployees[], int count)
{
reader >> allEmployees[count].id >> allEmployees[count].firstName
>> allEmployees[count].lastName >> allEmployees[count].salary;
}
void empPrintByName(Employee allEmployees[], Employee nameSorted[], Employee salSorted[], int count)
{
cout

Hey, if he manages to pacify real pedos with his overly detailed loli rape simulator, all the better. Let him work how he wants.

int empSortByName(const Employee allEmployees[], int count, int i)
{
string firstEmpByName = allEmployees[count].lastName;
string nextEmpByName = allEmployees[count + 1].lastName;
int firstEmpIndex;
for (int j = 0; j < 3; ++j)
{
if (allEmployees[count].lastName[j] > allEmployees[count+i].lastName[j])
{
firstEmpIndex = count+i;
return firstEmpIndex;
}
}
return -1;
}


So, I need to get this thing to print out the names of all the employees in alphabetical and then in order by salary from biggest to smallest. All it's doing right now is printing out pic related.

non imperitard here but this is some nice straight forward code without too much bloat or repetition or OOP garbage

Here's the input text file. I believe the problem lies somewhere in empSortByName, or in the calling line to it.
1000 George Washington 10000
2000 John Adams 15000
1212 Thomas Jefferson 34000
1313 Abraham Lincoln 45000
1515 Jimmy Carter 78000
1717 George Bush 80000

why don't you use std::vector and std::sort it would probably easier

Because I don't know how to use std::vector and I don't have the time to learn how because this dumb thing is due tonight.

I can now play a sine wave at various pitches.

>empSortByName
What exactly is it supposed to do?

It sorts the employee structs by name into nameSorted[]. Or it's supposed to.

Isn't that what sorter() does?

just take an hour to learn how to use std::vector and std::sort seriously it would look cleaner and it would be easier

sort yourself out

That's obviously supposed to teach him how to implement a sorting-algorithm, so your advice is retarded.

delte this

What sorter() is is a shell for the empSortByName() and the eventual sort by salary function.

ideone.com/ZStICn

..but you can call std::sort on arrays, too

I would if I had the time and if it wasn't outside the assignment parameters. As soon as this semester is over I will hop on that shit though, promise.

user pls. My professor would instantly recognize this as outside my abilities.

fake it till you make it

Gonna look into making a bot for slack that does some of our common elasticsearch management stuff tomorrow.

It'd be nice to get it working so I can do basic stuff even from my phone. If Okta/Duo integration was possible that'd be even better.

Are you perhaps the same faggot who was asking for advice about a week ago, who just had to put a function outside a loop? Because your code is similarly fucked.
For one:
for (int count = 0; count < 6; count++) {
getEmployees(empReader, allEmployees, count);
sorter(allEmployees, nameSorted, salSorted, count);
empPrintByName(allEmployees, nameSorted, salSorted, count);
}

makes no sense. Either you sort the employees unsorted, or you sort them and THEN print them. You can't do both at the same time.
Also consider this:
void sorter(Employee allEmployees[], Employee nameSorted[], Employee salSorted[], int count)
{
int minNameIndex;
int minSalIndex;
int i;
for (int i = 0; i < count; i++)
{
minNameIndex = empSortByName(allEmployees, count, i);
if (minNameIndex != -1)
{
nameSorted[i] = allEmployees[minNameIndex];
}
}
}

This is nothing like sorting at all. This is finding the first name that ranks before allEmployees[] (at least according to the first 4 characters) in the suffix [0, count] and storing it in nameSorted. This is partly because the function is not doing what you said it should, and partly because of empSortByName().
Lastly, the reason why it's printing garbage is that in the main loop above, you're resorting the entire array up to count everytime you read another in, but then you print the count'th entry, which is still unused.

P. S. Why do you pass fucking everything to every function?

This chick posts pictures and videos regularly in the Ancapistan® Facebook Group. She extorts and blackmails pedos after they send dick pics which is pretty damn AnCap.

>only pre-teens unironically believe in anarco-capitalism
Sounds about right.

Also,
>using facebook
ISHYGDDT

for (/* */)
{
/* */
}

/* */

if (/* */)
{
/* */
}

into the trash it goes

>which is pretty damn AnCap.

No it isn't, you fucking retard.

You program like a girl. Have you considered being a stripper instead?

Extortion and blackmail is a fucking cornerstone of Anarcho-Capitalism.

>Why are you using another function just to open the file, but did not force exit the program if there is no file?
>Why are you double declare i in the sorter function?
it's far better to do:
void get_int_from_file(int &output, ifstream& stream)
{
std::string temp;
stream >> temp;
output = std::stoi(temp);
}

since it will check if the stream really giving valid integer or not, and it will retrieve the valid number before it encounter invalid character,
unless you can't afford using a temporary string.

Try to output some part of the code while running to verify the program behave well until that point.
for example during the for loop in the main(), try to print the employee's data after the getEmployees(), just to verify it,
and if it's correct try to do that in other function where it may break.

I'm pretty sure both of those violate the NAP.

>She extorts and blackmails pedos after they send dick pics which is pretty damn AnCap.
That's bretty hot. How old is she then? I mean, I have a dick and a camera. There are possibilities.

when are people going to stop recommending python as a language for people that are new to programming to learn first, and when are they going to start recommending C++?

>Blackmailing with the threat of government force (presumably as they are hurr evil pedos durr) is not ancap retard.

Go back to shitposting with the Donald cunts on nu/pol/

Never. You either begin with C or Python. Both are simple. Python is more expressive, but C is more logical. Nobody knows what C++ is at this point.

>she exploits men at their most vulnerable point and then ruins their lives over a moment of personal weakness

There should a be a board solely for people who tell others to go back to Sup Forums.
I wish I had a psychopath gf. You'd never know if she wants to kill you or fuck you. Or both. That's preddy hot, I'm sure you agree.

Try this for size (it's not perfect, but it's something): pastebin.com/yHQVkG6g

I don't usually do it and most who do so are newfags but I have a feeling you'd fit right in with the /r/the_donald Invaders and their anti pedo hysteria.

Why do people think that duck typing and weak typed language is a good idea?

I have a feeling this is the way you view the world.

I have a feeling you have down syndrome.

Anti-pedo hysteria..?

You're a fucking joke.

This one's old too pretty sure I'm further down, maybe further right. Let's not detail this further little boy.

Yes? Why the question mark? Where's the question?

Sorting functions are something I never really got around to understanding. If you could explain how a bubble sorting function is supposed to work to me, I would really appreciate it, because that's what I was going for.

?

No one would want to see my hairy ass dude.

I think I will try that, thank you.

I really do want to do this thing myself, but I will see what I can learn from your code, and I do appreciate the effort.

Your exonerating child abuse can you not understand how awful that is?

>You're a fucking joke.
>Let's not detail this further little boy.
You certainly are obnoxious enough to fit right in reddit.

>If you could explain how a bubble sorting function is supposed to work

youtube.com/watch?v=lyZQPjUT5B4

...

Thanks, I needed that.

>youpoor
>CS
>lab assistants black and muslim woman and two Indian guys

Nobody but our university would hire them or something?

miniskirt and striped socks

plz be boy

how old is she?

she's got to be at least 18 right?

its the curlies, that style is dumb and is often used by C# """programmers""" (i.e. those who dont know shit)

also, if you want/need sorting, take a look at github.com/swenson/sort
it has lots of different algorithms and its fairly tested and benchmarked

There's literally no point in wasting breath on brainwashed feminazi retard white knights like you. Any rights violation, any overstep is okay because of same vague muh chilluns justification.

Calling me Reddit is pretty funny newfriend.


Now enough derailing newfags

pretty based 2bqh

I have the exact same situation in a Finnish university. We have more Indians than Finns here.

int give(string what)(int n) if (what == "square")
{
return n * n;
}

string give(string what)(int n) if (what == "cube")
{
import std.conv;

return (n * n * n).to!string();
}

void main(string[] args)
{
import std.stdio;

writeln(give!"square"(12));
writeln(give!"cube"(12));
}