/dpt/ — Daily Programming Thread

Previous: What are you working on, Jow Forums?

Attached: vlcsnap-2018-03-19-03h08m08s069.png (1280x720, 976K)

Other urls found in this thread:

euzy.com/if-barbie-was-a-hacker/
acm.timus.ru
icpc.kattis.com/problems
homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf
github.com/MrS0m30n3/youtube-dl-gui
twitter.com/SFWRedditImages

Yeah if you want to make a game and it's your first time, don't make an engine. You'll just get sucked into it.

:^)

but programming the engine is probably the most interesting part of making the game

Then you end up making the engine and never the game which is also a trap.

desu making a game is not really a programming challenge but a design and creativity challenge
Making an engine is a programming challenge and you may find it more enjoyable

Attached: 1526212960095.jpg (884x697, 72K)

What's the simplest way to copy pre-defined directories to other pre-defined directories using Python?

Attached: 38lSFFY.png (766x664, 151K)

import shutil
shutil.copy(src, dst)

Attached: 4e68cf1fa70caaeaf08112d66ee96843020cc0d8.jpg (595x800, 105K)

relevant euzy.com/if-barbie-was-a-hacker/

>not knowing the difference between the assignment and equals operators
>indenting the else if
>using namespace std;
Truly awful

here, still takin a couple feature suggestions. I'm on layover so I got a fair amount of time to code the deal. Once I get something minimal I'll post a link to the Github repo.
Yeah, I like this. Requires a bit of a different approach as far as under-the-hood stuff goes (sub-sub-threads and all that), but it's cool nonetheless.

it compiled so it must be correct right????

So I know a C struct's size isn't necessarily the sum of all of it's members because of alignment concerns of the compiler (or pre-processor?), but when I accidentally read 1 char too far into an unsigned char array member of a struct I noticed it contained 1.
Does C just let me read the "padding" after the last member of a struct? Would it let me write there too? And why would it contain 1? And why the fuck would C not throw a seg fault when I needed it the most?

you can read the padding, but it's value is undetermined. don't know if you can safely write to it (my guess is you could).

>Does C just let me read the "padding" after the last member of a struct?
The answer to that question is platform dependent.
>Would it let me write there too?
This one too.
>And why would it contain 1?
Also this one.
>And why the fuck would C not throw a seg fault when I needed it the most?
Because C doesn't throw segfaults. The OS throws segfaults, and it's not interested in helping you program, it's just trying to protect other running programs and itself.

C lets you read and write to anything the process has access to
For example you can fuck up bytes stored and needed by malloc if you aren't careful

>alignment concerns of the compiler (or pre-processor?)
It's the platform, ie your CPU
>Does C just let me read the "padding" after the last member of a struct? Would it let me write there too?
Undefined behavior; if you want to read/write there safely, fill it with variable(s) that will fill exactly that space.
>And why the fuck would C not throw a seg fault when I needed it the most?
A segfault is when the program accesses memory out-of-bounds, such as read-only segments. Your struct contains memory your program allocated, so it's not a segfault.

The idea of using Lisp to write mobile apps or server side JVMshit amuses me so I'm learning Clojure right now.

Oh shit, people who actually know technology on Jow Forums! I should hang around these threads more often.
Thanks for giving me some leads to research, anons.

Daily reminder that this is daily programming thread, not daily computer science thread. FPfags and haskell weenies get out, go back to

Excuse me, but Computer Science has nothing to do with science. Science belongs in the trash.

>Excuse me, but Computer Science has nothing to do with science.
good, neither does /sci/

>be me
>be deciding I want to stop being neet
>go to hackerrank
>pick out "hardest problem"
>success rate 17%
>solved in 10 lines
>MFW

suck my dick.

can anyone recommend a better site?

Attached: hackerrank.png (928x619, 25K)

Haskell shills don’t know mathematics proofs and still don’t understand monads.

If I plan on doing some OSDev should I just buy a thinkpad instead of emulating everything?

Codeforces
Spoj
acm.timus.ru

A monad is just a noidom in the gorecaty of functoendors.

dont delude yourself into thinking buying a thinkpad will make you more productive. write a functioning OS first, then test it on another hardware.

Thinkpads are popular for OSDev because they're generally well behaved hardware with good open source drivers. The X220 and X230 are the recommended models for Genode devs, for instance.

>actually considering buying a stinkpad
terry i have nothing but respect for your work but please take your meds before you hurt someone

how to get started with deep/machine learning? any book, tutorial recommendation?
help me anons.

All you need to understand monads is to realize that defining or setting a variable in imperative code is equivalent to function application in functional code when the latter is read backwards.

>Codeforces
>Spoj
>acm.timus.ru

:/

something more difficult?

/dept/ I am a haskell newbie, do I understand moan ads correctly?

memelang :: Monad m => Int -> m Int
memelang x = do
y

should be:
memelang :: Monad m => Num a => a -> m a

project euler
>:/
and back to lebbit

sort of

>project euler
that's just for mathfags

>and back to lebbit
your mom introduced this to me to 4chins shortly after your conception.

haven't been on Jow Forums for that long though :)

so wait... a monad is just an imperative function?

icpc.kattis.com/problems

Begin this original paper about monads on FP.

homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf

Monads are simply a special type of function composition with a monadic transform.

imageboard backend is (almost) a go, god bless ORMs

Attached: 2018-05-13-184201_642x758_scrot.png (642x758, 147K)

no

Is there some equivalent for non monadic transforms?
e.g
demelang :: Dyad d => Num a => a -> a -> d a
demelang a b = do
(x, y)

Homosexuals are simply a special type of person that have homosexual sex.

Dear newbie user: To prove you understand monads, implement this thing you're asking about. Implement the typeclass Dyad and its bind and return operators. And then write a short paragraph explaining to us why it's completely useless.

You should be able to solve this

Can someone explain to me how this works? It merges sorted inputs into a single sorted output, but I don't know how it actually works and it's making my head hurt. Please, help a brainlet.
def manual_heapqmerge(*input):
h = []

for itnum, it in enumerate(map(iter, input)):
try:
next = it.__next__
h.append([next(), itnum, next])

except StopIteration:
pass

heapq.heapify(h)

while True:
try:
while True:
v, itnum, next = s = h[0]
yield v
s[0] = next()
heapq.heapreplace(h, s)

except StopIteration:
heapq.heappop(h)

except IndexError:
return

Attached: 1519549861154.png (633x535, 70K)

XML was a mistake. It's nothing but trash.

Attached: mike_starwars.png (390x389, 237K)

the 21st century uses JSON, grampa.

Do you know how heaps work? All it's doing, far as I can tell, is taking the input list before turning it into a heap. Due to the heap property, you'll keep getting the smallest element (or largest, if you configure heapq that way) with each yield, so the result is an ascending sort.
If you've heard of heapsort, this is exactly the same thing.

I downloaded a folder of .c and .h files, opened main.c in Geany, and got a "The system cannot find the file specified" error.
Am I doing something wrong with how I open up the program source?

The source probably has header files that aren't in any include paths.

File corrupted

t. brainlet /agdg/ poster or unity shill

What's wrong with namespace std?

I'm going to assume for now that the files are right and I'm doing something wrong.
I opened main.c and pressed "build", is that the right thing to do or do I have to help it find the files in some way?

I'm guessing it's failing at this line in main.c:
#include "kgame.h"
kgame.h is in the same folder as main.c, a folder on the desktop.

I have an array that i need to pass it into the stdin. How do i do this?

For example, i stored the output of command "ls" into a array, and now i need to pass the array as stdin of yet another system call. Essentially replicating "ls | sort", for example.

Oh, and i am doing this in C, in case it wasn't clear.

perhaps you're thinking of stdout? writing to stdin doesn't make much sense

also FYI writing to stdout will pass it via stdin if you're piping the output

I guess I'm understanding it now, but I'm still confused because of v, itnum, next = s = h[0]
Why does this happen?

Ok, then basically, how to i rerout the stdin? For example, if i do "execvp("ls", argv) and i store the output in a array/file, how to i make the same array/file my new stdin? I want to replicate the "|"

Care to explain just a bit more in depth?

How hard would it be to make an youtube-dl GUI using QT, for someone who knows exactly nothing about programming?

Plz help

>reinventing the wheel
github.com/MrS0m30n3/youtube-dl-gui

Yeah I know that one, but it lacks a lot of youtube-dl options.

Bingo.
Game creation is just that. A creative dive.

Turns out that the problem is that I don't have gcc, because Geany is "minimalistic" by not containing necessary files.
It's also minimalistic by giving error messages that contain no information other than the error type, not saying what file is missing.

The monad laws state this equivalence:
do {y

It's a good choice if you want to learn/get better at programming, bad choice if you want to finish a game.

Euler project.

Nothing. Why would you say that?

>get home from work
>get drunk
>open up my personal projects I keep meaning to work on
>can't program anything meaningful bevxcaue im drunk

how do i break this cycle

Attached: image.png (680x521, 99K)

I don't know I'm asking because that guy implied it's a brainlet thing to do.

Stop going to work.

You're drinking because of work-related stress.
Quick fix: quit your job, buy tons of alcohol with your savings, attempt to drink it all in one night. Or, alternatively, go on a month-long bender. Lose touch with friends, family. Lose the ability to pay for your housing. Go hungry for a week.
Only then will you find the ambition to get off the sauce and back to programming. It's like a spiritual rebirth, user. Gotta crack a few eggs to make an omelette. So go all out.

I'm an employed Haskell programmer.

you're a liar.

He said that
using namespace std;
is dumb. Obviously. How do you jump from there to "std is bad"? You aren't making sense user.

What the fuck *does* dirent mean anyways?

I've used it for a while, but does the word come from anything?
On that note, what does "Inode" mean?

Attached: Screen Shot 2018-05-13 at 6.39.22 PM.png (1446x900, 195K)

you a gay

directory entry

Come on now, user. You should have been able to solve this.

why do people use buffer sizes of 256? if you were trying to be efficient you would use 255, which is max size of 8 bitz, but 256 uses 9 bits, and doesnt even use all of the ninth bit

Disappointed but not surprised.

You know that zero exists, right?

The length of a byte is 256 but if the index starts at zero it only goes up to 255.

See that's what I'm talking about.

It's so simple I completely fucked it up. What's Inode, then?

256 different values can fit into 8 bits, user.

1 bit: 2 values, 0, 1
4 bits: 16 values: 0, 1, 2, 3, 4, 5, 6, .. 13, 14, 15


Just like my dad

See:

Index node or indexed node

class Solution
{
public int arrayPairSum(int[] nums)
{
int sum=0;
Arrays.sort(nums);
for(int i=0;i

basic types (non-array, non-class) are passed by value

all others are passed by reference

I don't know Java but nothing in this code I plus that the original array changed.

Thanks, senpai!

Attached: Smug-nika.png (765x768, 228K)

arrays are considered primitives? wtf

>Arrays.sort(nums)
is the one...sorting the array of nums?

If the array is passed by copy it's just sorting a local variable called nums.

>local variable
you mean local to that function or the calling env? because if scope is within the function then the original array in the calling env shouldnt change

ARGHH WTF IS THIS c is a lot more intuitive than this shit

Local to the function. IF it's being passed by copy the outer array doesn't change, instead you have a local copy called nums.

>all this time and you could actually just use Array.sort in leetcode

Attached: jerry is high.jpg (800x450, 62K)

>parsing the output of ls
>in C
Theo de Raadt is crying right now.