/dpt/ - Daily Programming Thread

Remember to wear striped socks and eat raw hot peppers to improve your programming abilities! What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Big_O_notation#Multiplication_by_a_constant
youtube.com/watch?v=lisiwUZJXqQ
learnxinyminutes.com/docs/csharp/
twitter.com/SFWRedditVideos

void* based generics are strictly better than macro based generics

I don't get the peppers meme

Eat one and try programming. Then you'll understand.

>tfw to smart to go to university

generating fractals

this one's a little spooky

You mean void *based generics

Why user?

CS theory might seem useless at first but it's useful for becoming a great programmer

Autodidacticism

maybe she(he) means void *based, *generics

>tfw a really good programmer you look up to says you're a good programmer

Find the dangling reference.
>Protip:
You can't

#include
#include
#include
using namespace std;

struct StudentGrade {
public:
string name;
char grade;
};

class GradeMap {
private:
vector m_map;

public:
GradeMap() {}

char& operator[](string key) {
for (int i = 0; i < m_map.size(); ++i) {
if (m_map[i].name == key) {
return m_map[i].grade;
}
}
m_map.push_back(StudentGrade{key});
return (m_map.back()).grade;
}
};

int main() {
GradeMap grades;

char& gradeJoe = grades["Joe"];
gradeJoe = 'A'; // does a push_back

std::cout

But pointer are a part of the type ?

anything is better than macros

C disagrees

here is a challenge.

code arbitrary circular movement on a (x,y) grid WITHOUT using trigonometric functions.

? But the compiler will emit a warning if you try to call a fonction without the right amount of pointer.

int *x, y; // x is a pointer, y is not
C hates types and it hates you for liking types.

say, what is the difference between C, C++ and C#, and which one should learn to code in?

do x and y correspond to polar coordinates

I don't know how this is relevant to the conversation

C for desktop software is terrible and people should stop doing it
C++ is okay, but its syntax is horrid
C# is Java done right, with Microsoft's dick in your ass (in a bad way)

Yes

no

>C# is Java done right,
really sick of this meme

>WITHOUT using trigonometric functions.
People use trig for this?

just increase y

>x^2+y^2=r^2
ez

circular movement means going around, not in and out

>x^2+y^2=r^2

wrong

>hey guys I have this logical problem for you but the catch is: you can't apply logic to solve it

...

>hey guys I have this logical problem for you but the catch is: you have to come up with a different way to solve it,

perfectly valid thought exercise.

the proof of that theorem involves trig but application of it does not involve trig

unless you think pythagoras' theorem is trig

what the fuck are you even talking about? the definition of a circle with radius r and center p is "the set of points a distance r away from p." The distance formula is applied there, no trig needed.

>lets use the definition.
do you also write X equals X as the answer in your calculus tests?

cute

Does anyone have experience with pandas dataframes in python?
I'm normally a C programmer and I'm feeling quite lost. There doesn't seem to be a function that resolves a window of values into a single or multiple values. i.e. func(df[1][0+100*n:100+100*n]) -> new df or new column in existing df that resolves to one value per row.
I'm not particularly CPU-time constrained yet,
but given what's ahead it will surely happen. And I'm feeling like I shouldn't do a O(n*100) algorithm in python. Doesn't seem like good practice.

So if anyone has any pointers that'd be great.

>n*100
Well actually I don't even know the constant here.
Could be way worse.

firstly, dont prematurely optimize
secondly big O notation drops the constant, so its just O(n)
thirdly O(n) is the fastest you can get for most algorithms

>O(n*100)
that's sill O(n) you ape

Calm down, no need to be so hostile to him.

C will develop your understanding of how stuff works in memory

>dont prematurely optimize
Read the rest of the very page that you source that thinking from.
And if you haven't read the source (as you clearly haven't because this quote comes after pic-related) don't even bother quoting. What's the point? The point of quotes is to bring points across from previously established truths. But if you lie about the sources intent as you do here. You're just fooling others into believing the same falsehood.

Data science tools are designed to alleviate performance concerns using higher level languages. But you can't do that by having python iterate row by row, extracting values and doing whatever to them. You need something else.

>big o drops the constant
I'm perfectly aware I'm describing my problem succinctly.
Why would I tell you "I don't wish to iterate 100*n objects to yield a single output result directly in python, surely a data science tool have better methods for this?".
Rather than being perfectly clear like I've been.

If you're a god damned student who thinks having constants in bigO is somehow a sin you should immediately point out as if these constants are irrelevant to performance is pure lunacy.

I'm perfectly fine with hostility. He's being a dumbass.

Damn. I lack some commas here. You're riling me up with this ridiculous bullshit.
Why do I even come here anymore? Especially at these hours. Nobody with a brain is here at this hour.

neat

hmm wow you're so smart user you grace us with your presence

Just went to my first programmer interview and I froze up when asked what happens with an example piece of code.

I think I'm an idiot that can't problem solve under stress.

Well, I'm not gonna be here for long. Hope you can manage without me.

>not researching or practising before an interview

what was the example?

Oh I did but the real experience is where the stress is.

Can't remember too well but it was a for loop with the variable being incremented while under a fixed int literal. The variable was also being decremented inside the body of the for loop as well if a certain mathematical expression evalued to true. I thought the loop would terminate after 15 iterations but in fact it didn't terminate at all and looped endlessly due to the decrement operation.

Sucks since it was piss easy and I found the trick questions like 134 == 0134 easier.

Sum the primes under 2 million.

>a fucking gotcha question
The current state of software.

eat(ram) raw hot peppers?

It's called green chillies

Why?

green is my chili

heterogeneous representation

give it a go guys, its fun

O(cn) = O(n) for a non-zero c.

Both are asymptotic upper bounds. In infinite asymptotics, the c is extraneous. There. No more arguing.

Idiot here. I'm learning Java. Is there any disadvantage to printing things across multiple lines versus printing them all at once outside of clarity?

only in addition you god damn retard. multiplication is another ball game.

no.

What color is best for C?

mmm... no.

en.wikipedia.org/wiki/Big_O_notation#Multiplication_by_a_constant

>let's not use the definition
then it's not circular movement, retard.

baka

darker pink with black bands

C stands for Cutie

bro...

>out of college for a year
>got my job without being interviewed, because I knew my boss and he knew I wasn't too dumb
>he wants me to start interviewing possible interns in the next couple weeks
So, like, what do I ask them?

I'm thinking of starting off with super basic data structure and fizzbuzz-tier stuff, just to see if I should bother going on with the interview, but after that I'm not too sure.
My best guess is to give them a chunk of flawed, but working, code that does something basic, and give them an hour or so to "make it better".
I think that way I'll see how they actually program with an existing codebase, they can use Google or whatever documentation they like, and it lets me see if they're afraid to ask questions or not.

What do you guys think? Have any of you had any interviews that you liked?

Give them a segfault one to debug and fix.
Your idea.
And then throw a really pajeet-tier (but working) code-base at them and ask them if it needs changed, and if so have them change it.

>So, like, what do I ask them?
See

>Current laptop is old and shit
>Need new cheap one to at least run a decent text editor + command line compiling for some small to mid sized projects (webdev, python and java stuff mainly)

Any recs for something around 300 bucks? I'm a poor student so I don't have much of a budget.

go check out /tpg/

WOW... if you're a CS student, time to go to office hours.

BTFO

Any recommended books on R? Shit makes me wanna cut my eyes out, but I have to learn it well enough to pass to finish my degree.

I have experience programming in C and Lisp, I just need to learn what the fuck the difference between an atomic vector and a table is and why the $ operator doesn't work on atomic vectors and why it works on tables. This language seems like ass so far. Why do people use this shit?

Green and black, to match your terminal colors.

I need to program a simple maze solver

11111111111111111111
00000111111111110000
11110111111111110111
11110000000000000111
11111111111111111111


But I don't really know where to start. I already loaded the file in a pointer to pointer data structure and have a pointer to run through the stream but I don't really know how to control the rules for the movement of the 0's.

Any tips? Don't really want it solved for me, just need an idea.

having c++ issues need URGENT help sned backup on my location

even when I've cast the variable that's storing the result in as a double, fmod() keeps giving me a fucking integer. about to tear my hair out and im too autistic to figure out what exactly I need to google (i've already tried). thank

Welcome to AyyLmoa Company. Before we start the interview we need to make sure you know your stuff.

1)
int* (*itn)(int, int*, uint32_t, size_t); Explain this piece of code and how it might be used?
2)
How would you implement a tree with a fixed sized array? Could you show us on this whiteboard?
3) Implement a doubly linked list using a custom allocator so there's no cache misses.
4) what gets implicitly attached to a c++ class when you use virtual?
5) Can you implement a function on the whiteboard (show us your process) that can convert a number of any base to any other valid base.
6) What differences exist between a degenerate binary tree and a linked list if any?
7) What benefit does size_t have for loop counters over a short?
8) Why would you not use uint64_t?
9) You have to store a large list of objects, would you use a fixed array or a singly linked list?
10) Implement quicksort in x86 assembly (Show your work on the whiteboard)
11) When implementing concurrency do you prefer locks, STM, or CSP and why?
12) Are singletons acceptable in certain situations?
13) Does the wagegap exist and if so what should be done about it?
14) How many genders exist?
15) Using higher order functions or lambdas, implement a derivative/integral library. We will unit test it.

I'd start by loading it to a 2D array, then programming a function to read a cell, then a function to read the neighboring cells.

FUCK
I HAVE UNTIL SUNRISE TO LEARN C#
WHAT THE FUCK DO I DO?
HELP ME BEFORE I THROW MYSELF OFF A FUCKING BRIDGE

Welcome to AyyLmoa Company. Before we start the interview we need to make sure you know your stuff.
We apologize for any typos.
1) int* (*itn)(int, int*, uint32_t, size_t);
Explain this piece of code and how it might be used?
2)
How would you implement a tree with a fixed sized array? Could you show us on this whiteboard?
3) Implement a doubly linked list using a custom allocator so there's no cache misses.
4) what gets implicitly attached to a c++ class when you use virtual?
5) Can you implement a function on the whiteboard (show us your process) that can convert a number of any base to any other valid base.
6) What differences exist between a degenerate binary tree and a linked list if any?
7) What benefit does size_t have for loop counters over a short?
8) Why would you not use uint64_t?
9) You have to store a large list of objects, would you use a fixed array or a singly linked list?
10) Implement quicksort in x86 assembly (Show your work on the whiteboard)
11) When implementing concurrency do you prefer locks, STM, or CSP and why?
12) Are singletons acceptable in certain situations?
13) Does the wagegap exist and if so what should be done about it?
14) How many genders exist?
15) Using higher order functions or lambdas, implement a derivative/integral library. We will unit test it.

Why do you have until sunrise? How long did you originally have to learn it?

youtube.com/watch?v=lisiwUZJXqQ

ha ha epic meem, bro

>15) Using higher order functions or lambdas, implement a derivative/integral library. We will unit test it.

>working for free
t. company that will go down before the year finishes

Perhaps he's in Antarctica

learnxinyminutes.com/docs/csharp/

>call teacher a faggot for trying to scam us into registering into his additional class for some bucks where he only teaches subhuman level graphical diagram flow
>Tells me if i dont like it can teach it myself or get expelled
>Call him a cuck and proceed to accept the challenge

it's actually pretty tricky

Are graphics in C hard? Like in making graphic a sorting algorithm or some shit. By hard I mean should I just not bother and do it in another language hard.

>circular

Yeah its too hard. Do it in Nodejs

that's the base we'll mess with until it starts looking circular.

You dumb faggot.

359 nested ifs with movement rules for every integer angle.

Any significant modern graphics programming uses C-like shader languages. It's worth learning.

But if you're just trying to visualize things, don't use C. Use anything else. JS/Python/Ruby/etc.

>1
That's a variable declaration of a function point.
>2
Just make the "pointers" offsets in the array.
>3
That's almost already done if you can do #2.
>4
Are you really using C++? Shame.
>5
Yes. Progressive remainders and quotients starting at least power of the base b greater than or equal to the number n.
>6
Different data formats. An example implementation of a binary tree has cells with 3 entries, and a linked list 2 entries.
>7
You can iterate over a 100,000 element array.
>8
Negative entries in an iterative loop can be meaningful, such as on the program stack
>9
It depends on what I'm doing with the large list. You want me to say linked list because it doesn't have to be contiguous, but I passed operating systems and know what virtual memory is, unlike you, retard.
>10
Ok.
>11
It depends on the concurrency problem
>12
No because you're using oop
>13
Yes. It's because women aren't career oriented. It should be encouraged because women shouldn't be encouraged to be something they aren't, career oriented. 2nd wave feminism was a blight upon women for the benefit of the corporation.
>14
2 genders. 2 scoops. 2 terms.
>15
I did that in SICP already.
I'll just use taylor series approximations. If that's not allowed, I'll use euclidean distance. When 0