/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1536746400627.png (2537x2462, 2.59M)

Other urls found in this thread:

dcode.fr/double-transposition-cipher
twitter.com/NSFWRedditGif

C

Second for fuck anime.

lucky for you that isn't an anime OP.

I love you anons

Attached: 1462038524511.png (873x1079, 929K)

Can anyone help me decypher this please??

TAWETNSHENGAMINEQTNSUIOEFHYTUENLIUVOFHAYETCNSENEETSFRHIOOVOAUEGHENHUFDTO

All I know is that it is a double transposition cypher and that the first five letters of the message are ifyou

thanks!!!

use frequency analysis brainlet

I would use that if it was a substitution cipher, but because it requires double transposition that wont work.

Everyone hates you, disgusting pedo scum

pedo website

What should I call a function that takes in a collection of sets and two optional parameters N and M, and returns a set of all elements that appear in each of the input sets between N and M times?

Currently I just call it "intersection" (and describe it as an "arbitrary intersection" in a comment), but strictly speaking it's only an (arbitrary) intersection when N == M == length(collection_of_sets), which is the default. On the other extreme when N == 1 and M == length(collection_of_sets) the result is an (arbitrary) union. I'm not really sure what the call the cases for other values of N and M / the general operation represented by the function.

Mostly I want to avoid mathematicians pointing and laughing at my misuse of set theoretical terminology.

I love too, loli appreciating user.

Wrong, I love him

frequency filter

It's my understanding that filters are a set theory thing as well so I need to tread carefully.

>write an algorithm
>get infinite loop and don't know why
>leave my house, sitting on the bus
>rewrite it in my phone from memory, so I can post it here and ask about it
>works perfectly

Attached: 1554048394941.gif (720x312, 1.74M)

while(1)
{
break;
}


works perfectly.

no you dont
make it consistent with the rest of your code and thats it
if you want to have a formally correct in all contexts name it's going to be super long and stupid
filter is normally used for a function that takes one set and builds another set based on elements that pass the test, which is what you're doing, with a range, you could call it a range filter

you fixed it
well done user
also cute mashiro

echo 'TAWETNSHENGAMINEQTNSUIOEFHYTUENLIUVOFHAYETCNSENEETSFRHIOOVOAUEGHENHUFDTO' | tr -c 'IFYOU' '.'; echo ''

then resize terminal

glhf

I just spent an hour on "Codility" doing a C programming skill test. It was the first time programming C (not C++) in 10+ years. I felt so naked and weak.

It's a library not a standalone tool and intended to be used in a context where math-literate users are likely. Choosing a name that makes formal sense is a principle of least surprise issue.

I really like my job but it can be annoying sometimes. These people have the absolute worst decision making skills and a complete inability to think ahead. It's not uncommon for a major project to get cancelled deep into development because they missed something very obvious.

I've only been at this company for 4 years and in that time I ended up destroying moral on two major projects. One was a conversion program designed to convert data between formats so that an existing application can continue processing it without changes. I had to point out that the conversion process was completely unnecessary because the existing application was designed to read multiple formats and that updating it to read the new format was a couple weeks worth of work at most.

The second project was a batch job that read in files and updated a database. We have a special kind of "super record" that needs special logic to handle it and it needs the ability to have manual approval, meaning that the updates are only staged somewhere, but not applied until a reviewer hits approve. This project was 4 years into the rewrite and during a meeting where they were explaining it to me, they never once mentioned it so when they asked at the end "Any questions?" I asked "How do you handle super records?" and holy shit if everyone didn't have this look on their face like I just stabbed their grandmother. 4 fucking years into a project and they had just completely forgot that super records were even a thing. They didn't cancel the project outright but it went through development hell for another year to try to handle that scenario because their design didn't account for it at all.

Attached: think-ahead.jpg (500x500, 27K)

well as I said, filter is used for that function in major languages, and the naming convention still depends on the rest of your library so long as you aren't using a term incorrectly its kind of up to you

Why don't you just go and ask those math literates for a suggestion then?

I have, I just thought I'd ask /dpt/ in the mean time too.

>so long as you aren't using a term incorrectly
This is exactly what I'm worried about.

Thanks man, but how would I do that on windows?

I have never used two libraries with naming conventions that line up exactly. Just make sure yours is consistent with itself. You are doing a filter

set set;
Nothing better than debugging for an hour just because you don't this does not behave the way you'd expect

what happened

what do you expect it to do?

Ignored the order of elements when checking equality

The order of vector elements? Because the standard is clear on how vector comparisons operate.

Why would you expect that?

it ignores the order of the elements of the set, but the elements of the set are vectors. did you want set ?

please help

No idea.

I assumed no padding and close to square. 72 chars, so 8x9 or 9x8. Tried 8x9. Found two rows. Tried first one (LIUVOFHA). It's supposed to anagram to IFYOU___. So write out where you want to put them by index, so 15942993 (9 for don't care). That gives IFYOUVHA, which is almost IFYOUHAV. So change it to 15842673, now you get IFYOUHAV. And the other ones look right.

Now use the same process for these rows:
TTHEANSW
EMEANING
QUESTION
FULTHENY
IFYOUHAV
ESENTENC
EROFTHIS
OUHAVEGO
EFOUNDTH

I forgot
dcode.fr/double-transposition-cipher

Yeah, I was a dumbass

ok.
I hope this post was helpful.

underrated post

Why the hell does c++ not support local functions? I had to make a local struct inside of a method, friending the base class, just to have a local-scoped reusable function, this is ridiculous.

C++ has lambdas.

Lambdas don't have access to the variables in the scope they're defined though, or do they? I'll admit I've never used them before.

Yes, they do.
But they don't decay to function pointers like GNU C local functions do, you must use std::function or templates with lambdas that capture variables.

Just take your ballz and leave this brainled company.

I guess I'll look it up then. I found most explanations on what lambdas are are really obscure though, their syntax is just so weird, even for c++. Why not do it like lisp...

thank you for posting an anime image in the OP

I love you too.

I hate you more, double scum.

You're cute user.

>Why is c++ shit?

Attached: 1543946363945.jpg (683x1100, 341K)

[&]

Can someone explain big O notation. I don't understand it.

you can set what a lambda captures and how (i.e. reference or copy) that's what the weird [] part is for

it's about the asymptotic bound of a function, i.e. f(x) is O(g(x)) if in general f "grows no faster than" g

What does O(1) mean then?

C++ closures don't work like any other language I'm aware of other than Rust. I suppose that's because there's no garbage collection to manage the lifetime of the captures, so it must be done explicitly. That's what the weird [] syntax is for.

a function doesn't (in general) "grow faster than" the constant function 1
i.e. beyond a certain point it is essentially constant

gigantic hidden constant time factor.

don't confuse people who are trying to learn with your own incapacity to use concepts properly

this

Attached: file.png (1006x590, 42K)

stop being a faggot

can't stop what you don't start

>read half of page of book
>already switch to browser and proceed to funpost
there's no hope

Attached: 1494800626199.jpg (482x549, 57K)

just pic related

Attached: 1526055468882.png (392x44, 2K)

>quasi linear is bad
kys

Switch back and forth between /dpt/ and your book. It's the only way I am able to progress my projects. Make sure you don't go far outside /dpt/ or you'll just start shitposting for hours

This should be in the OP

Thank you anons.

First understand the mathematical meaning of small o and big O.
f1(x) = o(f2(x)) means that f2/f1 will tend to infinity when x does so. Basically, it means that f2 is wayyy "stronger" than f1, it won't be dragged down by the division.

To make this easier, consider f1(x)=x and f2(x)=x3. It is clear here that f2/f1=x2, and x2 will grow with x : thus x is o(x3).

Big O is the same thing but also includes the case when f1 and f2 are "as strong" - that is, when their division tends towards a constant.

This is interesting in computer programming. If the complexity of your program is O(n2), that means that at worst, your program will have to make k*n2 operations (where k is an unknown constant which you don't really care about). Indeed if you knew exactly how many operations there were (let's say : a*n2 + b*n + c), their division by n2 would be a constant when n becomes infinite (here, (a*n2 + b*n + c)/n2 -> a).

What means is that a can actually be very big, but this is not the use case of the O notation : what's interesting about it is how the number of operations of a program will scale with n. If your program is O(n2), and someone finds a way to do the same thing in O(n), they've made a better program than you : for n=1000, they'll be at a few thousand operations while you'll be in the millions!

Hope that's clear enough.

I'm trying to just replicate an example of code from Automate the Boring Stuff with Python and it doesn't run. What is wrong here?


print('My name is')
i = 0
while i < 5:
print('Jimmy Five Times (' + (str(i) + ')')
i = i + 1

The last line is what gives me an error. But it is as written in the book.

Friendly reminder that Celeron is pronounced "ke-LEH-ron".

use code tags

And to actually answer your question, based on what I just said, O(1) means that the number of operations of your program, when divided by 1, will (at worst) tend toward a constant when the number of elements you operate on tend towards infinity.

Here, that means that your program's number of operations does not depend on n - it won't have any loops in it.

print('My name is')
i = 0
while i < 5:
print('Jimmy Five Times (' + (str(i) + ')')
i = i + 1

well what error

jesus I'm retarded. How?

it's [ code ] [ /code ] , without spaces inbetween braces

invalid syntax on the last i = i + 1

>(' + (str(i) + ')')
remove the ( before st

U

print('My name is')
i = 0
while i < 5:
print('Jimmy Five Times (' + (str(i) + ')')
i = i + 1

hopefully that works and I can stop spamming your thread

T

E

Attached: 24024.gif (500x281, 237K)

but yea as said, your braces are unbalanced

for(int i = 0; i < 1000000; i++) {
if(i > n)
break;
dostuff();
}

Attached: 1545460277315.png (682x682, 444K)

awesome, thanks.

Anything P is fair.

And then there's this faggot.
Don't complicate things my dude.

you're flat out lying
>it won't have any loops in it
just stop fucking lying, you liar.

Alright, it won't have any loops based on n or prematurely broken through use of a constant limit. There, happy? If I needed to define everything that a normally-functioning brain should take for granted we'd be here all day.

Does anyone miss those cozy days where languages of higher level than C didn't exist, and programmers actually had to be good?

Attached: 1532062804526.png (1920x1080, 2.87M)

you werent alive then

>his whole understanding of big Oh rests on the number of nested loops
>calls other brainlets

Attached: 1551863927913.jpg (723x718, 173K)

>higher level than C

Yes, python is more high than C. How could you tell?

That time never existed. End Cnile revisionism for once.

Attached: DmQxyqRXoAE9qh1.jpg (1200x902, 155K)

Alright user, I know you're baiting, but outside of loops (and recursive functions, which nobody uses outside of very specific use cases because they are a mindfuck), how do you augment the complexity of a program?

By loop I mean while, for, and goto loops, since you want me to detail stuff :^)

>you want me to detail stuff
no, I only want you to stop being a faggot

No can do user, no can do :^)

Nice arguments though, I'm taking notes.

>why yes, I lecture people about computational complexity despite thinking recursive functions are a mindfuck, how did you know?

How the fuck do people have trouble with recursive functions? Like you're literally calling a function, how is that different?

Entire books on computational complexity have been written which use nothing but the amount of Turing Machine transitions to analyze time complexity.

So clear and obvious!

Attached: index.png (568x89, 5K)

class Maze{
private:
int dimX, dimY;
int **maze;
public:
void set_maze(int x, int y){
// set maze dimensions
dimX = x;
dimY = y;
maze = new int*[dimY];
for (int i = 0; i < dimY; i++){
maze[i] = new int[dimX];
}
}
};


Why is this function giving me 'bad_array_new_length' sometimes?

Attached: 7cvAR9trur_zmPB4DFQzImE3xovInk4IJYX3ibKzCxI.jpg (960x640, 79K)