[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: 311
Thread images: 33

File: neon_genesis_evangelion_212.jpg (2MB, 2963x4172px) Image search: [Google]
neon_genesis_evangelion_212.jpg
2MB, 2963x4172px
What are you working on, /g/?

Old thread: >>58500500
>>
>>58504863
thanks for using a gook image, again, cunt
>>
First for C
>>
>>58504863
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.
>>
File: ERBCLq.jpg (76KB, 640x480px) Image search: [Google]
ERBCLq.jpg
76KB, 640x480px
>>58504863
ded
>>
xth for if you have a lisp learning to program in lisp is more intuitive.
>>
File: 1484508171721.png (549KB, 1920x1080px) Image search: [Google]
1484508171721.png
549KB, 1920x1080px
>>
>>58504863
Writing a kernel in C++
>>
File: 1459888119410.jpg (129KB, 701x576px) Image search: [Google]
1459888119410.jpg
129KB, 701x576px
state your answer and your country
>>
>>58504863
Thanks for being a weaboo faggot
>>
>>58505076
But.. why?
>>
File: 1484508283982.png (3MB, 5288x2158px) Image search: [Google]
1484508283982.png
3MB, 5288x2158px
>>
>>58505092
Because C++ is suitable for writing kernels.
>>
Should programmers know abstract algebra?
>>
>>58505077
0.5
What kind of question is that?
>>
>>58505178
lol kys retard it's 2/3
>>
>>58505077
2/3
>>
>>58505156
it's not a top priority if you have other things you need to focus on but yes
>>
>>58505077
66.(6)%

poland
>>
"-1 and 1 java" literally breaks google
how in the fuck
>>
>>58505077
50%
United States of America
>>
>>58505228
prefixing a search term with - excludes those results
>>
>>58505185
>>58505203
>>58505209
Obviously that stupid image is just trying to start shit, but you clearly haven't read the question properly.
>>
>>58505256
no
"1 and -1 java" does the same
>>
>>58505251
>>58505261
>>
>>58505077
Conditional probability, so the box with only silver balls is a red herring. 50%.
>>
>>58505261

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
>>
>>58505228
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.
>>
>>58505284
>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.
>>
>>58505267
https://www.google.com/search?q=%221+and+-1%22+java
https://www.google.com/search?q=pajeet
https://www.google.com/search?q=pajeet+-curry
>>
>>58505318
EPIC
XD
>>
>>58505275
>>58505284
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.
>>
>>58505077
P(next ball) = 0.5
Brazil.
How is this programming related?
>>
File: 0d9.jpg (88KB, 960x702px) Image search: [Google]
0d9.jpg
88KB, 960x702px
>>58505314
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
>>
>>58505314
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 4chan 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
http://www.strawpoll.me/12023125
>>
PROGRAMMING FUEL POLL

http://www.strawpoll.me/12097496
>>
>>58505352
>>58505351
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%.
>>
>>58505351
>>58505352
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.
>>
>>58505431
And that whichever box it happens to be, is now short one gold ball
>>
>>58505422
>>58505431
Let's do what
>>58505384
suggests so we can solve this conclusively.
>>
>>58505422
>>58505431
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 >>58505384 if you can't figure it out by intuition
>>
they keep replying
>>
>>58505415
>cant choose more than one
what a shitty poll
>>
>>58505422
>>58505431
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...
>>
>>58505470
pick the best/most important one or the one you use the most often
>>
>>58505415
>no iced tea
if you think that's the same end yourself
>>
>>58505488
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.
>>
>>58505077

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.
>>
>>58505415
>>
>>58505415
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?
>>
>>58504901
You should've abstracted sooner. SOCKS is piss easy to implement, adjusting the test of the code is not.
>>
>>58505578
Kernel and a graphics card driver.
>>
>>58505578
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.
>>
>>58504863
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.
>>
>>58505592
Maybe. The infrastructure I am creating isn't closely tied to SOCKS, so it is pretty easy.
>>
>>58504863
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
>>
File: browser_.webm (3MB, 960x1040px) Image search: [Google]
browser_.webm
3MB, 960x1040px
>>
>>58505665
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.
>>
>>58505077
Why the fuck wouldnt it be 50%
Someone write a program that simulates this to prove all the 2/3 idiots wrong
>>
>>58505607
I'd assume the driver exposes an API, any idea where I can learn about that?
>>
>>58504863
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
>>
>>58505609
Is the Wayland source relatively easy to read through
>>
>>58505759
anime is the most advanced technology known to man
>>
>>58505741
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.
>>
>>58505765
https://github.com/dvdhrm/docs/tree/master/drm-howto
>>
File: 1478051922994.gif (46KB, 100x155px) Image search: [Google]
1478051922994.gif
46KB, 100x155px
>>58505806
Awesome, thanks senpai
>>
>>58505712
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
>>
>>58504885
>>58505088
>>58505759
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
>>
>>58505747
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.
>>
>>58505843
>fwrite(&e, sizeof(team), 18, fp);
>&e
This is taking a pointer to a pointer. You just want 'e' here.
>>
>>58505851
what
>>
>>58505077
2/3, France.
>>
>>58505851
>js
please, it's not /wdg/
>>
>>58505856
I'm asking about card level
>>
>>58505911
js is a general purpose programming language like any other
>>
>>58505911
that's stupid, baka
>>
>>58505912
It's not exactly a light read, modern cards are extremely complex:

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

several thousand pages.
>>
File: 1443604195353.jpg (125KB, 800x720px) Image search: [Google]
1443604195353.jpg
125KB, 800x720px
>>58505980
Eye am not baka, eye use C++
>>
>>58505741
#include <stdlib.h>
#include <stdio.h>

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<1000000; ++i) {
r = rnd(3);
if (!r) continue; // discard silver/silver
++onegold;
r = rnd(3); // 3 gold balls
if (!r) continue; // got silver, try again
++twogold;
}
printf("onegold: %d\ntwogold: %d\nratio : %f\n",
onegold, twogold, (double)twogold/onegold);
}


onegold: 666571
twogold: 443706
ratio : 0.665655
>>
>>58505993
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?
>>
>>58505877
thanks. but how do i make the load work?
>>
GG GS SS
>pick box with gold ball in it
GG GS <-- one of these boxes has been picked
G or S remains
50%

how do you get 2/3??
t. brainlet
>>
File: anim.webm (794KB, 1868x1005px) Image search: [Google]
anim.webm
794KB, 1868x1005px
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 <iostream>
#include <time.h>

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 << "Doing "<<tries<<" tries..."<<endl;
int success = 0;
for (int i=0; i<tries; ++i) {
Box b = boxes[rand()%3];
if (!b.take()) {
b.reset();
i--;
continue;
}
if (b.take()) {
success++;
}
b.reset();
}

cout << (float)success/tries << endl;
}



$ ./a.out 
Doing 10000 tries...
0.6654
>>
>>58506169
Basically the same way.
>>
>>58505077
it's 1/3 fucking retards

the second part doesn't matter, if you chose a box with <2 gold balls you already lost

only one out of 3 boxes applies to that
>>
>>58506150
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]
>>
>>58506233
FUCK IM A RETARD
nvm
>>
>>58505415
I take caffeine pills. No sugar, no calories, no carbonation stomach bloat. Better buzz anyway, IMHO.

They're cheap as hell, completely legal, and I dont have to play spazz to get a prescription.
>>
>>58506249
>>58506233
>it's 1/3 fucking retards
>...
>FUCK IM A RETARD
Foolproof way to recognize idiots: they think everyone else is stupid until they realize how wrong they are.
Every. Single. Time.
>>
>>58506190
GG GS SS
>pick box with gold ball in it

| | |
v v v
G G G S S S
| | |
| | \
v v v <-- you are here
G G G S
| | |
x x x <-- 2/3 ways lead to two golden balls
>>
>>58506269
You fucked up the last part, but the thinking is correct.

6/10 for effort
>>
>>58505384
No because it isn't the probability of picking a gold ball in the first box, it is the probability of picking a gold ball in the first box given that you have already picked a gold ball.
>>
>>58506290
It's 2/3, demonstrated in this very thread both in theory and in practice

To insist it's anything else is to be a retard of monumental proportions
>>
>>58506290
Bait.
>>
>>58506303
>>58506299
Bait
>>
File: brainstorm.jpg (66KB, 612x574px) Image search: [Google]
brainstorm.jpg
66KB, 612x574px
at what point should I prefer a database over a 100% in-memory solution with frequent linear and binary search?

less than 500k objects, each with 10 to 20 small fields
>>
>>58506269
thanks mayne i didnt understand
>>
>>58506285
Making cross-crossing ascii-pipes was too much effort, the left most should of course not be straight lines but selecting the other ball.
>>
>>58506318
As long as it fits in RAM and you don't need persistence, the database will always be slower than even the most naive solution you can write.

It's a simple question of overhead.
>>
>>58506318
Keep everything in memory until you run out memory duh
>>
I'm pretty solid in C. I want to learn something object-oriented. Python or C++. C# seems to not be a good starting point for learning this kind of programming.
>>
>>58506346

c++ because it aint that hard for a c programmer
>>
>>58506216
yeah i for some reason i was stuck in trying to return the array like in c#

now i just initialized the array before the load function and made the function void and it worked fine
>>
>>58506346
https://tour.dlang.org
>>
Run it in your browser
// Y = yellow, g = gray
// Balls:
// 0 1 2 3 4 5
// [Y Y] [Y g] [g g]

function otherBall (i) {
if (i % 2) {
return i - 1;
} else {
return i + 1;
}
}
function ballIsYellow (i) {
return i < 3;
}
function randomBall () {
return Math.floor(Math.random()*6);
}
function trial () {
var i;
// keep picking until we get a yellow ball
do {
i = randomBall();
while (!ballIsYellow(i));
// check the other ball
return ballIsYellow(otherBall(i));
}
for (var n = 1000; n < 10000; n += 1000) {
var k = 0;
for (var i = 0; i < n; i++) {
if (trial()) {
k++;
}
}
console.log("%s trials: P = %s", n, k/n);
}
>>
>>58506346
>I want to learn something object-oriented.
Why?
>>
>>58506482
Knowing the bad makes you better appreciate the good.
>>
>>58506490
That's not how a disease works
>>
>>58506420
Enjoy your mandatory GC and dead community.
Even alexandrescu gave up
>>
>>58506490
Why would you call object-oriented programming bad while it's the dominant paradigm in modern computing?
>>
File: andrei.jpg (104KB, 800x1067px) Image search: [Google]
andrei.jpg
104KB, 800x1067px
Is Andrei a vampire?
He looks like a vampire, and he is Romanian
>>
File: 1446933044470.png (346KB, 640x480px) Image search: [Google]
1446933044470.png
346KB, 640x480px
>>58504863
where to begin programming apps / beginner games

currently learning JS from codecademy, casually doing CS50x online (which focuses on C and programming logic).

eventually going to make some shitty extensions and games as practice and then research c / lua.

another construction anon had a similar question for networking

any advice would be great ty anons

>>58505077
>>58505178
50%

the question removes the 3rd box so now you're left with two boxes

the new problem is a) 100% chance or b) 0% chance so the 1/2 probability comes from the boxes and not the ball itself
>>
>>58506595
gb2a
>>
>>58506604
>gb2a portail service global avocats finances projets ingénierie
>Un réseau international, un contact de proximité. 12 bureaux en France et dans le monde, 4 sociétés, plus de 50 professionnels, avocats, ingénieurs, conseils,

what
>>
>>58506622
Go Back To /a/
>>
>>58506635
the entire website is /a/
>>
>>58506635
you should have just said that and not waste your time making a second post explaining your illiteracy
>>
>>58506659
No, there's also /mlp/.
>>
>>58506661
hownew.ru?
>>
>>58506674
ishiggydiggy
>>
File: 1448784582038.jpg (101KB, 500x666px) Image search: [Google]
1448784582038.jpg
101KB, 500x666px
I'm trying to find all possible paths, here is what I have so far:
https://github.com/4chenz/path_finder
It doesn't work or just never finishes a lot of the time. Any help?
It needs the text files to work.
import os
files = [f for f in os.listdir('.') if os.path.isfile(f)]
trackers = {}
for filename in files:
if 'txt' not in filename:
continue
with open(filename) as f:
trackers[filename.split('.')[0]]=[x.strip("\n").strip("\\n") for x in f.readlines()]

def backtrace(parent, start, end):
path = [end]
while path[-1] != start:
path.append(parent[path[-1]])
path.reverse()
return path

def bfs(graph, start, end):
parent = {}
queue = []
queue.append(start)
while queue:
node = queue.pop(0)
if node == end:
return backtrace(parent, start, end)
for adjacent in graph.get(node, []):
parent[adjacent] = node
queue.append(adjacent)

def path(graph, start, end):
x = bfs(graph, start, end)
if x != None:
for d,n in enumerate(x):
if len(x) > d+1:
print(n,end=" -> ")
continue
print(n)

for x in trackers.keys():
lel = path(trackers, str(x), 'AnimeBytes')
if lel != None : print(lel)

Output should be something like:
Interview -> MyAnonamouse -> UHDBits
bibliotik -> HDBits -> MyAnonamouse -> UHDBits
baconBits -> AnimeBytes -> UHDBits
MyAnonamouse -> UHDBits
PassThePopcorn -> BroadcasTheNet -> MyAnonamouse -> UHDBits
>>
>>58506445
Problem with this is you are picking a ball at random and not a box at random. The question states that you pick a box at random and out of that box you pick up a gold ball.
>>
>>58506595
People are making money on Steam using GameMaker kek but yeah, learn actual programming if you ever want to develop big budget games. To be fair, there have been some solid games made with GameMaker. AM2R comes to mind when I think of it's peak abilities. I'm not sure if MegaMan Corrupted is being made with GameMaker but it looks better than any MegaMan capcom has made to date.
>>
>>58506743
That's exactly the same thing
>>
>>58506595
C++ for anything where performance is valued.
>>
>>58506771
>implying
https://en.wikipedia.org/wiki/Monty_Hall_problem
>>
>>58506793
Yes, that's the same type of problem.

It seems like you read the "solution" without understanding it.
The important part is getting information before making the second choice, not making the first choice in two steps.
>>
>>58506512
These threads are shit. According to /g/ 99% of the time, the only programming language worth learning is C.
>>
Okay so theres 3 choices? Then 2 of those choices will be correct. 2/3 for you dense 50%
>>
>>58506764
I have gamemaker from a humble bundle a while back but I want to LEARN programming.

My interests lie in application, game, and homebrew developing and game modding as well. Heard JS was a good start for C so once I feel "good" at JS I'm probably going to jump to it. Or Lua. Lua does what I want it to at the moment and I heard it too is good for C.

>>58506778
I heard using C++ as a starting language is like drinking from the fire hose

but yes C++ is a language I want to learn if I ever master C
>>
How important is probability for CS? Cause I fucking suck at this shit.
>>
>>58506840
If you think of C++ as C with bells and whistles, it becomes a lot easier.
>>
>>58506862
C++ is a poorly designed and bloated clusterfuck.
It misses many of the key advantages of C.
>>
>>58506855
Not important in and of itself, but it's so simple that if you can't understand it you'll never go very far.

Maybe Javascript or PHP are good languages for you.
>>
>>58506879
>bloated
>implying having good features is a bad thing
>>
>>58506793
>any difficult probability problem with three choices is 2/3rds because monty hall!
>>
>>58506915
>implying being bloated and having """""good""""" """""features""""" are somehow the same thing
>>
>>58506884
I can understand it when it is explained to me but I almost always fuck it up when I'm asked on the spot.
>>
>>58506915
Conceptual simplicity is important, you know.
Also, most C++ are fucking garbage. They are not "good features".
>>
Is the emacs q4 browser guy here?

How come a reply count for each thread shows up when you use q4/browse-board, but there's no reply count for individual posts inside a thread?
>>
>>58505741
If there was a gold ball in the box, then it's impossible for it to be the box with only silver balls. You can safely ignore that one.
>>
>>58506950
There's a difference between understanding that what you're told makes sense, and truly understanding what you've been told.

If you go watch a lecture on Special Relativity you might think it all makes sense and it's really just obvious, but unless you go study the math and do exercises you won't be able to understand why the twin's paradox isn't really a paradox. All you'll have is a simplified and likely incorrect mental model.

TL;DR: Read a book, nigger. If you don't want to catch Dunning-Kruger.
>>
>>58506944
>>58506956
What are some bad features of C++?

>>58506943
>implying they aren't insanely simiar
>>
>>58506943
If you would map the probability, you would just be rotating the table by 90 degrees
>>
>>58506992
I already took a class on probability and somehow got a C. I think he gave it to me out of pity. Hardest class I've taken desu.
>>
>>58506993
A lot of C++ features are terrible in how they interact with each other.
There are too many to list.

While outdated, http://yosefk.com/c++fqa/ has a good list of some of the retardation in C++.
>>
Hey /g/
Does anyone know of a library I can use with C# that can read mp3 metadata?

I tried to use taglib but it hasn't been supported in years and is literally broken for me.
>>
>>58506445
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
void main() {
srand(time(NULL));
double goldTrials = 0, success = 0;
for(int ball = 0; goldTrials < 10000; ball = rand()%6) {
goldTrials += ball > 2;
success += ball > 3;
}
printf("Result: %lf\n", success/goldTrials);
}


golf it up
>>
>>58507029
The important part in learning is giving a shit.
If you're forced to learn something, you're brain will be happy to forget information it thinks is useless.

Go on your own and study something because you want to, that's how you git gud.
Y'all needmotherfucking bookz.
>>
File: MTQxMTY3ODM0MTQ2Mjg1MjUy.jpg (36KB, 641x480px) Image search: [Google]
MTQxMTY3ODM0MTQ2Mjg1MjUy.jpg
36KB, 641x480px
>>58506961
hi

Not a bad idea. The data is already there, I just hadn't thought about putting it in. I could do that in postprocessing and add a hook for it when refreshing.

Thanks for mentioning it.
>>
>>58507085
Probability just pisses me off most of the time.
>>
>>58507121
Then you only have yourself to blame.
Being pissed off is a choice you make.
>>
>>58507086
Thanks for your hard work

I just noticed that there's a new "multisite" branch. Are you planning on having a way for people to add support for other imageboards?
>>
>>58505077
People are misinterpreting the questions, it's not about the probability of picking a gold ball followed by a silver ball. This would result in 66%.

But the question clearly states that you have already gotten the gold ball 100%. It only asks the chances of the second ball being gold.


Since we know that the first ball is 100% gold, the 3rd box would be out of the picture because the probability of getting a golden ball out of the box is 0. Which leaves us with the first two boxes.

In the first box, if a golden ball has been taken out, the other ball will still be a gold ball, so that's 100% golden.

In the second box, if a golden ball has been taken out, the other ball will have to be a silver ball, so that's 0% golden.

Average 50% chance of getting a golden ball after knowing that you already got one.
>>
>>58505093
roll
>>
>>58507124
What pissed me off was that I couldn't always get what the questions were asking and the book didn't make it any clearer nor did searching the internet. Those kinds of questions just piss me off. Maybe I should have seen the professor but I was busy with other stuff.
>>
File: coverrw8.jpg (29KB, 396x520px) Image search: [Google]
coverrw8.jpg
29KB, 396x520px
>>58507085
>Y'all needmotherfucking bookz
Now would be a great time to plug that the first BasicTV channel will be broadcasting the audiobook of pic related uninterrupted. I'm also reading into BQP and post-quantum cryptography, as well as reading some non /g/ material
>>
Can someone post the image with a list of projects for rolling?
>>
>>58505093
>>58507193
>>
>>58507193
0-9: Get a job
>>
>>58507070
Here you go.
8 lines, one logical statement per line, properly indented.

#include <stdlib.h>
#include <stdio.h>
int main(int ball, char**) {
printf("Result: %lf\n", [&](){
for(double goldTrials = 0, success = 0; true; ball = rand()%6)
if ((success += (ball > 3), goldTrials += ball > 2)>=10000) return success;
}()/10000);
}


I doubt you can golf it further without breaking proper indentation.
>>
>>58505093
Rolling rolling rolling.
>>
>>58504863
What does /dpt/ know about energy efficient programming? Is there anything to it other than using fewer commands, libraries, and lines of code?
>>
>>58507138
Other people are definitely welcome to do that, but I'm going to be writing in support for pic related myself. Pic related is missing a few things from their API, like a board listing, but the changes seem to be fairly minor. Some code needs to be rinsed out but it should only take a day or two of fiddling with it to get it to work.

Speaking of other people, I'm trying to keep the internals documented and as sane as possible, for my sake and anyone else wanting to hack at it. But more work needs to be done there as well.
>>
File: anime.jpg (73KB, 960x362px) Image search: [Google]
anime.jpg
73KB, 960x362px
>>58507294
>What does /dpt/ know about _ programming?
Absolutely nothing
>>
>>58507296
Sounds good!
>>
>>58506507
wew, wrong on all counts
>>
>>58507387
Good thing he didn't say it was a shit language, because then you wouldn't have been able to make this post
>>
>>58507392
sick burn d00d, im posting this on reddit
>>
>>58507232
But why stop there.

extern"C"{int rand();int printf(char[],...);}main(int f,char**a,char**g)
{printf("%lf\n",[&](int x){for(auto t=0.,s=.0;1;f=rand()%6) if((s+=(f>3),t+=f>2)>=x)return s/x;}(g[f]-*a));}


Output: 0.607143
Close enough.
>>
>>58507417
when you get there tell them 4chan bullied your wife's language
>>
File: Wait, What.jpg (306KB, 422x750px) Image search: [Google]
Wait, What.jpg
306KB, 422x750px
This book I'm reading about λ-calculus has an unfortunate amount of spelling mistakes. Was this simply not proofread at all? What the fuck, man.
>>
File: 1465297400484.jpg (100KB, 500x500px) Image search: [Google]
1465297400484.jpg
100KB, 500x500px
>>58507435
can a book about lambda calculus really be that long?
>>
>>58507435
You're not supposed to actually read the λ-calculus books, just pretend you've read them to brag at the weekly academic circlejerkfest.
>>
>>58506694
your bfs doesn't track visisted nodes, so if a cycle exists in the graph, it won't ever finish. Just create another set called 'visited', add all process nodes to it, and only add nodes to queue that are not in 'visited'. This may be a non-issue if your graph is of a filesystem, which should just be a tree.

The real issue is that in your backtrace function, you use a variable named path, which is defined in this scope as a function. Rename that variable.
>>
>>58507294

Energy efficiency comes in great part due to speed. Faster software means that the CPU can be allowed to idle for longer (or even be downlocked if necessary), which translates to better energy efficiency. The things you mentioned aren't really good measures of this.

Lines of code do not translate to much of anything, since it is not the lines themselves that are executed, but either machine code from compilation, bytecode from compilation, or in the worst case, an abstract syntax tree being interpreted. If you condense a bunch of stuff into less lines and toss out all of the comments, the only thing you do is reduce the source code size, and thus maybe the time it takes to parse it, which isn't a heavy part of the computation process.

Using less libraries doesn't necessarily lead to better performance either. You need a function one way or another. It doesn't matter who writes it. It just matters how it's written.

As for "commands", unless you are talking about shell scripting, I would presume you are actually referring to functions and procedures? There are plenty of places where abstracting something into a function call is much better for performance than aggressive inlining.
>>
>>58507446
241 pages in total.

>>58507449
I now see the error of my ways.
>>
>>58507518
andrei is a NEET now
>>
>>58507522
With all that Facebook cash money he's got, I'd want to be a NEET too
>>
>>58507518
He's meming
>>
>>58507452
Thanks anon. I guess the looping thing make sense.
I'll try to mess with it again in a bit.
>>
>>58507614
https://github.com/azeemigi/graph-algorithms-haskell
>>
>>58505060
>if you have a lisp learning to program in lisp is more intuitive
>knowing lisp but not english
>>
guys I just realized something

programming books dont teach you shit they just present you what's possible

do you agree?
>>
>>58507782
your post doesn't teach me anything it just presents a choice

do you agree?

yes you fucking do
>>
File: 1482007225219.jpg (58KB, 600x415px) Image search: [Google]
1482007225219.jpg
58KB, 600x415px
Im currently working on something tile based and one big problem is that it needs to rebuild the framebuffer every time a state changes. I optimised and compacted everything as its in my ability but I still think its not enough. one rebuild with ca. 4000 tiles takes 2ms in the most basic state. will be probably much more with more different tiles.
so I wonder can can I move the whole shebang to the gpu with a shader of some sort. couldnt I technically just use a mesh and my texture atlas with the tiles, push everything to the gpu in one go and let it sort it all out? couldnt this technically speed shit up?
>>
i'm going along with think python and have just been using the python shell script editor to write the exercises. would i benefit from installing emacs?
>>
>>58507873
Vim
>>
>>58507934
is it better and/or easier to use than emacs?
>>
>>58507962
Is Vim better and/or easier to use than notepad?

I don't know about easier, but it sure is better.
>>
>>58507870
just looking into it and Im guessing this should actually work. the "regular" way is actually nothing else than building a mesh out of the tiles and render it. but the tiles are 99% of time unchanged and thus I can skip the whole part of building and just cache the mesh. I guess thats the solution
>>
File: .png (84KB, 1338x641px) Image search: [Google]
.png
84KB, 1338x641px
>>58507978
i'm using this not notepad, though.
>>
File: snap121.png (26KB, 1345x655px) Image search: [Google]
snap121.png
26KB, 1345x655px
>>58508008
But can your wordpad do this?
>>
File: 1475455423545.jpg (27KB, 480x519px) Image search: [Google]
1475455423545.jpg
27KB, 480x519px
>>58508030
>greentexting outside of 4chan
fuck you
>>
>>58508030
well i guess i'll give it a try since it's even on the official python wiki.
>>
>>58508049
>What is email?
>>
>>58507873
Emacs has good REPL integration with python out of the box: Under C-c there are several bindings to send parts of the program (regions, functions, lines, etc) straight into the REPL.

https://emacswiki.org/emacs/PythonProgrammingInEmacs

Its handy, but if this is the first time you've never messed with programming you should use something less intimidating. Sure as hell NOT vim. Emacs/vim are tools for when you've learned programming proficiently enough to actually get bottlenecked by editing speed. Until then, keep it tame. PyCharm is probably a good place to start.

>>58506961
this is done now, and also native timestamps
>>
>>58504863
Why does Shinji have breasts and a nerv uniform?
>>
>>58508096
Because it's 2017
>>
>>58508096
why wouldn't she? she works there
>>
>>58508096
>Shinji
(You)
>>
>>58508069
vim is easy if you start by working through vimtutor
>>
Kan jeg stille noen spörsmål?
>>
>>58505093
rollllll
>>
Is it possible, in Java, to create a MyInteger class that handles assignment like the real thing? e.g.
MyInteger a = 10; // This
MyInteger b = new MyInteger(10); // Not this
>>
I'm messing around in C#, which I don't know very well. I come from a C++ background.

My program requires one or more URLs on the command line. It optionally accepts options (before the URLs), indicated with a leading slash character.

For example, args might be { "/a", "/b", "www.google.com www.bing.com" }.

The first thing I do is process the options. Now, I want to pass the *remaining arguments* as a list of URLs. What's a clean, efficient way to pass only a subset of the arg array as a new array?

e.g.

public static void Main(string[] args)
{
// do some stuff
string[] urls = args.subarray(last_option_index, args.Length - last_option_index);
>>
>>58508243

No. Java is not C++ and does not allow you to overload the assignment operator.
>>
Why shouldn't I use notepad++ instead of an IDE?
>>
>>58508305
it literally doesn't matter

do what the fuck you want
>>
>>58508305
IDEs can be nice, but I find it better using a compiler, debugger, text editor separately, especially when I got someone proficient with each
>>
>>58508305

Feel free to use whatever editor you want, man. I've always found text editors to be less distracting than IDEs, easier to navigate, and less resource intensive. Notepad++ is a bit bland when it comes to editors, but it gets the job done, and it's easy to use.
>>
>>58505093
alright lets see
>>
>it's another >why shouldn't i use this bloated text editor with a million highlighting features that's literally an IDE instead of an IDE? episode
>>
>>58505077

zero, you cannot know the fate of the cat.
>>
>>58508280
string[] urls = args[args.Count - 1].split();

Something like that I guess?
>>
>>58508280
See if C# has anything like slices
>>
CHALLENGE
Simplify this snippet

if (a || !b){
if (!a && !b){
do X
}
do Y
}
>>
>>58508436
i.e. I don't understand boolean logic and do my homework for me.
>>
File: textfile.png (19KB, 1063x593px) Image search: [Google]
textfile.png
19KB, 1063x593px
I'm taking a python class in school as an elective and I was hoping that I could get some help with my code. I've got a text file that's in the attached picture that I need to pull data from. My code then needs to create a new textfile and sort all of the data. I've got everything that's required except for changing the city names to be in all capital letters. Would someone help me change them? Also, general tips would be much appreciated if you see that I'm doing something wrong. Thanks.

textinput = open('rainfall.txt','r')
textoutput = open('rainfallfmt.txt','w')

fifty = []
sixty = []
seventy = []
eighty = []
ninety = []

for line in textinput:
rainfall = line.split()
city = rainfall[0]
rainfall[1] = float(rainfall[1])
if rainfall[1]<=60:
fifty.append(rainfall)
elif rainfall[1]<=70:
sixty.append(rainfall)
elif rainfall[1]<=80:
seventy.append(rainfall)
elif rainfall[1]<=90:
eighty.append(rainfall)
else:
ninety.append(rainfall)

fifty.sort(key=lambda x:x[1])
sixty.sort(key=lambda x:x[1])
seventy.sort(key=lambda x:x[1])
eighty.sort(key=lambda x:x[1])
ninety.sort(key=lambda x:x[1])

textoutput.write("[51-60]\n")
for line in fifty:
textoutput.write('%+25s %5.1f\n' % (line[0],line[1]))
textoutput.write("[61-70]\n")
for line in sixty:
textoutput.write('%+25s %5.1f\n' % (line[0],line[1]))
textoutput.write("[71-80]\n")
for line in seventy:
textoutput.write('%+25s %5.1f\n' % (line[0],line[1]))
textoutput.write("[81-90]\n")
for line in eighty:
textoutput.write('%+25s %5.1f\n' % (line[0],line[1]))
textoutput.write("[91-100]\n")
for line in ninety:
textoutput.write('%+25s %5.1f\n' % (line[0],line[1]))

textoutput.close()
[code/]
>>
>>58508436
>|| !
&&
>! && !
||

Muh boolean logic.
>>
0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0


I have a sequence of integers: 0s and 1s. I want to:

>find average width of successive 1s
>in this example there's a sequence of 4, 3, 6, 4 = average width of successive 1s is 4.25
>find number of successive 0s with width less than what's found above
>in this example there's a sequence of 3, 1, 4 = 3 sequences

how?
>>
>>58508436
if (a) do Y
>>
>>58508472
or not b
>>
>>58508436
(if (or a (not b))
(when (not (and a b))
(x))
(y))
>>
>>58508464
Not good enough. You now have

if (a && b) {
if(a || b) {
do X
}
do Y
}


Doesn't look simplified to me.
>>
File: hrrrrrmmmm.png (116KB, 400x468px) Image search: [Google]
hrrrrrmmmm.png
116KB, 400x468px
>>58508483
i really missed the point here
why even post
>>
>>58508430

I don't think it does. People say to use LINQ, which seems a bit absurd.

>>58508415

I don't think there's any syntax like that.

I ended up going with System.Array.Copy(source_array, source_index, dest_array, dest_index, count).

It's a little clumsier than I'd like, but much better than manually duplicating the array portion.
>>
>>58505077
50%
STRAYA
>>
>>58508498
Yeah you're right, my first simplification is wrong. Anyway look up boolean simplification laws, I'm sure you can figure your homework out.
>>
File: oh.png (29KB, 633x302px) Image search: [Google]
oh.png
29KB, 633x302px
>>58508436
>>
>>58508521
https://msdn.microsoft.com/en-us/library/26ts046k(v=vs.100).aspx
>>
>>58508526

As expected, the Aussie cunt gets it wrong.
>>
>>58508534
>t. faggot who forgot computer science

I'm long out of school buddy. It's a legitimate challenge
>>
>>58508552
>It's a legitimate challenge
I don't see the words fizz or buzz anywhere
>>
>>58508536

Nice.
>>
>>58508521
>I don't think there's any syntax like that.
string[] urls = args[args.Length - 1].Split();

Here I went and got the exact line.
>>
Im hoping to learn Terraform for AWS. Was wondering if someone had any experience here. Wanted to try spinning up an EC2 instance and conneect it to a RDS or something
>>
>>58508526
>>58508550
no he got it right

this anon explained it
>>58506595
>>
>>58508436

i dont think you can
>>
>>58508455
I don't know much about python, but could you not use string.upper() to capitalize the cities?
>>
File: 1484542600.png (17KB, 377x168px) Image search: [Google]
1484542600.png
17KB, 377x168px
>>58504863
I am working through SICP and am getting stuck on making an iteration out of this recursion
>>
>>58508735
Yeah I figured it out by using rainfall[0] = city.upper()

Thanks.
>>
>>58508436

>A & !B no output
>A & B Y
>!A & B no output
>!A & !B X Y

so,

if (!B)
{
if (!A)
do X
do Y
}
>>
>>58508746
And further, if (!b && !a) { ... }.
>>
File: Richard-Stallman.jpg (60KB, 480x411px) Image search: [Google]
Richard-Stallman.jpg
60KB, 480x411px
>>58505076
>kernel
>C++
>>
>>58508753

Huh?
>>
>>58508769
>if (!B)
>{
> if (!A)
You can collapse these to one if statement is all I'm saying.
>>
>>58508455
>Also, general tips would be much appreciated if you see that I'm doing something wrong. Thanks.

What's with all the arrays? What if a piece of data comes in that's not in 50 - 90?
>>
>>58508787

Why would you want to do that?

if (!B)
{
if (!A)
do X
do Y
}


vs

if (!A && !B)
{
do X
}

if (!B)
{
do Y
}


I fail to see how that's an improvement.
>>
>>58508746

think this is right
>>
hello, how do I set up android to simply read from a string array, and display it? It keeps crashing.
        String[] myStringArray = new String[9];
myStringArray[1] = "Wow";
myStringArray[2] = "Wow";
myStringArray[3] = "Wow";
myStringArray[4] = "Wow";
myStringArray[5] = "Wow";
myStringArray[6] = "Wow";
myStringArray[7] = "Wow";
myStringArray[8] = "Wow";


ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, myStringArray);
ListView listView = (ListView) findViewById(R.id.listview);
listView.setAdapter(adapter);
>>
>>58508816
Yeah I guess you're right, it depends on circumstances. The latter is preferred in some languages (go) etc. but it's not strictly better in general.
>>
>>58508746
Nope. It won't do Y if A and B are both true, where in the original it would.
>>
>>58508860
..uh duh I wasn't using the first value, disregard this...
>>
@58508902
>..uh duh
>wow
Fuck off, plebbit
>>
>>58508940
I've been here for years fagoo, deal with it
Also you don't even know how to quote a post.
>>
>>58505077
0.5 wtf is this...
>>
>>58505092
In my uni class we are writing a kernel in C++ as well lol
>>
@58508965
>I've been here for years fagoo
nah, post a non-ribbit anime image and maybe then you can stay.
>she thinks her plebbit kind deserves my (You)s
nice one
>>
>>58508980
>lol
bleh
>>
>>58508436
A B X Y
0 0 1 1
0 1 0 0
1 0 0 1
1 1 0 1

There's a few ways you could write this in code, like:
if (a) { do Y }
if (!a && !b) { do X, do Y }
>>
>>58506233
The first thought In my head was 2/6 = 1/3? No way it's that easy, I must be fucking retarded, as per usual *kappa*
>>
Is it bad if I delete master? Is it even possible? Is there a way to just copy one branch over top of another? What about renaming branches?
t. man who's used git for about 1.5 years
>>
>>58509065
>man
Thanks for specifying, I thought you were a cute anime girl
>>
File: how_to_be_a_better_programmer.png (1MB, 1702x2471px) Image search: [Google]
how_to_be_a_better_programmer.png
1MB, 1702x2471px
>>58509085
I know it can be confusing.
>>
>>58508190
I didn't find vimtutor very helpful, personally. I never managed to hammer the vim way into my skull until I installed evil and started using it in addition to regular emacs. It slowly started to stick and now I'm really glad I've learned it, even if im not actually using vim.

But, more importantly, I'm just not of the opinion that anyone learning a language for the first time should be fucking around with text editors that are drastically different from what they are used to. Cant run until you've learned to walk, blah blah

I shill emacs any time I get the chance, but I started programming in Geany which didn't make my head explode. I didn't need tutorials on how to use Geany. I spent 100% of my time and effort learning PYTHON, with zero bullshit or obstruction from the editor. Thats more important imho
>>
>>58508898

Aw, fuck, you're right. Oh well, I've been drinking.
>>
>>58509065
There's nothing special about master, it's just what everyone calls their main branch
>>
>>58508737
hard way would be to iterate through each possible path of the ternary tree that this recurrence relation generates. easy way would be to compute f(3) from f(2), f(1) and f(0), then compute f(4) the same way, and then f(5), etc. until you reach your desired n.
>>
>>58509385
OK good thank you
what about copying a branch? or renaming it?
>>
>>58509399
idk, google it
>>
>>58509431
reminder that git can fill a whole general
>>
>Python 3 is uncompatible with Python 2
>Perl 6 is uncompatible with Perl 5
>C11 is uncompatible with C99
What the heck
>>
>>58505112
>C++ is suitable
kys
>>
>>58509723
>technology moves forward
holy fuck were gonna die the skie is faling
>>
>>58509723

Pretty much every C99 feature is either optional in C11 or a part of C11. I don't think there's a single C99 program that will compile with -std=c99, and not compile with -std=c11, unless it was with something intentionally removed from the language on the justification that it should never ever be used for any purpose (i.e. the gets function).
>>
>>58509892
>the technology moves forward
>the people who use don't and stick with old versions

it happens EVERY single time
>>
>>58509038
Had a similar idea.

if(!(a || b))
do X
do Y
elif(a)
do Y

I would imagine a decent compiler would produce identical output for both, but if they were translated literally, my code do less operations on average. Heres the full autistic analysis.

Original, Average of 7 ops

AB
TT:not,or,IF,not,not,and,IF,Y 8
TF:not,or,IF,not,not,and,IF,Y 8
FT:not,or,IF 3
FF:not,or,IF,not,not,and,IF,X,Y 9

New, Average of 4.5 ops

AB
TT:or,not,IF,IF,Y 5
TF:or,not,IF,IF Y 5
FT:or,not,IF,IF 4
FF:or,not,X,Y 4
>>
>>58509965
when none of the changes are needed or there's incompatible changes or lacking features why change when it already just werks

now let's bump this and get a new thread
>>
Anyone know of any good articles on register allocation algorithms, particularly those which concern register allocation from stack machines (i.e. JVM Bytecode, CIL -> native code)
>>
how many layers of abstraction are you guys on right now
>>
Python 2 or 3m

LPTH says 2, but reddit says 3.
>>
>>58505077
What an interesting way of showcasing the gambler's fallacy.
>>
>>58510299
the wankoff that wrote LPTHW is delusional. Dont fuck with 2 unless you know you need it.

Protip: you dont
>>
>>58505077
2/5 or 40%
America
>>
>>58505077
guys, you're all idiots. the probability is 7/13

kazakhstan
>>
>>58510381
LPTHW's stance was true when it was written. It's no longer true.
>>
>>58510481
Yes, I relize that. I dont think the guy wrote a bad book for python 2.

But read this drivel, holy shit
https://learnpythonthehardway.org/book/nopython3.html
>>
>>58510505
He's got a point about strings and bytes being a pain in the ass to work with
>>
>>58510381
But a shitton of libraries...
>>
File: 1129294958856.jpg (40KB, 433x380px) Image search: [Google]
1129294958856.jpg
40KB, 433x380px
>>58505077
1/3 or 2/5? I'm not sure.

> Brazil

I would go on 1/3 because they are sorted into boxes, I mean, if there was only one box with two gold balls, and the other boxes with just silver balls, then the answer to the same question would be 1/1 and not 1/5.
>>
New thread:

>>58510588
>>58510588
>>58510588
>>
>>58505093
rooooooll
>>
>>58505077
Let G1 be: "the first ball you take is a gold one".
Let G2 be: "the second ball you take is a gold one".
The probability we're looking for is P(G2|G1), the probabilty of G2 under the condition of G1, expressed as this:
P(G2|G1) = P(G1 ∩ G2) / P(G1)

There are 3 gold balls over 6, so P(G1) = 3/6 = 1/2.
Now, let's find out P(G1 ∩ G2). It is the probability of taking a gold ball first, then another gold ball secondly, which means picking the box with the two gold balls. There is 1 box over 3 which contains the two gold balls, hence P(G1 ∩ G2) = 1/3.

Thus, P(G2|G1) = (1/3) / (1/2) = 2/3.
>>
>>58505077
Let's consider a restricted version of this problem where the first ball you draw from a box is always the left one.
Now you could have either picked box 1 or box 2 since they are the only one with a left gold ball, then you remove the left ball. There are now two possibilities remaining you either picked box 1 and the remaining ball is gold or you picked box 2 and the remaining ball is silver. Now there are two possibilities which give results you've either picked:
left ball of box 1 -> gold ball
left ball of box 2 -> silver ball
Two possibilities and one of them gives a gold ball. So the probability of second ball being gold is 1/2.

Now we do the more general problem which was state in the image. You now pick either the left ball or right ball from a box at random. This complicates things. Box 1 is always safe, but box 2 is only a safe pick half of the time. There are now three possibilities, you've either picked:
left ball of box 1 -> gold ball
right ball of box 1 -> gold ball
left ball of box 2 -> silver ball
Three possibilities and two of them give a gold ball. So the probability of second ball being gold is 2/3.

Hope that clears it up. Country is Australia.

>>58510905
>P(G2|G1) = P(G1 ∩ G2) / P(G1)
Interesting. Never seen that before. At least it seems to agree with both of my probabilities.
>>
>>58506318
What kind of things are you storing / what kind of queries are you doing? You always want to keep that shit in memory when possible, just wondering why linear scan is coming up.
>>
>>58508289
Isn't that almost always going to directly invoke MyInteger(int) because you can violate the as-if rule when optimizing copy elision?
>>
Is anyone else using C++17 yet? I built gcc 7 a couple of weeks ago and it is magic. I did get a segfault in the compiler doing some deeply recursive template shit when it failed to resolve a method, but other than that it has been really nice. The new additions to -fverbose-asm also make optimizing way easier.
Thread posts: 311
Thread images: 33


[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.