/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

google.com/search?q="1 and -1" java
google.com/search?q=pajeet
google.com/search?q=pajeet -curry
strawpoll.me/12023125
strawpoll.me/12097496
github.com/dvdhrm/docs/tree/master/drm-howto
01.org/linuxgraphics/documentation/driver-documentation-prms/2014-intel-processors-based-bay-trail-platform
twitter.com/SFWRedditVideos

thanks for using a gook image, again, cunt

First for C

I'm working on SOCKS proxy support in my decentralized TV system, as well as a lot of misc. networking infrastructure.

I also set up an IRC channel for the project (#basictv on Freenode)

Fourth for Python does nothing wrong.

ded

xth for if you have a lisp learning to program in lisp is more intuitive.

...

Writing a kernel in C++

state your answer and your country

Thanks for being a weaboo faggot

But.. why?

...

Because C++ is suitable for writing kernels.

Should programmers know abstract algebra?

0.5
What kind of question is that?

lol kys retard it's 2/3

2/3

it's not a top priority if you have other things you need to focus on but yes

66.(6)%

poland

"-1 and 1 java" literally breaks google
how in the fuck

50%
United States of America

prefixing a search term with - excludes those results

Obviously that stupid image is just trying to start shit, but you clearly haven't read the question properly.

no
"1 and -1 java" does the same

...

Conditional probability, so the box with only silver balls is a red herring. 50%.

If you picked a gold ball, you're in one of 3 possible situations. In 2 of those, the next ball you pick is gold.

QED

In Google search syntax -X means to exclude any results containing X from the results. Which means a query of the form "foo -foo" is guaranteed to return no results, because there is no result that both contains and does not contain foo.

>you're in one of 3 possible situations
No you're not, you fucking idiot.
You're in 2 possible situations: there is a silver ball left in the box or there is a gold ball left in the box.
Which of the two balls you picked in the left box makes no difference.

google.com/search?q="1 and -1" java
google.com/search?q=pajeet
google.com/search?q=pajeet -curry

EPIC
XD

If you picked a gold ball, that means that the box is NOT the third box, so you can ignore it completely. The box is either box 1, containing only a single gold ball (100% of getting gold) or box 2, containing only a single silver ball (0% chance of getting gold). So it averages out to 50%. "Take a ball from that box AT RANDOM" kind of makes it a trick question, because there's only one ball remaining in that box, no matter which box it is.

P(next ball) = 0.5
Brazil.
How is this programming related?

there are 3 gold balls

if you picked one of the first two, the other one in the same box is gold

if you picked the third one, it's silver

2/3

You picked one of three gold balls, therefore there are three situations:

1. You picked gold ball #1 in the first box
2. You picked gold ball #2 in the first box
3. You picked the only gold ball in the second box

In situations #1 and #2, the next ball you pick is gold. In situation #3 it's not. The probability is 2/3. QED.

all of those idiots falling for Sup Forums reply bait

The answer to the gold ball puzzle can be demonstrated to be 2/3 by writing a short script that will randomly pick balls a large number of times.

Text editor poll continues
strawpoll.me/12023125

PROGRAMMING FUEL POLL

strawpoll.me/12097496

No, you are wrong, it wouldn't matter even if box 1 had a million gold balls. All you know is that you picked a box at random, took out a gold ball; what is the probability that the next ball from that box will be gold? Of the two boxes you could have removed that original gold ball from, one contains only silver balls now, the other contains only gold - the number doesn't matter, since you're only talking about removing one more ball. So one gives you a 100% chance of gold, the other gives you 0%.

You're being tricked the picking the first ball part of the question. It's completely irrelevant.
All you know is that you have a gold ball in your hand, and you picked either box 1 or box 2.

And that whichever box it happens to be, is now short one gold ball

Let's do what
suggests so we can solve this conclusively.

pick box 1 -> gold -> gold
pick box 1 -> gold -> gold
pick box 2 -> gold -> silver
pick box 2 -> silver -> discard
pick box 3 -> discard
pick box 3 -> discard

see if you can't figure it out by intuition

they keep replying

>cant choose more than one
what a shitty poll

It's like the monty hall problem. I know it's counterintuitive, but that's how math works. I hope you guys aren't out of high school yet...

pick the best/most important one or the one you use the most often

>no iced tea
if you think that's the same end yourself

damn i totally forgot about iced tea and iced coffee, but vote tea/coffee anyway

It's best to think of these problems qualitatively in terms of incremental evidence.

You 50% guys are correct in thinking that the hand is in one of two boxes. However, these two boxes are not equally probable.

The key is that you picked a gold ball on your first try. Since the first box has two gold balls, it is more likely to give you one; this means that it is more likely that your hand is in the first box, thereby skewing the odds towards the second ball also being gold.

Well let's see here. The fact that you found a gold ball on the first trial means that there is a 2/3 chance that you picked the first box, and a 1/3 chance that you picked the second box, since 2/3 of the gold balls are in the first box. Knowing this, if you picked the first box, there is a 100% chance of picking a gold ball a second time, and if you picked the second, there is a 0% chance. Multiplying out these conditional probabilities and summing them, you would of course get a 2/3 chance overall to pull a gold ball.

...

Kratom is the best kind of fuel

So theoretically, how does X work? What part of the hardware or the OS does it go through in order to draw to the screen?

You should've abstracted sooner. SOCKS is piss easy to implement, adjusting the test of the code is not.

Kernel and a graphics card driver.

X is ancient and does some stupidly ancient shit.
If you want to know how to draw to the screen, you should look at what a wayland compositor does. They use Linux's DRM/KMS interface to take control of the screen.

Create windows post installation program with intensive use of uiautomation to configure GUI settings. It's written in python and I use pywinauto, no problem for now.

Maybe. The infrastructure I am creating isn't closely tied to SOCKS, so it is pretty easy.

Writing over-engineered intersection tests for a blocky 3D gameworld.

Meant to use these in game mechanics, but now I feel tempted to benchmark them by raytracing images instead.

any good tutorials on using fread and fwrite in c? i have to deliver an assignement tomorrow and im still stuck in the saving the program state part

...

What are you confused about? They're pretty straightforward

Trying to write a function that takes a list of random bit sequences and generates a finite state machine that terminates when it receives any of sequences in the list as input.

Why the fuck wouldnt it be 50%
Someone write a program that simulates this to prove all the 2/3 idiots wrong

I'd assume the driver exposes an API, any idea where I can learn about that?

ANIME IS NOT TECHNOLOGY ANIME IS NOT TECHNOLOGY ANIME IS NOT TECHNOLOGY ANIME IS NOT TECHNOLOGY ANIME IS NOT TECHNOLOGY ANIME IS NOT TECHNOLOGY ANIME IS NOT TECHNOLOGY

Is the Wayland source relatively easy to read through

anime is the most advanced technology known to man

at least write the program yourself considering the thread you're posting in. if you lack the skills to write it quickly it'll be good practice.

github.com/dvdhrm/docs/tree/master/drm-howto

Awesome, thanks senpai

alright lets say i created a struct (with just 2 variables) and then created an 18 position array of that struct and filled the info. now i need to save that struct array into a binary file.

the code that i tried for the write part is this
int store(char file[], team e[]) {
FILE* fp;
fp = fopen(file,"w+b");

if(fp == NULL) {
printf("Cant open %s\n", file);
return 0;
}
else {
size_t res = fwrite(&e, sizeof(team), 18, fp);
fclose(fp);
if(res != 0) {
printf("Saved in %s\n", file);
return 1;
}
else {
return 0;
}
}
}

which does write shit into the file but i cant verify if it's correct because i have no idea in how to load the file back.

i tried something like fread(&e, sizeof(team), 18, fp); but it doesn't seem to work. i wish i could just return arrays

Welcome to anime website.
Go complain and report if anime is unrelated to this board.

var gold = 'gold';
var silver = 'silver';

var boxes = [];
var box1 = [gold, gold];
var box2 = [gold, silver];
var box3 = [silver, silver];

boxes.push(box1);
boxes.push(box2);
boxes.push(box3);

var getRandomBox = function() {
var randomNumber = Math.random();
var chosenBoxNum = Math.floor(randomNumber * 3);
var chosenBox = boxes[chosenBoxNum];

return [chosenBox[0], chosenBox[1]];
}

var getRandomBall = function(box) {
var randomNumber = Math.random();
var chosenBallNum = Math.floor(randomNumber * 2);
return box.splice(chosenBallNum, 1);
}

var totalFirstBallsGoldChosen = 0;
var totalSecondBallsGoldChosen = 0;

for(var i = 0; i < 1000000; i++) {
var chosenBox = getRandomBox();
var chosenBall = getRandomBall(chosenBox);
var secondBall = chosenBox[0];

if(chosenBall == gold) {
totalFirstBallsGoldChosen++;
//chosenBall was gold, so let's see if the second ball is gold too
if(secondBall == gold) {
totalSecondBallsGoldChosen++;
}
else {
//second ball was silver
}
}
else {
//chosenBall was silver, so it doesn't count
}
}

console.log('Total First As Gold: ' + totalFirstBallsGoldChosen);
console.log('Total Second As Gold: ' + totalSecondBallsGoldChosen);
console.log('Probability: ' + totalSecondBallsGoldChosen / totalFirstBallsGoldChosen * 100);


[en@carina ~]$ time node boxes.js
Total First As Gold: 499390
Total Second As Gold: 333496
Probability: 66.78067242035283

real 0m0.797s
user 0m0.794s
sys 0m0.007s

What level of abstraction are you talking about here?
For the actual driver part it's specific to each card (and only Intel has fully open specs for their hardware).
If you're talking about a common abstraction in the kernel for accessing graphics hardware there's DRM (Direct Rendering Manager), and above that you have DRI (Direct Rendering Infrastructure) and Mesa as an implementation of OpenGL and Vulkan.

>fwrite(&e, sizeof(team), 18, fp);
>&e
This is taking a pointer to a pointer. You just want 'e' here.

what

2/3, France.

>js
please, it's not /wdg/

I'm asking about card level

js is a general purpose programming language like any other

that's stupid, baka

It's not exactly a light read, modern cards are extremely complex:

01.org/linuxgraphics/documentation/driver-documentation-prms/2014-intel-processors-based-bay-trail-platform

several thousand pages.

Eye am not baka, eye use C++

Piotrzcezcs

#include
#include

int rnd(int n)
{
int s = RAND_MAX/n, r;
do r = rand(); while (r >= s*n);
return r/s;
}

int main(void)
{
int onegold=0, twogold=0, i, r;
for (i=0; i

Eh, I got pretty far in Intel's developer manuals, we'll see how it goes
Thanks senpai

The fact that I'm once again unemployed. I don't feel that far away from my career, I'm waiting on return conversation from four different locations.

is there any real advantage to using maybe over lists? it seems kinda redundant

>tfw graduating in a year but still feel like a noob at programming

Is this normal?

thanks. but how do i make the load work?

GG GS SS
>pick box with gold ball in it
GG GS

I moved the queue bar to the left sidebar which can now display other content as well

It will be used to browse the queue and feature buttons to change the contents of the main panel

Over-engineered C++ version:

#include
#include

using namespace std;

struct Ball {
Ball(bool golden) : golden{golden} {taken = false;}
bool golden;
bool taken;
};

struct Box {
Box (bool gold_left, bool gold_right)
: left{gold_left}, right{gold_right}
{}
Ball left, right;
bool take() {
while (true) {
if (rand() % 2) {
if (!right.taken) {
right.taken = true;
return right.golden;
}
} else {
if (!left.taken) {
left.taken = true;
return left.golden;
}
}
}
}
void reset() {
left.taken = false;
right.taken = false;
}
};

int main() {
Box boxes[3] = {
{true, true},
{true, false},
{false, false}
};

srand(time(nullptr));
constexpr int tries = 10000;
cout

Basically the same way.

it's 1/3 fucking retards

the second part doesn't matter, if you chose a box with

when you want a list that can only be 1 element

also there are some interesting generalisations

Maybe a appears to be [a] with at most 1 element, but it also appears to be Either () a

perhaps Either a (NonEmpty b) is a useful type, or even Either a [b]