[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 315
Thread images: 25

File: himegoto.webm (3MB, 720x405px) Image search: [Google]
himegoto.webm
3MB, 720x405px
old thread: >>55346344

What are you working on, /g/?
>>
File: it's a trap.png (873KB, 1275x677px) Image search: [Google]
it's a trap.png
873KB, 1275x677px
5 posts too early edition

>tfw no refinement types
>>
>>55354159
>Posted before the bump limit
>Forced memes
Delete this fucking thread.
>>
>>55354281
Please don't post in this invalid thread, even if it's just shitposting.
>>
File: minkowski.png (27KB, 1016x507px) Image search: [Google]
minkowski.png
27KB, 1016x507px
Just finished my Minkowski Difference calculator. Now I just need to get the vertices from the product to render in a none shit order and I can focus on adding it to my graphics calculator.
>>
>>55354302
In the second example, shouldn't the minkowski difference include 0?
>>
File: 1466678593641.jpg (57KB, 567x561px) Image search: [Google]
1466678593641.jpg
57KB, 567x561px
>>55354190
>>55354225
>5 posts too early
>>
File: cute anime pic 0608.gif (885KB, 459x410px) Image search: [Google]
cute anime pic 0608.gif
885KB, 459x410px
Rate my captcha verification code!
int validate_captcha(char *captcha_response)
{
/* open a shell and validate captcha externally */
char *cmd_str = (char *) malloc(sizeof(char) * BUF_MAX);
sprintf(cmd_str, "curl -d \"secret=%s&response=%s\" %s > /tmp/aaaaaaaa.ok",
captcha_secret, captcha_response, captcha_url);
system(cmd_str);
free(cmd_str);
char *verify_str = create_filebuffer("/tmp/aaaaaaaa.ok");
system("rm -rf /tmp/aaaaaaaa.ok");
int success = (strstr(verify_str, "\"success\": true")) ? 1 : 0;
free(verify_str);
return success;

}
>>
>>55354351
> ? 1 : 0
0/10

use !! in future
>>
>>55354325
It does. The shape isn't rendering correctly because I haven't made a function to render it correctly yet.
>>
File: vis.png (336KB, 2652x1664px) Image search: [Google]
vis.png
336KB, 2652x1664px
Still working on my neural network to detect if a person in picture is wearing clothes or not.

I wonder if the kernel in 6th row is for detection of female nipple shape. I wonder if it's safe to post on a christian imageboard then.

Also seems like a lot of kernels are unused, as they haven't changed at all from their original form.
>>
>>55354351
garbage
>>
>>55354327
Not posting threads before the bump limit is fucking important you fucking newfag.
Now it's just going to be a competition to who can post their OH SO LE FUNNAY XDDD forced meme (see OP) the earliest, and new threads will keep getting posted earlier and earlier.
>>
File: ghci.png (1KB, 201x57px) Image search: [Google]
ghci.png
1KB, 201x57px
>>55354384
Ask your neural network if I'm wearing clothes right now
>>
>>55354416
This. I personally think if a duplicate thread is made before the original is at page 8 and at the bump limit it should be auto deleted and the person that created it area banned.
>>
>>55354351
You can do it easily in a shell script what the hell are you smoking
>>
>>55354441
>>55354416
> samefag autist trying to justify his autism
>>
File: turtling.png (126KB, 795x717px) Image search: [Google]
turtling.png
126KB, 795x717px
>pic related
Has programming gone too far?

>>55354441
fortunately you aren't a janitor and hopefully never will be
>>
>>55354416
>new threads will keep getting posted earlier and earlier.
sounds great anon!
>>
Anyone know of a decent overview of pointers/references/how+when to allocate memory/etc. for C++?

Something that covers syntax too. I'm trying to read a code and I have no idea why some functions take references, why the return references, or pointers, it's all very confusing. Coming from dynamic languages.
>>
File: fragezeichenmödchen.jpg (36KB, 500x375px) Image search: [Google]
fragezeichenmödchen.jpg
36KB, 500x375px
Why should a programmer know anything more than Lisp and C?

One high-level expressive language, and one low-level bit-diddling one.

Why do we even bother with anything else? Abstracting abstractions and gaining nothing in return?
>>
>>55354597
trying to read code*
why the functions return*
>>
>>55354598
>Lisp
>high level expressive language
Learn Haskell anon
>>
>>55354302
>>55354380
So regarding this. Is the "correct" way to render the product just to draw every shape produced during the operation? So say I subtract a triangle from a square. Would I just render the 4 triangles produced by subtracting each point of the square and the 3 squares produced conversely by subtracting each point of the triangle and then slap them on top of each other?
>>
>>55354635
Haskell is a meme. Primarily a vehicle for mathematical syntax circlejerking.
It's not even homoiconic ffs.
Lisp is more expressive.
>>
>>55354641
{ x - y | x ϵ A, y ϵ B }
>>
>>55354641
>>55354662
and generally you want to use a convex hull algorithm and render that
>>
>>55354561
>>55354561
>>55354561

New thread:
>>55354674
>>55354674 >>55354674
>>55354674 >>55354674 >>55354674
>>55354674 >>55354674
>>55354674
>>
>>55354662
Okay but is that a yes or a no? I have the calculator already. I just want to cobble something to draw it so I can move on.
>>
>>55354351
>har *cmd_str = (char *) malloc(sizeof(char) * BUF_MAX);
Why malloc?
> sprintf(cmd_str, "curl -d \"secret=%s&response=%s\" %s > /tmp/aaaaaaaa.ok",
>captcha_secret, captcha_response, captcha_url);
Nice buffer overflow waiting to happen.
>>
God damn I want to fuck hime
>>
>>55354656
>mad for not being a real programmer
why are you even here?
>>
>>55354744
but you're mentally ill m8, why don't you seek help?
>>
>>55354751
>tumblr tier illiteracy
it's like you don't even want to be a good programmer
>>
>>55354766
XDDDDDDDDD
>>
>>55354758
>no u
no need to get defensive anon, it's just obvious you're not a programmer
>>
>>55354773
no need to get mad for getting told laddie
>>
>>55354774
>>55354782
OH MY LE GOD, uR so funnay!!
Us traps amirite XDD
>>
>>55354351
>sizeof(char)
Are you literally retarded?
>>
>>55354816
Us trap coders le sizeof(char) amirite?
XDD
>>
The Gameboy is a bitch to program for. By which I mean this platform will bend you over and make you its bitch if you try to program it.
>>
>>55354695
https://en.wikipedia.org/wiki/Convex_hull

alternatively going back to the minkowski difference
{ x - y | x ϵ A, y ϵ B }
(a set of vertices)

You could do this:
{ { x - y | y ϵ B } | x ϵ A }
(a set of sets of vertices)
This is like the first but grouped by x - you could treat this as a set of polygons and draw them all
>>
>>55354853
Anon, I'm just asking if the way I am sugggesting will be accurate. It is demonstrably accurate from the tests I have run but I'm not sure.
>>
>>55354877
yes
>>
>>55354894
Thank you. And thank you for going out of your way. I wasn't getting snippy I promise, I really do appreciate the help whether it is what I am asking for or not.
>>
>>55354806
>not a programmer
you should leave /dpt/ at once
>>
>>55354858
you talking about animu shits?
>>
>>55354962
(You)
>>
>>55354981
>I'm literally retarded
>pic related
you can't make this shit up! lel
>>
>>55355002
>trap, tranny and crossdressing fags
there's literally nothing wrong with that, plus it's a sign of superior programming skills
>>
>>55355011
XD
>>
>>55354659
>It's not even homoiconic ffs
And?

>Lisp is more expressive.
Are you talking about macros? Haskell doesn't need them most of the time. Even then, you also have different levels of abstraction on macros: template haskell, quasiquoting + template haskell, quasiquoting + custom parser
>>
>>55355019
>I got told and proven to be retarded
kekels
>>
>>55355019
>timewasting useless garbage
>kill yourself
anon... I'm not saying you're retarded, but your brain might not be fully developed
>>
>>55355022
Does Haskell always perform computation at compile time where it can? You'd think anything without an IO or IORef signature (and without doUnsafeIO calls, etc) would be fit to be computed at compile time
>>
>>55355054
>no, let me prove beyond any doubt that I'm mentally ill
ishyggy
>>
>>55355019
>stay delusional
sour grapes, m8?
>>
>>55355059
Are you talking about template haskell? If so, yes, it runs 100% at compile time. The template haskell Q monad can run IO actions at compile time. You can literally compile a web template at compile-time and check for broken links, missing parameters, etc.

For other parts of the code, the compiler may run it or not, it depends on the complexity of the expression and the inlining threshold I guess
>>
>>55355072
>trying to damage control his proven mental illness
lad...
>>
>>55355094
but you confessed not to be a real programmer; calling names on the ones that are great programmers is literally the definition of sour grapes; don't tell me you're also mentally ill and you can't use logic
>>
>>55355110
>mouth raping fantasies
is this what you dream of? and you say you're not mentally ill? top kekeroonies!
>>
>>55355086
I don't mean template haskell, but I suppose that's a good point. I mean if you had something like

functions = [ ("Add", fnAdd), ("Sub", fnSub) ]
getFn s = ...
(getFn "Add") a b
(getFn "Sub") x y

Could Haskell optimise the (getFn "Add") or would it do dynamic lookup?
>>
>>55355110
>he said
>but now he
>4chan
habib...
>>
>>55355159
>he recognizes superior beings by the taste of their dick
wew laddie
>>
>>55355159
have you been recently told and rekt anon?
>>
>>55355218
are you saying you're a faggot because you were made to suck dick?
>>
File: original.jpg (99KB, 500x341px) Image search: [Google]
original.jpg
99KB, 500x341px
Could it be plausible to get a child window from an arbitrary application using something like user32 and change it's parent to a window of my choosing? What would the effects of this be?
>>
>>55355218
>talking about gay oral sex
you're the only one talking about gay m8
>>
>>55355132
No, it doesn't in this case:

import Data.Maybe

functions :: [(String, Int -> Int -> Int)]
functions = [("Add", (+)), ("Sub", (-))]

getFn :: String -> Int -> Int -> Int
getFn = fromJust . flip lookup functions

main :: IO ()
main = print (getFn "Add" 1 2, getFn "Sub" 3 2)


(compiled with -O3)

It doesn't substitute it either if I replace strings with an enum
>>
>>55355244
there's no need to lie on the internet
>>
>>55355244
>i haven't voluntarily sucked
but you were MADE tho
>>
>>55355258
>kill yourself
>damage control
top fucking kek
>>
>>55355229
Why don't you try it?

auto win1 = FindWindow(...);
auto win2 = FindWindow(...);
SetParent(win1, win2);


Also kill yourself weeb.
>>
>>55355251
That's a shame, that seems like the kind of thing it could do

Maybe if you bind
add = getFn "Add"
sub = getFn "Sub"
outside of main?
>>
>>55355278
>try to actually do some programming
but you already confessed you were owned on anything programming related by the big dick playa, it's the reason you can't get "dick" and "mouth rape" out of your head; why would you even dare approach the programming subject if you're not worthy?
>>
>>55355286
>getting told makes me feel bad
:^)
>>
>>55355285
GHC already does that. In fact, it floats out each component of the tuple, converted to string for printing

Main.main14 :: [Char]
[GblId,
Str=DmdType,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 40 0}]
Main.main14 = GHC.CString.unpackCString# "Add"#

Main.main3 :: [Char]
[GblId,
Str=DmdType,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 160 30}]
Main.main3 =
case lookup
@ String
@ (Int -> Int -> Int)
GHC.Classes.$fEq[]_$s$fEq[]1
Main.main14
functions
of _ [Occ=Dead] {
Nothing -> case Data.Maybe.fromJust1 of wild1_00 { };
Just x_a1hl ->
case x_a1hl Main.main15 Main.main8
of _ [Occ=Dead] { GHC.Types.I# ww3_a1jZ ->
case GHC.Show.$wshowSignedInt 0 ww3_a1jZ Main.main4
of _ [Occ=Dead] { (# ww5_a1k3, ww6_a1k4 #) ->
GHC.Types.: @ Char ww5_a1k3 ww6_a1k4
}
}
}


(main15 and main8 are the integers to be added)
>>
>>55355258
>delusional
you were the first in this thread to say the word "gay" so you're the only one talking about it m8; do you have some unfulfilled fantasies?
>>
>>55355336
I can't read GHC goop but I always figured if you're going to have typed IO in this fashion (doUnsafe excluded) that you'd always be able to tell and evaluate at compile time an application of a non-IO signatured function
>>
>>55355340
>you were wrong
you are imagining things, m8, must be your mental illness acting again
and really, can you say with a straight face that I'd be wrong on trivial issues when I rekt your ass each and every time on every possible subject? c'mon, be honest: I'm better than you in every way and you'll always be shit tier; why do you even try when you can't compete?
>>
>>55355357
>I got proven to be a closet fag
>full blow damage control
anon...
>>
why would you ever prefer having special "invalid"object states instead of simply setting references to null, nil, nullptr or equal?
example:
if(employee.Company != Company.Invalid())
{
//Impl
}

vs
if(employee.Company != null)
{
//Impl
}
>>
>>55355372
It definitely could, but in some cases the point of the program is to compute something. Making the compiler simplify it at compile time would be waay slower. And you can't easily determine when something is that expensive or not.

What you can do, though, is to tell the compiler what can be simplified into. For instance, mapping over a list twice is the same as mapping once applying the function twice. Then, GHC combines these rewrite rules and inlining and makes all the magic happen.
>>
>>55355417
If it is literally a nullable / invalidatable type you should be using a monad like Maybe/Option or Error

Otherwise, because you might have multiple "invalid states" or because you might have different kinds of states that are valid in different circumstances
>>
>>55355390
m8...
>>
>>55355419
But there could be some kind of -O4 for that
Within reason, compile time is free and runtime is not

Haskell could at least have some kind of pragma to tell it to evaluate something at compile time
>>
>>55355409
>char* can alias any object pointer
yes, as I've told you, big dick style; no need to repeat to the teacher the knowledge he has himself bestowed upon you
>you didn't have any valid argument against it
this is your strawman and proves your mental illness: I've never claimed anything against it
>>
>>55355409
admit it: you're mad because you can't average 2 numbers, right? :^)
>>
The Scheme implementation I'm using can't do native threads, so it blocks up whenever I make a FFI call.

With that in mind, I want to write a small C program that waits for messages from the Scheme program and sends output in its own threads, but I don't know much about C.

What's the proper terminology for a C program that waits for input from another program? Does it just use read() and stdin? I've heard of sockets, but those seem like a network thing? I just want one local process (Scheme) to be the input for another local process (C).
>>
>>55355485
>that's exactly the problem
not entertaining your mental illness?
>which says that char* can alias any object pointer
yes, that's what I taught you, why do you keep repeating it? not to forget? :)
>>
>>55355417
The most difficult problem in CS in naming things. Code is written for maintaners to read, and only incidentally for computers to execute.

null generally indicates an absence of value. Using null for an abnormal state (error state, invalid state, there are multiple) in your APIs you place a huge cognitive burden on your programmers. null will have a slightly different meaning for each and every class and each and every method.

Also than can be the occasion when a bug makes a method return a null reference, and you can't distinguish btween a valid and invalid case.

Giving a name to invalid states, makes everything more clear and laid out. Yours isn't a great example, but you get the idea.
>>
>>55355499
>you're not funny
am I being mean to you? how do you really feel, anon? you still bitter because you didn't know how to average 2 numbers?
inb4
>no bully
>>
>>55355441
well, in that case, moving getFn to a separate module (stage restriction) and modifying main...

main :: IO ()
main = putStrLn $(lift (show (getFn "Add" 1 2, getFn "Sub" 3 2)))


Main.main2 :: [Char]
[GblId,
Str=DmdType,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=False, ConLike=False,
WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 50 0}]
Main.main2 = GHC.CString.unpackCString# "(3,1)"#
>>
Doing Code Academy's Python course for my motivational letter to Tallinn IT school or whatever.
>>
>>55355488
>He can't even average an arbitrary number of integers
int iavg(int n, const int arr[static const n])
{
int avg = 0;
int rem[2] = {0, 0};
int add[2] = {0, 0};

for (int i = 0; i < n; ++i) {
avg += arr[i] / n;

int a = abs(arr[i] % n);
int j = arr[i] < 0;

if (rem[j] >= n - a) {
rem[j] = a - (n - rem[j]);
++add[j];
} else {
rem[j] += a;
}
}

avg += add[0] - add[1];

if (avg < 0 && rem[0] > rem[1])
++avg;
else if (avg > 0 && rem[0] < rem[1])
--avg;

return avg;
}
>>
>>55355589
>iavg ([int] -> int)
>iavg
I'll let you go this time anon, but be careful next time
>>
>>55355536
>damage control
why can't you even admit when you're provably wrong? is it related to your mental illness?
>shitty threads
you mean sour grapes?
>poorfag neet
but anon, I'm filthy rich and the owner of my own company
>>
File: 1466578032508.png (191KB, 1000x386px) Image search: [Google]
1466578032508.png
191KB, 1000x386px
>>55355589
Holy shit this is fucking verbose

>>55355581
>Python

>>55355680
Programming?
>>
>>55355648
Integer average. Are you so retarded that you couldn't figure that out.
I only ended up naming it that because I had a double average which did the same thing, and I used to verify my results against.
>>
>>55355717
>this is fucking verbose
not a problem because it's also incorrect
>>
>>55355730
Please tell me how it's incorrect.

>>55355717
>verbose
How? Fucking every C like language is like that, and there aren't many languages less verbose than C without getting into domain specific or esoteric languages.
>>
>>55355739
>do me again
and scar your insecure soul for another 6 months? is this what you really want?
>>
>>55355729
I know it's integer average you fucking idiot, I'm saying I'm letting you go because while it does return an integer, it's called iavg and not avg
>>
>>55355765
tell me how you really feel tho :^)
>>
>>55355863
>>>9gag
>>
>>55355491
somebody pls answer this

I feel like there's just a specific term I'm missing which makes searching DuckDuckGo so hard
>>
>>55355491
That's called IPC and can be done in multiple ways (named pipes, unix sockets, local TCP sockets, shared memory, etc).
>>
class Complex {
double re;
double im;
public:
Complex();
Complex(double, double);
void display(){
cout<<re<<" "<<im<<endl;
}
};

Complex::Complex(){
re = 0;
im = 0;
}


Complex::Complex(double x, double y){
re = x;
im = y;
}


int main(){
Complex c1(7.2,9.3);
Complex c2;
c2.Complex(); //<-- Here's my prob
c1.display();
// shows 7.2 9.3
c2.display();
// shows 0 0
return 0;
}

>ERROR: 30 4 [Error] invalid use of 'Complex::Complex'

Trying to get into object-oriented programming and I'm stuck at step 1. What gives that error?
>>
>>55355968
>IPC
>Unix socket
these are most likely what I'm looking for
searching "c socket" just turned up a whole bunch of TCP/IP stuff
>>
>>55355986
You can't call a constructor explicitly like that.

Complex c2;
automatically calls the default constructor
>>
>>55355986
You don't invoke the constructor on an object like that. What you should do instead is this on the previous line:
Complex c2();


Then get rid of the error line.

>>55356007
Keep in mind that those won't work on Windows if you ever plan to run your stuff on that system.
>>
Holy fuck i got an 8.5 for datastructures/algorithms im so happy ;3
>>
>>55356017
I don't lol
>>
how do you into designing huge ass applications and modules?
everytime i try i just end up with tight ass coupling and flawed design in general

are there good books on this?
>>
>>55355491
man select_tut


By the way, there is very little difference between a TCP/IP socket and a local socket.
>>
>>55356015
>>55356017
Complex c1(7.2,9.3);
Complex c2();
c1.display();
c2.display(); <-- PROBLEM
return 0;


[Error] request for member 'display' in 'c2', which is of non-class type 'Complex()'

Fml I just want to git gud :c
Any links to an OOP 101 primer? Video/pdf doesnt matter I just want to learn.
>>
a realistic 3D cheese pizza MMORPG in WebGL that I hope to keep under 100mb
>>
Mine kind of suck. I mostly just write shell scripts but I have one in Python. I don't really know what to make.
>>
>>55356094
>Complex c2();
You don't call a constructor without params like that, it should be
Complex c2;
instead

What you do here is a forward declaration of a function called c2 which returns a Complex.

This is not an OOP problem, this is a problem with you not understanding the C++ syntax.
>>
>>55356094
Ok nevermind I misread what you guys wrote. One more question tho:

Why does the code from the first line work but the one from the 2nd won't?

Complex c2;  //WORKS
Complex c2(); // ?!!?!!
>>
>>55356160
See what I posted in this post
>>55356148
>>
>>55355924
why are you quoting him instead of someone with a bigger dick?
>>
>>55355968
>>55356007
So it looks like Chicken's
(open-output-pipe)
will handle this with minimal hassle. Neat.

Now it's time to start writing some C.
>>
>>55356212
why would you want to get upset even further? do you want to go completely insane?
>>
>>55356173
4 models, a tiny map, some small animations, maybe some compression, pretty doable.
>>
>>55349497
int problemFive()
{
const int MINIMUM = 1;
const int MAXIMUM = 20;

int i = MAXIMUM;

while (!found)
{
for (int j = MINIMUM; j <= MAXIMUM; j++)
{
if ( i % j > 0 )
{
continue;
}
}
found = true;
}
return i
}
>>
>>55356326
>doesn't compile
m8...
>>
>>55356326
>all those unnecessary braces
>>
>>55356382
of course, I am planning with pure WebGL, all kinds of tricks to reduce footprint etc
>>
>>55356352
>>55356377
Yeah I made a shitload of mistakes. Here's code that compiles and does exactly what I intended:
int problemFive()
{
const int MINIMUM = 1;
const int MAXIMUM = 20;

int i = MAXIMUM;
bool found = false;
while (!found)
{
for (int j = MINIMUM; j <= MAXIMUM; j++)
if ( i % j > 0 )
goto notfound;
found = true;
notfound: i += MAXIMUM;
}
return i;
}

I thought it was important to break out of the for loop as soon as a non-multiple number is found to save on CPU cycles.

Also I feel like the code is less legible now that I removed unnecessary braces.
>>
>>55354190
>not full dependent types
kys
>>
>>55356500
Why the fuck are you using a goto?

There are situations in which it is appropriate to use goto. This is not one of them.

You're also still using the naïve approach, I see.
>>
>>55356586
Refinement types are dependant
>>
>>55356500
...
>>
>>55356631
They're a crippled form of dependent types, yes.
>>
>>55356620
How else am I supposed to continue the while loop from within a for loop?
>>
>>55356662
break
>>
>>55356620
int problemFive()
{
const int MINIMUM = 1;
const int MAXIMUM = 20;

int i = MAXIMUM;
still_not_found:
int j = MINIMUM;
next: if (i % j > 0) goto not_found;
j++;
if (j > MAXIMUM) goto end;
goto next;
not_found: i += MAXIMUM;
goto still_not_found;
end: return i;
}
>>
>>55356690
If I use break, then it runs the code after the for loop. I have to add an extra if statement to decide whether to return i or keep searching. More legible, yes, but less efficient.

The code already takes about a second to run.
>>
>>55356762
>muh problem five efficiency
ishyggy
>>
>>55356764
I gave him the solution in the last thread, but he ignored it. You're wasting your breath.
>>
>>55356764
Everybody else in the thread is brute forcing it.
>>
>>55356799
Which one was it?

I'm not the guy who posted problem 5. I'm just a beginner who decided to tackle it.
>>
>>55356762
>My code takes about a second to run!
>This is unacceptable for some reason, so I'm going to focus on the wrong things to try to make it run faster
>>
>>55356820
>legibility over optimization

Seriously?
>>
>tfw you solved everything on projecteuler
>tfw you're smarter than the entire /g/ combined
Feels good friends!
>>
>>55356818
>>55349513
>>
>>55356839
>shit optimization
srsly?
>>
>>55356857
Okay then you optimize it faggot.

>inb4 not doin ur homework lol
>>
>>55356839
I favor using a better algorithm over quibbling over small details that the compiler may or may not do for me anyway.
>>
>>55356844
Wow. Okay. This might work. But it is not "basic" math.
>>
>>55356902
>might
fucking retard
>>
>>55356928
For fuck's sake, pull your head out of your ass. There's a reason nobody at the office talks to you.

You didn't even provide the full solution. "Compute"? That's not a math operation, dumbass. So yes, your theory still needs to be proven on the basis that the holes you left in it can be filled with valid approaches.
>>
>>55356877
my code is already better than some of the shits that has been spewn in the last thread. None of them used constants to declare the range and some of them iterated through every integer instead of by steps of 20.
>>
Teach me to be as good as you guys I been programming for about a year and a half and the most useful thing I built is an online store for a few clients. How do I get so good that many people will use my software?
>>
>>55356962
That wasn't me, man.
>>
>>55357007
>Teach me to be as good as you guys
Okay, just lay your head on that rock there, and I'll start hitting it with this hammer.
>>
>>55357007
Through fapping to tranny porn.
>>
>>55356980
I'm sure your CS prof would be very proud.
>>
>>55349513
>first principles
I hate this meme
>>
>>55356962
>"Compute"?
protip: it doesn't mean "brute force"
just making sure, you're a retard after all
>>
>>55357034
I already do this already but i'm not gay

>>55357022
I'd rather we play vidya

>>55357044
This sounds useful. Okay.. Hmmmm... such as what?
>>
>>55356962
>theory still needs to be proven
do it gee, prove that prime factorization is a thing! top fucking tard
>>
>>55357043
>thinking is a meme
well, aren't you the absolute shit
>>
File: 1466574188084.gif (485KB, 450x562px) Image search: [Google]
1466574188084.gif
485KB, 450x562px
>>55357053
>faps to dickgirls
>not gay
You can't be in the closet forever.
>>
>>55357075
It's not first principles and it's a retarded meaningless phrase
>>
>>55357086
chicks with feminine penises are not gay tho
>>
>>55357080
Making a video game is way too hard though it requires being able to draw, do art, and more. I can only program
>>
>only one on my team in the office
pls don't hack us thnx
>>
>>55357112
>I can only program
and not even that worth a shit
>>
>>55357109
you sound pretty feminine and subby yourself, i bet you'd make a good trap girl anon
>>
File: 1466562396696.jpg (2KB, 125x93px) Image search: [Google]
1466562396696.jpg
2KB, 125x93px
>>55357109
You can only tell yourself this for so long, anon.
>>
>>55357126
why is everyone in this thread so actively toxic?
>>
>>55356962
Okay, tell you what. Here's a simpler approach, in pseudocode.

let result = 1
for i in 2 to 20:
if i is prime:
let a = i
while a × i ≤ 20:
a := a × i
result := result × a
>>
>>55357086
>>55357109
>>55357132
>>55357135
my gf thinks it's cute I watch trap stuff and I like big juicy dongs. My dream is to get double teamed by a trap and my gf with a strap on
>>
>>55357179
so tolerant and progressive, I am proud anon
>>
>>55357173
I'm trying to convert that to code althrough you made it reeally difficult. What is ":="?
>>
>>55357139
>lie to me gee, I need validation
gtfo
>>
>>55357261
assignment, I'd assume
>>
File: monad-id-law.png (20KB, 358x260px) Image search: [Google]
monad-id-law.png
20KB, 358x260px
>>55357139
summerfags, we're full of redditors right now
winter /dpt/ is chill /dpt/

pic not remotely related
>>
>>55357283
Did your daddy rape you or did he just beat you up? :^(
>>
>>55357261
Oh sorry, it's reassignment.

I just had another thought: you can keep a list of primes as you go, and use it to determine whether the current i is prime.
>>
>>55357308
>projecting
anon...
>>
>>55357319
>list of primes
vectors are better
>>
>>55357319
I'm still not sure what you do with the prime.

I tried running that in a shell script.

result=1
for ((i=2; i <= 20; i++))
do
#check if i is prime
prime=false
for ((j=2; j < i; j++))
do
if [[ $((i % j)) == 0 ]]
then
prime=true
fi
done

if [[ prime == true ]]
then
a=$i
while [[ $((a*i)) -le 20 ]]
do
a=$((a*i))
result=$((result*a))
done
fi
done
echo $result


It returns 1.

I'm not sure if I made a mistake. Maybe I should have stuck to c.
>>
>>55357346
>Maybe I should have stuck to c
why? are you under the impression that you know c?
>>
>>55357346
If it's returning 1, then that suggests to me that your prime detection might be faulty, and that the prime check is never succeeding.
>>
>>55357380
Okay, I tried making it print each number it finds to be prime.

4 is prime!
6 is prime!
6 is prime!
8 is prime!
8 is prime!
9 is prime!
10 is prime!
10 is prime!
12 is prime!
12 is prime!
12 is prime!
12 is prime!
14 is prime!
14 is prime!
15 is prime!
15 is prime!
16 is prime!
16 is prime!
16 is prime!
18 is prime!
18 is prime!
18 is prime!
18 is prime!
20 is prime!
20 is prime!
20 is prime!
20 is prime!


I could try to debug it, but I'm just gonna port it to c. bash is not made for this.
>>
>>55357397
>sounds like you got
why do you keep projecting tho?
>>
>>55357421
Anon
It's returning all non-primes
This is a super easy fix
>>
>>55357421
>bash is not made for this
you're not made for programming either
>>
File: 1451705365563.png (1MB, 1280x720px) Image search: [Google]
1451705365563.png
1MB, 1280x720px
>>55354351
>>
>>55357421
I think that would help both of us. I don't know C, and I know bash even less.
>>
File: 1445407387091.png (24KB, 850x400px) Image search: [Google]
1445407387091.png
24KB, 850x400px
>>55354351
!
>>
>>55357451
why would you argue with the mentally ill?
>>
>>55357397
sorry you were abused as a child anon
>>
File: anime.png (201KB, 335x365px) Image search: [Google]
anime.png
201KB, 335x365px
>>55357451
Quality meme
>>
NEW THREAD WHEN?
>>
>>55357475
You're too late
>>
>>55357475
>le ignorant of the bump limit meme
kys my man
>>
>>55357475
I found a new memepic so I will make one.
>>
>>55357490
>sizeof(char) is retarded though
just like you
>>
>>55357490
Oh good, it's not just me that the captcha keeps breaking for, then?
>>
>>55357429
Oh... fucking kek. What the fuck am I doing? Holy shit I'm slow.

This is a day off and I didn't have my coffee.
>>
>>55357475
>guaranteed replies
I love this meme!
>>
>>55357525
I think you need to put on a pair of panties, anon.
>>
File: oshit.jpg (42KB, 600x541px) Image search: [Google]
oshit.jpg
42KB, 600x541px
WADDUP M80S!
>>
>>55357173
Alright!

#include <stdio.h>
#include <stdbool.h>

main ()
{
int result=1;
for (int i=2; i <= 20; i++)
{
//check if i is prime
bool prime=true;
for (int j=2; j < i; j++)
{
if (i % j == 0)
{
prime=false;
}
}

if (prime == true)
{
printf("%d is a prime.\n",i);
int a = i;
while ( a * i <= 20 )
{
a = a * i;
result = result * a;
}
}
}
printf("%d\n",result);
}

It does return all distinct prime numbers, and the result is 4608.

Anon, do you think I misinterpreted your pseudocode or are we forgetting something?

This is a really good learning experience by the way so thanks for playing along.
>>
>>55357558
>>>/out/
>>
File: 1460229777578.png (1MB, 1000x1400px) Image search: [Google]
1460229777578.png
1MB, 1000x1400px
What language should I learn this summer?
>>
>>55357586
None
>>
What does this pink haired girl have to do with programming?
>>
>>55357569
I think something has gone wrong somewhere. The answer should be a lot larger. Let me have a closer look at things.
>>
>>55357586
GHC Haskell
>>
>>55357586
the language of death
consider suicide
>>
>>55357596
But I want to do something.
I already feel bad enough going full NEET.
>>
>>55357586
Japanese
>>
Name a comfier IDE than MPLAB

> emacs is an IDE :^)

No, it's not.
>>
>>55357617
you weren't going to learn a language anyway and you know that
>>
>>55357628
ask me how I know about your mental illness
>>
how hard is it to create a borderless gui. Say with glfw
>>
>>55357605
The final multiplication needs to be outside the while loop.
>>
If /dpt/ were in a room together, what would it smell like?
>>
>>55357632
Why not? I'm not such a lazy fuck.
>>
>>55357656
Immediately start hormones and order yourself some knee socks from Amazon if you really want to be an amazing programmer.
>>
File: 1464557405366.png (5KB, 207x124px) Image search: [Google]
1464557405366.png
5KB, 207x124px
>>55357678
No u
>>
>>55357668
>knee socks
>not pantyhose
Pleb
>>
>>55357668
I even started sucking dicks but my code skills are pretty much the same.
>>
Lets make /dpt/ great again it all starts by helping your fellow man program
>>
File: 1433616075856.jpg (115KB, 2161x885px) Image search: [Google]
1433616075856.jpg
115KB, 2161x885px
>>55357640

How do you know about my mental illness?
>>
File: 1457096627144.jpg (197KB, 1080x1920px) Image search: [Google]
1457096627144.jpg
197KB, 1080x1920px
>>55357701
I'm just here for the traps
>>
>>55357569
Just in case you miss it: >>55357652
>>
>>55357654
It would smell pretty awful.
The desktop thread neckbeards would huddle in a corner while the one sociable guy is hitting up the one crossdresser that showed up.
>>
>>55357707
MUH DICK!
>>
File: smug_maid.jpg (3MB, 2560x2880px) Image search: [Google]
smug_maid.jpg
3MB, 2560x2880px
>2016

>His software doesn't evolve

>His software doesn't learn from experience

What a pleb.
>>
we need a new thread
>>
File: 1461603681898.jpg (62KB, 549x549px) Image search: [Google]
1461603681898.jpg
62KB, 549x549px
>>55357721
more like her dick amirite
>>
>>55357712
yes you can by explaining to them how to think like a computer scientist and how programming really works

>>55357719
I wish someone here would draw this that is so funny!
>>
>>55357654
If I made the mistake of going to a /dpt/ meetup, I'd shower first
Also, is the captcha being retarded for anyone else?
>>
BAMP FOR NEW TRAP THREAD!
>>
>>55357708
Okay, you mean do the multiplication again right after the while loop?
Like this:
result = result * a;
?

Because that returned -1033707520

Why? Oh my god what am I doing?
>>
>>55357754
It's being retarded for me on mobile.
>>
>>55357759
wait until 110 and I will make it
>>
>>55357754
>I'd shower first
you just know you'll be fucked in the ass, don't you fuccboi
>>
>Haskell has type inference guys!
But you need to write the type signature no?
>>
>>55357754
Yes. I get two white panels, and I have to click around to get one of them to show images, and sometimes it turns white again.
>>
>>55357767
Only do it after the while loop, never during the while loop.

I wish I could be more helpful, but I don't have access to a compiler right now.
>>
>>55357754
Me too.
I would also wear my best panties.
>>
>>55357734
>2016

>He doesn't write his own software
>>
NEW THREAD!!

>>55357801
>>
>>55354659
Lisp can't even do partial application properly
>>
>>55357769
>>55357789
Thanks Google
>>
>>55357802
BUMP LIMIT NOT REACHED AT TIME OF NEW THREAD POST, NEW THREAD IS INVALID
>>
>>55357802
>before the bump limit

delete this shit and kill yourself
>>
>>55357779
>good programmers are just naturally like that, they can't explain how to think like them

They can.
>>
>>55357802
>309
You fucking idiot, this was created before the bump limit.
>>
>>55357802
>>55357806
>>55357810
Congrats, you did it
>>
>>55357846
illegitimate as it was made before the limit.
>>
>>55357839
I deleted mine, didn't see the other one.
>>
>>55357818
mods said: "suck a dick, worthless faggot!"
BTFO
T
F
O
>>
>>55357865
I'm a good programmer and I can explain how to approach solving problems. Any good professor can do the same.
>>
>>55354355
>>55354159
Himegoto
http://myanimelist.net/anime/22835/Himegoto
>>
>>55358127
Prove it. Explain to me how would you solve a problem of reversing a binary tree
>>
>>55357827
No one is born a good programmer they only get good at programming by having things properly explained to them like any good professor or teacher
>>
Guess we're back here again
>>
what a day to be alive!
>>
sooo.... n-new thread w-when?
>>
>273 posts
I guess that solves the new thread issue
>>
>>55358466
What does reversing a binary tree mean?
>>
>>55358632
Flip it around so that the first node is last and the last node is first.
>>
>>55358632
Swapping each side for each node.
>>
>>55358662
Which is the last node?
>>
mods = gods
>>
>>55358632
Def Reverse(root):
If root is null then return
Swap root.left and root.right
Reverse(root.left)
Reverse(root.right)
>>
>>55358689

what happen?
>>
>>55358689
Agreed. Anti-Anime faggots BTFO
>>
>>55358739
3 threads were made after this one hit bump limit.
A trump thread, hime thread, and anime thread.
2 got deleted. The trump one stayed until it was flooded with tranny porn and the mods deleted random posts in here to un-bump limit it.
>>
>>55358729
Oh wow, I knew recursion would be involved, but I was overthinking that greatly
>>
Is there an easy way to get a file explorer up with c++. would prefer to not use winapi. Hoping for some kind of library that lets you explore then returns the paths in an array
>>
>>55358769
The trump thread was made before the bump limit but linked after
>>
>>55358819
No, it was linked as post 309.
>>
>>55358769
>3 threads were made after this one hit bump limit.
No, the trump one was made before the bump limit.

>flooded with tranny porn
What the hell? This is not what happened.
>>
>>55358817
Qt?
>>
>>55358752
anime is a mental illness tho
>>
>>55358769
>tranny porn
it was regular porn
>>
>>55358834
>bloat
ishyggy
>>
>>55358834
I dont want to use qt just for a file explorer.
>>
File: ssh.png (409KB, 1473x776px) Image search: [Google]
ssh.png
409KB, 1473x776px
>>55354159
https://github.com/RubenRocha/ftpscout

this shit, picture somewhat related as its just modified to test ssh instead
>>
>>55354159
Does anyone want to make a kik group chat or something about programming?
>>
>>55359630
Normalfag detected.
If you want to chat either use this thread of the irc channel.
>>
>>55359630
I bet you live in Cali and program in JS.
>>
>>55354384
That's beautiful, anon
>>
>>55359957
t. butthurt red stater
>>
>mew thread got pruned
why the fuck
>>
Is there really no better way to launch a php action than a JQuerry/Javascript AJAX call?

The php code starts a shell_exec with information from the clicked thing.
>>
>>55360793
I think this hasn't hitted the bump limit.
>>
>>55360793
Not even American but it's common knowledge that California is singlehandely responsible for most of the garbage that's going on in programming circles.
>>
Thanks for the help. I am still not understanding a problem about the LZ77 Algorithm:

If I have a two bit string:
A|AB|ABB|B|ABA|ABAB|BB|ABBA|BB
A=0
B=1

And then have these compressed under these blocks:

000,0 = 0A
001,1 = 1B
010,1 = 2B
000,1 = 0B
010,0 = 2A
101,1 = 5B
100,1 = 4B
011,0 = 3A
111,- = 7-

How do the BB come into play?

I mean, 100,1 = 4B says that there are four known bits/chars/whatever before I am presented with BB.
When do I know that there's another B behind it?
Shouldn't it be another sequence?
Where does the BB come from, I can somehow not wrap my head around it.
>>
Should I learn C before C++?
>>
>>55360839
No, learn C++ first
>>
>>55360839
Yes.
>>55354159
Reposting from the deleted thread:
>In what should I get into if I want to git gud at WPF? Any developers of this framework here? I'm interested in creating LOB/Enterprise apps. I was thinking in study Databases, and the MVVC pattern.
>>
>>55360839
Yes, in fact you should learn every other language before C++.
>>
wat do i learn if i want to do AI
>>
>>55360919
What kind of AI?
>>
>>55357296
In the winter everyone was just talking about how Python was for brogrammers, Java was for Pajeet, and C was a meme.
>>
>>55360931
Robots and shit
>>
>>55360919
https://www.youtube.com/watch?v=BNX2zrMGRZk
>>
>>55360932
And which of those statements aren't true?
>>
>>55360919
Soo, after a long time of looking into CS and even studying.
You need to learn lots of math.
I just assume you are a total newbie and talk about making vidya games.
But if you want to be ready for a rigorous math degree, too, this link is also good enough for you:
http://boards.420chan.org/math/res/15040.php

Enjoy the math and apply it to the AI of your dreams.
>>
>>55360932
Haskell > Java > C > Python
>>
>>55360932
>C is a meme
because they were too dumb to use it lel
>>
New thread >>55360972
>>
>>55357808
wut
>>
>>55355022
Lisp is more expressive because it can run valid programs that Haskell, due to it's type system, thinks are invalid.
>>
>>55360795
AnyJuan?
Thread posts: 315
Thread images: 25


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.