[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]

CAN YOU HELP ME GUYS? COZ ITS TO BE SUBMITTED TODAY 11:59AM EST TIME

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: 45
Thread images: 1

File: java.jpg (107KB, 1280x768px) Image search: [Google]
java.jpg
107KB, 1280x768px
QUIZ WEEK 1

1. Suppose you are given 1 cent on day 1 and on day 2 you are
given twice as much. If each day you are given twice as much
as on the previous day, then on day 10, how many pennies will
you receive? Can you program that? (HINT: use loops)
>>
thank me later.

sum(map(lambda x: x * 2, range(1, 11)))
>>
class p{public static void main(String[]a){System.out.println(1<<9);}}
>>
>>56359137
Math.pow(2, n)-1


Add a while(false) {} if you need a loop.
>>
>>56359166
Thank you for what? Being wrong? The question is how many pennies will you receive on day 10, not how many pennies you'll have in total on day 10.
>>
>>56359166
I don't think that's Java =_=

>>56359180
WE ENEED TO USE LOOPS

>>56359185
I dont know
>>
>>56359137
Should be easy in Python, like 5-6 lines or something.
>>
receivedPennies :: Integer -> Integer
receivedPennies n = foldr (+) $ iterate (*2) [1..n]
>>
>>56359221
Why do you need to use loops to calculate 2^9…?
>>
Why are you guys spoonfeeding this retard? This is literally some of the simplest shit I've seen.
>>
>>56359260
This.
>>
Lmao this faggot
>>
>>56359252
Beautiful.
>>
>had to take class on recursion for Uni
Makes you open up your mind desu familia. Every problem you would solve with iteration seems so easy if you think about solving it with recursion.
>>
>>56359137
int result = 1;
for(int i = 0; i < 10; i++) {
i*=2;
}
System.out.println("Result: " + result);

I'm doing this because I don't want you to succeed
>>
>>56359137

Why don't you just bend over so Pajeet can fuck you
>>
literally
return 1024;
>>
>>56359333
oops: it's
results*=2
, not that other shit
>>
>>56359342
>1024
see me after class.
>>
>>56359333
THANK YOU!!!
Can you help me with these one to?

"Fizz buzz is a game where players take turns to count incrementally, replacing any number divisible by three with the word "fizz", and any number divisible by five with the word "buzz".
Simulate this game for numbers 1 to 100.
>>
>>56359262
It is however one of the very best examples of why it is important to understand mathematics and algorithms before reaching for the keyboard and hack out loops compulsively.

It is also a good example on what happens with outsourcing.

Also it explains why Visicalc could be made in 48 KB (yes - kilo byte) RAM while today you cannot do anything before the CPU chomps a few gigabytes RAM.

Read - remember - weep.
>>
Stop being such a fucking bitch
>>
>>56359221
Ok, I can do java

_.range(1, 11).map((x) => x*2).reduce((a, b) => a + b, 0)
>>
>>56359384
i % 3 will check if int i is divisible by 3 if it equals to 0
>>
>>56359387
>Also it explains why Visicalc could be made in 48 KB (yes - kilo byte) RAM while today you cannot do anything before the CPU chomps a few gigabytes RAM.
no it doesn't you fucking idiot.
>>
>>56359462
What does '%' do? My teacher dont really explain it well.
>>
>>56359506
>thinks a loop with multiplication is not far bigger than 10 arithmetic shifts of a 16 bit value.
>>
>>56359525
It gives you your percentage in the course.

Go ahead, type 3%3 into google and see what you get.
>>
>>56359567
No, it isn't dumb fuck.

A loop to calculate 2^n would have be O(1) when regarding space. For each iteration you would only need to know
1) n-m, where m is the amount of iterations that has already occurred
2) the number being multiplied by 2
>>
>>56359137

public static void main(String... args) {
System.out.println(""+Math.pow(2,9));
}
>>
>>56359656
Forgot to mention
Read the beginning of SICP, it goes into this within the first chapter.
>>
Fuck man, I also need help with this assignment guys.

Suppose you are given 10 dragon dildos and each day you stick 1 inside your anus, then on day 5, how much dragon dildos would have disappeared inside your anus? (HINT: Use lube)
>>
>>56359695
ok anon. that sounds like a O(5 days) problem. I'll be back in a week with a solution.
>>
>>56359656
Are you seriously denying assembly code for 10 shifts is smaller than the preposterous loops!?

Have you ever programmed in assembly?
>>
total = 1
loop from 1 to 10
total *= 2 each time


if you still need help with this you have no chance
>>
>>56359525
>What does '%' do? My teacher dont really explain it well.

It's called the modulo.

It does division and then displays only the remainder.
>>
>>56360505

Uhhh my teacher said it was the percent sign. We are in excelerated 4th year.
>>
>>56359137
function howmanypenis() {
myaray = [1, 2, 4, 8, 16, 32, 65, 128, 256, 512]
]

for (var o = 9; o < 10; o++) {
return 512;
}
}

// meet me after class, prof ;3c
console.log(512);
>>
>>56360604
This fizzbuzz thingy has been solved before by what I guess is a student going to the same school as you. You can find his solution here:

https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
>>
int total = 1024;
int current = 0;
while(current != total) current++;
//there you go senpai :^)
>>
How did people pass programming classes without help from the internet?
>>
>>56361501
Before the internet, only the children of programmers, computer scientists, mathematicians and physicists learned to program. In other words, only smart people programmed.
>>
>>56360792
If dubs OP sends this as his answer.
>>
>>56361755
Dubs demand
>>
>>56359384
You definitely came to the right place.
Thread posts: 45
Thread images: 1


[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.