/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

communequation.wordpress.com/2017/07/05/im-not-a-woman-in-tech/
github.com/avinassh/rockstar
stackoverflow.com/questions/1421811/how-do-i-represent-a-unicode-character-in-a-literal-string-iso-ansi-c-when-the-c
cogsci.ed.ac.uk/~richard/utf-8.cgi?input=e9&mode=hex
libgen.io/search.php?req=The Art of Computer Programming&open=0&res=25&view=simple&phrase=1&column=title
aima.cs.berkeley.edu/python/games.html
frayn.net/beowulf/theory.html#abpruning
chessbin.com/post/Move-Searching-and-Alpha-Beta
twitter.com/NSFWRedditVideo

First for D.

Second for anime

At least make it programming related ffs

That's pretty rude, OP.

I bet you don't even program in C#.

main = putStrLn "Hello, reddit!"

dumb frogposter

what side project can I make in 2-4 weeks to put on my resume to get an entry level job?

A CRUD application that works with a database and makes calls to some sort of public API.

Fizzbuzz in Haskell.

We don't fuck anime around here, we just masturbate to it.

It's sad that Rust gets more attention than D. Fuck you Reddit.

That does what exactly? Isn't this too easy?

>Rust gets more attention than D
On Sup Forums maybe. In the real world, D is several orders of magnitude more relevant than Rust.

/dpt/ what is the proper way to type? asdfjkl; or aetbnip[shift]?

It could be anything.

You'd be surprised at the number of applicants I get that don't know how to properly read/write data from a database, or utilize REST APIs.

Point taken. Though it's still not in the top 20 of programming languages.

Made a thread about MiniMax algorithm, though I'd like some more answers.I've seen it implemented in games like Tic Tac Toe using two functions, heuristic and MiniMax. I have trouble understanding the point/score system specifically. How do I assign points to what and should I do it during the game (for turns) or after a game ends (for wins/loses).

I can read pretty much all languages save for the obscure ones. I have already made a very small Tic Tac Toe game that didn't take long so it's a bit messy. All I need is to implement an AI that's not stupid.

thank you for using a non-anime image

>aetbnip
what

>/dpt/ what is the proper way to type?
On a keyboard.

That second one doesn't feel right at all, who the hell does it?

Making a deep learning app that identifies intimate interracial relationships using photos on social media

I do
It's pretty comfortable actually but you have to have been doing it since you first started using computers and never actually learned how to type the other way

>I’m not a woman in tech

what does Sup Forums think of this article?

communequation.wordpress.com/2017/07/05/im-not-a-woman-in-tech/

I should mention that I made the program in Visual Basic.

Alright well I always wanted to learn Node.js

What do you recommend for generating SVG's ? Vue.js ? D3.js ?

Why are you asking me about webdev shitlangs?

>article
>wordpress

>On a keyboard.
pleb

statically

What you porting to python this week, user?

well shit what do you work with?

the illiac suite, unfortunately
i would much rather be doing it in c

the motion looks like shit

is it just linear interpolation?

linux kernel

C#

Implementing QCPMC in Fortran for fun.

why cant I put the access modifier in front of every individual member and function like in java in c++?

I nearly bought her story until I saw this.

wtf I also work with C# for around 2 years now, fuck you're dissing web dev for?

You can if you want, you just need a colon.
class MyClass {
private: int x;
private: int y;
public: MyClass(int, int);
public: int sum();
public: int product();
public: int difference();
public: int quotient();
public: int remainder();
};

That would be pure autism though.

I do backend dev with C#, not webdev.

meh the colon makes it really nasty. without I would do it

So what counts then ? I have a web app, it has a database, API calls, bunch of code, ASP.NET MVC and all that, hosted on Azure, does that not count?

do you use WPF or UWP ?

LOL I DID THIS.
My solution is bloated as fuck kek, but I dont even care.
#include

int is_pandigital(int fact[]);
int add_product(int product);

int products[100] = { 0 };
int endsum = 0;
int count = 0;

int main()
{
int sum = 0;
for(int i=1; i < 100; i++) {
for(int j = 1; j < 10000; j++) {
int fact[] = {i, j, i*j};
if(is_pandigital(fact)) {
add_product(i*j);
}
}
}
printf("sum: %d\n", endsum);
return 0;
}

int is_pandigital(int fact[])
{
int has_num[9] = {0};
for(int i = 0; i < 3; i++){
while(fact[i] > 0) {
int rem = fact[i]%10-1;
if(has_num[rem] == 0)
has_num[rem] = 1;
else
return 0;
fact[i] /= 10;
}
}
for(int i=0; i < 9; i++) {
if(has_num[i] == 0) return 0;
}
return 1;
}

int add_product(int product)
{
for (int i=0; i < count; i++) {
if(products[i] == product)
return 0;
}
printf("new product: %d\n", product);
products[count++] = product;
endsum += product;
return 1;
}

>I have a web app, it has a database, API calls, bunch of code, ASP.NET MVC and all that, hosted on Azure, does that not count?

This would be fine; a project encompassing all of this would put you miles ahead of 90% of all other developers looking for jobs.


>do you use WPF or UWP ?
Neither, most of the time. I do create simple WPF applications for people from time-to-time, but most of my dev work is purely backend automation, such as creating Azure infrastructure based on on-prem data that needs to be modified, and then system-versioned in the cloud.

Are you french? Stop putting a space before your question marks.

>What are you working on, Sup Forums?

Exploring the darkest corners of Racket.

I am trying to find a way to produce a spiral of numbers without the need of an array/buffer.

A spiral like these

1

1 2
4 3

1 2 3
8 9 4
7 6 5

1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7

1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

1 2 3 4 5 6
20 21 22 23 24 7
19 32 33 34 25 8
18 31 36 35 26 9
17 30 29 28 27 10
16 15 14 13 12 11


I heard there is a solution in The Art of Computer Programming but i have no copy here.

Okay this is a stupid question but I've never had to do it before. What's the syntax in C for a string literal that isn't just the string in quotes. I'm forced to use this editor that doesn't display unprintable characters at all, I want to pass ASCII character 31 + the null terminator to strtok as a literal, in Vim I can just insert the character and quote it, it looks like "^_" but as 1 character, in this other editor it literally just looks like "", the character is inside the quotes but it looks like it's an empty string. Is there another way to form a string literal composed of 2 characters? I don't want to use a variable just for this.

>What are you working on, Sup Forums?

an optimizing drawing and coloring trainer

I'm just starting learning C
I'm trying to make this program print me the lesser of two entered numbers.
When I run it no matter what two numbers I enter I just get 0.00000.
(Example, First number is 2 and second number is 3, it prints out "The smaller of the two numbers is: 0.0000)

#include "stdafx.h"
double min(x,y);

int main()
{
double x, y, z;
printf("Enter your first number\n");
scanf("%lf", &x);
printf("Enter your second number\n");
scanf("%lf", &y);

z = min(x,y);
printf("The smaller of the two numbers is %lf : ",z);
return 0;
}

double min( x, y)
{
if (x < y)
return x;
else
return y;

}

Alright well will try to focus more on those things in my resume I guess.
No I'm not French, its just a habit of mine

Does your company do A/B testing?

works on my machine
#include
#define min(a,b) ((a) < (b) ? (a) : (b))

int main()
{
double x, y, z;
puts("Enter your first number");
scanf("%lf", &x);
puts("Enter your second number");
scanf("%lf", &y);
z = min(x, y);
printf("The smaller of the two numbers is : %lf", z);
return 0;
}

stop trolling you mongoloid.
If no troll, then read k&r again.

For starters:
>double min(x,y);
>double min( x, y)
In C, you need to specify the types of function parameters. If x and y should be doubles, you need to specify that they should be doubles. Otherwise, they're treated as ints.

I wouldn't think this would be your problem, since casts between double and int are well defined, but try fixing it first and see if it helps.

Forgot the types and ordered wrong, my compiler complained about all this when I compiled your program.
#import

double min(double x, double y)
{
if (x < y)
return x;
else
return y;

}

int main()
{
double x, y, z;
printf("Enter your first number\n");
scanf("%lf", &x);
printf("Enter your second number\n");
scanf("%lf", &y);

z = min(x,y);
printf("The smaller of the two numbers is %lf : ",z);
return 0;
}

No, I'm just wondering how it's so technologically hard and why nobody has managed to decentralize it and so on. It seems very, very easy to do.

>not using the ternary operator
double min(double x, double y) {
return x < y ? x : y;
}

>import
Nobody make fun of me, I had too much coffee today.

2 late fgt

*makes fun of u*
nothing personnel kid

>make github account
>find random project
>look at issues until you find one which seems easy to fix
>fix it
>do this three times a day so the activity thing is dark green
There's a tool that makes backdated commits to your own repositories so you can fill out history, even for before the account was made.
github.com/avinassh/rockstar

It's literally my first week in a programming class and i've never coded in my life, so relax.

Wow I just had to specify that x and y were doubles within the argument parameter. I was trying to figure that out by myself for a good 15 minuets now.

Thanks guys!

Anyone?

Then grab a copy of K&R, read and take notes to remember stuff. Also do the tasks inside the book.

GCC actually had an alias to #include for it.

you wan to implemnt min max?

left hand - caps lock, wef (just in the general wasd area really)
right hand - kop] (doesn't matter as long as it's on the right side, it moves a lot anyway
for space use right hand index finger or lefthand thumb

The professor i'm taking instructs out of "C Primer plus 6th edition" and its only a 6 week course so he's skipping tons of shit.
But thanks, I'll look into that aswell.

Sure. But I'd like to see it implemented in a pseudocode so I could understand it better.

Like I said, mostly the point/score system.

anime website

I remember getting a good understanding of a*, alpha beta pruning and minimax from picrelated, it was long time ago thou

fren website

Thanks user. Curiously, does it have examples?

In case anyone was wondering, I just had to do "\037" I was hoping there would be a way to do it using decimal instead of octal or hex though. I'm really surprised visual studio doesn't just print a character for the literal though.

>for space use right hand index finger

stackoverflow.com/questions/1421811/how-do-i-represent-a-unicode-character-in-a-literal-string-iso-ansi-c-when-the-c


For UTF8, you have to generate the encoding yourself using rules found, for example, cogsci.ed.ac.uk/~richard/utf-8.cgi?input=e9&mode=hex here. For example, the German sharp s (ß, code point 0xdf), has the UTF8 encoding 0xc3,0x9f. Your e-acute (é, code point 0xe9) has a UTF8 encoding of 0xc3,0xa9.

And you can put arbitrary hex characters in your strings with:

char *cv = "r\xc3\xa9sum\xc3\xa9";
char *sharpS = "\xc3\x9f";

libgen.io/search.php?req=The Art of Computer Programming&open=0&res=25&view=simple&phrase=1&column=title

You can also do this:
char the_literal = {31, 0};

aima.cs.berkeley.edu/python/games.html

frayn.net/beowulf/theory.html#abpruning

chessbin.com/post/Move-Searching-and-Alpha-Beta

oops that's not quite right
char the_literal[] = {31, 0};

2 late fgt

meme

>not doing it branchless with bitwise operators
#define min(x,y)((-(xy)&y))

The compiler complains: "too many initializer values" when I try to use it as an argument, I want to avoid assigning it since there's no reason to.
i.e. like this
function(const char *parameter) //signature
function({31, \0}) //does not work
function("\037") //does work

>wasting clock cycles doing retarded shit
don't call us. we'll call you

that's not even the worst of it all, ring and pinky are almost never used except for hitting something when the hand is at the wrong side of the keyboard (i.e. left hand is on srth and I need to type shift)
Can you repair your muscle memory and relearn typing?

Thanks a lot.

Try this
function((char[2]) {31, 0});

reminder that carpal tunnel will take your livelihood and then you'll be homeless

>try being a massive faggot
how about no?

In a non-optimizing compiler this is the fastest way lad

Continued from : I just tested this myself, it works
You can also do this:
function((char[]) {31, 0});

Still working on my SDL OpenGL bindings for OCaml.

see

>non-optimizing compiler
hmmm

>"\037" is better

Not if you regularly workout.

No luck, I tried casting it earlier but it expects an expression after the cast before the braces.

gif for reference, ideally I'd just use the literal unprintable character, it's still there but the editor doesn't show it. I might just do that and add a comment about it. What a dumb editor.

That's weird mine won't let me do either cast, I'm stuck with the msvc compiler which may be why.

That's what I'm doing for now Just fyi that guy isn't me.

Ah, yes, the good ol' Mongolian vowel separator issue.

Everything is the same in an optimizing compiler, nothing matters anymore

Isn't there already bidings for opengl for ocaml?
Also SAD.
Ocaml isn't even standardized language so you are making bindings for just one implementation.
Ocaml doesn't support native threading because of the design of the garbage collector.
Also ocaml has fucking ugly C interface.