/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

learnpythonthehardway.org/book/nopython3.html
docs.cs50.net/problems/mario/less/mario.html
youtube.com/watch?v=LhqUk28OwHs
youtube.com/watch?v=8Sr3BAu-zLk
youtube.com/watch?v=xihzgEsV2nw
youtube.com/watch?v=BI0gwjg0h2E
twitter.com/NSFWRedditGif

We should get rid of for-loops, they're not practical, they're too abstract.

Recursion is academic nonsense, all you need is a while-loop.

Agreed, anything more abstract than conditional jumps belong in the bin.

learnpythonthehardway.org/book/nopython3.html

Holy shit is Zed Shaw retarded?

Anybody who writes subroutines should be fired.

Yes

Anyone who uses type systems should get the gas.

Pygame

Are there any games that teach coding? I'm interested in something like python or C++

I have a full time job as a DBA so I don't want a tutorial, more something relaxing that will also teach me new skills

...

CS50 problem set 1, I just finished mario and was wondering if there is a way to complete this application by not using 23 if statements?

Just wrote a simple LUA addon for Elder Scrolls Online. Should be publishing it on the ESOUI website soon.

If you want a zero and your target arch doesn't have a zero register then you better fucking xor a register with itself.

Would you care to expand on this thought?

How much are you charging?

What is cs50 problem set 1? LIke what is the question? Link me to it

>filtered champagne

that fucking file name

SHENZHEN I/O or TIS-100, although you'll learn assembly rather than a high-level language.

Just read the shit where he says Python 3 isn't Turing complete.

docs.cs50.net/problems/mario/less/mario.html

there is no source code...

>Dynamic typing is [..] one of the reasons I advocate it for beginners.
The future, ladies and gentlemen.

I did it for myself because there aren't many UI addons out there, and there was certain information I wanted that was only available through the API and not through the stock UI.

>no anime image
dropped

>alex jones
>not anime

>for(int i=0;i{ continue; }
it wurks

get on my level
(do ((i 0 (1+ i))
(sum 0 (+ sum i)))
((= i n) sum)))

>Currently you cannot run Python 2 inside the Python 3 virtual machine. Since I cannot, that means Python 3 is not Turing Complete
holy fuck i didn't realize how dumb this retard is. he's talking about how everything is "simple math" but he can't grasp any of the shit he refers to.
the best part is he tries to pass it off as a joke in the "Note" section, but he still sounds extremely autistic and tries to defend his claim, while also trying to back it up by repeating exactly what he said above
exactly. we should start using more concrete loops, such as map and fold

why would you use map or fold when you can do it all in a foreach loop

>Haskell still doesn't have full dependent types
trash.jpg

>implying Alex Jones isn't better than anime
It's nice to see some people on this board growing a pair

Alright I solved it user, its not the cleanest solution, but it beats the multiple if statements that you probably used.

import java.util.Scanner;
public class Mario {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);
System.out.println("Enter height");
int height = scanner.nextInt();
int counter = 2;
while(height-->0){

//checking if this is the first loop, then we know it starts with 2 ##
if(counter == 2){
for(int x = counter; x > 0; x--){
System.out.print("#");
}
}

//this gets called everytime after the first loop
else{
for(int j = counter; j > 0; j--){
System.out.print("#");
}
}
counter++;
System.out.println();

}

}
}

thank god for apis haha

>{ continue; }
You don't need this, just say {} or ;
for (...;...;..); is quite a frequent pattern. Haven't you read K&R?

...

...

where the fk is my thanks. IM FKIN WAITING

...

thank you user

...

>xkcd

np

The code for the fast inverse sqrt is ugly and redundant.
float Q_rsqrt(float x)
{
float y = x;
long i = 0x5f3759df - (*(long *) &y >> 1);
y = *(float *) &i;
y *= 1.5F - x * y * y * 0.5F;
return y;
}

Thx user

>no anime picture
>on anime forum
why?

I want to play with sound programming in C.
How do I generate a PCM sine wave if I intend to pipe stdout to my soundcard?

see youtube.com/watch?v=LhqUk28OwHs
youtube.com/watch?v=8Sr3BAu-zLk
youtube.com/watch?v=xihzgEsV2nw
youtube.com/watch?v=BI0gwjg0h2E

OK

does anyone here use jetbrain's rider? why?

laughing gas?

kys

Nothing beats VS for C#.

>java
it asked for C but whatever

Here's my solution
#include

#include "mario.h"

const char BLOCK = '#';
const char SPACE = ' ';
int main(){
int input;
printf("Enter height:");
scanf("%d", &input);
printHalfPyramid(input);;
return 0;
}

void printHalfPyramid(int height){

int spaces;
int blocks;

for(int step = 1; step

cool looks neat, i didnt really line up my mario hill. I think there is a printf for writing from right to left in java.Too lazy to look it up

What do you mean you didn't line up the hill? I thought that was the point of the exercise?

Not trying to be an ass if I sound like it (^:

why would you use a for loop when you can just use >>= ?

Why would you code when you can kode?

I'm working on Conway's Life in Python and I have a small issue:

I know that it's just something wrong with my 'rules', since it seems to work relatively fine, and is a fully functioning cellular automata, but I'm familiar enough with Conway's Life to know that the rules aren't right, because the normal structures aren't showing up from a randomly generated array.

This is the my calculation function:

def calcStep():
global listNew
i = 0

while i < 100 :
z = 0
while z < 100 :

if( listFull[i-1][z-1] + listFull[i-1][z ] + listFull[i-1][z+1]
+ listFull[i ][z-1] + listFull[i ][z+1]
+ listFull[i+1][z-1] + listFull[i+1][z ] + listFull[i+1][z+1]) == 2 and listFull[i][z] == 1:

listNew[i][z] = 1

elif( listFull[i-1][z-1] + listFull[i-1][z ] + listFull[i-1][z+1]
+ listFull[i ][z-1] + listFull[i ][z+1]
+ listFull[i+1][z-1] + listFull[i+1][z ] + listFull[i+1][z+1]) == 3 and listFull[i][z] == 1:

listNew[i][z] = 1

elif( listFull[i-1][z-1] + listFull[i-1][z ] + listFull[i-1][z+1]
+ listFull[i ][z-1] + listFull[i ][z+1]
+ listFull[i+1][z-1] + listFull[i+1][z ] + listFull[i+1][z+1]) == 3 and listFull[i][z] == 0:

listNew[i][z] = 1

else:
listNew[i][z]= 0

z += 1
i += 1

essentially I'm just looking at every cell around my target cell ([i][z]) and figuring out if it lives, dies, or is born.

The behavior I'm getting is not Conway. It is interesting in it's own way, but not what I want.

spotted the pajeet

Yes I am Pajeet as fuck, but I just started programming. Any help?

really? I thought it just about creating the right number of "#" per line. But i guess u can line it up using space = " ";

How do I define a new type of neural activation function in Tensorflow?

Rate my sine wave generator~
It outputs 8-bit unsigned 8kHz mono pcm to your soundcard.
#define BITRATE 8000
#define AMPLITUDE 50

void sine(float freq, float sec)
{
float samplesPerCycle = (float) BITRATE / freq;
unsigned totalSamples = BITRATE * sec;
unsigned i;
for (i = 0; i < totalSamples; i++)
{
float sample = sin((i / samplesPerCycle) * (2 * M_PI)) * AMPLITUDE;
putchar((unsigned char) sample);
}
}

>float
Stopped reading at that point

>LUA
It's Lua or lua, no that hard

Does someone have any homework or is stuck somewhere? i'm bored.

Could you teach me how to make a square or sawtooth wave function?

I don't know that kind of stuff. I was hoping more of algorithmic programming questions they ask in CS classes.

So basically what you're saying is you don't know shit about math?
What are you even learning in your CS coursework?

how else would you do it

a lookup table would be shit because it could be any frequency

I have seen bigger bullshit from this macfag, but anyway good catch.

CS courses just teach you algorithms now, which is why every CS grad will talk endlessly about sorting binary trees but can't do a clean fizzbuzz

square wave is just "on/off"

sawtooth increases linearly and then drops down instantly, could use ++i in an unsigned char (unsigned integers have modulo "built in") for the simplest sawtooth wave

They teach us discrete maths. They have a few courses on discrete signal processing but fuck if I care.

>square or sawtooth wave function
>math

Are you saying the CS courses should teach fizzbuzz instead?

what's with the expectation being put upon the college?

the individual should be able to learn the shit they need.

I agree. They're also redundant with while loops and goto's.
We should really only have goto's for loops.

We can't listen to an old computer scientist who hasn't been relevant in years on a topic that is as performance sensitive as flow control.
His argument weren't that good anyway.

>algorithmic programming questions
Not sure what you're asking for but to be completely honest it sounds like computer science and not programming.
So GET OUT.

>pay $25,000 a year to self-teach

keep it up debt slave

>tfw when you realize javascript isn't even that bad

the problem is webdevs themselves, who are just bottom of the barrel in terms of intelligence. if the web ran on Lisp or C instead, they'd still be loading MBs worth of C/Lisp code to display some simple text, just like they do with javascript today

This. It's ludicrous. I quit college early because of this. Just a complete waste of money. Ran ahead of my class by two years in 1 year. Probably learned more relevant information than they did.
Looking at the projects they did they haven't come far. It's surprising.

How do I get a programming job?

Look for junior positions

??? i don't even have a CS degree. i've self-taught myself everything from statistics to multivar calc.

my degree is in a comfy field with a comfy job. my comment was a general response.

But those require a CS degree and 5+ years paid experience only.
>the requirements are NOT OPTIONAL do not apply if you are missing requirements you will be blacklisted

It rarely says that.
Very rarely.
And honestly it looks like trolling.

Nah I'm good thanks

I used to think so too but I just landed a job and I haven't even finished my BS. But it is a very "developers first" kind of place, so once someone at the actual company got to look at my example code rather than the recruiter they had no doubts about my ability.

What was the example code? Something they had you code for the application or just something from your github?

I have a Github where about half of it is stuff I've done in school and cleaned up a bit and the rest is random stuff, and then they sent me a test where I had to write a couple of small programs.

was this in person, or via email?

How do i into programing. I have no idea where to start.

They sent the test via e-mail. I was expecting some fizzbuzz or quicksort bullshit because that's what everyone says they get to do for interviews but these were more "real" programs. I guess if they're gonna let you do the test on your own time asking for something as googleable as a sorting algorithm would be fucking retarded though.

Im thinking of picking python for my first language , I've heard that is really beginner friendly and easy to learn . I don't really have plans of becoming a programmer or anything like that just think its fun , cool to know how to , you know ? Anyway I wanted to ask how good of a language python is, what is the most I can accomplish with if I'm really good, what are good examples of stuff done with python and what can I use it for in a day to day life ?

if they say you'll get blacklisted maybe stay away but otherwise the "requirements" are really just a wishlist and they could have a really hard time finding the right guy for the right salary, you don't need to match the requirements 100% or even at all if they're desperate enough and/or you prove yourself worthy of the position

You can do just about anything in Python. There are libraries for most things. I'd say the big pro of writing Python is how easy it is to just throw something together with really few lines of code and have it just work, but it comes at the cost of running slower than many other languages (which honestly is going to be irrelevant for the majority of programs) and it has some really weird quirks in my opinion, though if you've never used another language you're unlikely to care.

I think if you're just going to do programming as a small time thing you'll get away with learning just Python, but I would recommend learning another language like C as well.

ldx #10
:
dex
bne :-


The only loop I need

Dynamic Typing can be useful for beginners, that's all though. It shouldn't be used by people being paid to program.

I was think between that and C ++ since I am teaching myself gamedev and unreal engine, but with the option to use blueprints there I never really felt the need to start. I will probably need it later for more complex stuff. I know that a lot of people are picking C# , but I dont like unity so learning both C# and/or C++ seems a bit too much . I figure that python is good place to get start and get generally introduced to programming.
How hard/difficult is to learn C++ compared to python ?