[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
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: 33
File: 1865428-revycasualmurder.png (520 KB, 853x480) Image search: [Google]
1865428-revycasualmurder.png
520 KB, 853x480
Previous thread: >>53610616

Lazy ass programmers thread

What are you working on half-assedly?
>>
Help me out please

How can I find a project or community to join and contribute to that will actually value me?

I have some programming skills.
>>
>>53617152
>Requires validation from others
You're weak
>>
please do not use an anime image next time, thanks.
>>
>>53617152
>special snowflake syndrome
>>
>>53617190
When you make your own thread you can have any image you want. In this case, deal with it faggot.
>>
>>53617125
half-assing my way through work
The hardware I'm working with doesn't have any documentation, so I have to look at a similar piece of hardware for documentation and guess and check when things don't work.
>>
>>53617125

Just making a simple account class in Java :^)
>>
First for pl/sql
>>
>>53617239
Noice. Embedded systems?
>>
>>53617125

All my classmates think I'm a whiz kid because I ask a lot of questions, but I'm probably one of the worst in my class. I second guessed my degree choice but fuck it, I like programming, even if I'm not the best at it.
>>
>>53617264
Yeah.
It's fun most of the time, but then you run into some terrible protocol or have to reverse engineer something, and then you drink yourself into a coma so you feel better.
>>
What does /dpt/ think of Rust? I've found that some people in other sites think it's made by web developers that like CSS, HTML and Javascript.
>>
>>53617384
SJW
>>
>>53617334
God damn it I want to be where you are. I'm still a college cuck trying to get an internship. Fuck this shit.
>>
Newfag to C, what is wrong?
#include <stdio.h>
int main()
{
int sum, con, n ;
printf("input n\n");
scanf("%d", &n);
for(con=1;con<=n;++con);
{
sum+=con;
}
printf("Sum=%d", sum);
}
>>
You are given a 3 × 3 Tic-tac-toe board stored as a two-dimensional array. Find out the winner of the game, or return ' ' if there is no winner.


char TicTacToe(char[][] board)
{
for(int i = 0; i < board[0].length;i++)
{
if(board[i][0] == 'x' && board[i][1] == 'x' && board[i][2] == 'x' )
return 'x';

if(board[0][i] == 'x' && board[1][i] == 'x' && board[2][i] == 'x' )
return 'x';

if(board[i][0] == 'o' && board[i][1] == 'o' && board[i][2] == 'o' )
return 'o';

if(board[0][i] == 'o' && board[1][i] == 'o' && board[2][i] == 'o' )
return 'o';
}

if(board[0][0] == 'o' && board[1][1] == 'o' && board[2][2] == 'o' )
return 'o';

if(board[2][0] == 'o' && board[1][1] == 'o' && board[0][2] == 'o' )
return 'o';

if(board[0][0] == 'x' && board[1][1] == 'x' && board[2][2] == 'x' )
return 'x';

if(board[2][0] == 'x' && board[1][1] == 'x' && board[0][2] == 'x' )
return 'x';

return ' ';
}

>>
>>53617515
You need to initialize variables in C, otherwise they will have random garbage. Set sum to zero first.

You also should handle user input better, because if someone enters a non-numeric character, your program will crap out.
>>
>>53617529
looks like a project I did in high school
>>
>>53617688
rate my code tho
>>
>>53617674
All I wanted as to take a number a n! it :(. It still doesn't work even though sum=0.

#include <stdio.h>
int main()
{
int con, n ;
int sum=0;
printf("input a number n\n");
scanf("%d",&n);
for(con=1; con<=n ;++con);
{
sum+=con;
}
printf("Sum=%d", sum);
return 0;

}
>>
>>53617515
remove the semicolon in the for statement
>>
File: doge 2.jpg (107 KB, 600x804) Image search: [Google]
doge 2.jpg
107 KB, 600x804
>>53617718
And n! it*
>>53617729
Jesus fuck I'm stupid and dyslexic. Really..
>>
>>53617718
#include <stdio.h>
int main()
{
int con, n, sum = {0};
printf("input a number n\n");
scanf("%d",&n);
for(con=1; con<=n;con++)
{
sum+=con;
}
printf("Sum=%d", sum);
return 0;
}
>>
>>53617799
C would be much better if you could
#pragma pythonic-indenting

at the beginning of your code. curly brackets and semi-colons are deprecated, and lead to buggy code.
>>
>>53617384
Rust is pretty awesome. It's a bitch to learn but once you got it everything you make is blazing fast and safer than a retarded baby in a room full of pillows.
>>
Help me out please

How can I find a project or community to join and contribute to that will actually value me?

I have some programming skills.
>>
File: 1429039187363.jpg (58 KB, 778x720) Image search: [Google]
1429039187363.jpg
58 KB, 778x720
>got FFI with Vulkan to work no problem in Haskell
>any call from Rust to Vulkan causes a segfault
>>
>>53617729
and this is just one of the reasons why you don't put a newline before the opening brace
>>
>>53617957
It's because I'm on Windows and Vulkan only builds with MSVC, isn't it?

Do I really have to load everything in dynamically?
>>
>>53618140
fucking this
>>
>>53618140
>you shouldn't make this style choice because of an easily avoidable error

Okay bud
>>
>>53617125
An 10th in-memory database using Node.js.
>>
>>53618245
>>>/g/wdg
>>
>>53617152

If you have no creativity and just want a project, find something that's abandonware and build upon that.

>>53618191

I'm actually considering requiring all if statements to have braces in my projects, even when they're one liners, because of the number of errors that have been caused by them (i.e. the Apple goto fail bug), despite it being easily avoidable.
>>
>>53618267
Node applications aren't run in a browser.
>>
>>53617190
Fuck you, Black Lagoon was amazing.
>>
>>53618278
HTML isn't programming, get the fuck out
>>
>>53618278
it's still webshit, backend dev goes in /wdg/ too
>>
>>53618278
Javascript has forever etched itself and it's descendants into the category of weebdev
>>
>>53618293
Well I'll go but I'll just correct you before I go. My in memory database has nothing to do with a web backend or web at all even, it's just a project written in Javascript.
>>
Pleb here, working with stacks with ArrayLists for the first time on java

/g/, in what occasion would an insertion to a stack could it cause an exception?

I'm working on a project and the teacher is asking me to do a push method and make it throw an exception

I have an idea in C++ that I'd use try{} and catch(bad_alloc e) which I guess it's what can go wrong

tl;dr What type of exception should I catch in Java when pushing an item into an ArrayList?
>>
>>53618333
>javascript
just fuck off already
>>
>>53618336
Java isn't real programming either.
>>
>>53618333
Java isn't real programming either.
>>
>>53618290
>>53618293

Maybe if we want to kick the web developers out, we should change our name to "Desktop Programming Thread"?
>>
>>53618336
>What type of exception should I catch in Java when pushing an item into an ArrayList?
You could catch it as just an Object, but better check the docs, it will tell you.
>>
>>53618336
if your array is full and at max capacity
>>
>>53618336
Java isn't real programming either.
>>
>>53618336
if it is a circuller buffer, then you can throw buffer_full_exception or something. if it stack extends as you push then not_enough_memory allthough this one will be harder to produce
>>
>>53618359
>>53618367
JAVA ISN'T PROGRAMMING MIND

>>53618336
GET OUT
>>
>>53618336
Just catch exception e and you'll get any exception that could occur. You don't have to be specific.
>>
>>53618378
>>
>>53618372
You should name it Desktop Programming Thread (Node.js doesn't count)
>>
>>53618270
>I'm actually considering requiring all if statements to have braces in my projects

I already do that.. mostly. The only time I don't is if I'm working on a project that doesn't use braces for one-liners.
>>
>>53618389
I'm the Node.js guy but I didn't type that Java part, I just found it hilarious as fuck.
>>
>>53618395
>>53618270
how interesting, please tell us more about your coding conventions name fags
>>
>>53618417
>coding
>>
>>53618427
>java
>>
>>53618336
Post your assignment we will all help do your homework especially Ruby and OSGTP
>>
>>53618438
>memes
>>
File: NY-Comic-Con-Avengers-812x522.jpg (136 KB, 812x522) Image search: [Google]
NY-Comic-Con-Avengers-812x522.jpg
136 KB, 812x522
>>53618417
>tell us more about your coding conventions name fags

I don't go to conventions, they're for turbo-nerds.
>>
>>53618448
>java is a meme meme
>>
>>53618449
what's the deal with dressing up as fictional characters is it some kind of fetish like with furfags or something
>>
>>53618465
>python isn't shit meme
>>
Almost all programming languages are garbage, and the rest are only partially garbage with some redeeming elements.
>>
>>53618471
There is literally nothing wrong with being a furry it actually helps to program things being a furry
>>
>>53617125
Just made a mobile botnet client, server and naive crypter in golang.
More than 200.000 infected machines (85% mobile) in 12 days.
>>
>implying any language other than haskell and ocaml aren't shit

if you primarily program in a non-functional language you should just kill yourself
>>
>>53618504
>Says the guy who only programs in Java
>>
>>53618513
haskell is literally shit and ocaml is a shitty meme
>>
>>53618535
>muh classes
>muh object oriental cartoons
>muh operator overloading

KEKE
>>
>>53618513
Haskell's got a lot of bad parts. Its type system is a mishmash of extensions upon extensions upon extensions. No totality checking, and lots of standard library functions are partial. On the topic of the standard library, it's in a pretty bad state, especially with respect to functors and all of their compatriots.

I still like it though, it's worlds ahead of every other practical language (so not counting academic or immature projects like Idris) out there in all respects but efficiency.
>>
>>53618535
le true sepples language
>>
>>53618513
Oh, and I haven't used OCaml myself but I'd put it about Haskell's level from what I've seen of it.
>>
>>53618571
>it's worlds ahead of every other practical language
lel, did it overflow to the other side or what.
>>
Hello, this morning I came across a code similar to this one and I've been trying to understand how it works. I was told that it just cast to an integer, but it's not enough for me. Mind anyone telling me what this is called? I want to search for further information but looking for "changing the integer value of characters inside an array" gives me no useful results.
char buf[] = "Hello";
unsigned char test[UCHAR_MAX] = {
['e'] = 1,
};

printf("%d\n%d\n", test[(unsigned char)buf[1]], test[(unsigned char)'z']);
>>
>>53618631
This is why C isn't considered real programming but rather rain dancing around a compiler. Why do you need to know this if you just want to write a program that does something simple like changing a character to an int?
>>
>>53618417

I've taken to programming using the stroustrup style for C and C++. Basically, opening brace only goes on a new line for functions, and otherwise shares the line with the if/for/struct/whatever keyword. For if and else, the else keyword is not placed on the same line as a closing brace. This allows for easier commenting of these blocks if necessary.

// comments look much nicer
if (condition) {
do_thing();
}
// if they are consistent like this
else {
do_other_thing();
}


For tabbing, I use hard tabs for indentation and spaces for alignment, using a "smart tabbing" technique that allows the code to maintain alignment regardless of tab width. My default tab width in my editor is usually 4.

I sometimes tend to put function types on a separate line from the name and argument(s). For example:

static inline bool
does_thing(int thing)
{
// ...
}
>>
>>53618631
god designated initializers are awful, thankfully they are not in C++

it justs sets 'e'th element to 1, I am assuming that code prints 1 0

buf[1] is 'e' test[buff[1]] is 1, all other test values are 0
>>
>>53618703
We need a /jdpt/ and /cdpt/ and a /fdpt/ for Java, C, and functional programming. This is because nobody can get along. In fact there should be separate boards for each one.
>>
>>53618770
That's not true as a Java programmer I get along with all of you other programmers just fine
>>
>>53618770
we already have /sqt/ for java
>>
>>53618705
based stroustrup
>>
>>53618792
>>
>>53618770
we actually used to have a lisp general
>>
>>53618721
>designated initializers
Thanks, that was what I needed.
And yes, that's what it prints.
>>
>>53618939
INITIALIZERS
>>
>>53618939
uh, I can understand open defecation but what is this
>>
I wrote compile-time list comprehension in C++. I feel dirty. I'll post the code if anyone is interested.
>>
>>53618832
it's on lainchan now, but lainchan is slow as fuck so nobody really posts in those anymore
>>53618770
i don't mind C in my /dfpt/
>>53618962
the garbage around them helps them mask the smell of shit on the road
also they can get their daily meal from the sewage at the same time
>>
>>53618972
sounds pretty cool, is it using a lot of templates? desu despite how much templates can be fucking insane to use, they're probably one of the most versatile language features i've seen
>>
>>53618939
We see all these disgusting old men doing this but can we get some pictures of cute Indian girls doing some designated pooing?
>>
>>53619028
but anon, girls don't poop
>>
>>53619048
My wife's daughter does
>>
>>53617152
codingame, you may even get a job
>>
File: 1415445272011.jpg (69 KB, 542x637) Image search: [Google]
1415445272011.jpg
69 KB, 542x637
>>53619048
and that's why they're so full of shit
>>
>>53619060
It's because her father is dirty nigger
>>
Best place to learn C#?
>>
>>53619158
buy some proprietary book
>>
>>53619158
iPhone devs
>>
File: 15367858765.jpg (21 KB, 500x500) Image search: [Google]
15367858765.jpg
21 KB, 500x500
Can't understand it for the life of me.
int iexp(int x, unsigned n) {
int p, y;

y = 1;
p = x;
while(1) {
if (n & 1) y = p*y;
n = n >> 1;
if (n == 0) return y;
p = p*p;
}
}
>>
>>53619309
take some example inputs and write it out on a piece of paper
>>
Going from C to Python is spazzing me out. Dynamic typing is uncomfortable.
>>
>>53619336
i hate this C+python meme

C++ and java is a more sensible middle ground

anyway i'm going to bed so i won't argue with you spergs

g'nite
>>
>>53619309
p = x;


pointless.

Infinite loop, if the whatever the binary rep of n is AND'd with 0b0001 is > 0 set y = p*y.

Shift n to the left by 1. Loop until n == 0 (meaning all bits are shifted out)
>>
>>53619358
Nope, making an app in python just because I need a quick gui thingy. It's whatever.
>>
>>53619017
LOTS of templates
http://pastebin.com/PXnMm3TW
>>
>>53617529
Look up breadth first search
>>
>>53619293
>>53619288
Thanks for nothing senpai
>>
>>53617701
It's shit.
>>
>>53603476
I improved my code a bit. Is there a better way to do this in C++?
string::size_type count_vowel(const string &str)                                  
{
auto size = str.size();
decltype (size) count = 0;
static unsigned char letters[UCHAR_MAX];
letters['a'] = 1; letters['A'] = 1;
letters['e'] = 1; letters['E'] = 1;
letters['i'] = 1; letters['I'] = 1;
letters['o'] = 1; letters['O'] = 1;
letters['u'] = 1; letters['U'] = 1;

for (decltype (size) i = 0; i < size; i++)
count += letters[(unsigned char)str[i]];
return count;
}
>>
>>53619309
It makes more sense recursively
int iexp (int x, unsigned n) // = x^n
{
return iexp_(1, x, n);
}

int iexp_ (int a, int b, unsigned n) // = a * b^n
{
// a * b^(2x + 1) = (a * b) * (b ^ 2x)
if (n % 2 == 1)
return iexp_(a * b, b, n - 1);

// a * b^2x = a * (b^2)^x = a * (b * b)^x
else if (n != 0)
return iexp_(a, b * b, n / 2);

// a * b^0 = a * 1 = a
else
return a;
}
>>
>>53619739
string::size_type count_vowel(const string &str)
{
static const string letters = "aeiouy";
string::size_type count = 0;
for (char c : str)
count += letters.find(to_lower(c)) != string::npos;
return count;
}


I have not tested it, might not compile because of the static initialization or the ligature on "find".

I just realized you tried to get a computationally less expansive method, but, you're initializing your array on every single call, where it should only be initialized once.

The lookup table is pretty much needlessly big, for the problem it's trying to solve. You could reduce it by converting each character to a specific subset of the ascii (lowercase, for example) and applying an offset.
>>
>>53618509
How does it spread?
>>
Anyone know of a good resource for learning how to get c++ custom node.js modules to work in Electron? Sorry for asking to be spoonfed, I've been killing myself over trying to get this to work and I just want to end it
>>
typedef int sq;
typedef sq board[9];

#define EMPTY ' '
#define CHARX 'x'
#define CHARO 'o'

/*
0x00001 0x00004 0x00010
0x00040 0x00100 0x00400
0x01000 0x04000 0x10000
*/
int states[] = {
0x10101 /* 100 010 001 */
0x01110, /* 001 010 100 */
0x01041, /* 100 100 100 */
0x04104, /* 010 010 010 */
0x10410, /* 001 001 001 */
0x00015, /* 111 000 000 */
0x00540, /* 000 111 000 */
0x15000, /* 000 000 111 */
};

sq ttt_winner (board b)
{
int state = 0, masked;

int i;
for (i = 0; i < 9; i++)
{
if (b[i] == CHARX)
state += 1;
else if (b[i] == CHARO)
state += 2;

state *= 4;
}

for (i = 0; i < 8; i++)
{
masked = state & (states[i] * 3);

if (masked == states[i] * 1)
return CHARX;
if (masked == states[i] * 2)
return CHARO;
}
return EMPTY;
}
>>
>mfw i try to build my program on all my linux machines and my makefile works perfectly every time

why is linux so comfy
>>
>>53617125
Implementing A* search in unity using C# scripts. Learned C#, basically Java
>>
>>53620026
It compiles and works. The only thing I changed was to_lower() --> tolower(). I'm quite impressed with your code, anon.
>>
>>53620402
>>53620026
>>53619739

#include <stdio.h>
#include <stdlib.h>

int isvowel(char c) {
switch(c) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
return 1;
default:
return 0;
}

return 0;
}

int main(int argc, char** argv) {
char c;
int vowels = 0;

while(1) {
c = getchar();
if(c == EOF) {
break;
}
vowels += isvowel(c);
}
printf("Vowels: %d\n", vowels);

return EXIT_SUCCESS;
}
>>
>>53620655
that is beautiful
>>
>>53620655
this is the best way. Most readable and simplest.
>>
>>53618703
>C isn't considered real programming
butt blasted web "dev" detected.

>>53617125
A quick hex dumper in C:
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {

if(argc <= 1) {
puts("Usage:\nHexDump <file_to_dump> <file_to_save_to>");
puts("Specifing a file to save to is optional.");
return(0);
} else {

FILE *d;
int x, y, byte;

d = fopen(argv[1], "r");
if(!d) {
printf("Unable to open '%s'\n", argv[1]);
exit(1);
}

x = 0;
y = 0;
printf("Hex Dump of: < %s >\n", argv[1]);
printf("Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
while((byte = fgetc(d)) != EOF) {
if(!(x % 16)) {
printf("x%08X | ", y);
}
printf("%02X ", byte);
x++;
if(!(x % 4)) {
printf("| ");
}
if(!(x % 16)) {
putchar('\n');
y++;
}
}

putchar('\n');
fclose(d);
}
return(0);
}

>>
>>53620655
int is_vowel(const char c)
{
const static VOWEL_COUNT = 8;
const static char vowels[] = {
'A', 'E', 'I', 'O', 'U',
'a', 'e', 'i', 'o', 'u'
};
int i;
for (i = 0; i < VOWEL_COUNT; i++)
{
if (c == vowels[i])
return 1;
}
return 0;
}
>>
>>53620788
>8 vowels

Are you stupid?
>>
Godamn you guys, ive embarrassed myself
I could have invoked the first method for everything on the second, why didnt you tell meeee

public boolean isMultiple(int one, int two) {
return two % one == 0;
}

public boolean isMultiple(int one, int two, int three, int four, int five) {
return isMultiple(one,two) && isMultiple(one,three)
&& isMultiple(one,four) && isMultiple(one,five);
}
>>
>>53620798
you're right, how silly of me, that's 4 vowels too many to check
int is_vowel(const char c)
{
const static VOWEL_COUNT = 5;
const static char vowels[] = {
'a', 'e', 'i', 'o', 'u'
};
int i;
for (i = 0; i < VOWEL_COUNT; i++)
{
if (tolower(c) == vowels[i])
return 1;
}
return 0;
}
>>
>>53620808
>10 vowels
>nope it's 8
>okay let's subtract 4
>now it's 5

Go to sleep.
>>
>>53620828
but there's only 5 vowels
>>
Good night AND STOP STARING AT REVY'S THIGHS kthnx
>>
Looking to get into Android Studio to create some basic apps in Java, maybe a Calculator to see how I fair.

Is there any tutorials that step you through the way and I will be able to understand what's going on with the code?
>>
>>53620808
thats really bad c code.
>>
>>53621196
explain
>>
File: window.png (6 KB, 491x223) Image search: [Google]
window.png
6 KB, 491x223
hey /g/
I'm trying to make this Window run while I'm doing some work on my Main thread
I've been reading a lot and it says I need to make a new thread for my window and then send something to a delegate so the window closes itself when I'm done but I kind of don't get that shit at all. Fuck, I should have taken a C# book out from the library.
>>
Just made this to convert a file to BASE64
char table[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

void ToBase64(char filename[1024])
{
int a, b, c;
FILE *in;
in = fopen(filename, "rb");
while(1)
{
a = fgetc(in);
if(a == EOF)
{
break;
}
b = fgetc(in);
if(b == EOF)
{
printf("%c", table[a >> 2]);
b = 0;
printf("%c", table[((((a<<6)&0b11000000)>>2)+(b>>4))]);
printf("==");
break;
}
c = fgetc(in);
if(c == EOF)
{
printf("%c", table[a >> 2]);
printf("%c", table[((((a<<6)&0b11000000)>>2)+(b>>4))]);
c = 0;
printf("%c", table[(((b&0b00001111)<<2)+(c>>6))]);
printf("=");
break;
}
printf("%c", table[a >> 2]);
printf("%c", table[((((a<<6)&0b11000000)>>2)+(b>>4))]);
printf("%c", table[(((b&0b00001111)<<2)+(c>>6))]);
printf("%c", table[c & 0b00111111]);
}
fclose(in);
printf("\n");
return 0;
}
>>
>>53621296
do you even understand what you're bitshifting?
>>
>>53621310
Well since i wrote everything, yes
>>
>>53617247
I half assedley done a PL/SQL assignment a few weeks ago. started it the day before and some how got a 2:1 :L
>>
>>53617674
>random
undefined*
>>
>>53621296
Copy-pasting the same line three times won't get you far.
>>
>>53618544
>Implying
I program in C.
>>
>>53618544
>object oriental cartoons

okay I laughed
>>
>>53621861
OCaml has 2/3 of those and Haskell has the other one.
>>
>>53621834
>tfw i never noticed i could make a function out of those three lines
Well i guess thats what you get when an electronics major tries his hand at programming
Thanks for pointing that out
>>
File: Tell me your secrets Gaben.png (40 KB, 180x228) Image search: [Google]
Tell me your secrets Gaben.png
40 KB, 180x228
Working on a navigation mesh pathfinding system. Is there any rule of thumb for how many nav mesh nodes I want to make the program place in spots other than polygon corners in order to create more natural-looking paths and avoid wall hugging? I looked at Valve's famous L4D image and their placement of nodes outside of object corners/edges just seems completely random to me. Why would you subdivide all of that open space like that?
>>
>>53622303
you make it be like it is and it do
>>
>>53622105
http://www.valvesoftware.com/publications/2009/ai_systems_of_l4d_mike_booth.pdf

It's A*!
As predicted of course.
>>
>>53622303
Without a range, substring prints all characters after what you specify by extracting the rest. In your case substring(2) would remove the 0,1,2 characters from the string.
>>
>>53622374
thank you
>>
>>53622343
this isn't for an AI program this is how to make a predefined path
>>53622105
i assume that your talking about strategy game lvl AI path finding. so what you need to do is draw a straight line to the object and find the shortest path by (lazy method) finding all the possible combinations of paths with every combination of nodes and any path that crosses another object adds another node to skirt around it. select the shortest path.if your codeing this it shouldn't be to hard as long as there arnt too many objects with this path finding, not too many objects to skirt around, and its running on a decent computer. this is taken right out of the first 2 age of empires AIs.
>>
File: Capture.png (5 KB, 343x281) Image search: [Google]
Capture.png
5 KB, 343x281
What gets printed?Why?
>>
>this isn't for an AI program this is how to make a predefined path
sorry misspoke
not how to make an AI path finding program
>>
>>53622524
the answer gets printed and if you dont say print than the computer just dose the problem and dosn't do anything with it. also i dont think you can add strings to intigers could be wrong
>>
>>53622524
numbers
>>
>>53622562
have you tried java
>>
>>53622574
basic java and some others. i half to convert to string or integer depending.
>>
DAMN ITS 1AM
im going to bed
>>
File: 1455489985108.gif (196 KB, 350x263) Image search: [Google]
1455489985108.gif
196 KB, 350x263
>>53622608
never go to bed without faping
>>
does anyone on /g/ studying programming at uni/college actually want to work in an office? or is everyone a startup fag
>>
Anyone have the image where Rasmus (the creator of PHP) admits he has no idea what he's doing? It was a mashup of his quotes and twitter bio or something like that.
>>
>>53622562
>>53622596
>>53622619
are you 12
>>
>>53622630
a twelve year old who know basic programming architicure
>>
>>53617282
>All my classmates think I'm a whiz kid because I ask a lot of questions
Thats how you become a whiz kid.

If you dont ask these questions you wont know the asnwers then you're just as useful as anyone else (not very)
>>
File: 1455494433682.jpg (5 KB, 184x184) Image search: [Google]
1455494433682.jpg
5 KB, 184x184
>>53622630
>>
>>53622663
le tricky hooky meme
>>
>>53622524
I haven't tried it, and I'm not 100% about the semantics of this language, so this is a guess

12 (int+int+int)
345 (string of "3" concatenated with 4 makes string "34" concatenated with 5)
75 (int+int makes int 7 concatenated with a string "5")
756 (int+int makes int 7 concatenated with string "5" makes a string "75" concatenated with string "6")
>>
File: capture.jpg (230 KB, 1024x679) Image search: [Google]
capture.jpg
230 KB, 1024x679
>>53622619
ugh, porn addict

if i cant go to sleep i would do a bunch of push ups/sit ups or take a lap around the block. that puts me to sleep
>>
File: 1458337202838.jpg (209 KB, 756x1100) Image search: [Google]
1458337202838.jpg
209 KB, 756x1100
>>53622619
>>53622630
>>53622697
3/8
>>
>>53622724
its called my penis
>>
>>53622736
dick or gtfo
>>
>>53615366

Hey dependent-typing-in-C++ guy! I love your code! I don't have much time to comment right now tho. Note that you don't need to mark methods which are defined inside their class definition as inline, they are anyway automatically
>>
How much ram do you need on a VPS to run Java Services? Is 512M enough?
>>
File: 1458012774655.jpg (214 KB, 1008x1323) Image search: [Google]
1458012774655.jpg
214 KB, 1008x1323
>tfw know how to do University assignments
>can't bring myself to go through the code and do so much pointless annoying shit
I have made a huge mistake.
>>
>>53622625
>want

I don't think that's the issue. That's what I will be doing if I can't find a job though.
>>
>>53623022
What level are you?

If it's so easy then you have time for personal projects. When you get to OS and Compiler Arch you will feel the burn.
>>
File: Capture.png (6 KB, 353x288) Image search: [Google]
Capture.png
6 KB, 353x288
How do i access the other class without object or making static methods?
public class Add {

public void multiple(int[] arr, int numb) {
for(int x = 0; x<arr.length;x++){
arr[x] = arr[x]+numb;
}

}
}
>>
>>53623162
I think you can just do 'multiple()' without the 'Add.'
that or it's 'super.multiple'

I haven't used java for ages
OOP is dumb
>>
>>53623184
HAHAha
>>
>>53623162
>How do i access the other class without object or making static methods?
You don't. You can't.
Stuff in a class can only be accessed through instances (either directly for public members, or through instance methods for other members) or statically (either by using static methods or directly for public statics members only).
>>
>>53622625

I would rather work at a large, successful company, than work at a startup. More job security, and quite possibly, more benefits.

>>53623132

>When you get to OS and Compiler Arch you will feel the burn.
This shit right here. Same with anything involving machine learning.
>>
>>53623132
I'm 3 years in. I just want to listen to my weeb music and cry, not write a substandard kernel no-one will ever use.
>>
>>53623185
what do you use?
>>
>>53623162
Why is test extending add
what
are
you
doing
>>
>>53623295
oh oops

i was "testing" things
>>
>>53623470
>>
>>53623273
whatever makes the nicest code
usually D-style functional programming / composition / generics
that sort of thing
If I'm doing something that's better implemented with global mutable state I just do it

It's great to get things done quickly and well, but I'd never get anywhere in the industry doing this because they all fell for the OO meme
>>
>>53623424
There's clear and compelling reasons to use OO.
>>
>>53623444
name three
>>
>>53623474
>reasons to use OO.
generic plasticity
eliminates redundancy
inherent abstraction of sensitive data
>>
>>53618270
>requiring all if statements to have braces
I do this too
>>
>>53623493
>generic plasticity
a template system as capable as D's or (even) C++'s make these enormous unwieldy inheritance hierarchies that OO guys like to throw around completely pointless
>eliminates redundancy
the whole paradigm is redundant
what's the first thing you have to write in any java program?
public static void main

a request that the language ignore the entirety of object oriented programming for a moment because every concept it introduces is superfluous
a concession that this whole 'everything is an object' meme is totally wrong
outside of those little toy examples with little pretty shapes inheriting each other, inheritance is almost useless

OO people can't write anything without trying to make up bullshit abstract noun classes so that they can pretend the 100 lines of procedural code they wanted to write is better implemented with 5000 lines of java where every function has parts of its definition hidden in 20 different files so they can 'reuse' it once

>inherent abstraction of sensitive data
What? You mean it does contract programming but worse?

Object orientation is fine in moderation, but when you have a language that demands you take an axe to your code, turn it inside out and stretch its skin over some sickly, meaningless object hierarchy, you get something truly horrifying
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition/tree/master/src

don't pretend every java project doesn't start looking like that after a while

give me three better reasons
>>
File: 141.jpg (46 KB, 276x369) Image search: [Google]
141.jpg
46 KB, 276x369
dammit guys I made a thread on r9k posting an email my teachers sent, but forgot to cover up the address. how fucked am i?
>>
>>53623621
link
>>
>>53623653
NO

im gonna stop posting school related shit on here from now on
>>
File: shreks.png (1 MB, 1587x1600) Image search: [Google]
shreks.png
1 MB, 1587x1600
HOW NICE IS R9K PLEASE???
>>
>>53623621
>r9k

you deserve everything you get and even more
>>
>>53623607
>hurr durr main exists!
>>
>>53623697
/r9k/ is full of autistic neets who hate themselves, but more importantly, hate women and socially well adjusted people for indirectly making their lives hell.
>>
>>53623698
no i dont
IM JUST A KID (over18)
>>
>>53623709
Do you think they would have caught the thread so late? I deleted it like a minute after post

Also would they send an email to the teach? Would they cap the thread and show it?
>>
>>53623726
Only if you gave them a reason to hate your guts.
>>
>>53623754
Well i tried to post as if i was a desperate neet trying to grow out of my neetdom
>>
>>53623766
yeah they hate you then

enjoy your email
>>
>>53623793
okay actually i was asking for help to get a good letter to the teach, it was about a late assignment and I didnt want to mess up the opportunity so i asked for their service. They helped me before on an essay, as if they were professors themselves.
>>
goodnight

i will sleep in fear
>>
>>53622625
>>53623225
I work at a small, successful company. About 35 employees.

All the job security of a big corporation, with the free beer and like 2 months of paid time off of a startup.
>>
/!\ REMINDER /!\

IF YOU CAN COMPILE WITH THIS IN YOUR CODE:
int i = 2.5;


YOUR LANGUAGE IS SHITTIER THAN YOUR WAIFU

/!\ REMINDER /!\

(Uncommented, of course.)
>>
>>53624101
You should not have a waifu if you type this kind of code.
>>
Help me out please

How can I find a project or community to join and contribute to that will actually value me?

I have some programming skills.
>>
>>53624101
If you're language complains about shit like this you don't deserve a waifu. Get a real language that doesn't hold your hand.
>>
>>53624172
Consider getting a job, anon.
>>
>>53624101
What's the problem? Can't into integer arithmetic? Do you need your language to wipe your ass for you too?
>>
>>53624185
This, C/C++ is the Dark Souls 2 of the programming world, and they don't hold your hand like a child.
>>
>>53624075

Sounds pretty cushy. Smaller companies are alright too, as long as they have an already established profit model. My big beef with startups (aside from a large number of them being located in a state that I do not desire to live in), is that most of them tend to fail because they're run by people who can't into business.
>>
>>53619432
learn java

https://docs.oracle.com/javase/tutorial/

but seriously, if you want to learn C#, then buying some textbook is probably your best option. which book, i don't know.
>>
>>53619158
>>53619432
Murach's C# is a good book to start with.

Honestly, the easiest way to learn C# is to do a few simple GUI applications after you understand the basics of using Visual Studio.

At that point, you're just Googling how to do each thing you want to do. Then you end up Googling less and less and just writing.
>>
>>53624129
>>53624185
>>53624216
if you do anything beyond fizzbuzz (hahaha, i know you neckbeards don't) it could feasibly happen for example that you change from integer to float arithmetic in your processing and then you get degraded accuracy with no indication whatsoever that something's is wrong
>>
>>53624721
*and forget to change the type in one place
>>
>>53619432
I don't really remember how I learned C#, but I'm pretty sure knowing C/C++ helped me A TON. IIRC I just started to mess around WinForms and .NET in general, it is really pretty straightforward and if there's something you don't understand (most likely because you don't know what the code is doing) there's plenty of documentation / tutorials / stackoverflow questions and really a lot more.
>>
Hey, Im new to programming, about to hand in an assignment, and I have ran into a bug.
my assignment wants me to animate a simple 2d tank that places it self back into place when mouse pressed and changes color when key pressed. however after the half way point it wont change color if the tank has not been reset. im coding in Processing, also general tips for cleaning up my code and being more efficient would be appreciated.
http://pastebin.com/dY6zQf4Q
>>
fucking C sperg neckbards suck balls at programming and only use C because they're unable to understand higher level languages like C++
>>
>>53618703
>rain dancing around a compiler
it may just be the drugs but this mental image is great.
>>
>>53624786
void mousePressed(){ //This resets the position of the tank
a= 92;
b = 140;
c = 190;
d = 240;
e = 288;
g = 64;
g1 = 120;
h = 121;
h1 = 260;
i = 261;
i1 = 320;
j = 191;
k = 192;
l = 252;
l1 = 298;
l2 = 326;
}


IT HURTS TO LIVE
>>
>>53624831
>hey im new to programming
>also general tips for cleaning up my code and being more efficient would be appreciated.
thought this was a place for criticism ?
>>
File: 1374577775522.jpg (3 KB, 125x126) Image search: [Google]
1374577775522.jpg
3 KB, 125x126
>>53624787
fucking C++ sperg neckbards suck balls at programming and only use C++ because they're unable to understand elegant languages like C
>>
>>53624840
>a place for criticism
to say the least
>>
>>53624786
Your code formatting is shit.
You have way too many variables.
Your variable names are shit.
Your have ridiculous amounts of duplication; use a loop or some shit

Honestly, I'm not even sure what language you're writing in.
>>
>>53624840
You have magic numbers everywhere.

You're dealing in absolutes when you should be dealing in relativity.

If I'm at (2,2) and I want to move to places to the right I will be at (4,2).

I do not set my location to (4,2).

I add 2 to my x-axis location.

color m1 = color(196,162,75);
color m2 = color(17,144,16);
color m3 = color(206,89,46);

Use MEANINGFUL variable names.

Name these 'blue', 'green', or 'red'.

Even ColorRed would be fine.

  text("ITEC 102 - Assignment 1",600,20); // This is the text.

Use MEANINGFUL comments.

Everyone knows it's text, dipshit. Stop insulting people.

Try to comment the WHY not the WHAT.

  fill(0,0,255);// The blue colour for the text

You defined color variables above, and now you're setting this one manually. Make up your mind.

At least you told us with the hell 0,0,255 was this time.

I can keep going if this is helpful at all.
>>
>>53618336
ArrayList<Integer> list = new ArrayList<>();
list.set(-1, 0);

That should throw IndexOutOfBoundsException
>>
>>53624937
please, im here to learn from my mistakes and get better
>>
How hard is HTML? I want to make a website to educate people about the truth of Islam and how it's not the cause of these terrorist attacks and we shouldn't be scared of the refugees.
>>
>>53624937
also not asking for you to do my assignment for me or anything, but how can i use less variables?
>>
>>53624965
>>53624984
Anon already gave you a bunch of advice. If you want help, the most important is to indent your code properly and to use proper variable names. Nobody is going to help you if they need to spend an hour first deciphering your code.
>>
I have to make some kind of "troll" program in visual c# for april 1st as an assingment in school and since my imagination is shit, I'm asking you anons for ideas. Nothing fancy only beginner level shit.
>>
File: G724Npb.png (62 KB, 700x700) Image search: [Google]
G724Npb.png
62 KB, 700x700
>>53625644
shitpost generator
>>
>>53625677

How are these shitposts generated?
>>
File: gnu.png (80 KB, 388x206) Image search: [Google]
gnu.png
80 KB, 388x206
>>
File: rEdz9wI.png (59 KB, 700x700) Image search: [Google]
rEdz9wI.png
59 KB, 700x700
>>53625734
babby's first Markov chains.

Number selector that you see allows for different magnitudes of connections, higher being more englishy, but tends to just imitate the posts if there isn't enough material.

Low ends up in gibberish, but it somewhat humorous; pic related.

You can generate based on a keyword, which just generates results and tosses those that don't contain the keyword. Application crashes if keyword is too complex or not found at the moment.

>good leard shitposts!
>>
>>53625788
>babby's first Markov chains.

That's what I figured. I've never bothered to jerk around with them before, though. Any good resources?
>>
>>53625819
Why would you want to? You saw the result, intelligible gibberish.
>>
>>53625822
>Why would you want to?

Fun? It's the same reason I invented my own shitty lisp.
>>
>>53624281
>>53624324
>>53624755
Thanks
>>
>>53625819
Here's the website I was looking through when I implemented it on 4chan's APIs:

http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=745

>>53625822
It's actually passed a Turing test (so to speak) on some other boards multiple times.
>>
>>53625863

Thanks, m8.
>>
Lads anyone know what this "697yqf3e3d9e3ej6d80y34y7jqh" could be? Is it info hash?
>>
>>53625917
Me when I program blackout drunk. Translates to "if".
>>
Need some help connect to remote ssh server with socks proxy on Golang.

https://stackoverflow.com/questions/36102036/how-to-connect-remote-ssh-server-with-socks-proxy

What i do wrong?
>>
>>53625917
sixty nine sex
7 years
queef
Be Bed Niney Bej
Apartment 6D, 80 years of Rule 34
Year 7 of Jewish Questions
Helsing
>>
http://pastebin.com/BXH10v5e
What's wrong with this one?
Code compiles but when I run it it doesn't do anything, as if it's running forever, but it shouldn't take time to compute.

It's Project Euler problem 7, by the way.
Can functions be used in conditionals in C like in Python? (I mean since they return 0 or 1).
>>
>>53626054
In nth_prime, when iter=9 the while loop never exits.
>>
>>53626101
Ignore this, I'm retarded.
>>
>>53626054
In
p<pow(n, 0.5+1)
, shouldn't it be
p < pow(n, 0.5)]
? This is probably causing your code to slow down significantly.

Also, it should probably be
while (p*p < n)
. This is nicer and faster.
>>
>>53626127
im the retard here ;(

>>53626145
yeah you are correct i fucked up the parenthesis, but it still does the same thing when i run it?
>>
So I got a couple of functions to study, trying to figure out what these ones do
>>
>>53626179
Your while loop in is_prime is missing braces.
Thread replies: 255
Thread images: 33

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.