/dpt/ - Daily Programming Thread

old thread: This is a japanese game developer.

Other urls found in this thread:

youtube.com/watch?v=rRQGtoJHo2M
librebook.xyz
astrolog.org/labyrnth/algrithm.htm
opengl.org/registry/specs/NV/fog_distance.txt
github.com/finnstr/gdx-liquidfun-extension
github.com/finnstr/gdx-liquidfun-extension/blob/master/src/finnstr/libgdx/liquidfun/ParticleSystem.java
ideone.com/3FLwas
youtube.com/watch?v=HLk4eiGUic8
better-dpt-roll.github.io/
github.com/nick-gits/calcupy
dev.modern.ie/tools/vms/
i.4cdn.org/(board)/(timestamp).(extension)
msdn.microsoft.com/en-us/library/ez801hhe(v=vs.110).aspx
twitter.com/NSFWRedditGif

First for D

Thanks for the tip user, but it seems like that's just more code that will end up making things messier since it's not like there are a ton of variants for the crawler.

Playing with Processing.

program quine; uses sysutils; var s: String; begin s := 'program quine; uses sysutils; var s: String; begin s := %s%s%s; WriteLn(Format(s, [chr(39), s, chr(39)])); end.'; WriteLn(Format(s, [chr(39), s, chr(39)])); end.

Dammit, i wanted to see what she looks like with her let out.

is that a probe taken from OP's ass

Code please?

Here you are, senpai.
boolean looping = true;
ArrayList points = new ArrayList();

// Redraw background with slight transparency -- fades old lines
void layBg() {
fill(40, 20);
noStroke();
blendMode(DARKEST);
rect(0, 0, width, height);
blendMode(BLEND);
}

void setup() {
size(600, 600);

background(40);

for (float x = 40; x

Actually, nevermind. I think i know how you did the tails.

>This is a japanese game developer.
What did he mean by this?

That's not fair, you get fancy effects for free.

>This is a japanese game developer

Speaking of the Japanese, why the fuck don't they into pretty much any open source software?

Jap game devs are cute anime girls who change in the bathroom.

What rendering keyboard input library(ies) is that?

anime is open source software

contributing
youtube.com/watch?v=rRQGtoJHo2M

It's all pure Processing 3.

Not familiar with.

>tfw too intellectual for typed languages

Is there a way to have a method that you call only once but works on all of the class instances?

I have processing 2 installed but never used it much. It says it can't find "Point".
Is this your class or a Processing 3 builtin?

but typed langugaes r better

They do but they rarely target an English speaking audience.

>Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology.
>visual literacy
wat

It's a simple custom class. The tick method moves the point by the specified amount in a direction in each step and the draw function plots the point in the pic.

Wew

Can I define it in the same file?

librebook.xyz

now with ssl

I would think so.

You should post it.

depending on what you mean

1. yes a static method

2. keep a record of all instances and update as you go
when you call a static class method let it do something to all of the instances

What's the proper way to maintain a master and development branch in git?

How often should I be committing?
Git guides often recommend squashing commits before merging with master, but I only commit on considerable functionality change.

Left as an exercise for the reader.

...

>2.
What the fuck? Why would you ever want to do that? Isn't that just a long and complicated way to do 1.?

if this post appears, then surf, the "simple web browser", supports javascript

I hear surf, the "simple web browser", supports javascript.

no

>surf, the "simple web browser"

SPAMMERS BEGONE

it doesn't like my isbns
give me some that work

but to call a method on all instances in existance you need to touch all instances in existance right? A static method could do that

stupid frogposter

>tfw you want to write code but you don't know what to do
How do you guys even find fun stuff to do, I can't become good by just reading programming stuff (books etc.).

I've alerted the publishes. This will not stand.

Aoba was pretty great but my mind started to associating her name with Adobe until it reached a point where I would read it as Adoba every single time. Now I think I have programmed myself into some sort of brand loyalty. How do I reverse it?

all 13-character integer numeric strings work. isbn-10 is outdated.

In Java, I want a thread to send a message /call a method on all other threads upon its death
What would be the best way to achieve this?

Read some nasty Adobe doujinshi.

>Java

doesn't matter if other people aren't pushing.
commit to your branch often, rebase against origin/develop branch, then when done squash into an appropriate amount of commits.

>call a method on all other threads
>on
what do you mean by this?

>Quibbling over languages instead of producing work

Why do you even want to learn programming?

Literally all /dpt/ is

I think he means that a static method only has access to other static shit. By having a list of all existing instances you can perform operations on a specific instance. So it can have a different effect per instance (modify instance variables) instead of modifying other static variables.

The guy who asked the question probably wanted something like add 10 to the position of all entity of type X. The guy who answered gave an answer to this.

Let's say I have to workers; left worker and right worker. They're given (what appears to be) an equal amount of work.
left worker finishes before right worker, and when the thread dies, it calls createHelper on right worker that spawns another instance of left worker, this time targeting half of right worker's work

What would be the best way to call createHelper? Just store a reference to the other thread and then call it that way?

>Java

My hovercraft is full of eels.

>artist
>dev

That's more boring than I expected. I was hoping for some highly parallel system in which to implement an efficient thread registry that allows registration, deregistration, and notification. And all of this should scale linearly to thousands of threads and dozens of cores.

But you're talking about two threads. Two. Wow, just wow.

well then if it's so simple it should be easy to provide me with an answer :^)

Just keep two variables around and check them whenever the worker loops.

Oh, i see. Making that into a method seems like bad practice, though.

I've made a maze generator with depth-first search but making a 30 by 30 maze takes about 10 seconds.

Is this normal or have I screwed up somewhere?

okay i must have fucked up when i stripped the dashes. the manifesto confused me a little although we probably agree
i have hundreds of technical books on my laptop so that i don't have to carry around a small library in order to work. most of these are from libgen. is that the sort of thing you're aiming for? i've never been able to figure out who actually has upload privileges there

do you use a randomized DFS
30x30 is not a very large number, 10 seconds sounds a lot if i remember correctly when i did a random dfs maze generator

I DIDN'T NEED YOU ANYWAYS FUCKER
class Point {
float x, y, dx, dy;
Point(float x, float y, float v, float dir) {
this.x = x;
this.y = y;
this.dx = v*cos(dir);
this.dy = v*sin(dir);
}
void tick() {
x += dx;
y += dy;
}
void draw(){
point(x, y);
}
}

i don't understand how you use a tree traversal algorithm to GENERATE a maze

how do you make a maze generator with depth-first search if DFS is a search algorithm?

pls explain

stupid frogposter

1. generate random graph
2. traverse it

The DFS *is* generating the random graph.
Why would you need to traverse it after construction?

I made it check all 4 neighbouring tiles, then pick a random intact neighbouring tile/.

what about dfc

What do you run the DFS on?

you wot

X = 10

you just do DFS, but at each step you visit a random child
and you sort of break "walls" using the idea that you shouldn't visit a node twice
if i remember correctly i started out with a map where all cells have 4 walls and as you visit you "break" a wall along the path

you get a maze with a path from start to finish

You just take a grid, make it search a path through it and remove the walls in the path, then make paths until it's been on all the tiles.

astrolog.org/labyrnth/algrithm.htm
Scroll down to "Perfect Maze Creation Algorithms".
Maze generation is very closely related to graphs/trees.

>if i remember correctly i started out with a map where all cells have 4 walls and as you visit you "break" a wall along the path
I did the same thing, like I said here

only books?
also, hide your whois info...

The implicit non-random graph of the grid.
The DFS randomly traverse forming random subtree.

>Why would you need to traverse [the graph] after construction?
>The implicit non-random graph of the grid.
uhh

Btw, this is how my end result looks.

I made it in c++ and SDL, both of which I don't have much experience with so that might be why I have some slow code

user said "generate random graph" then traverse it.
The traversing of the NON-RANDOM grid is what creates the random graph/tree.

i made mine in python, generates a 50x50 instantaneously
though because i used recursion to do the DFS, because lazy, at 60x60 stack overflows kek

10 secs is a lot, do you have a "visited" record so you don't do the same cell more thna once?

It's the same thing then. The former is just the explicit form of the latter.

How do I change a variable in a makefile when calling make release?
I just want to it to ignore my debug flags.

alex pls

Because I wanted to and I like it.
I wrote some small stuff and can already program, just out of ideas.

>do you have a "visited" record so you don't do the same cell more thna once?
Nope, I have a boolean inside the cell class which keeps track of if it's intact, when I load in the neighbours it only loads in the neighbouring cells which are intact and then chooses a random one from the intact neighbours

post code

i want to learn

Then write it yourself and learn even more than by copying someone. srsly

Does doing stuff like that imply being good at math?
Not the same poster, I'd rather learn by doing.

no it implies yuou know about depth first search and can use algorithms found on the internet and translate them into code

Not really. If you know to to program a language well you can probably figure out how to make a maze like that by thinking about it for awhile without knowing any math really.

I'm trying to do this with SDL, but now I have to figure out where the segfault is happening. :^)

could be wen you present the maze something goes slow

by the way have you made a solver
to solve i just do a dfs that can't go through walls and it finds a path

I'm learning opengl and I realized I have no idea what an opengl extension actually is or how I'd go about using one.
So I went to glad's loader generator and there's a list of extensions I can choose to include. But how do I know what they're for and how to use them?
I googled GL_NV_fog_distance and found opengl.org/registry/specs/NV/fog_distance.txt
But it doesn't really tell me all that much.

So how would I find out where there's some useful extension I can use for my purpouses? Read about all of them?

You can't separate the traversal from the random tree construction because they're one and the same.
Separating them like user did is confusing if you're trying to explain to someone how a traversal algorithm makes a maze. It makes it sound like their is something special generating the random graph.

Embrace the aidsdobe and start making flash apps

Did that user ever skim the chain matrix multiplication paper?
Are you here?

Wew

post source pls

How do I make a video from a processing sketch?

printf("Hello World!");

>could be wen you present the maze something goes slow
No, I only measured the time it took to complete the generate function, the draw function is a separate function.

Gas yourself

"no"

ah shit i got wrapped up in work
the second paper where they show that the fun stuff from the first actually computes what you want is quite long so i deferred reading it

Yeah part II.
I understand.

>Please help me, I am desperate

github.com/finnstr/gdx-liquidfun-extension
In the libs folder, there is a file called gdx-liquidfun.jar

I need to be able to edit the source code of gdx-liquidfun.jar, but I do not know what I am looking for.

The class I need to edit can be found at
>gdx-liquidfun-extension-master\src\finnstr\libgdx\liquidfun\ParticleSystem.java

Where in the file tree is the source code for gdx-liquidfun.jar, and what do I do with it?

Thank you, I've been stuck for 12+ hours

>thank you
You're welcome :)

>libgdx
hahahahahaha

github.com/finnstr/gdx-liquidfun-extension/blob/master/src/finnstr/libgdx/liquidfun/ParticleSystem.java

I haven't the slightest idea what you are doing but I rewrote it to be a lot less potato:

import Data.List
import Control.Applicative(())

ffloor = fromIntegral . floor
fceiling = fromIntegral . ceiling
whole x = ffloor x == x
dist a b = abs (a - b)

sumRecurse total marked target@(j,k) (x,y)
| onGrid && nearTarget = total + targetLen
| onGrid && onEdge = -total
| onGrid = sum $ map (sumRecurse (total+1) (new ++ marked) target) new
| whole x = recur (x-fx) (fx,y) + recur (cx-x) (cx,y)
| otherwise = recur (y-fy) (x,fy) + recur (cy-y) (x,cy)
where
recur d m = sumRecurse (total + d) (m : marked) target m
onGrid = whole x && whole y
onEdge = x == 0 || y == 0 || x == 10 || y == 10
nearTarget = dx < 1 || dy < 1
targetLen = if whole j then dx else dy
new = [(x-1,y), (x+1,y), (x,y-1), (x,y+1)] \\ marked
(dx, dy) = (dist j x, dist k y)
[fx, cx, fy, cy] = [ffloor, fceiling] [x, y]

Testing it with a couple values just seems to infinitely recur, or at least take a disgustingly long time. What on Earth are you doing here?

Do you even know what a jar file is?

>JAR (Java Archive) is a package file format typically used to aggregate many Java class files

That jar file has the libgdx source code

class files are compiled, they contain the bytecode, not the source.

no shit

Is this statement correct. Or is my understanding of pointers fucked.

int main(int argc, char *argv[])
{
/* Declare and Initialize variables */
char **theInputs = argv; // theInputs is an array of pointers that point to an array of pointers to chars

>makes it sound like their is something special generating the random graph.
It's the other way around. With a random matrix, all the probabilities are explicit. With the magic hidden in the traversal function, it doesn't look so great.

Jokes on you, I got a (you)

What's wrong with it, it's made what I want to do easier.

Is there a way that I can add this as a class, and use something like @Override to override the entire class within the library?

The library gdx-liquidfun.jar contains a few hundred files, the one you linked to me included.

>Do you even know what a jar file is?
I have a rough idea what it is, but I don't know how to edit one.
I've tried just opening it in eclipse, and nothing happens

the poster said the jar file contained source code, which is false.

You're welcome.

Thank you for the clarity. I thought this user was incorrect, but I'm too new to the subject to trust myself

I'm just here to Correct The Record™.

char *argv[] //equivalent to char** argv

Expresses the idea quite well.
A C-string is an array of characters.
You have many arrays of characters.
argv is a pointer to a set of pointers that points to characters.

and shart in mart

>I'm just here to spew shitty memes because lel xD
Sounds about right

Should probably have made it clear that yes you're description is correct.
Except there's no real 'arrays' in C as there are in other languages. They're just pointers, you get the length of the 'array' of pointers in argc. The character arrays themselves are null-terminated.

How can pointers be real if arrays aren't real?

>Except there's no real 'arrays' in C
Yes there is. They just decay into pointers when passed into functions or arithmetic is used on them.

Thanks lads.

Is there anyway to add additional classes to a .jar?

Alternatively, can you override classes within a .jar with your own?

>in interview
>recruiter asks: What's the difference between a linked list and an array?
>say they're the same
>don't call us we'll call you

>.jar
>java
untermensch

>How can pointers be real if life isn't real?
FTFY

>recruiters asking such retarded questions

Why am I so nervous I'll never get a job.

What is an array?
Because to me something that's just a pointer to memory is a pointer. If there's no real way of differentiating the two what's the point?

Nope, you're just being ignorant.

memory is an array

git gud

There are no pointers just indexes into arrays?
That's another way of putting it. I'd be fine with that too.

...

It's actually a good question. Effectively weeds out retards like that poster.

Seriously... The answer is in the question.

>What is an array?
One or more elements stored contiguously in memory.
Stop protruding the incorrect fact that arrays and pointers in C are equivalent. It's just not true.

>Effectively weeds out retards
Yes. Sure. But really, what's the point in asking "What's 2+2?" to someone who's gonna do a lot of math in their work.
Yes it weeds out some portion of complete retards. But it doesn't get you that far.

How to learn a large codebase when you go to a new job?

give up?

Can Microsoft actually fuck off? I literally can't find a serial that makes this dumb installer work and I need an XP vm.

Read the test suite.

>what's the point in asking "What's 2+2?" to someone who's gonna do a lot of math in their work.
Because in the real world a lot of people can't answer that question in interviews, and a lot of jobs don;t need much more ability than to answer that question.

It's the same reason FizzBuzz is used in interviews. Very simple, but a lot of people can't do it and it weeds out the retards quick. And a lot of jobs are just code monkey jobs anyways so you don't need some masters degree CS graduate who's a Haskell compiler expert to fix bugs in your PHP login page.

Fuck off you bloody pirate

An array of size 1 is not an array?
That's a rather exceptional case.

Regardless. I'm not saying there's arrays in C I'm just saying that you either call the pointers in C indexes into the array that is the memory of the machine as was suggested by that other guy or you say there's no arrays and it's all just pointers. Because having both is just redundant and doesn't mean anything.

rewrite everything. if those guys were so smart they wouldn't have needed you

>i'm too retarded to install XP pls kill me
It can;t possibly be that hard to find a key to pass that shitty installer. I must have done it 20 times.

It seems like your interpreted my post in the exact opposite way it was supposed to be interpreted.

Apparently it's something to do with VMware.

No no, let him mine BTC for me.

bizarre. Maybe try "XP: pirated edition" from the pirate bay. Always worked a treat for me. Probably a massive botnet, but fuckit.

I only need it so get an installer working, which will allow me to copy the files over to Win7, so a botnet should be fine.

is part 1 understandable for you?

J9TMY R4T7T YF48V 3JW99 7YX2Q

oops. meant to link this to

Too late, I baleeted the iso. Downloading another.

The compiler can tell the difference.

#include

void ptr(int a[]) {
printf("%d ", sizeof a);
}

void main(void) {
int a[5];
printf("%d ", sizeof a);
ptr(a);
}

/*
C:\Users\Nick\Documents\code>tcc -run arrays.c
20 8
*/

Yeah I know because what you said doesn't make any sense in context.

>tcc

is bellard the programming god?

>void main
>No #include
>Windows
Disgusting.

For anyone interested; I actually found reason why my maze generating was so slow by the way, it was retarded as fuck.

There was a system("CLS"); inside the loop, I honestly don't know why in gods name I put that there.

Now generating it takes about 70~80 milliseconds instead of 10 seconds.

>Implying the pajeets have one

extern int i[];
extern int *i;

Learn the difference.

catch { }

I want to eat out Aoba's pussy

>it's a 'dpt answers trivial questions and ignores anything beyond first week of programming'-episode
God you guys are shit.

Except there's no real 'arrays' in C
ideone.com/3FLwas

That's rude.

What's a real array?

>its a réddit episode

If getting length isn't O(1) it's not an array.

>réddit
rèddit*
Who the fuck pronounces it ree-dit, obviously it's re-dit

>What's a real array?
An array you can touch, smell, etc?

>Used 7-zip to get source files from .jar
>Edited .java files in eclipse
>Exported as a .jar
>Add the .jar as a library to existing project
>It's as if the changes I've made don't exist

The new methods that I've created aren't recognised
What have I done wrong?

What is the difference?

does anyone know some good resources for learning about genetic algorithms? touched on them in one class but it was theory. Want to learn more and program them

less chars

>genetic algorithms?
Can you define that for me?

Practically everything.
Why don't you try run it?
//file1.c
int i[5] = {1, 2, 3, 4, 5};
//file2.c
#include

extern int *i;
int main()
{
printf("%d\n", i[3]);
}

Can't we all just agree C is a mess of a language. When will new languages replace it?

Genetic Algorithms (GAs) are adaptive heuristic search algorithm based on the evolutionary ideas of natural selection and genetics. As such they represent an intelligent exploitation of a random search used to solve optimization problems. Although randomised, GAs are by no means random, instead they exploit historical information to direct the search into the region of better performance within the search space. The basic techniques of the GAs are designed to simulate processes in natural systems necessary for evolution, specially those follow the principles first laid down by Charles Darwin of "survival of the fittest.". Since in nature, competition among individuals for scanty resources results in the fittest individuals dominating over the weaker ones.

It's getting there:
youtube.com/watch?v=HLk4eiGUic8

you can use rust today

>Can't we all just agree C is a mess of a language
What is wrong with that code specifically?
>When will new languages replace it?
Probably never.

That's a C++ replacement, not a C replacement.

it does look better with pattern guards
but still, it uses too much ram

they are a machine learning tool, a bunch of learners try, you judge them, kill off the weak, make the strong mate, and then you test the new ones and survivors

It's basically how to solve a problem without finding a solution.

Are you that one guy from Waikato University that I have called out before?

What does it do? I only did a mechanical refactoring of it. I don't understand the onGrid && !(nearTarget || onEdge) case.

no

imagine a grid, and there are any two points on the lines of the grid
its supposed to find the shortest distance between points if the only path is through the lines in the grid

it does this by trying out every path possible from a point until it reaches the target or the edge

Lack of differentiating pointers and arrays? There is no reason for both to exist. Pointer arithmetic is faster, but can be achieved with induction variable optimizations on array indexing, so I'd err on the side of array being more useful. Why does malloc exist at all? VLAs can replace the need for many of malloc's usage, let the compiler or runtime decide where to store variables. Something conceptually different could replace it and remove most of the shitty parts. Like why the fuck is overflow checking not available? Things like that CANNOT be missing from a good systems language.

So... the taxicab metric?

taxicab (x1, y1) (x2, y2) = dist x1 x2 + dist y1 y2

Why haven't tech companies applied to this to programmers?

>it does this by trying out every path possible from a point until it reaches the target or the edge

not enough girls

tree traversal can be done in a depth-first manner, as can many other types of traversals and searches

>Lack of differentiating pointers and arrays?
C doesn't allow arrays to be passed into functions. It allows for [] to be used, for notational convenience, but they're actually just a pointer.
>Pointer arithmetic is faster
No it's not. Accessing a pointer is slower than accessing an array, due to an extra layer of indirection.
>Why does malloc exist at all?
To allow allocation of dynamically sized things which have a lifetime longer than the function it was called in.
>VLAs can replace the need for many of malloc's usage
No they can't, as they only exist for the block they are declared.
>let the compiler or runtime decide where to store variables
One of the advantages of C is that you get to manage where shit is stored yourself.
>Like why the fuck is overflow checking not available?
Several compilers have overflow checking available. However, the standard C language is trying to be simple to implement and allow for the generation of efficient code.
>Things like that CANNOT be missing from a good systems language
Go back to your masturbatory Ada then.

I don't have it but if someone posts it do the Cred Forums challenges.

there are lots of coding competition/practice sites. i'm sure some people here use those

>However, the standard C language is trying to be simple to implement
This is not a good reason not to have bounds checking for arrays in the spec.
It's absolutely trivial.
Don't defend poor decisions.

You blew it at the first comment. I'm not talking about C, I'm talking about a better language. I know a lot about C.

>No it's not. Accessing a pointer is slower than accessing an array, due to an extra layer of indirection
You don't know what you are talking about.

write a game of life implementation
then think hard about how to make it fast

Not only that, but
>easy to implement
Lol, he hasn't ever read through an implementation of cdecl.c.

better-dpt-roll.github.io/

Yeah, you're right.
I was confusing shit about shit where more than 1 level of pointers are involved, like double pointers or linked lists.
In terms of simple pointers to arrays, they should be equivalent, although that wasn't true in the past.

It's much easier to implement that every other major programming language.
>Lol, he hasn't ever read through an implementation of cdecl.c.
It's just a matter of following the grammar. Just because it's somewhat difficult for a human to parse them, it doesn't mean that it's hard for a machine.

I'm having issues with a dinamic array to generate n random numbers, then apply a hash function to allocate them within the array.

I actually know how to generate random numbers and how the division method for the hash function works, I have problems with the dinamic array.

int main()
{
int size;
std::cin >> size;
int *array = new int[size];
delete [] array;
return 0;
}

dist a b = abs (a - b)

taxi (ax,ay) (bx,by) = dist ax bx + dist ay by

taxi2 a@(ax,ay) b@(bx,by) = taxi a b + 2 * overlap
where
[fax, fay, fbx, fby] = map (fromIntegral . floor) [ax, ay, bx, by]
minDist as bs = minimum (zipWith dist as bs)
overlap
| fax == fbx = minDist [ax, ax, bx, bx] [fax, fax+1, fbx, fbx+1]
| fay == fby = minDist [ay, ay, by, by] [fay, fay+1, fby, fby+1]
| otherwise = 0

*Main> taxi2 (0.7,0) (0.9,5)
5.4

Thatta boy

What norm is this? Shouldn't it be 5.2?

taxi2 is the metric wherein you can't step between
gridlines, so you have to move right onto x=1 and then back left onto point b at x=0.9, thus the extra 2 * 0.1.

I assume that's what the original poster wants.

Though, I see an error:
*Main> taxi2 (0.8,0) (0.9,0)
0.29999999999999993
Ignoring fp error, this should obviously be 0.1, not 0.3. It's not a hard fix, but I'm working on making the code look like how I like.

make CFLAGS="-O2 -Wall ..." release

Or whatever other variable.

And here we are:

dist a b = abs (a - b)

taxi (ax,ay) (bx,by) = dist ax bx + dist ay by

taxi2 :: RealFrac a => (a, a) -> (a, a) -> a
taxi2 a@(ax,ay) b@(bx,by) = taxi a b + 2 * overlap
where
[fax, fay, fbx, fby] = map (fromIntegral . floor) [ax, ay, bx, by]
minDist as bs = minimum (zipWith dist as bs)
(v, h) = (fax == fbx, fay == fby)
overlap
| v && not h = minDist [ax, ax, bx, bx] [fax, fax+1, fbx, fbx+1]
| h && not v = minDist [ay, ay, by, by] [fay, fay+1, fby, fby+1]
| otherwise = 0

*Main> Text.Printf.printf "%0.2f\n" $ taxi2 (0.8,0) (0.9,0)
0.10
*Main> Text.Printf.printf "%0.2f\n" $ taxi2 (0.7,0) (0.9,5)
5.40

Unless I misunderstand that can't be a metric because it's not symmetric.
d(1.25,2) = 1.75
d(2,1.25) = 0.75

How difficult would it be to pick up C or C++ having learned the basics of C#?

I heard if you perform good on codefights, you will get a job

i heard you like to dress up in girls clothes

Anybody have any recommendations concerning things I can add or change to make this better?

github.com/nick-gits/calcupy

>basics
If I were you, I'd stick to a single language until you feel very comfortable with it. Knowing the "basics" of a thousand languages is useless.

only cfags do that
source. himegoto and akarin fags in /dpt/

Try to find a and b for which taxi2 a b != taxi2 b a, for this definition of taxi2. I don't think there are any.

task: implement an array in haskell

import Data.Array

>implement

>implement

>javafags

>implement

well you listed off points on a line
anyway check it again. someone wrote a whole book on this metric (i don't think it found much success)

Sorry, sorry.

import Data.Array
myArray = listArray (0,3) "fuck"

taxi2 is a 2D metric. Your examples make no sense.

That is slander! Slander I say!

I am a C programmer and I do not wear women's clothing. In fact, I prefer not to wear any clothing at all while programming!

>Cred Forums is NOT your personal tech support team or personal consumer review site.
anyway: google will give you some keys.

then use dev.modern.ie/tools/vms/

I wonder if the person that was going to learn Go yesterday is here...

I shouldn't be helping the anarcho-statist-individualist-conservative-neoliberal-militarist.

I don't know that language, is the result is the normal taxi metric + 2*overlap?

What's the name? I can't find anything under taxi2.

>is the result is the normal taxi metric + 2*overlap?
Yes, that's what it says. Overlap in most cases is 0, but in the case where ax and bx are between the same pairs of integers, overlap is the distance to the integer nearest either; and analogously for vertical.

Hey Cred Forums, got a C# question for you.
I'm working on an abandoned *chan image downloader, YChan, and I wanna know how I can save the files with the original filenames instead of the Unix timestamps.

The way the program works for Cred Forums is:
Convert the thread URL to XML
Get the timestamp/extension from that
Create a string of all the files in the format i.4cdn.org/(board)/(timestamp).(extension) \n
Split that string using Regex.split and output into an array(I think, String[] is an array, right? I don't know C# all that well. At all, really.)
Finally it iterates through that array(?) and from that it downloads the files using WebClient.DownloadFile, which saves the image with the timestamp, not the original filename obviously.

I know how to get the filename from the XML, that's simple enough (XmlDocument.DocumentElement.SelectNodes("/root/posts/item/filename"))
What I'm wondering is how to make it so that when the images are downloaded, they save with their related filename.

I'm packaging my program in deb and rpm. Both launchpad and Fedora require a build script, but it's just so much easier to build it myself. I wonder if I should forego that shit and supply my packages in the releases section on github.

Yes it's an array.
msdn.microsoft.com/en-us/library/ez801hhe(v=vs.110).aspx
DownloadFile takes 2 arguments, the URI to the file, and the filename to save the image as. If you know how to get the filename, just plug it into DownloadFile and you should be golden. You might have to join it together with a path so that it saves to the right folder.

>I shouldn't be helping the anarcho-statist-individualist-conservative-neoliberal-militarist.

I thought you'd disappeared entirely!

Okay, I think I get it now.
The way it was written in the program made me think WebClient.DownloadFile took a location to save the file as the second parameter, not the filename itself (which I guess can also include the path?)
Thanks user!

we are here forever

Shamefully true.

i can't program for shit, but what is the sauce on the op?

>programming test tomorrow morning
>teacher is paranoid of online platform failing or the IDE saving fucking up or just about anything going wrong
>we're required to take a written programming test
>programming
>with pen and paper
>mfw
Please tell me this isn't as uncommon as I think. I want to believe it is but I honestly can't tell.

I've never taken a pen and paper test in any of my programming courses

I had to do it for a couple freshman/sophomore level classes.

It's not uncommon, I did plenty of pseudocode wirtten tests back in the day, they are more fun and the score is based on the logic and structure of your program, won't deduce points for simple syntax mistakes. Like says, common for those levels when programs are simpler, and better alternative IMO.

That's not very nice is it?

I don't understand what the point is though. Compiling is as vital to programming as anything and you're basically fucked out of the machine pointing out your mistakes if you're forced to do it written.
I can understand if you have years of experience and still depend on the compiler to pick up your shit but I only have like 2 months of "experience", if you can even call it that. I don't feel like I have the mastery needed to manage a program in just my head yet.
For the record, I don't think we're using pseudocode, but actual code with valid syntax. I reckon the teacher will be a bit lax with simple mistakes anyway but I've been eyeing tests from past years and it's making me fear tomorrow.

These took off for syntax errors.

in the past, everyone was taught that way
also, computers distract the users, and cheating or IDEs won't teach you a thing

The programs are quite simple and people can and will cheat of you give them computer access during an exam. Also people will use the compiler/interpreter as a crutch.
My classes that had pen & paper programming that had to be syntax perfect and runnable were
Intro to CS(Python)
Intro to OOP(Java)
Computer Organization (C/ASM)
Intro to Data Structures & Algorithms (Java)
Past that the vast majority of tests were still pen and paper still but any coding or algorithm description was done in pseudocode.

you'll be ready for interviews user

*hugs you*

please help, i need it

gnu+sauce?

Array.prototype.binarySearch = function (
target,
insert = false, // return index for insertion
compare = function(a, b){ return a - b; }
) {
var low = 0;
var high = this.length - 1;
var mid;

while (low 0)
high = mid - 1;
else
return mid;
}

if (insert)
return (this[mid] < target) ? mid + 1 : mid;
else
return false;
}

It's New Game! you fucking weaboos.
Now stop shitting up the thread.

Array.prototype.sortedInsert = function (
item,
compare = function(a, b){ return a - b; }
) {
var index = this.binarySearch(item, true, compare);
return this.splice(index, 0, item);
}

Array.prototype.sortedDelete = function (
item,
compare = function(a, b){ return a - b; }
) {
var index = this.binarySearch(item, false, compare);
return (index) ? this.splice(index, 1) : false;
}

Array.prototype.sortedContains = function (
item,
compare = function(a, b){ return a - b; }
) {
return Boolean(this.binarySearch(item));
}

/************************************************
EXAMPLES
************************************************/

const sortedArray = [1,3,5,7,9,11];

test0 = sortedArray.binarySearch(7);
test1 = sortedArray.binarySearch(4);
test2 = sortedArray.binarySearch(4,true);
test3 = sortedArray.sortedInsert(6);

console.log(test0); // 3
console.log(test1); // false
console.log(test2); // 2
console.log(test3); // 1,3,5,6,7,9,11

> IDEs won't teach you a thing
Compiler and IDE will just be there and assist you, they don't need to teach you.

It's shit you can avoid being meticulous about in general. You'll actually get your errors and warnings, and a chance to fix them. You also have easily searchable documentation and what not.

Programming without computers is retarded, it's for learn by heart bullshit. Not a more logical (but not necessarily in-depth where it's useless) understanding.

Maybe tackle some of the harder EulerProject questions then try and GUI-fy it or something?

I fucking hate C.

Can someone tell me how I can parse user input into an array of strings? I know this is a fucking stupid question, but it's killing me.

I figure it would be something like
char* str1 = "Shoot me in the fucking head.";
char* strArr[50];
char* token;

token = strtok(str, " ");
strcpy(token, *strArr);
while(token != NULL)
{
token = strtok(str, " ");
strcpy(*strArr, *token);
}
//I would think this would make
//strArr into {"Shoot", "me", "in", "the", "fucking", "head."}

>he can't write simple programs with pen and paper

Anime is humanity greatest achievement.

Don't bully the Code Artisan.

hello /dpt/, I want to practice my C skills, can you guys suggest some project or program for me to do it? The furthest I went on was pointers

Make a simple heap data structure.

you declared the string str1, but you never use it.

Pretend str is str1. What I'm getting at is that this doesn't seem to actually work at all, even if the variable names were right.

In fact I'm getting segfaults doing anything similiar.

Also pretend that instead of having str1 defined you're getting it from scanf().

Yup, can't do it correctly on paper.

Because I often don't remember whether this language or that language had this or that way to set up a regex and apply it to a pattern, whether I was allowed to use named capture groups.

Or even whether I had a possibly variadic printf that does string interpolation or whether it supported supplying multiple types or whether I had to explicitly cast to a string first or whatever the fuck.

I'll have that looked up and tried out in some seconds in reality, but it's not shit I learn by heart.

I don't know. I/O stuff is really boring...
Why don't you do something fun like write graph algorithms or something?

So you don't even know the basics of the languages you're using?
Practice more.

str1 is read only, you can't modify it
char* str = "Shoot me in the fucking head.";
char* dynamicString;
char* token;
dynamicString = malloc(strlen(str));
strcpy(dynamicString, str);
token = strtok(dynamicString, " ");
while(token != NULL)
{
puts(token);
token = strtok(NULL, " ");
}

yeah, and I forgot to free that dynamicString and allocate space for \0

So... you're going to have a few issues here. Let's look at your first declarations.

char* str1 = "Shoot me in the fucking head.";
Most C compilers are going to shove this in read only memory, even though the pointer is non-const. Yet it is clear that you want to use this with strtok which mutates the string it is passed as an argument. Instead of using a pointer to the string literal, you should declare an array of chars whose length is the size of the string literal, plus one to account for the null pointer (i.e. "hello" would be an array of 6 chars).

char* strArr[50]
This appears to be an array of 50 strings... which is all fine and dandy, but keep in mind that you do not initialize any of these pointers. They could be pointing to garbage, or to NULL.

Now let's look at what's going to happen.
token = strtok(str, " ");
So... right off the bat, str isn't a variable you declared. If you meant to use str1, you're going to get a segmentation fault for writing to write-protected memory.

strcpy(token, *strArr);
So... you want to get the first string in strArr, which is a pointer pointing to garbage, and you want to copy the memory from the token into a garbage buffer. You should malloc some memory first. Alternatively, just set strArr[0] to token. At this point, token is pointing to the first character in str1, which was modified to replace the first space with a NUL character.

On subsequent calls, the first argument to strtok should be a NULL pointer (see the documentation for strtok to guess why), and you should once again not be using strcpy, or else alloc a buffer first.

Calm down, just pratice a little and you'll see that you can actually remember things

Hvorfor snakker dere ikke norsk? Norsk er det beste programmeringsspråket.

Demonstrating on all of these concepts:
#include
#include
#include

#define ARY_LEN 50

int main(void)
{
/* Stack allocated, writable memory */
char str[30] = "Shoot me in the fucking head.";

/* NULL initialized array of strings (pointers).
* In general, it can help to initialize pointers to NULL,
* so as to detect bugs caused by dereferencing arbitrary
* memory addresses.
*/
char* ary[ARY_LEN] = { NULL };
char* tok = NULL;

/* Count of number of legal strings in ary */
size_t count = 0;

/* Tokenize string using strtok */
tok = strtok(str, " ");
ary[count++] = tok;
while (tok != NULL) {
tok = strtok(NULL, " ");
ary[count++] = tok;
if (count == ARY_LEN) {
break;
}
}

/* Print each tokenized string */
count--;
for (size_t i = 0; i < count; i++) {
printf("%s\n", ary[i]);
}
}

> The basics
I *only* don't remember the endless number of useless details I can call up immediately.

This shit is as pointless to remember as the line number of function and symbol definitions.

I think I could learn to blindly touch type my nose using a swipe input on an arbitrary sized android keyboard provided.

But I hold that perhaps I should instead just fucking program as happens in reality to show that I can program.

Daddy, where is mummy? I installed Visual Studio today, I want mummy to see.

How do I make my code appear inside those boxes?

Read sticky, last sentence.

Where is mummy?

Why is my half tower mario program not compiling? I have checked to see what was wrong, but for some reason it isnt compiling. Can you guys check it out to see if there anything wrong with it?
#include

int main (void)
{

int height, i, j, k;

do
{
printf("Height: ");
scanf("%i", &height);
}
while ( height > 0 || height < 23);

//Print Rows
for ( i = 0; i < height, i++)
{

// Print spaces

for (j = height - 1; j > 0; j--)
{
printf(" ");
}

// Print Hashes
for (k = 0; k < i + 2; k++)
{
printf("#");
}
// Spaces between lines
printf("\n");

}

}

Hasn't been on in 2 hours, probably doing homework.

>tfw fell for the category theory meme

WOOF

DOGGO! Haven't seen you in ages!

Would you like a chewtoy??

*wags*

*throws you a strawberry-flavored chewtoy*

Anyone knows a good book/guide on Discrete Mathematics? I heard it's like Algebra.

anime was a mistake

must be perfect for you, then!

Post compile error

Have you finished your language yet? Does it support semitypes?

mario.c: In function ‘main’:
mario.c:16:33: error: expected ‘;’ before ‘)’ token
for ( i = 0; i < height, i++)

Alright so I got a degree in Geology and a minor in computer science from a pretty good school, and I've decided I want to work in tech because I love it.

My option are that I get a 2nd bachelors in CS, get an online Master's in CS or to just try to get a job with my minor and self teaching. I'm not doing some bootcamp gayness.

HONESTLY, it doesn't even matter to me what I do, but I want to do something that's going to give me lots of freedom in the future. What should I do? What does Cred Forums advise?

Just ran it on my computer.

for ( i = 0; i < height, i++)

Read the compile error messages and figure out what they actually mean.

>;

;;;;;;;;

s/,/;

Man, I am a complete idiot lmfao.
I didnt notice that I used a ',' instead of a ';' on that for loop. Thanks user.

...

HaHaHaHa Look At All These Skiddies Thinking They Know How To ProGram Maybe If They Had A Look At Hera V4 From The Golden Days Of Sub Atomic Gaming They Might Learn A Thing Or Two

Might I Suggest Reading Tyler Wearings Guide On Proper ProGramming On Sale Now For Onlt Fourty Nine Ninety Nine Plus Shipping And Handling