[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

>intro to program class >think I know how to code >teacher

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 113
Thread images: 22

File: 1getj5.jpg (29KB, 640x480px) Image search: [Google]
1getj5.jpg
29KB, 640x480px
>intro to program class
>think I know how to code
>teacher put problems in class
>not understand it
>teacher claims is easy
>can't do it
>teacher uses high school math to solve it in 30 seconds
I'm a brainlet.

How do I learn to solve problems using high school math?
>>
File: 0e9.jpg (27KB, 600x600px) Image search: [Google]
0e9.jpg
27KB, 600x600px
>>59527079

learn more maths?
>>
>>59527079
Learn high school math
>>
File: 1488990752471.jpg (21KB, 362x362px) Image search: [Google]
1488990752471.jpg
21KB, 362x362px
>>59527079
>>59527103

dumb frog posting aside... if its an intro to programming, how hard could it have been? Can you even "hello world"?
>>
In tech people have massive egos they use to compensate for their crippling insecurities. Break out of that bubble it's not worth it. You don't have to, and won't, be the best.

As for math, a surprising number of neets struggle with it. That's because you grew up in a third world country with piss poor early education. Study, study, study. You will experience so much shit in college just because you're trash at Algebra. Lots of people are and yeah it's not your fault your education and country sucks, but it is your fault if you refuse to fix that. Now hustle and lurk more.
>>
>>59527118
I want to learn how to solve problems.
>>
>>59527130
being good at programming / problem solving is something ur born with bro
if u don't have it, u never will
>>
File: kode.png (3MB, 1038x808px) Image search: [Google]
kode.png
3MB, 1038x808px
>>59527079
At least you;re being challenged. Most "programming classes" are normie-tier garbage that won't teach you anything you didn't learn in kindergarten.
>>
>>59527269
>3.2 MiB
I'm mad
>>
>>59527269
This is a very friendly program :-)
>>
>>59527079
What was the problem?
>>
>>59527269
That return 50023; really got me at the end.
>>
>>59527507
A snail goes up a wall, in the first day it moves 1 meter, but every new day it moves 0.9 of what it moved the previous day and in the night it sleeps and goes down an aditional 20 cm.

Determine how much it goes after N days.
Also determine when it will stop going up and how much overall it climbed.
>>
>>59527553
Sorry I can not. Fuck this is not possible for me in 30sec. Give me 10 minutes to write a function or something.
t. sysadmin at a company.
I am really laughing and cringing over myself a bit now.
>>
>>59527553
kek, literally did ths shit in elementary school
>>
File: 1.jpg (8KB, 203x203px) Image search: [Google]
1.jpg
8KB, 203x203px
>>59527269

at least she comments the code
>>
>>59527553
tha fuck...

Keep a variable with the previous increment, which you use to multiply by 0.9 every time a day (N) passes and add it to the total after the calculation. Then just subtract 20cm

How is this hard?
>>
>>59527602
>*she*
>>
>>59527079
Almost 95% programming challenges involve highschool math exclusively. You'll rarely do anything advanced.
>>
>>59527638
it goes down 20 centimeters every night so you'd just do the function (1*.9 - 20 cm (idk the conversation im a hamburglar)) N number of times.
>>
>>59527553
>figuring out a for loop
>hard
>>
>lesson 1: Hello world
>lesson 2: designing and implementing a crypto algorithm
>>
>>59527638
>>59527688
is a functional language class.

also I have no clue over math.
>>
File: 1485402361784.png (174KB, 373x373px) Image search: [Google]
1485402361784.png
174KB, 373x373px
>>59527688
Well he did admit he was retarded already.
>>
>>59527672
the 1 meter is only at the start.

f(x) = x*0.9-20

x = 1000

for N
do x = x + f(x);
>>
File: JLKIJFq.jpg (146KB, 640x720px) Image search: [Google]
JLKIJFq.jpg
146KB, 640x720px
>>59527708
fuck you're right
>>
>>59527708
samefag here, there's one thing missing: what he climbed the previous day is not the sum, but the increment. So, just put another buffer variable there and add it after.

f(x) = x*0.9-20
y = 1000;

for N
x = x + y:
y = f(y);
>>
>>59527705
if your programming classes are legit, you really need to buckle up hard
>>
>>59527766
https://kheavan.files.wordpress.com/2010/06/paul-zeitz-author-the-art-and-craft-of-problem-solving-2edwiley20060471789011.pdf

It's this book good enough?

I know I need to review my precalculus.
>>
>>59527801
Dude, this isn't even precalc. It's just basic addition, subtraction, multiplication, and iteration. I don't know what to tell you.
>>
>>59527896
dude, I'm looking for books about how to solve math problems.
>>
I've been working in IT for some years.
I don't know shit about mathematics.
If I have to I do basic subtraction or addition I do it by "echo x-y|bc". Anyone else is mathematically disabled?
>>
The most important math for everyday programming is basic alegbra, bedmas operations and geometry.

Just pick up an IT mathematics textbook and study on your own time if ur passionate about learning programming
>>
File: rosen_cover.jpg (82KB, 484x598px) Image search: [Google]
rosen_cover.jpg
82KB, 484x598px
Pirate pic related and do all the exercises.
>>
>>59527919
The problem isn't hard because it's math, it's hard because you lack basic problem solving skills.
Break it down into steps.

You have a snail. The snail's position can be described by a floating point variable. It starts at zero.
You have the amount it moves per day, also a floating point number. It starts at 1
You have the amount it falls per day, this is a floating point variable too. It starts at 0.02
One iteration is: position = position + dailyMovement - nightlyLoss
Then compute your new daily movement: dailyMovement = dailyMovement * 0.9

That's one day. To get more days just put the calculations in a loop. The output is your position variable, and the unit is meters.
>>
>>59527553
what made you think you could code?

i don't consider myself a programmer at all, but i could do that
>>
>>59527602
>>59527642
kkkomments**
>>
>>59528578
problem solving != math
math != code
writing code is the easy part.
>>
>>59528613
this doesn't really make sense to me

how can you write code without involving math and problem solving?
>>
>>59528635
because I learned from youtube java tutorials and writing pong clones.
>>
>>59528635
because not everything involved with numbers is really math
>>
>>59527553
>BAWWW I CAN'T SOLVE THIS MENIAL EASY SHIT
>This is the state of your retards on common core while being pumped estrogen non stop
I honestly feel sorry for you all
>>
>>59527553
The 0th day it goes up 1m, then down .2m.
The first day it goes up .9m then down .2m
the second day it goes up .81m then down .2m

SO

After n days it will have gone up
1 + .9 + .81 + ... + .9^n = (1 - .9^(n+1))/(1 - .9) meters
and down
.2*n meters

Conclusion : height(n days) = 10*(1 - .9^(n+1)) - .2*(n+1)
>>
>>59527079
Im currently working through Sedgewicks Introduction to Programming in Java and I hate it. He uses so many math and science examples but im not currently enrolled in college and forgot all my college algebra and calculus so I have no idea what hes talking about half the itime in his example problems.

His second book, Algortithms 4th edition is reallly nice though.
>>
File: 1482138113285.png (46KB, 619x453px) Image search: [Google]
1482138113285.png
46KB, 619x453px
>3rd week into my programming class
>assignment is to figure out an algorithm for the small world phenomenon
My shit code only got around 70% of the possible points.
>>
>>59529006
the fuck, is this an intro level class?
>>
>>59529098
Yes, that was my first semester introduction to programming class.
The small world shit was our assignment to practice recursion.
>>
>>59529174
did you take this at MIT or something? my intro level class was too busy learning about primitive data types, loops, methods, and learning how to output shit to text files. you know, like learning how to program.....
>>
File: meeelc.png (14KB, 467x402px) Image search: [Google]
meeelc.png
14KB, 467x402px
is this correct?
>>
>>59529238
No, I'm at a mediocre german university. (In some rankings place 6 of the german universities, but I don't know about that)
My curriculum looked like this
>2,5 months to learn Java
>~1 month of Haskell
>Rest of the time theoretical shit about programming (IMP,Hoare rules, etc.)
>>
>>59529443
>not having Haskell as 1st language

Disgusting
>>
>>59529238
MIT starts with Python and gets into algorithms the second or third week. Python makes writing algorithms and learning OOP simple.
>>
>>59529482
>Haskell
That meme got me good, thank God we only had to do 4 or 5 Haskell assignments.
The real fun was learning the semantics of imperative languages, I don't know how many pages of handwritten IMP-programs I have in my notepad.
>>
>>59527553

Here's my solution, did it as verbose as possible:

public class AnonsSnail {

public static void main(String args[]){

AnonsSnail snarky = new AnonsSnail();
snarky.move(10);
}

public double move(int days){

double position = 1000;
double multiplier = 0.9;
double sleepytime = 20;

for(int i = 1; i <= days; i++){
position = position * multiplier - sleepytime;
System.out.println("Day "+i+":"+position);
}
return position;
}

}


Output is:
Day 1:880.0
Day 2:772.0
Day 3:674.8000000000001
Day 4:587.32
Day 5:508.5880000000001
Day 6:437.7292000000001
Day 7:373.9562800000001
Day 8:316.5606520000001
Day 9:264.9045868000001
Day 10:218.4141281200001

can someone confirm if it is correct?
>>
>>59528944
this is such a weird coinsidence, I literally JUST got this book in the mail. Still have to open the box. (Algorithms I mean)
>>
>>59527708
>>59527754
I understand the answer(f(x) = x*0.9 -20), the only parts I don't understand are the "y =1000"(where does the 1000 come from?), and the "for N" part. I am, like OP, a retarded programming newbie.
>>
>>59529806
Position should be 100, not thousand. Also, the 0.9 multiplier applies to the snail's movement, not the position directly. After two days and nights, the snail should be 1.5m up the wall.
>>
File: solve_2.jpg (208KB, 1280x720px) Image search: [Google]
solve_2.jpg
208KB, 1280x720px
Wait until you learn about problems that you CAN'T solve with computers. Crazy I know.
>>
>>59529806
Completely wrong.

Let f(N) be the position after night N then
f(N) = f(N-1) + 0.9^(N-1) - 0.2
and f(0) = 0.

Solve the recursion to get:
f(N) = - 0.2 * N + (10^10 - 1)/10^9 * (1 - 0.9^N)
>>
File: r346234631.jpg (46KB, 490x385px) Image search: [Google]
r346234631.jpg
46KB, 490x385px
>>59527079
>have years of programming knowledge.
>graduate from university.
>apply for job
>called for interview
>okay anon now write a function without using builtin functions, you can use whatever language you want
>sort randomly given numbers in an array from least to greatest
>couldn't write and i thought it was easy because i could solve high level math stuff
>>
const moveNDays = (dayCount, movePerDay = 1, distance = 0) => dayCount === 0 ? distance : moveNDays(dayCount - 1, movePerDay * 0.9, distance + movePerDay - 0.2);


JS GOAT
>>
>>59529958

did your course just not have an algorithms module?
>>
>>59529992
i could just answer the question just by typing this, they wanted it hard way
asort($person, SORT_NUMERIC);


>>59530011
yea we had but i don't remember shit, i just memorized algorithms and passed exams
>>
>>59528635
>how can you write code without involving math and problem solving?

Software engineer here. In my 25 years years of work, I would say that at least 99% of the time, there was no mathematical component to the code I was writing.

But problem solving in general? I've done lots of that. It's just that the problems were usually not math problems. The were mostly "figure out how to get data from point A to point B" problems.

Here are some examples of the kinds of problems I solved:

Need to write a script that checks out the software from the repository, automatically assign it the next build number, compile it, create an installer for it, and then copy the source code and its deliverables into an archive. Set up a web page so that people can click a button to trigger the whole process, and automatically send them an e-mail when it's done. (Technically, it does require math: the script needs to add one to the previous build number to get the next build number.)

Need to send various pieces of data from a robot to a server. (The data is log info, error events, diagnostic tracing, etc.) Let's connect the robot and the server on a WLAN. For the protocol, let's use HTTP request/response, posting application/json data. Need to write a script for the robot to execute whenever it wants to send the data -- use nc to actually post the data. On the server side, set up Apache/PHP to receive the data, and when it comes in, write it to a MySQL table.

Need to develop a USB flash drive that the field technicians can use to install firmware updates in the field. Write the installer scripts. Write the scripts needed to create the flash drive image. Write the code necessary to detect when a flash drive is plugged in, and automatically execute the installer it contains.

See? No math needed. You're just hooking stuff up, and writing the glue code to make it all work.
>>
>>59529958
>he can't quicksort or mergesort in his sleep
Dude, you need to prepare those interviews.
>>
>>59530068

how do you not remembe any sorting algorithms at all?
>>
File: de1.png (316KB, 500x455px) Image search: [Google]
de1.png
316KB, 500x455px
>>59530068
>i don't remember shit, i just memorized algorithms and passed exams
Literally what is wrong with humanity.
>>
File: 1480232200068.jpg (32KB, 702x629px) Image search: [Google]
1480232200068.jpg
32KB, 702x629px
>>59527079
>sign up for IT at university
>have to learn linear algebra AND calculus

wtf... I just wanted to learn to make video games
>>
>>59529958
I really recommend learning at least bubble sort: Just go through the list and swap adjacent elements if necessary -- then repeat until you make a full pass that doesn't require any swaps. I don't have the code memorized, but knowing the basic idea of the algorithm, I could figure out the code on the fly.

They were testing you to see if (1) you had remembered the basic process of at least ONE sorting algorithm, and (2) if you could figure out how to code a fairly simple algorithm on the fly.

The same goes for a lot of the classic stuff, like binary tree traversal. You really should have the basic idea of the algorithm memorized.
>>
>>59529958
I'm currently learning this type of question in school. Wouldn't you just assign the first number in the array to an empty variable, and then use a for loop to compare every variable in the array to that variable. If it's higher it's moved up in the array and if lower then it doesn't move. Loop through each variable and then check if it's in order then print?
>>
>>59528405
Slow down, dude, most of us aren't geniuses

I just want to learn how to do math. Can you try explaining it without making it complicated for no reason??
>>
>>59530346
I'm surprised IT requires that. Take advantage of it, though, being mathematically literate is a good thing.
>>
>>59530346
Depending on what parts of video games you'll end up working with, either of those can be pretty important. A lot of graphics programming makes use of matrices, for instance.
>>
>>59530245
Yeah man, your'e just a code monkey.
>>
>>59527602
Good code doesn't need comments, just documentation.
>>
>>59530582
Too complex for code monkeys.
>>
>>59527079
>How do I learn to solve problems using high school math?
At the high school classes. Or at college math classes if you're from United Sates.
>>
>>59530582
Dumbest thing I ever heard
>>
>>59527269

>cout is like printf, but for smart people
chuckled softly
>>
>>59530635
Go read the id tech 3 source then come back.
>>
>>59530537
You've got to be baiting at this point. There's no way you could be this retarded
>>
>>59530805
Whoops my bad messed up in trying to get it to work in cm
f(n)=n(.9^(n-1)) - .020n
>>
>intro to program class
>C++
>basically the same as java which I already know, don't even listen most of the time
>>
File: w-what.jpg (43KB, 1280x720px) Image search: [Google]
w-what.jpg
43KB, 1280x720px
>>59530967
>basically the same as java
How about no?
>>
>>59530684

>let me just read something that another retard created and hail it as the ultimate truth
>>
>>59531047
Can't help you see the truth if you refuse to look at the evidence anon.
>>
>>59530967

>C++ is basically the same as Java
and PHP is basically the same as C
>>
File: 1482912636270.png (33KB, 1020x426px) Image search: [Google]
1482912636270.png
33KB, 1020x426px
>>59530967
>>
File: smug.jpg (95KB, 724x720px) Image search: [Google]
smug.jpg
95KB, 724x720px
>>59531113
>>59531093
>>59530991
I'm not even kidding
>>
>>59531093
Haskell is basically the same as COBOL
>>
>>59527269
>Return 50023
My fucking sides
>>
>>59527553
>>59527574
>>59527638
>>59527688
>>59528789
>>59529806
he means solving it with math, you tards.

snail position = (Σn(1meter/.9^n)) - .2meter*n
>>
File: 1477064881814.jpg (81KB, 561x595px) Image search: [Google]
1477064881814.jpg
81KB, 561x595px
>>59530346
have fun
>>
Not OP, but I got an assignment today on my fourth introduction to programming class, to make a Tetris clone in C.

I barely know how to sum two matrices and I can't even wrap my head around how to make pieces stop once they collide with another one. Searx isn't really helping since all the results are either too complicated for my limited information, or too simple. I also have a physics and a discrete math test that same day.

I really hate that fucking university right now.
>>
>>59535198
Just test ahead.

if (block on top of stopped block) {
stop the block
}
>>
File: mouse.gif (283KB, 807x555px) Image search: [Google]
mouse.gif
283KB, 807x555px
>bad eyesight
>don't get glasses until 16
>couldn't see any of the blackboards all through school
>suck at math as a consequence
>did well in other subjects so never really addressed by teachers
>struggle with basic addition and multiplication
>do low level khan academy over and over but has only helped a little
>30 years old and it has probably contributed to ruining my life
>>
>>59536076
Had the same problem after 9th grade. I was considered pretty good at math as well...
>>
>>59529436
>using your own language in programming
Duten plm
>>
>>59527079
>he fell for knowing syntax equals programming knowledge
top kek


Honestly it's very common on /g/
>>
>>59528080
I skimmed that book and it looks awesome. Some of the stuff I can easily understand since I took logic at school, but other stuff just goes way over my head. Is there a MOOC somewhere out there (coursera, edx, etc) for Discrete Math to help me along?
>>
>>59536076
worst cat
>>
>>59528635
There's tons of software out there that does just string manipulation of some sort. No math required there.
>>
>>59530579
Oh yeah? Well you're just a code GORILLA! How does that feel?
>>
File: l.jpg (13KB, 620x364px) Image search: [Google]
l.jpg
13KB, 620x364px
>this thread
>>
>>59531078
give him the argument you loser
>>
>>59530582
not if its written by chinese hacks

then again comments wouldn't save the shit I'm saddled with

fuck my life
>>
>>59534782
I never did higher level math and don't know what the fuck this edgy E is, but if I'm understandig it correctly (1meter/.9^n) means that the snail is accelerating, right?

Shouldn't it be (1meter*.9^n) instead?
>>
>>59527079
You should start by learning the English language first.
>>
>>59539678
https://en.wikipedia.org/wiki/Sigma#Science_and_mathematics
>>
>>59539678
>sums
>higher level math
>>
>>59529436
>not even writing your own language properly
I'm pretty sure GCC supports Unicode names for stuff.
>>
>>59529443
>hating on god tier german education
>>
File: 4L_A1PVJSu2.jpg (9KB, 238x192px) Image search: [Google]
4L_A1PVJSu2.jpg
9KB, 238x192px
OP
Thread posts: 113
Thread images: 22


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.