The Big Programming Thread - Page 870
Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
Deleted User 3420
24492 Posts
| ||
Acrofales
Spain17848 Posts
On April 07 2017 22:32 travis wrote: the repeating part must be floor of n/3 length Exactly floor(n/3) length? Or at most floor(n/3) length? Or at least floor(n/3) length? | ||
Deleted User 3420
24492 Posts
On April 07 2017 22:35 Acrofales wrote: Exactly floor(n/3) length? Or at most floor(n/3) length? Or at least floor(n/3) length? exactly | ||
Acrofales
Spain17848 Posts
Ok. Then the only thing you had wrong was that x = floor(n/3) and not floor(n/2). And don't forget the simplification: you have 3^(ceil(2n/3)) combinations ![]() | ||
Deleted User 3420
24492 Posts
thank you ![]() these are relatively easy questions compared to what I expect to find on the homework hehe but it's good to know my thinking for the simpler stuff is right | ||
Deleted User 3420
24492 Posts
first check on my assembly code please be gentle, I have no idea what I am doing. I feel like our instruction was really disjointed so I have no idea what I am doing. I am mostly guessing based on example code. + Show Spoiler +
Please disregarding the line numbers. They come with how I get my source (since the files are on a remote server). It'd be a pain to remove them. The idea with this code is that I want to have an array of size 20, and read characters in a for loop and store them into the array. If we are given a newline, the for loop ends. If we fill our array, the loop ends. There will be more to it, but I wanted to make sure I fixed up any misunderstandings before I continue. edit: do I need to use rmmovl to assign the value into my array? That's not in our examples anywhere so I was guessing before but I found this online. edit2: you can't do an add between an integer and a register? It has to be between 2 registers? That is annoying. edit3: well, it's not looping. it's just asking for input once and going straight through to the halt. edit4: ok it looks like my problem has to do with me reading characters, not ints edit5: ok this code is all wrong. I realized that it was making me hit enter each time, and the user should be able to put in an entire string all at once edit6: okay nevermind, it actually is working. for some reason i was being a dumb idiot and hitting enter after entering the first character, rather than just typing my string in.. | ||
phar
United States1080 Posts
On April 08 2017 01:16 travis wrote: Please disregarding the line numbers. They come with how I get my source (since the files are on a remote server). It'd be a pain to remove them. sed 's/^....//' On April 08 2017 01:16 travis wrote: edit2: you can't do an add between an integer and a register? It has to be between 2 registers? That is annoying. This depends entirely on the assembly language. For example MIPS assembly I think supports an add that lets you add a register to a given value directly (though it's been awhile, so I may be fuzzy on that). But actually, if you think about the underlying hardware, restricting add to two registers makes some sense. Underneath, an add operation is done by a physical bit of hardware on the chip (called an ALU). It can, for example, add two integers - say 32 bit integers for a 32 bit ALU. It has to get those integers from some input signal - in order to add it's gotta get the bits on the wire from somewhere. Generally that somewhere is coming from a register. If you have an immediate add operation that works on a register + constant, you have to physically load that constant somewhere to send the signal to the ALU - so at the end of the day it's going into something like a register anyways. So basically you either have: Register1 signal -> ALU Register2 signal -> ALU -> Add them together (This is an assembly language that only allows add between two registers) Or you have Register1 signal -> ALU Some constant from your instruction code -> load it into what is essentially a hidden register -> send signal -> ALU -> Add them together (This is an assembly language that supports add between register + constant) Certain assembly languages just cut the shit and make you do the register loading yourself instead of having extra hardware to hold your hand there. Again though, been awhile, so this may not be the clearest/most accurate explanation. | ||
Deleted User 3420
24492 Posts
We have to write comments tabbed over on the right side to correspond to our code on our left but i'd rather write the comments on top since it'd make it easier to write the comments first, and then write code that does what the comment I wrote says | ||
raNazUra
United States10 Posts
| ||
Zocat
Germany2229 Posts
On April 08 2017 01:16 travis wrote: I hate the way the professor insists we write comments We have to write comments tabbed over on the right side to correspond to our code on our left but i'd rather write the comments on top since it'd make it easier to write the comments first, and then write code that does what the comment I wrote says Its just preference. Do what you want. (and if you get graded - do what gets you the best grade). | ||
Deleted User 3420
24492 Posts
2 more to go | ||
Shield
Bulgaria4824 Posts
| ||
WarSame
Canada1950 Posts
| ||
Deleted User 3420
24492 Posts
I think im actually finding this easier to do than C, lol just have to be careful and plan ahead edit: finished my assignment about a week ahead of time all 3 programs work, I feel amazing, lol | ||
Shield
Bulgaria4824 Posts
| ||
Thaniri
1264 Posts
CTRL+F to "bonus question" Couldn't this be solved by adding up the levels of all the characters, then subtracting that number from the sum of all numbers 1-85 inclusive? Short example of numbers between 1-5 inclusive: 1 + 2 + 3 + 4 + 5 = 15 {3, 2, 5, 1} 3 + 2 + 5 + 1 = 11 15 - 11 = 4 Therefore 4 is the missing level I have no idea what this guy was trying in his assignment. edit: and my solution is O(N) because even though I have two loops they are not a loop within a loop? | ||
Hanh
146 Posts
On April 11 2017 11:59 Thaniri wrote: https://github.com/ch00kles/ATM/blob/master/src/ca/bcit/comp2613/a00657642/wow/Wow.java CTRL+F to "bonus question" Couldn't this be solved by adding up the levels of all the characters, then subtracting that number from the sum of all numbers 1-85 inclusive? Short example of numbers between 1-5 inclusive: 1 + 2 + 3 + 4 + 5 = 15 {3, 2, 5, 1} 3 + 2 + 5 + 1 = 11 15 - 11 = 4 Therefore 4 is the missing level I have no idea what this guy was trying in his assignment. edit: and my solution is O(N) because even though I have two loops they are not a loop within a loop? You don't need to loop to compute the first sum. It's 85*86/2 | ||
CorsairHero
Canada9489 Posts
int i = 4; I compiled with gcc which gave me a different result than expected... any insight? | ||
Nesserev
Belgium2760 Posts
| ||
beg
991 Posts
On April 11 2017 14:30 CorsairHero wrote: for you c experts: int i = 4; I compiled with gcc which gave me a different result than expected... any insight? What did you think the & does? I think it's trying to do "bitwise and" here. (Just guessing. Definitely not an expert ![]() | ||
| ||