/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

reddit.com/r/learnpython/comments/7esmuw/how_can_i_wrap_my_head_around_recursion/dq7cw51/
openbookproject.net/thinkcs/python/english2e/ch21.html
cs.indstate.edu/~cbasavaraj/cs559/the_c_programming_language_2.pdf
stackoverflow.com/a/2482610
tusubtitulo.com/original/59350/0
tusubtitulo.com/episodes/59350/star-trek-discovery-1x11-the-wolf-inside
ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/1b-procedures-and-processes-substitution-model/
twitter.com/NSFWRedditVideo

First for anime and C

Working in python for the first time- what's the best way to save series of dictionaries that look like this:

logic_steps = [
{
'pattern': "asdfghjkl",
'message': "This is not possible"
},
{
'pattern': "anotherpatterntomatch",
'message': "The parameter provided application is invalid"
},
{
'pattern': "athirdpatterntomatch",
'message': "Expected value for debugging"
},
]

i want to be able to access the most recent pattern and messages...from a txt file.

is this possible with 100+ entries?

Is it valid to cast a pointer to a union to a pointer to a member of the union?
Same for structs. I think I heard that a struct pointer is equivalent to a pointer to its first member.

Thank you for using an anime image.

Rust isn't really as bad I thought it would be.

>cast a pointer to a union to a pointer to a member of the union
As standard C, no.
As a GNU extension, yes.
>Same for structs. I think I heard that a struct pointer is equivalent to a pointer to its first member
That is true.

why do i get a squiggly?
how to fix?

it's not portable then, fucc

It's not like accessing a member then taking the pointer is hard, though.
(int *)a
vs
&a->b

use code tags

using System;

>when spoon feeding is not enough

it literally asks you a retard-proof question in the error list

JSON or binary serialization to disk

gotta learn sometime
i'm too new to know half these terms

didn't get to go to CS college for free
trial and error, baby!

thanks, half the squiggy is gone, but lenny is still there

I recently got asked to solve this coding exercise in pic related and am pretty stumped on how to do it.

I can do it in any language of my choosing. I've been trying with Java since it's what I know best but I've also considered trying Python.

How would Sup Forums go about solving this? Second part of explanation will be next post.

Explanation 2/2

Read a beginner's book. Seriously. Don't go about it by trial and error, trust me.

literally nigga you need to get some o dat baseline edumantication
gotta try thinking for yourself, making some guesses, posting them here, etc

books are how i know what i do know.
this is the PRACTICE

how the fuck does it NOT exist?
i made it exist
whether it's spinner_ItemSelected or spinner1_ItemSelected

same error.

4got pic

separate the problem into subproblems
- what way would you represent your data to allow you to easily solve the problem (data structures, DSs)?
- handling the input and turning it into said DSs
- algorithm to operate on said DSs and produce the result

now try thinking through it and posting your guesses as to how you can approach this

>i made it exist
you sure about that?

>remember reading some trashy harem and the guy needed a book on C++ template metaprogramming
How often do people actually need to use C++ templates for advanced metaprogramming shit?

pretty sure, i think?
if not, what am i missing?

>C#, XAML, AXML, VS, Xamarin they said... it'll be fun they said

I must be retarded. I keep getting errors when trying to dump the dictionary to json files

>spinner_ItemSelected = spinner1
Duh durrrr

>advanced metaprogramming
Almost never

Started with panda3d yesterday evening. Development is rapid. Inspiration struck. Now gotta implement game mechanics, design a test level.

Tomorrow I'll work on collision detection some more. Then AI of computer to find and follow the player.

This will become an utterly retarded meme game.


I must say, python is less a dick in the ass than java on android was. At least no gc fucking me over.

so, did you figure out what was wrong, or are you still stuck?

That's the approach I was taking in Java. I made a Cow class to store the ID and two ArrayLists of folder permissions for each individual cow.

Then I use a Scanner to parse the input info and I ran out of time before I could start on the algorithm to sort the cows.

well, based on this and trying to stick it everyone, a tip popped up and suggested to make it a method. building now to see if it runs on emulator

gj m8

Convince me not to start learning Haskell

No.

Well according to this guy:
reddit.com/r/learnpython/comments/7esmuw/how_can_i_wrap_my_head_around_recursion/dq7cw51/
Hasklel is the one twue way to learn recursion.

I am planning to learn Haskell too.
How did you guys learn Haskell?

>I made a Cow class to store the ID and two ArrayLists of folder permissions for each individual cow.
>algorithm to sort the cows.
why sort them?

you're using a cow-centric approach. That may work, dunno
To me the most intuitive approach is:
- we have a tree of dirs (folders) in the problem statement, so let's build a tree
- users (cows) have permissions that propagate down the tree
so:
- build a tree of dirs
- annotate each dir with its access list (set of users) based on the input
- then solve the problem.
A. Either propagate permissions down the tree, then for each leaf list which users *don't* have access to it
B. Or for each leaf calculate (by going up the tree) which users can/not access it
In both cases above, your algorithms should handle the difference between pub/prv dirs properly.
In short,
- data organization: tree of dirs, each with a set of users that can access it
- algo:
- a. either propagate who can access what down, then check each leaf
- b. or directly for each leaf check (by going up the tree) who can/can't access it

note that the language you use may make this more/less tedious
e.g. I have a feeling that doing this in Java's going to be verbose, tedious and take long enough to make me give up
while in Scala (I believe) this ought to be short/easy enough

note that this is the straightforward approach. There may be smarter/simpler approaches, but that'd require more thinking than I'm up to doing right now

t. terse

Learn you a Haskell for Great Good is the classic book and what I used but from what I understand it's a little outdated now. I've heard a lot of people recommend Haskell Programming from First Principles though I haven't read it. I think you can find it on libgen. Beyond that, just find a personal project and try to implement it in Haskell. If you just try to do nothing but Project Euler or something you'll probably get bored.

tried every available AVD
they all hang here
wtf?

Because I don't know shit about data structures desu. I have a semester each of Java and Python under my belt and the "make class to represent thing and its data, build array/list of thing, perform necessary operations on list of thing and print results" was pretty much the default template for all of the Java projects we did.

I'd unironically say that SICP is the best way to really learn recursion.

I think HTDP is better because of the "recipes".

As wrong as reddit is to give this guy an abundance of minus points and the responders plus points recursion is not a difficult concept and you should probably be advised to look at how you handle knowledge in general if you struggle with that.

ah, I see
yeah, probably a way to do it without trees, check for hints on how the others did it

but I'd highly recommend
- learn how to use sets (just adding stuff to them and union for this problem), Java has them built in, just like ArrayLists
- learn how to make a simple tree
- later, learn how to traverse it

that should be sufficient for the straightforward approach

actually, I'd recommend you try doing it in python
shit's much more concise there, although the dynamic typing means you'll get no help from the compiler
e.g. tree:
openbookproject.net/thinkcs/python/english2e/ch21.html
sets are just
allowedCows = set(1, 3, 5)

Stop using an AVD. Use a real device.

Best way to learn C?

what is hard about recursion?
int main(void)
{
main(void);
}

oh you

calling main() is undefined behavior

the difficult part is wrapping your head around how the function call tree works and how to return useful information when you can't send state down the line.

This is what I started with:
cs.indstate.edu/~cbasavaraj/cs559/the_c_programming_language_2.pdf

It's honestly pretty simple. Learning from a book might not sound fun but you don't even have to get very far into it before you know enough to write programs.

Ok i fell for the college meme and now we are being taught OOP with dbz ms paint memes like a bunch of fucking retards.

What learning materials do the big boys use? I am about to burst a vessel or something

Nothing so long as you get it explained to you properly. i remember the first CS textbook I ever had told you that recursion "just works" and the best way to comprehend the concept was to "not think about how it works". This same "for everyone" book also used Riemann sums to explain how Big O works rather than just practical examples.

switch majors and learn programming yourself
going to college for anything computers is a meme and a waste of time and money

> we are being taught OOP with dbz ms paint memes
Uh what? Slides please.

cool thanks!

Still working on this from last night.
A Lo Shu Magic Square.
rows, columns, and both diagonals have to add up to 15.
I have the rows, and columns, still working on the diagonals, and how to return the flag using them.
bool loShuMagic(const int numbers[ROW][COL])
{
bool flag = false;
for (int x = 0; x < ROW; x++){
int sum = 0;
for (int y = 0; y < COL; y++){
sum += numbers[x][y];
}
cout

alright, lets try again
#include
#include

void meme(unsigned int counter);

int main(void)
{
meme(5);
exit(EXIT_SUCCESS);
}

void meme(unsigned int counter)
{
puts("meme");
if(counter > 0)
meme(--counter);
}

python trees, even simpler:
stackoverflow.com/a/2482610
class Node(object):
def __init__(self, data):
self.data = data
self.children = []

def add_child(self, obj):
self.children.append(obj)

example usage
>>> n = Node(5)
>>> p = Node(6)
>>> q = Node(7)
>>> n.add_child(p)
>>> n.add_child(q)
>>> n.children
[, ]
>>> for c in n.children:
... print c.data
...
6
7
>>>

waiting on my last classes, la's

people say java is difficult because it has so many libraries but other languages do as well...

?

>lmao java? Enjoy your 5mb hello world
>*links 20gb of boost*

c++ is the greatest language of all time

...

haha ebin xD
pls post the one with the cars where see plas plas is cool car like my dad's :D

:)

>start working in cpp for months
>go back to c for a small project

these compile times are amazing wtf

...

you cringey fucker

>we are being taught OOP with dbz ms paint memes
Post 'em

thanks doc

le gag army is here!!

Believe it or not this is actually very useful because you can just choose to remove and ignore the unnecessary features if you want. If you just need pliers just use the pliers. Same with C++.

I'm trying to download this link
tusubtitulo.com/original/59350/0
with urllib.request.urlretrieve but I can't.

why does this link only work when clicking? it doesn't even work by copy and pasting it in the urlbar

how can I do it?

Lisp is the most powerful programming language.

I agree with this dude.

I am making six figures and most of my friends are still in college. I got hired cuz Im a brainlet and you are still lil babi's first code, nub.

Yeah, but what's your location's CoL?

>tusubtitulo.com/original/59350/0
this link doesn't exist?

it does, mate, but it only works when you click it from the site. it's here:

tusubtitulo.com/episodes/59350/star-trek-discovery-1x11-the-wolf-inside

in English
tusubtitulo.com/original/59350/0

When you leave school and get a job, are you literally programming for 7-8 hours a day or does it vary on a day to day basis? Seems like unless you spend most of your day programming while in school and don't hold another job that would be a massive jump. And how are you suppose to go to school, have a job, and still code in your spare time? Because even if I were to have a part time job I'd probably have around 10 hours a week to code in my spare time max

31-32mins in, lecture 1 b explains recursion fairly well
ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/1b-procedures-and-processes-substitution-model/

So all you do with SQL is just manipulation of data tables? Is there anything more to it or is that basically it?

All right dpt. I have like 4 months to build a couple of projects so I can get a summer job. Senile++. Give ideas. I already have 2 slightly longer term ones in the works, but I want to go full autist and diversify.

if you're really really really really really good at programming, you don't need to program at all.

Stop shilling Python.

That may be the dumbest thing anyone has ever said ever

Cute
Sauce?

this picture bothers me
the slit is in entirely the wrong place and at the wrong angle

>if you're really really really really really good at , you don't need to program at all.
ftfy

>slit
uhhh

>the slit is in entirely the wrong place and at the wrong angle
that's the gap between her groin and her left leg, not her pussy

>her
uhhh

What's your opinion on this?

maybe, it's just not registering correctly in my brain
like when I looked at this picture the first time

>tfw you'd like to read the book but your language doesn't do OOP

Look up the rest of the set. None of the others are traps. Her tits look small because of the angle that she's laying down.

kys