/dpt/ - Daily Programming Thread

What was you working on before you dropped it, Sup Forums?

Old thread:

Other urls found in this thread:

nntpchan.info/
en.wikipedia.org/wiki/IEC_61131-3
en.wikipedia.org/wiki/Subset_sum_problem
scratch.mit.edu
introprogramming.info/english-intro-csharp-book/read-online/
twitter.com/NSFWRedditImage

C#

watched some c# tutorial on youtube and got to like video 10 and i dropped it lol programming is hella confusing

A game in unity (C#)

Lisp.

ur mom

My ambition.

nntpchan.info/

may start adding country flags to the frontend repo but eh

Sounds like a legal nightmare.

chilling at codewars
>solve a problem using c
>same solution in js times out

Do you give your classes cool -non-cringy- names?

>classes
You mean typeclasses, right user?

Anything that isn't easy to understand and descriptive without being too long is cringy.

A cool name is cringy.

are there any good programming games?

Yes, otherwise we would have to deport him right away.

SHENZHEN I/O
tis-100

Working with MFC in C++ atm, not sure what to make of it. This doesn't get used at all anymore, does it?

>C++
>This doesn't get used at all anymore, does it?
only by subhumans.

> MFC
Isn't it dead and buried?

it gets resurrected here where I am studying for everyone done with classes/inheritance in c++

general module plan is

c
sql
c++ (+MFC)
c#
java

everything over 2-8 weeks respectively

there is a ton of legacy mfc code that needs maintenance I believe
companies shat out a lot while waiting for c#

as for new stuff, no, nobody uses it anymore

is there any option or way without base64 or rot13 to encrypt a password in a python source code? any tip or help guys?

# create a interactive shell
chan = ssh.invoke_shell()

# enable!
chan.send('en\n')
time.sleep(1)
resp = chan.recv(9999)
# print resp

# enablepassword!
chan.send('enablepassword\n')
time.sleep(1)
resp = chan.recv(9999)
# print resp

>base64
>encryption

Anons

I met this guy the other night while I was drinking. He called himself an "automation engineer", and said that he programmed factories.

He told me that there were two languages he used for it. He showed me an example of a program in one of them and it basically looked like he was drawing a state diagram. Obviously very high level languages. I don't remember the names because I was drunk.

Anyone know what languages these might be? I studied computer science but never heard of anything like this.

nevermind I found it.. one of them is called "Ladder logic". have any anons used this ?

en.wikipedia.org/wiki/IEC_61131-3

>base64
>encryption

yes, that was stupid written from my side, shame on me. it's not kinda encryption I know that, too

yep that was it. looks pretty low level actually.

It's just a way for CS-illiterate electrical engineers to program simply logic in PLC, there is not reason to use if you aren't one.

What was the last tool you built to assist you with programming in some manner?
>I haven't built any
Well we all have to start somewhere obviously.
>I'm 18+
Oh.. Well, maybe you should get on that now?

I've come in contact with it. Management told me to translate that junk to C because they don't have people who program in that anymore. And there's so many different flavors of tools for this it really doesn't make sense to try to find people who know how to program it. But this was for PLC. I'm not exactly what automation entails.

He told me that he used it to program PLCs. I think he called himself an automation engineer because he programmed the "automation" of the factories.

Not really, any encrypted form of that password would require there also being a key in your script which would make it pointless.

Either prompt the user for the password, or if it needs to be automated, keep it in your script(or an external file) with the proper permissions so that only your user can read it.

Been working on embedding Guile as scripting language for a game engine. Managed to create an ingame repl as well.

Why sticking certain functions to certain types of data is not considered to be a good thing?

Is it possible to do this in one loop instead of making all possible subset of initial set, thus wasting 2^n steps?

Solution says yes, but they didn't write the program

I know how to do it with all subsets, but i'm interested in more optimized solution

-> 59399177
Please do not use the following when promoting your reddit garbage here:
1) A Karen image.
2) An anime image.

If you're thinking about OOP, that's not all OOP is.
Practically nobody is complaining about member functions. Though if you make use of implicit this pointers and whatnot it reduces code reuse unless you do inheritance and suddenly you're inside the event horizon of OOP.

To be clear, they didn't say it's possible to do it in 1 loop, maybe they meant 2 loops, which is still faster than 2^n

Isn't C just a scripting language for low level stuff at this point?

Feel free to reply with your opinion.

Yeah, pretty much.

>not making your own language
pleb identified.

Why? It seems to be better than Java.

Trash language.

>scripting
I don't think you know what it means.

It is.

Problem is that you get made fun of here because Sup Forums hates Microsoft, so I had to stop using it.

>using C* of J*va

I intend on taking over the OP, can someone please post their best OP image(s)? Give me your absolute best.

Is this image real?

>american education

Probably.
I had a physics teacher who didn't believe atoms could be split. We had multiple discussions about it to ensure that she was in fact retarded and not just wrong.

Remember that only anime image makes /dpt/ OP image.

if you're doing two loops you're basically only checking pairs aren't you

see if sorting the list helps

...

I may have procrastinated in my Operating Systems homework. How difficult should it be to improve an OS I wrote in C/ASM that simply prints the value of the EAX register to the screen, to instead capture keystrokes and write them to the screen?

The subset sum problem is NP-complete, so there's no known algorithm which time complexity in the worst case is O(2^N), despite it being a decision problem.

However, there are some ways to make it somehow faster in practical cases, beneath them:
- dynamic programming: using results computed on subsets of the input to compute a result on the input itself
- integer linear programming: turning the problem into a system of linear equations and pass it to a solver. If there is a solution, it may find it quickly thanks to some heuristics and optimized backtracking techniques.
- approximation: under some conditions (for example how near the numbers are from each other), the polynomial time complexity approximation algorithms can give the same results as a brute-force algorithm.

You know English is considered as a really bad language too, so your your argument is insufficient.

But it's not. You not being able to speak it doesn't somehow make it "bad".

>yet another knapsack's np-complete cousin
damn, I remember fucking up this problem in highschool

there is a "neat" dynamic programming trick, explained here en.wikipedia.org/wiki/Subset_sum_problem

basically, fill up the 2d array of partial solutions starting with n = 1

scratch.mit.edu

HackNet on Steam seems kinda cool.

>so there's no known algorithm which time complexity in the worst case is O(2^N), despite it being a decision problem.
wew I meant "time complexity in the worst case is LESS THAN O(2^N)"

btw, what's that book called?

Does anyone know algorithm to find all available paths in a graph from one point to another? I can easily find the longest one, the shortest one, but not all paths...

So why are the giant enterprises still recruiting c#/asp/xamarin engineers?

I was just firstposting.

I haven't dropped C#. It's my main language. Easy as fuck to get pretty much anything done in C#.

depth first search with backtracking

>children are more imaginative than their teachers
Not surprising, but also terribly self-reflecting.

>pic related
is my proposition for OP.

Isn't the simplest solution just a Flood?

introprogramming.info/english-intro-csharp-book/read-online/

Pretty hardcore for a total noob like me, ut i like it because it's a mix of basic c# and actual programming logic (that logic is way harder than learning the language itself)

I tried picking up C++ a while ago, attempting to write a web framework with it just to try it out and see what it went for.

Ended up dropping it because, while C++ has features that seems nice over C on paper, like RAII or symbolic initializer lists, it seems that for whatever reason it's just impractical in practice. I'm not entirely sure why, but it just feels like nothing comes out convenient in the end. I guess one reason is that you have to write a whole class with three different constructors and two assignment operators for whatever little thing you want to manage.

It feels like I'm just getting the worst of both worlds whatever I do: The inconvenient parts of C, along with the inflexibility of Java. I'd rather just use one of those instead, and get some of the good stuff also.

plan9 people are the worst, it's hard to say whether I'd rather spend time with plan9 people or furries

>plan9 people
Do they still exist? Or aren't they an endangered species?

You can just treat it like C with better namespace management if you really like C.

C++ is really good if you just treat it as procedural for most things and OO for really complicated Self contained objects.

In games for example; a good way to do it is to make most everything Procedural with the exception of Components, Blueprints and the Engine System blocks.

You'll need to write and IRQ manager. If you really only want to capture your keystrokes then it's a matter of an hour max. If you want to make an actual system of it eg a shell then it will take several days or weeks as it requires setting up all descriptors, memory management, etc. Since you mention eax I assume you are doing protected mode then youre in luck because many tutorials exist.

Nice first time I see someone post sensible about Cpp and not just the usual memes.

they exist on Rizen and Freenode, thank god they keep to themselves but sometimes they leak out

How do you find in C# the count of all elements in array that are NOT 0?

arr.Count() returns all elements, but i need only those that are not 0

Found it

arr..Where(x => x>0).Count()

its what I grew up on; C, C++, ASM(pic32/x86/x64)
Also, it turns out that C# isn't amazing for speed
and C isn't great when you have extremely complicated objects
so C++ is great for games (which need both)

Iterate on your own

>You can just treat it like C with better namespace management if you really like C.
You *can*, but then you could just as well write C and not get mangled symbols.

>C++ is really good if you just treat it as procedural for most things and OO for really complicated Self contained objects.
What I found is that the OO-influenced parts of C++ end up "contaminating" the C inheritance, though. Since everything kinda "wants" (not "requires", but wants it heavily enough to make you feel dirty otherwise) stuff like const-correctness everywhere, references, RAII-handled resources, proper classes for using any library, and whatnot, it limits the ability, or at least willingness, to write more C-like code. And even if you try to regardless, it ends up looking kinda ugly and weird.

Not to mention that you end up having to put everything in header files, so every time you change some little implementation detail, you end up having to recompile the entire project since everything depends on those headers, at which time you also start noticing that the C++ compiler takes an order of magnitude more CPU time and RAM to do its job than the C compiler.

C++ seems like an attempt to mix two very different programming styles which, while they *can* mix, don't mix very well, and the result ends up grainy and unappetizing.

Not doing C#, but knowing a little LINQ, you could either iterate on the whole array or filtering it and applying Count() on the filtered array.

Ah.

Thanks. Yes it is protected mode, not a shell. Just captures keystrokes and writes the data to VGA memory 0xB8000.

I'll probably just have to set up an IRQ manager like you said, then fault handlers and a service routine for the keyboard inputs

I think it would be more efficient with Aggregate, something like
arr.Aggregate((acc, value) => value == 0 ? acc : acc + 1)

because this is just a single loop without allocations, while Where creates a temporary IEnumerable.

What is acc here, next elements in array?

Use private/public keys you fucking dingus

I personally disagree, but then I don't tend to mix libraries and tend to avoid building things that rely on the aspects that require const correctness.
I can see where you are coming from though.

Like I said, I tend to use it because it lends itself to things like game programming well, but allowing both a higher level management of data, as well as allowing you to write large amounts of code with a little bit better namespace management than C but otherwise almost just straight C.

Also, about the Header files; you can mitigate this through some amount of templating (though i don't suggest it for most things) and pre-processor shenanigans. It does come up more often if you are treating it very like a procedural programming language though.

>C# on Windows
Should I use SharpDevelop or VisualStudioCode?

Translating the keystrokes to something human readable takes a bit more work. I'm sure you'll manage. Good luck!

It's all a question whether you prefer style over efficiency. Of course, it the array would have millions of elements, I would recommand efficiency.

acc is the ACCumulated number of values which are equal to zero. You start with acc=0, and it increments each time the current value is equal to zero.

Is there even a sorting algorithm that could beat quicksort. And I'm not talking about randomized quicksort, hell I'm not even talking about randomized quicksort with a cutoff. I'm talking about randomized quicksort with a cutoff using a median of three to chose pivot as well as employing 3-way partitioning.

Bogosort

Are you retarded, use Visual studio

If you meant linux, you can also check jetbrains rider

Nah, sleep sort (© /prog/)

Count takes a lambie, actually.

arr.Count(x => x > 0);

>2017
>US scandals
>not using self-built, free and open source software
Sorry but you are retarded.

>self-built
>free and opensource
gl with cia injections in your opensource

care to share muxExtension?

Disregard this, need bigger sample sets and more iterations.

We value your opinion.