/dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1540753363925.jpg (960x598, 119K)

Other urls found in this thread:

leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/
gcc.godbolt.org/z/gJeyPU
gcc.godbolt.org/z/j7oLZR
twitter.com/SFWRedditVideos

First for Haskell

nth for j

If you're not programming in C++2a, you're not programming.

Making a game in C for the first semester of my CS degree.

But mafuyu isn't cute

forgot to say i went to CS because i like video games

Gr8 thread OP

Attached: 1533840968098.gif (350x197, 353K)

>tfw

Attached: 7102012232216iwsmt.jpg (574x606, 82K)

literally me right now

fuck discrete

not me though this is definitely some of my classmates
had some of them unhappy about the difficulty of the freshman math courses and apparently there were some complaints to the CS department about having to learn assembly in one of the three first semester CS courses

the absolute state of brainlets.

i wanna fug mashiro

imagine believing that babby's first reduction is hard
dumb cslets

whoops you misspelled hug

the madlad made his own thread lmao

and a click bait image

nice

nobody cares about your java homework rajeet

ah yes let me learn the rules of academia to appear smart xD
brainlet

and you misspelled Kobeni

Attached: 1510447342152.gif (476x720, 738K)

???

I want to massage kobenis breasts and tease her nipples while telling her why C++ is the most powerful programming language in the world.

whoops you mean tests (results) and by massage you mean manipulate and by nipples you mean nibbles and by tease you mean feed and by C++ you mean literally any decent fucking language you bjarnewashed retard

Been trying to get better at dynamic programming. Currently stuck on this problem: leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/
Plz don't spoil, but feel free to make me feel bad by solving it in 10 minutes and posting results.

Can someone give me an example of bad branching that makes optimization hard for a compiler?

>Ooops, page is crashed
Great error message

my first year class prohibited games as the final project because they're too complicated.

>10 minutes
you are like little babbby, watch this
public class Solution {
public int maxProfit(int[] prices) {
int hold1 = Integer.MIN_VALUE, hold2 = Integer.MIN_VALUE;
int release1 = 0, release2 = 0;
for(int i:prices){ // Assume we only have 0 money at first
release2 = Math.max(release2, hold2+i); // The maximum if we've just sold 2nd stock so far.
hold2 = Math.max(hold2, release1-i); // The maximum if we've just buy 2nd stock so far.
release1 = Math.max(release1, hold1+i); // The maximum if we've just sold 1nd stock so far.
hold1 = Math.max(hold1, -i); // The maximum if we've just buy 1st stock so far.
}
return release2; ///Since release1 is initiated as 0, so release2 will always higher than release1.
}
}

>I want to manipulate kobenis breasts and feed her nibbles while telling her why literally any decent fucking language (lol) is the most powerful programming language in the world.
?

better than
>oopsie whoopsie our coder monkeys...

>tests
also a nibble is like a smaller bite (in both the eating and crumb sense)

>...made a fucky wucky

>>tests
You didn't specify what "tests" replaces

i'd forgive them if they used a moe >_< image

Attached: 1526911161799.png (538x538, 492K)

>posting solution
>not submitting on site and posting results
I'm gonna guess this doesn't even work before hiding it

yppo unless u become who u is

>using leetcode
>using leetcode without reading Discussions
not gonna make it

Well I guess I'm not programming then

Attached: shrug_emoticon_waifu.jpg (820x901, 371K)

pls help

I thought CS being brainlets was just a meme.

the postgres server is running on something like
localhost:3000


so connect the mobile app to this address

1. No you dont
2. You posted it in the right place the first time
3. You need to do about 10 things different for this to work

the server is running on the local machine so the address will be 'localhost', aka 127.0.0.1
make sure you have the correct port as well

Reminder that the optimizer is actually a cute (and lewd) 2D girl!
Remember to love her lots and rub her cute breasts and tease her cute little nipples, cum on her face (she loves that), and tease her cute little bean very conservatively until she literally cannot hold back anymore. You can do this by:
- Supplying as much type information / other information as possible
- Computing as much at compile time as possible
- Avoiding anything dynamic as much as possible
- Preferring static zero overhead abstractions
- Enabling LTO
- Using the latest C++ standard
She's just a lewd little girl who can't stop thinking about dirty things like performance and efficiency all day!
She gets totally turned off when you:
- Use void pointer "generics"
- Unnecessarily make static information dynamic
- Not enable LTO
- Use shared libraries
- Enable PIC
- Use old C++ standards
- Disable her with -O0
- Unnecessarily use inline assembly

Finally, don't hold back on the templates and constexpr. Let your lewd little template hungry optimizer cum all over the place and spew highly efficient code everywhere.

This has been a public service announcement from the ISO C++ standards committee.

Attached: 1530231929805.jpg (742x551, 253K)

>C++
>Optimised
Your shitty meme language doesn't even have restrict pointers.

Attached: 1376182921994.jpg (445x488, 65K)

Restrict pointers are stupid, if two pointers do not alias then assert that they do not alias.

C++ has restrict pointers implicitly through strong typing.

You don't know what restrict pointers are.

Nice sour grapes, idiot.
Enjoy no optimisations.

Strict aliasing is not a replacement for restrict pointers. C has strict aliasing too.

You're an idiot.

thanks I'm gonna try that tomorrow. I thought localhost was supposed to refer to the machine itself only, not for my mobile phone to refer to my computer.

Any decent assert implementation will include an unreachable intrinsic if the assert fails when NDEBUG is set. In this case the same optimisations may be applied.

see help pls

Does algebra get much harder than linear equations?
Trying to relearn math to help me get better at programming and I was never good at it before.

>Does algebra get much harder than linear equations?

You learn this in like 4th grade. Yes, it does get harder.

>Does algebra get much harder than linear equations?

Attached: 1463064892991.png (270x360, 139K)

A shitty game in python. I think ive gotten my use out of it tho

>trying to relearn linear equations
Jesus Christ dude, how old are you?

I mean just basic highschool algebra 1, not moving into linear algebra and that stuff for a while.
>You learn this in like 4th grade
[spoiler]I'm very bad at math in case you cant tell. I realized yesterday that I dont know how to do basic arithmetic involving fractions.[/spoiler]

Attached: 1455583175374.jpg (319x310, 43K)

gcc.godbolt.org/z/gJeyPU
Seems compilers aren't smart enough to figure that out.

24

Linear & compex algebra is highschool algebra, user.

I'm 22
granted, this stuff is really easy but I'm just starting low and making my way up.
please dont laugh at me

Attached: 1458626540237.png (240x240, 24K)

it's ok to be a retard user, most of the OOP programmers here are

Attached: 83421.png (203x248, 14K)

Well gee, I sure am embarrassed. I'll have to look into this some more.

don't worry too much about it

It gets harder, like non linear algebra. But I never felt it really got harder, You just build your knowledge.

gcc.godbolt.org/z/j7oLZR
Even clangs __builtin_assume is too dumb for it

If you're using intrinsics in assert, then there's nothing stopping you from #defining restrict to your compilers restrict intrinsic.
All relevant compilers have a restrict intrinsic, like the one used in the godbolt snippet above. This is simply a non issue and Ctards are just scraping the bottom of the barrel for excuses.

Joke's on you, I do both.

Attached: me.jpg (1300x956, 150K)

oh shit i totally misread the question
localhost on the mobile phone will not connect to the computer

if the mobile phone is connected to your home wifi you can use the local network address. if it's not, the connection has to go over the internet and you will need your home's public IP and you will probably need to forward some ports.

Working through problem set 2 of CS50 Crack problem right now.

Attached: 1540462202326.jpg (675x873, 89K)

Your house has 2 computers.
one is connected to the WiFi, the other through an Ethernet cable.

how do you ping one computer from the other?

They're both on the same network so you use local IP.

The problem gets more difficult if user wants to connect to the server over mobile data while outside the home

Help

New here to learning how to program and this has me totally stumped.

All these points would be true if I was making programs by myself only for myself, but I have to manage working with a bunch of programlets and make our framework flexible enough to prevent fuckups.

>They're both on the same network so you use local IP.

computer 1 (WiFi) : 192.168.1.73
computer 2 (Ethernet) : 192.168.1.65

computer1 $ ping 192.168.1.65
requested timed out
requested timed out
...

but if i ping another computer connected through WiFi it works. that one with the Ethernet cable doesn't.

weird.

how do I get my local network address? isn't it the number in ipconfig?

>bjarnewashed

Attached: 124.png (1920x1076, 3.11M)

You literally haven't even looked up the syntax of a function yet and you're already asking for help. You are the definition of a lazer zoomer who is never going to make it. Put some effort in.

public class PlayANdPauseOnIpod {

private static boolean playButton = true;

public static void playMusic() {
if (playButton) {
System.out.println("Music is playing");
} else {
System.out.println("Music is paused.");
}
}

public static void main(String[] args) {
playMusic();
}
}

2018 Jow Forums sucks

Attached: spoon.jpg (1280x720, 54K)

>implying I didn't use my Java Code Recognition program to translate an image to code

weebs go and stay go

ping is not a good method of testing connectivity because the echo command (what ping uses) is often disabled by default on newer operating systems

Thanks for the help; I've messed about with moving stuff already but this is the same problem I keep having; trying to understand why.

Attached: file.png (746x470, 44K)

>ping is not a good method of testing connectivity
works fine in 99% of computers

in this case your router is likely being fucky and treating them as separate networks or something

I also had a curly bracket in at the end and that is underlined in red too.

where do you poo?

unless it's disabled, then it works on 0% of computers

Read the error message ya fucking tard.

by default, it's enabled on 99% of computers

I'm new to this, you asshat.

Attached: file.png (187x51, 2K)

Lisp is the most powerful programming language.

So if it's expecting a class and you are giving it a method, what does that tell you? THINK FOR GODS SAKE. WHAT IS METHOD?

Reminder that there's no such thing as "bad at math", there's just being an absolute lazy retard. CS/engineers who pass their calc courses are at least not lazy.

Attached: smug_ran6.jpg (802x1240, 114K)

Vary your images kudasai

>need to get dressed
>what if i put my socks on my hands?
>what if i put my pants on head?
this is what you're doing, dunce

I passed my calc courses just by studying the day before the tests and now I've already forgotten everything

based fox

This confusion started in trying to understand the difference in functions and methods. I'm not au fait with every command and syntax in the world so it's not the most straightforward.