[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread: Headache edition
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 29
File: dCrlO67.jpg.gif (876 KB, 500x281) Image search: [Google]
dCrlO67.jpg.gif
876 KB, 500x281
old thread >>54153694

what are you fucking working on you fucking cunts /dpt/?
>>
>>54159551
im going my homework
>>
>>54159551
Fuck off anime cunt.
>>
>>54159557
homework*
>>
A well designed tetris clone in java, for the lulz
>>
>>54159611
>Well designed
>Java
I actually lol'd at this
>>
>>54159551
still working on dcbljack.tv, going to abandon it pretty soon because I drank the MEAN stack kool aid and now I'm sick of it. Maybe a month or two more on this then I'll probably rewrite in some other language and hang it up to dry.
>>
>>54159616
you know what i mean by well designed. If you don't i feel sorry for you.
>>
>>54159681
>you know what i mean by well designed.
No I don't
>If you don't i feel sorry for you.
Do tell
>>
>>54159681
its ok anon, Java is the language of the working man. Java is like a fat chick, everybody's done a few, but nobody admits it.
>>
>>54159551
learning android development
>>
File: poo-in-loo.jpg (54 KB, 628x314) Image search: [Google]
poo-in-loo.jpg
54 KB, 628x314
Ok guys. lets make a hello world program in c++ together. You are only allowed to write one line, Ill start:
#include <iostream>
>>
>>54159715
>Boilerplate
>Object-oriented
>Garbage collector
>No pointers
>Muh virtual machine

Lotta hard work there
>>
>>54159681
How many moves can you look ahead? Shuffled "bags" of pieces like the official games or truly random for each drop? Can you hold a piece off to the side? Can you spin along the bottom indefinitely?
>>
You know, following the SOLID principles, and making it adaptable, consistent, correct, extensible, flexible, etc
>>
>>54159743
int main(void) { return 0; }
>>
>>54159748
i will try to make it like the original, knowing the next piece that will appear, the pieces will be created like the original ones, i like the idea of random pieces.
>>
>>54159762
you cock
>>
>>54159715
>Java is like a fat chick
>Java
>fat

You got that right.
>>
>>54159746
honestly, tell me whats wrong with those things? I get it, its not the hip trendy new language, but why do you feel the need to shit on it anonymously on the internet?

>boilerplate
code generators?
>object-oriented
easy to collaborate on in big teams
>garbage collector, no pointers
those aren't things the customer cares about, just douchenozzle college kids.
>virtual machine
yea, its pretty great. thanks.
>>
>>54159795
if you can't work around that then you shouldn't be here.
>>
>>54159816
i like this guy
>>
File: 1239581209518502492835.jpg (99 KB, 539x270) Image search: [Google]
1239581209518502492835.jpg
99 KB, 539x270
>>54159762
>(void)
>(void)
>(void)
>(void)
>>
>>54159816
Pajeet please leave
>>
>>54159854
i don't know much about C++, why is "void" bad?
>>
>>54159762
>void
This is C++
>>54159833
How do you work around not being in the main function?
>>
first for java
>>
>>54159890
I don't actually know C++, I just typed out a C main function and hoped it would work
>>
Newfag learning C here.
How do I merge 2 numbers from different int variables into one to further work around the new number?
and I don't mean adding them.
>>
>>54159918
>and I don't mean adding them.
Then what do you mean?
>>
>>54159890
the context of the program was never stated, we could be writing a program for a freestanding environment, like an embedded system.
>>
>>54159918
use std::to_string and concat them the change them back to ints
>>
>>54159878
In C++ it's bad because your compiler puts in "void" for you if you do "int function()"
In C it's bad because the compiler doesn't do that
>>
>>54159926
1st number stored in a int variable = 4
2nd number stored in a int variable = 2
3rd int variable = 42
>>
>>54159936
I said write a hello world program. How can we do that without writing inside of the main function?
>>
>>54159938
i don't think someone learning c will want to solve a problem by dipping into std.
>>
>>54159950
That would be concatenation.
Google it.
>>
>>54159950
what if the first one is 13? do you want 15 or 132?

also >>54159914
>>
>>54159954
Oops, sorry. Thought we were talking about c++.
>>
>>54159954
especially when these are two different languages
>>
>>54159950
C, right? if this is a homework thing, the professor is asking you to realize that a char is an int.
>>
Anyone wants to write me a Python script?
I have a 256 by 254 image that consists of 24 by 24 cells, I want to recreate it so that instead of multiple rows the cells are in a single row.
>>
>>54160073
Just getting rid of newLine characters?
>>
>>54160073
Come on, it's Python. If you're seriously asking other people to write something for you in the most abstract, readable, and easiest to learn language, stop trying to associate yourself with programming
>>
File: voronoi.png (10 KB, 1376x608) Image search: [Google]
voronoi.png
10 KB, 1376x608
I made a little Voronoi Diagram generator. For some reason in the past I felt intimidated when people mentioned Voronoi Diagrams, but of course they're actually super simple.
Pic related was generated by this code.
vector<vpoint> voronoiPoints;

int numPoints = 12;

for(int i=0; i<numPoints; i++) {
vpoint vp;
vp.x=(rand()%width);
vp.y=(rand()%height);
vp.color.RandomColor();
voronoiPoints.push_back(vp);
}

fColor pointColor;
pointColor.SetColor(0.0f, 0.0f, 0.0f);

for(int x=0; x<width; x++) {
for(int y=0; y<height; y++) {
int leastDistSq = INT_MAX;
int nearestPointIndex=-1;

for(int p=0; p<numPoints; p++) {
int dSq = distSq(x, y, voronoiPoints[p].x, voronoiPoints[p].y);
if(dSq<leastDistSq) {
leastDistSq=dSq;
nearestPointIndex=p;
}
}

if(leastDistSq<=25) {
//Draw the point in black
SetPX(x, y, pointColor, bitmapBuffer, width, height);
} else SetPX(x, y, voronoiPoints[nearestPointIndex].color, bitmapBuffer, width, height);
}
}


This is outputting the result directly to a raw char array that's rendered as a 32 bit bitmap. I also wrote all the structs and helper functions (vPoint, fColor, RandomColor, distSq, SetPX, etc.) and altogether it's just another 40 lines of code or so.
>>
Hey /g/uys, programming noob here, need to make a game which uses at least 3 classes other than the main class. Needs to be an Android game but written in Java. What do? How do?

Teacher didn't teach shit, gave us this assignment with the advice of "research Java programming".

Grade 12 comp sci assignment.
>>
>>54160216
you have to be 18 to post here
>>
>>54160216
Make a lame hangman game, with a Word class (lol), a Diagram class, and a GameState class.
>>
Is there any particular reason the first way works but the second one doesn't, for c++? I'm aware I can use a string but that only really works for this specific case of the problem that uses chars. I've tried various types of casting and combinations but nothing works, you just always get "taking address of temporary address". I've googled the error and found stack overflow, but they never explain why you can't do it the second way, just stating that the first is necesary or providing some obscure workaround that only works in c++11. A solution to make it a one liner would be nice but I'm moreover just curious why it won't let me do this, if anyone knows.
char dummy[] = {'a', 'b', 'c'};
foo(dummy); // foo takes in a char*

foo( (char[]) {'a', 'b', 'c'} ); // Won't compile, typecasting as char* doesn't work either
>>
>>54143604
What are those patterns used for?
>>
>>54160255
The GameState will contain the current Word to be guessed, and the current Diagram, as well as the player's number of guesses, or something.
Diagram will have a DrawHangman function based on the number of tries permitted and used. The Word class will have a function to set the word, of course, but also to return whether a guessed letter was in the word or not, and a version of the word with all guessed letters shown. Which letters have been guessed can also be stored directly in the word.
>>
>>54160248
I am 18

>>54160255
>>54160299
Ty senpai
>>
>>54160276
I think that syntax is just a special case for defining arrays. You can't use it as a generic expression to be evaluated, or at least I've never seen it used that way.
Maybe I'm wrong, in which case, I never thought of using it that way, and that's cool.
>>
>>54159762
this literally happens every time
>>
>>54160187
That's a very slow method, have you considered using fortune's algorithm?

https://en.wikipedia.org/wiki/Fortune's_algorithm
>>
Friendly reminder to filter EVERY tripfag. It's the only way to get them to leave.
>>
>>54160386

Please don't.
>>
>>54160276
this works in java
>>
>>54160373
I've never heard of it before, so no. I'll give it a try.
>>
>>54160276
foo("abc");
>>
>>54160412
Why use a trip code?
>>
>>54160493
read the post. That only works for this one specific type

>>54160355
yeah I figured there wouldn't be a nice solution. Making temporary variables is fine but to make it even more frustrating apperantly people have said it works in pure C.
>>
>>54160537
because he's an attention whore, better to just filter all tripfags
>>
>>54160334
good luck anon
>>
File: rust-logo.png (24 KB, 209x208) Image search: [Google]
rust-logo.png
24 KB, 209x208
Could I get some suggestions for projects to work on as a novice? Kind of like basic text-editor tier, or even below that. Just not a toy program.
>>
>>54160608

It's true. It's all true.
>>
>>54160850
holocaust sim
>>
I'm learning how to program. Currently installing an IDE right now.
>>
>>54160895
no toy programs
>>
Quick question. In my Intro to Comp. Sci class we have been using "cout " to output to monitor, but I see "std::cout" being used as well online (we haven't learned it in class. Is there a difference?
>>
>>54160895
Since it was mentioned yesterday, I've wanted someone to actually make one. I don't know enough about the history involved to make an accurate one, or to know what kinds of mechanics there might be.
>>
File: Untitled.png (8 KB, 1012x74) Image search: [Google]
Untitled.png
8 KB, 1012x74
I don't have to pay to keep my github repositories private because I accessed the site with NoScript.
>>
>>54161169
well done
>>
>>54161138
well, being it didn't happen your sim shouldn't be to complex
>>
>>54161138
Can someone offer some ideas for such a sim? Other than the inevitable and admittedly funny >>54161413
>>
>>54160895
Minecraft already exists.
>>
>>54161011
they are making you use cout which is in the std namespace
because they haven't taught you about namespaces yet

at the top of the file, or around there at least, look for a
using namespace std;


that is what does it and they are exactly the same.
>>
lua a best brogramming language :DDDDDD
>>
benis hahaha :-DDDDDDD
>>
>>54161426
just fork simloli and replace the character with a gestapo or ss officer then make all the lolis jewish and replace rape with killing them
>>
>>54161449

Thanks. I figured they were analogous but didn't know the reason one wa used over the other. If you don't mind, what namespace is std::cout in? You don't have to explain it, I can look it up on my own.
>>
>>54161504
I was thinking more like a holocaust tycoon instead of like a storyboard game.
>>
>>54161545
ah, something along the lines of prison architect maybe?
>>
>>54161548
yes!
>>
I need a sanity check guys, this problem is 10 points on my homework but it seems stupidly simple

Is the relation R = {(1, 2), (2, 3), (1, 2)} on Z transitive, irreflexive, and not symmetric? The question is just "Give an example of a relation on Z that is irreflexive, transitive, but not symmetric"
?

I understand if I don't get confirmation because "we're not going to do your homework" but this is bugging me
>>
Is Lisp really as enlightening/magical as its users say? I want to get into wizardy
>>
>>54161652
lua is better
>>
>>54161660
uh
>>
>>54161652
Only useful for going through SICP
>>
>>54161652
It teaches you to think symbolically rather than wire pure state. But it's not about state purity.

Yes it's worth it. Pair with SICP
>>
How many programming languages do you need to know exactly?
>>
>>54161705
Only the instruction sets for every single CPU ever created
>>
>>54161705
as many as your goal requires of you
>>
>>54161705
https://en.wikipedia.org/wiki/List_of_programming_languages
all of these
>>
>>54161705
One. Everyone here just gets a chub from learning a new syntax everyday.
>>
>>54161705
Exactly 17
>>
>>54160850
Write an interpreter for a basic calculator
>>
>>54161705
You *need* one, I'd recommend being able to write two. (One fast to write, one fast to run)
>>
>>54161595
Draw that shit out. Also, not transitive, unless the second (1, 2) was a typo for (1, 3)
>>
>>54161749
Yes it was a typo, my mistake!
>>
>>54161705
You should aim to learn enough that you can pick up a new language and be productive in it in days to a week. What that number is depends on the languages you pick. Learning a dozen dynamically typed C-family languages won't be enough but maybe a language from each major paradigm would.
>>
I'm just going to stick with c++ thanks though.
>>
Anyone have experience writing HM type inference algorithms?
What's the best way to accomplish assignment to type variables? Substitution map? Some sort of shared pointer shenanigans?
>>
This is a simple tkinter program, I haven't gotten the clear button set up yet.

Right now I'm just trying to make each button append a string to the label because every single time I click a button it only displays the number once. I'm almost done this has been bugging me for a while.
>>
>>54159961
They're not strings you stupid fuck.

>>54159950
c = a * 10 + b
That will only work if b is one digit though, figure out the rest yourself.
>>
>>54161912
Nice! How'd you get started? I'm going to be getting myself into it soon hopefully, after I have more free time.
>>
>>54161907
Anyone have any advice? This is python.
>>
>>54161953
Went through the google sponsored Udacity course up to the end of the Sunshine app. Before that I was hopelessly fucking around with docs and youtube vids while getting nowhere.
>>
>>54161907
isn't it supposed to be root.mainloop()?
>>
>>54161990
I looked at that, seemed kind of cancerous but I suppose I'll have to get over it.
>>
>>54162001
I'd suggest blowing through it and using the resulting project as a reference for a project of your own. I commented the shit out of everything and now docs in my own words.
>>
>>54161992
Not necessary.
>>
>>54159950
It's possible that what you really want to do is store two 16 bit ints in a 32 bit int, which could be accomplished by something like:
int a=4;
int b=2;
int c = (a&0xffff)|(b<<16);
int a2 = c&0xffff;
int b2 = c>>16;
assert(a==a2 && b==b2);
>>
Does class Loo extend ShittingStreet?
>>
Who /java/ here?
>>
University student doing coursework at 5:30am here. Doing some 501 Darts program for C++ class that I have absolutely no clue how to do. How fucked am I /dpt/?
>>
>>54162140
Java is currently #1 on the TIOBE index. Fuck yea Java!
>>
>>54161544
The syntax is:
NAMESPACE_NAME :: OBJECT_IN_NAMESPACE

'std::cin' is inside the "std" namespace as well. C++ comes with a lot of things in the std namespace, but you have to include them with the #include directive at the very top of your file.
For instance:
#include <string>
// contains the std::string class
std::string my_string = "wow!";

#include <map>
// contains the std::map class
std::map<int, std::string> foo;
int main () {
foo[3] = "hello";
foo[4] = "world";
std::cout << foo[3] << std::endl;
return 0;
}

#include <string>
#include <utility>
// contains the std::pair class

std::pair<std::string,std::string me("john", "doe");
int main () {
std::cout << "my first name is: " << me.first << std::endl;
std::cout << "my lane name is: " << me.second << std::endl;
return 0;
}

I'm not necessarily asking you to understand the above code examples but they show some of the features of the standard library (std).

"using namespace X;" makes it so all "X::y" can be abbreviated to just "y".
>>
>>54159951
If you're using something like an embedded system, you would probably use interrupts, which by definition run outside of the main function.

Depending on the application, you could have a program that only uses interrupts, and have a main function that consists of

int main(void)
{

setup();

while (1);

}
>>
How do I study algorithms and data structures? What's the best language to practice implementing them with?
>>
File: dc6BMpxc9.gif (1 KB, 235x219) Image search: [Google]
dc6BMpxc9.gif
1 KB, 235x219
>>54162140
here
>>
>>54159762
struct I { I () { std::cout << "hello, world!" << std::endl; } }; static I _;
>>
>>54162198
If you're asking this, then you're obviously too lazy to just learn it. It literally doesn't matter what language. Preferably, use psuedocode instead of any language at all.
>>
>>54162198
ML and by reading Okasaki's Purely Functional Data Structures
>>
>>54161907
lab.configure(text=lab['text'] + str(val))
>>
>>54162211
C++ is shit
>>
>>54162198
Read a book nigger. I just learned Data and Algos through Wikipedia one summer. Wherever the information is available is the best location.

Any language is good, I learned with C and I'd recommend it because it's quite the challenge. But if you don't know C then just do it in whatever language you are comfortable with.
>>
I'm finishing up my first course in Java and programming in general. I always feel like there might be a better way of doing things when I'm doing my projects and we have more freedom.

Like, it works, but in the back of my mind I'm thinking there might be a better way of doing it, maybe even a way the teacher may prefer or just makes everything more efficient.

Do I let that eat up my time, or should I just finish the project the best I can and learn as I go?
>>
>>54162308
You'll get better
>>
>>54162295
I know C and I've taken a data structure class with C 2 years ago. I want to go over it again..
>>
>>54162211
if you use function pointers or functors you need to make yourself a nice arsenic cocktail tonight. lambdas or named only pls thx
>>
>>54162248
>ML
nice, working on anything cool recently?
>>
>>54162308
I'd say if you have the time to explore how to make things better then by all means do so.
Over-optimising is really fun but you'll learn eventually that it isn't worth it. IMO it's good to know when you can over optimise but choose not to.
>>
What programming language will land me a job?
>>
>>54162391
Java
>>
>>54162308
>Should I put in extra effort to learn and topic better when it's something I'm interested in
Yes, of course. Given you have the time to do so.

>>54162323
Then just do some practice problems. Write your own Data Structures and Algorithms and use them to solve problems. See how using different data structures in certain algorithms make them more efficient. Like using a heap instead of an array in Dijkstra's (or a sorted set god forbid. No one cares about the cost of O(n) updates?).
>>
File: 1437871943266.png (173 KB, 600x600) Image search: [Google]
1437871943266.png
173 KB, 600x600
More like this?
>>
Python lists are fucking shit.
>>
>>54162415
>__builtin_popcount(n)
>>
>>54162331
cool, but what does it have to do with the post?
>>
>>54162415
Yawn
int sum2(int n)
{
int ret = 0;
while(n > 0)
{
ret += n % 2;
n /= 2;
}

return ret;
}
>>
>>54162430
No you're fucking shit. Python's sets and maps are shit.
>not immutable by default
>no immutable map available
>so no arbitrary nesting of data structures
>>
>>54162415
int sum2(int n) {
int result = 0;
while (n > 0) {
result += n & 1;
n >>= 1;
}
return result;
}
>>
>>54162479
>what is frozenset
>i cant implement my own frozendict

Can anyone on /g/ program? Jesus christ.
>>
>>54162469
WRONG.
-1 should equal 16 or 32 depending upon machine.
>>
>>54162469
rekt on negative numbers, m8
>>
>>54162415
sum2 :: Int -> Int
sum2 0 = 0
sum2 n = q + sum2 p
where
(p,q) = n `divMod` 2
>>
>>54162415
>bet i can trick you into doing my homework.jpg
>>
>>54162493
It should be included by default. I mean what the fuck is coverage and orthogonality?
>>
>>54162415
Here, I literally wrote this in 30 seconds:
int sum2(int n) {
int sum=0;
int nBits = 32;
for(int i=0; i<nBits; i++) if(n&(1<<i)) sum++;
return sum;
}
>>
>>54162484
Nope. Can't handle negative numbers.
>>
>>54162495
>>54162501
int sum2(unsigned int n)
{
int ret = 0;
while(n > 0)
{
ret += n % 2;
n /= 2;
}

return ret;
}

:^)
>>
>>54162506
wow i didn't know know about divMod. now i feel dumb as hell
>>
>>54161705
you just need to know each family once
Like C and you are good for majority or ML and you are good for Haskell
>>
>>54162559
ML will get you about 80% through Haskell, but Haskell is more than just another ML language.
And then theres stuff like Coq...
>>
>>54162536
Just change it to while(n) and it should work, right?
>>
>>54162553
Haskell the shit
>>
>>54162576
Sure but you won't need to have your hand held
>>
>>54162576
yeah, ML wasnt enough for me to get into Haskell straightaway. Coq is more theory that you need to know than anything, though
>>
>>54162579
No. Shifting signed numbers does signed shift. It will loop forever.
>>
>>54162189

The only one I think I understand is the first example. I believe you are declaring string my_string as "wow!" What is the advantage of using this as opposed to

string my_string = "wow!";
>>
>>54162579
It hangs when I do it
I'm too tired to figure out why though
Night lads
>>
>>54162415
le popcount face
>>
>>54162622
They are literally identical, in functionality.
The thing is that if you "use namespace std;" then it prevents you from naming any of your own variables or classes "string" because that name is already used.
Also, even if "string" isn't a problem, "use namespace std" imports EVERYTHING from std, so if there are other clashes, like with "pair" or "map", then you'll have issues with those.
I never "use namespace std" but it's kind of a matter of personal style.
>>
New challenge: check if a number is perfect number. (N is perfect if the sum of all its divisors except itself is N.)
>>
>>54162660
>do my project euler for me!
>>
>>54162415
int somefunc(uint64_t value) {
int sum = 0;
while (value) {
sum += value & 1;
value >>= 1;
}
return sum;
}
>>
>>54162415
pretty easy really
int sum2(int n)
{
int ret = 0;
unsigned int j = n;
while (j != 0)
{
ret += j & 1;
j >>= 1;
}
return ret;
}
>>
>>54162660
literally the easiest shit, got anything a 5 year old couldn't do?

int is_perfect(int n) {
int i, sum = 0;
for (i = 1; i < n; i++) {
if (n % i == 0) sum += i;
}
return sum == n;
}
>>
>>54162657

So basically this is a way to access part is the standard library without importing all of the assets which would otherwise hobble customization and optimization?
>>
>>54162727
no
when you include something it "imports" it all
using use declarations is entirely syntax, deciding if you want to use std::cout or cout
>>
>>54162727
if you know python:

import thing
#include <thing>

fromt thing import *
#include <thing>
using namespace thenamespaceinthing;
>>
>>54162727
it would only "hobble customization", optimization has nothing to do with it.
If would restrict you or cause potential bugs, e.g.

#include <map>
#include <vector>
#include <string>

using namespace std;

struct map {
int treasure_location;
int start_location;
std::vector<int> traps;
};

// error! which "map" are we talking about?
map<string, map> all_maps;
>>
>>54162746
So I could just swap
cout << 


With
 std::cout << 
>>
>>54162760
from*

>>54162770
yes
>>
>>54161705
Need? No more then your job description says, probably a bit less.
If unemployed see >>54162559 or >>54161728.
>>
>>54159551
now I know why no one replied

trying to generalise cellular automata in D. Figured I'd implement a matrix class to help
apparently this is how you implement the 2d slice x[a..b, c..d]
matrix!T opIndex(size_t[2] rs, size_t[2] cs)
{
auto ret = matrix!T(rs[1]-rs[0], cs[1]-cs[0]);

// I should use a memcpy for this shouldn't I?
foreach (col; cs[0]..cs[1])
foreach (row; rs[0]..rs[1])
ret[row-rs[0], col-cs[0]] = this[row, col];

return ret;
}

size_t[2] opSlice(size_t dont_know_what_this_is_for)(size_t a, size_t b)
{
return [a, b];
}


what the fuck?
>>
File: thefuck.png (76 KB, 1920x1080) Image search: [Google]
thefuck.png
76 KB, 1920x1080
Doing Riemann's sum calculator (dont worry about menu code below it works, etc). Something in the loop code for calculating is fucked. Any ideas?
The initial x value checks out and the width is right, the loop works. I've narrowed it down to the increment.

I'm getting a final area of like 9.5x10^8 when for my example inputs should be an area of 173....
>>
>>54162415
#include <stdio.h>
#include <stdint.h>

int sum2(uint32_t n)
{
int sum = 0;

for (int i = 0; i < 32; i++)
{
if (n >> i & 1)
{
sum += 1;
}
}

return sum;
}

int main()
{
printf("%i\n", sum2(0));
printf("%i\n", sum2(1));
printf("%i\n", sum2(2));
printf("%i\n", sum2(3));
printf("%i\n", sum2(7));
printf("%i\n", sum2(4575));
printf("%i\n", sum2(0xffffffff));
return 0;
}

Easy.
>>
>>54162151
LMao, done squad. Ease$. I should probably learn programming one of these days.
>>
>>54162773
>>54162763

Thank you. I don't think I still understand it 100% but this is my first time ever trying. I'll approach my prof next week over it for clarification and hopefully he won't make me wait until 256.
>>
I have an app idea and Ill give 90% stake in my company to the code monkey that develops it
>>
>>54162856
pitch it here
>>
>>54162936
without an NDA? ha!
>>
hello i am from lativa
>>
>>54162962
Prove it
>>
>>54162830
Right lads, since I don't go into uni, throw me books and projects I should look at/complete so uni programming becomes easier.
>>
>>54162819
Did you solve it yet? Your code for "rectarea" looks fine. Might be a computer precision issue if you're making "rectangles" really large, although I kind of doubt that. I bet the bug is somewhere else.
>>
File: gfT5h68.webm (2 MB, 640x368) Image search: [Google]
gfT5h68.webm
2 MB, 640x368
Ask your much beloved programming literate anything (IAMA)

>>54162415
Not using hamming weight,

unsigned int sum2 (unsigned int n)
{
unsigned int const t[] = {
0u, 1u, 1u, 2u,
1u, 2u, 2u, 3u,
1u, 2u, 2u, 3u,
2u, 3u, 3u, 4u
};

unsigned int s = 0;

while (n)
{
s += t[n & 0b1111];
n >>= 4;
};

return s;
}


>>54161705
One (Scheme)

>>54159551
Sauce ?
>>
>>54160216
Just make a few variables that are actually classes. This is fucking Java, everything is a class. Main is a class. The variables are classes. The graphics are classes. Android is a class. Your phone is a class. You're a class. The structured learning environment you're turning this in for is a class.
>>
>>54162827
you don't have to go up to 32 if you know n is less than 2^32, etc.
>>
>>54163024
binary literals are a gnuism
>>
>>54163005
Not yet.. still trying to pin point it. That's what I thought too it looks fine.... Not sure where the problem lies. I'll have to look around.

I've been putting in 5 for the rectangles and a=2 b=3. So not large numbers by any means.
>>
File: hydrophobic_sand.webm (318 KB, 352x264) Image search: [Google]
hydrophobic_sand.webm
318 KB, 352x264
>>54163063
GNU C > C
>>
>>54163063
could be c++14
>>
>>54162616
So cast to unsigned int?
>>
>>54163024
Nichijou
>>
>>54163069
Oh I got it.
You should just be saying "double x = a;" instead of "function_1(a);" It's so obvious when you see it, but so sneaky when you don't.
>>
I'm convinced guys, clang >>>>>>>>>>>>>>>>>>>>>> satan's thorned cock >>>>>>>>>>>>>>>>>>gcc

Clang is better in literally every way
>>
>>54162856
Why don't you change your wording of code monkey? Why not code autist.
>>
File: testover.webm (3 MB, 684x385) Image search: [Google]
testover.webm
3 MB, 684x385
>>54163090
Thanks.

It's the same anime as this webm, no ? (never knew the source till now)
>>
>>54163113
MUH
BENCH
MARKS
MUH
GAHNOOO
>>
>>54163093
I get what you mean, but x initially is going to have to equal to f(a) not just the value a. Because I need to get the initial height.
>>
>>54163113
Of course. LLVM is awesome.
>>
>>54163134
ill only give 89% to a code autist
>>
File: 3pnkbuj.jpg (32 KB, 720x405) Image search: [Google]
3pnkbuj.jpg
32 KB, 720x405
>>54163113
>Clang is better in literally every way
C++ clang++:                    5.518077517 seconds time elapsed
C++ G++: 4.659448453 seconds time elapsed
>>
>>54163144
No, "x" is the x axis. "f(x)" is the height. Always.

F(b) - F(a) = lim[N -> infyt] sum[k = 1 -> N] f(a + k dx) dx
where dx = (b - a) / N
>>
WHat exception do i use for this program if the user enters shit that's not numbers, (like $,OUG*$, etc)

public class MouseTail{
public static void main(String[] args){

try{
String first = JOptionPane.showInputDialog("Enter first cock");
String second = JOptionPane.showInputDialog("Enter second dike");

double one = Double.parseDouble(first);
double two = Double.parseDouble(second);
double sum = one + two;
JOptionPane.showMessageDialog(null, "The sum is " + sum,
"Sum of Two Integers", JOptionPane.PLAIN_MESSAGE);
} catch(){

}

}
}
>>
>>54163157
>++
>>
>>54163135
Yes, it's a pretty relaxing show for how humble it is. I'd recommend watching it even if you think anime is retarded.
>>
database ranking

postgresql >>> sqlite3 > berkeley db > couchdb > h2 >>>> mysql
>>
>>54163169
create an InvalidInputException? (or some other name)
>>
>>54163166
Jesus Christ you are right. Bingo.
>>
>>54163157
More time = more runtime optimization
>>
>>54163195
preceded by oracle and mssql of course
>>
>>54163195
what about mariadb?
>>
>>54162308
>Do I let that eat up my time, or should I just finish the project the best I can and learn as I go?
the fundamentals are what's important, but you should absolutely research and experiment on your own. You'll be doing a lot of that if you ever program as your job, and it will make you a more efficient programmer overall, regardless of what language or technology stack you ultimately decide to use.
>>
>>54163157
>1 second difference
DUDE SO MUCH FASTER LMAO
You're pathetic
>>
>>54162415

        public static int Sum2(int n)
{
return Convert.ToString(n,2).Count(c => c == '1');
}

meme languages are fun
>>
>>54163328
When seconds count police are minutes away.
>>
>>54163352
>>
File: large.jpg (21 KB, 600x450) Image search: [Google]
large.jpg
21 KB, 600x450
So my friend has some shitty Toshiba laptop and the left third of the screen swaps with the right third. The middle third stays fine.

Now here is my question. Is there some code I can write or a preexisting program that can solve this issue?
Pic related kinda similar but not rly
>>
>>54163371
install gentoo
>>
>>54163328
>pathetic
~20% faster.
>>
>>54163371
>a preexisting program that can solve this issue?
the proper graphics drivers
>>
>>54163371
>>
File: Untitled.png (7 KB, 641x129) Image search: [Google]
Untitled.png
7 KB, 641x129
Does this crash your python?
print 'Fran smells like dirty socks. '*10000
>>
>>54163422
It's a hardware issue with the display itself. I verified this with external monitors whcih are fine

I was wondering if can just code my way outa the issue. He doesn't wanna spend money
>>
>>54163458
>2.7
wew lad
>>
>>54163517
I like to live dangerously
>>
>>54163371
Try booting a Linux LiveCD, maybe that's just Windows being Windows...
>>
Hey /g/,

Been at this homework due tomorrow for an hour and I'm literally one step away from being able to sleep.This enter button basically reads the label and if it's equivalent to the string "54321"(meant to be a password), it'll say it's unlocked and otherwise it'll set an alarm. No matter what I do it doesn't wanna work. It obviously means that the label isn't being read as "54321" and I can't find the problem. Help would be appreciated.
>>
>>54163458
Nope. Not in 2.7 or in 3.4
>>
>>54163463
i forgot about break;

someone tell me why break is bad way to close program.
>>
>>54163579
I have no familiarity with the framework you're using, but maybe you need to test against lab.text, not lab?
If that doesn't work, print out the value of lab to make sure it's what you think it is.
>>
>>54157955
>what's gonna make me the most money
>hurr learn some shitty webshit framework that's way past its peak because reasons
fuck you retard
>>
>>54159551
Apparently /sci/ can't even read a text file. Lets laugh at them >>>/sci/8021375
>>
rust is a waifu-tier language :3
>>
>>54162415
ubyte sum2(ulong n)
{
ubyte sum = 0;
while (n)
{
sum += n & 1;
n >>= 1;
}
return sum;
}

7.sum2.writeln;
=> 3
>>
>>54159816
> hip trendy new language

/g/'s problem is that it's not the hip trend old language.
>>
File: smug alexandrescu.jpg (94 KB, 960x540) Image search: [Google]
smug alexandrescu.jpg
94 KB, 960x540
>>54163938
>not D

>>54163943
is that a repl? The fuck?
>>
>>54163955
No, I just left out the pointless main function.
>>
>>54163955
>not D
why not both?
i think i could find a use for D alongside Rust~
>>
>>54159743
>>#include<iostream>
>>void print();
>>int main(){
>> std::cout << "Why should we?\n";
>> print();
>> return 0;
>>}
>>void print(){
>> std::cout << "It's simple shit.\n";
>>}
>>
>>54163169
if/else statement?? Profit?
>>
>>54164021
no im learning exception handlng
>>
I just spent an hour fucking around with android studio trying to figure out what the fuck was wrong. Turns out I can't use mysql directly with android ;_;
>>
I'm writing something in JavaScript and it's made me realise how much I hate JS. Not to mention the fact no one teach any way to actually use it. It's a clusterfuck with everyone using it their own way.
>>
>>54164096
Your diagnosis is retard.
>>
>>54164099
your diagnosis is >>>/g/wdg
>>
merging systems in an enterprise.
>>
>>54164106
>fuck i cant figure out this language REEEEEEEEEE
>never mind its for webshits below me haha

this is your 2-standard-deviations-below-average ass. Even the most poopy pajeets can grasp JS.
>>
>>54164115
There is no correct way to use JS. Everyone who uses it abstracts it out to all fuck and sometimes write in an entirely different language.
>>
>>54164115
No idea how people can't figure out JS of all languages. It's supposed to be easy.
>>
>>54164125
There is a correct way to use JS and it's called not being a complete retard
>>
>>54164131
>>54164128
Writing JS in a single function isn't using it correctly.
Thread replies: 255
Thread images: 29

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.