thoughtcoder 167 Junior Poster

If you believe in freedom then that includes the freedom to buy whatever cellphone you want.

thoughtcoder 167 Junior Poster

Here is a simpler implementation, but without the fun of computing the to'th power of 10.

double round_nplaces(double value, int to)
{
    double places = pow(10.0, to);
    return round(value * places) / places;
}
thoughtcoder 167 Junior Poster

Why aren't you using the signature double round_nplaces(double value, uint32_t to) ?

Passing primitive types by reference is useless unless you want multiple return values.

Also, you don't need to separate the value out into whole number / fractional part.

Also your code doesn't even compile.

thoughtcoder 167 Junior Poster

Here's a better implementation of apow, assuming I don't have bugs.

double apow(double x, int y)
{
    if (y < 0)
        return apow(1 / x, -y);
    double m = x, p = 1.0;
    while (y) {
        if (y & 1)
            p = p * m;
        m = m * m;
        y = y >> 1;
    }
    return p;
}
thoughtcoder 167 Junior Poster

And if/when you return to your own time

That would require traveling backwards in time.

thoughtcoder 167 Junior Poster

Traveling forward in time doesn't give any paradoxes.

thoughtcoder 167 Junior Poster

That's not a C# question have a nice day.

thoughtcoder 167 Junior Poster

base-64 encode it. base-96 (or whatever) encode it. encode it into unicode characters.

thoughtcoder 167 Junior Poster

Beginner/Novice:
Lacking most of the things mentioned below.

Average/Intermediate:
Inexperienced in the things mentioned below.

Experienced at programming:

  • able to make the most of the type system he's working with
  • thinks about API design in terms of how to minimize the amount of mistakes made while using the API (and able to take advantage of the type system for that purpose)
  • able to stop worrying and write some gosh-darned code
  • awareness of the homomorphisms in his program.
  • able to design his own algorithms and data structures
  • doesn't do stupid stuff like silently ignoring errors and adapting around them -- see the bullet point on API design

Expert:
A silly notion.

On design patterns: Learning design patterns separates beginners who have heard of design patterns from beginners who have not. Learning several design patterns is like learning several chord progressions -- it doesn't make you a good composer, or a composer at all. Knowing some design patterns doesn't make you good at making the most of your type system. Knowing some theorems doesn't make you a good mathematician.

Some popular design patterns are basically harmful and most classification systems are unnecessarily fine-grained. There are some tricks useful to know for my first two bullet points, especially the first. That's all design patterns are. I'd rather refer to the knowledge of several design patterns as "experienced with the Tricks and Ways of Doing Things." If that's what it was called, people wouldn't …

thoughtcoder 167 Junior Poster

Time travel is possible. The mind evolves at the rate of time travel. I am a visitor from the future and I got here by programming my mind.

They ask that if time travel were possible, where are the time travelers? Well, here I am.

We will have an openly gay president in 2021, and he'll be a Republican.

thoughtcoder 167 Junior Poster

Who gets viruses? You have to try hard to get viruses on Windows. Stop pirating software, then you won't get viruses.

thoughtcoder 167 Junior Poster

Static Polymorphism (the compile-time) means basically those language structure which will cause the compiler to produce code at the compile-time. That is, the compiler is well aware that what code is to be generated at the compile-time itself. The example includes: specifically overloading of operators, functions.

And template metaprogramming.

As you know, the Shape.h will be compiled differently, hence the compiler won't know what code should be generated when someone calls Shape->Draw().

Uh, no, the compiler knows exactly what code to generate: something that looks up a function pointer specified by the object and calls that function.

Hence , he delays(whence the name Late Binding) the code generation.

Uh, no. Code isn't generated at runtime when calling virtual functions.

I guess you were under emotional pressure when making that post.

iamthwee commented: Your grammar is much better than the person below you. And you're from Bangalore too Sammy! +20
thoughtcoder 167 Junior Poster

Wow GrimJack, you really like leaving passive-aggressive reps around. If other worldviews pain you so much, you should perhaps consider leaving Internet behind.

thoughtcoder 167 Junior Poster

What part of 'blind adherence to any ideology' do you not understand?

I was just asking that to point out how you're a hypocrite. Or do you distinguish between blind and unblind adherence to ideologies?

It doesn't matter if you do, because there are many ideologies that you blindly adhere to. Like the way you like your opinions more than other people's. That's an extremely egocentric thing to do. And you do it blindly.

GrimJack commented: Twit -2
thoughtcoder 167 Junior Poster

What? I'm pretty sure everybody is an idiot and most of the time most people don't know what they're talking about. I don't know what I am talking about usually. That has nothing to do with being senior.

thoughtcoder 167 Junior Poster

Ancient Dragon is an idiot and doesn't know what he's talking about. Look up the terms online and you'll find definitions, and you can use your brain to see how they're different.

siddhant3s commented: He atleast gave some help by providing that pointer. We don't need your advice about who is an idiot and who is not. -1
tux4life commented: If you blame AD, your against me!! (and that rimes) -1
serkan sendur commented: you are retarded yourself -1
thoughtcoder 167 Junior Poster

I, personally, am against the immoral, unfettered precepts that capitalism stands for

What is capitalism?

Blind adherence to any ideology

Such as blind adherence to centrism?

jephthah commented: your mumbling vague and inane questions is neither probing nor insightful, Socrates. -2
Aia commented: “The inherent vice of capitalism is the unequal sharing of blessings; the inherent virtue of socialism is the equal sharing of miseries.” ~ Winston Churchill +16
thoughtcoder 167 Junior Poster

We should definitely prevent any sort of international trade because it hurts American jobs. No country has ever had severe economic problems like crippling depressions due to the shutdown of international trade.

thoughtcoder 167 Junior Poster

The "first" answer? Any number congruent to 13 or 29 (mod 32) is correct. There is no "first" answer.

thoughtcoder 167 Junior Poster

Do something thinking and figure it out for yourself.

thoughtcoder 167 Junior Poster

They're aware. If it's anything like most sites, not a whole lot goes on in the employees only area/mod lounge/whatever its called anyway. (Although the site I adminned only has 100,000 members and this one has 5x that, so I'd imagine this one has a larger staff).

Only a third of the members can speak English and of them the average is too dumb to follow the link from the email, so the number's not really that big.

thoughtcoder 167 Junior Poster

This should be, like, basic recursion.

thoughtcoder 167 Junior Poster

To be fair, he has a point. Its only called Math in American English. In british english its called Maths, and most internationals know it by its full name of Mathematics.

That wasn't my point at all. You are so brain-dead. My point was that if he wants to apply "math" to software engineering he's going to have to explain what he means by "math." He can't even define the term, apparently. It's as if he's heard of this thing called "math" and would like to know how it's used.

The first part of his problem he needs to solve then is in figuring out what it is he wishes to apply to software engineering. Is it logic? Is it a practical knowledge of combinatorics and number theory? Is it the study of type systems? Who knows.

What is tricky about his question is that there is no way to do software engineering without applying logical reasoning and algebraic manipulation. I mean math. So the question remains: What does he mean by math? Probably the task of understanding this question is valuable in itself.

BestJewSinceJC commented: too much attitude, not enough helpfulness -1
iamthwee commented: Bad Sam, Bad -4
thoughtcoder 167 Junior Poster

I fail to understand why this thread is named what it is. No one's interested in Rashakil Fol anymore I guess.

I am very interested in him.* He is the reason I joined this forum.

You should unban him! I bet you are just jealous of the size of his Young modulus.

* Not in the way in which I am interested in Serkan.

Nick Evan commented: It's kinda funny how much the two of you have in common. It's like you're one and the same person ;) +17
iamthwee commented: I would agree with niek_e's observation. +19
thoughtcoder 167 Junior Poster

What is math? You need to say what that word means so that people can understand your question.

thoughtcoder 167 Junior Poster

Ok, so this question spans from the typical "Math is/not needed for software engineering"

I do believe that math is at least partially important, but I have to admit that i know pretty little of it...

Math is very important for software engineering. It's impossible to write correct code without being able to prove things. Learning programming is really an informal education in dealing with concrete manifestations of abstract algebra. That's why you know that the following snippets of code are equivalent.

for i = 1 to n step 1
  x[i] = 2 + y[i]
end
for i = n to 1 step -1
  x[i] = 2 + y[i]
end
for i = 5 to n + 4 step 1
  x[i-4] = 2 + y[i-4]
end
for i = 1 to n step 1
  x[i] = 1 + y[i]
end
for i = 1 to n step 1
  x[i] = 1 + x[i]
end

So i was wondering if there's any math-applied-to-software engineering-kind of book out there

I don't understand what your notion of "math-applied-to-software engineering" is.

What is math? You could help by answering that.

thoughtcoder 167 Junior Poster

That's a vague question. No, nobody can help you with such a vague question.

thoughtcoder 167 Junior Poster

You could use code tags in your messages.

thoughtcoder 167 Junior Poster

It's hard to understand what you're trying to do with all that unindented code.

thoughtcoder 167 Junior Poster

Sorry, the key length is the same length as the message (4 bytes). Guess I should said that. I double checked and made sure it was right.

What? What does the fact that your key length is 4 bytes have to do with anything? Please post some code that implements your algorithm because your english explanations are not exactly clear.

thoughtcoder 167 Junior Poster

No.

thoughtcoder 167 Junior Poster

They just achieved ordinal numbers of clock cycles in a finite amount of time.

thoughtcoder 167 Junior Poster

What? So you're saying something different than what you wrote -- not that linked lists are useless but that one is already written for you. Too bad it's the bad of linked list, the mutable kind.

thoughtcoder 167 Junior Poster

Too bad they are still teaching these prehistoric methods.
Since Generics were introduced, link lists are pretty much useless in the real world.

This is a very wrong thing to say. Generics is a feature orthogonal to the question of what data structure to use for collections of things.

thoughtcoder 167 Junior Poster

Well I guess if you're Turkish then you can't be blamed for inheriting some of its stalker culture.

jephthah commented: aha +8
thoughtcoder 167 Junior Poster

Don't be such a baby about the answers you get, and what the fuck does "Soz" mean.

thoughtcoder 167 Junior Poster

I learned Sendur is an azerbaijani-originated name, are you azerbaijani? So where did your ancestors come from?

serkan sendur commented: this has nothing to do with my question to Dani +0
scru commented: It sure is funny though. +6
thoughtcoder 167 Junior Poster

It's still not secure, buts its not bad.

It's not really any more secure than just doing subtraction. Subtraction is an operation where you work bit by bit on inputs x and y and produce one output bit and one "borrowing" bit. You figure out the output and borrowing bit using a truth table with the next two input bits and the current borrowing bit.

Addition works the same way, only we call it a "carry" bit and the truth tables are different.

And so do your combinations of subtract+xor and xnor+subtract+xor. The only change is in the truth tables.

thoughtcoder 167 Junior Poster

Your second byte in document 1 seems impossible.

The plaintext byte is 10101010 and the ciphertext byte is 10010000.

There should be some k such that (k - 0xAA) XOR k = 0x90, right?

thoughtcoder 167 Junior Poster

I should have been a little bit more clear. Can version 1 be cracked without a key (The answer is probably yes) assuming that the information & key is random.

What? If the information is random? You mean the plaintext? You can't crack a file without a key if the original file was random numbers, assuming the algorithm's output is the same length as the input. Only if it's something nonrandom, such as English text.

Can the version 1 key be found if you have a cypher/plaintext.

No, because not all parts of the key affect the output. (Edit: i misread your algorithm slightly in that I thought subtraction was going the other way. That should only slightly affect things.)

The idea of version 2 was to make pairs of bytes relitive to eachother. Heres an example of what I mean: If you have a small key, say "ab" and a plain text "cdce" and it cyphers into "ghgi" on version 1, but on version 2 it cyphers into "ghqj" becouse you are not doing a byte by byte cypher. (I.e. the byte beside the byte you encrypt will change both bytes.) Is my methed of doing this (subtracting in pairs) a good (simple) way to do this? If you make the bytes subtract in pairs of 4 or 8, will it provide better protection?

That only makes a nominal difference. With plain xor, there's only one possible output for any given (byte, index modulo keylength) value in …

thoughtcoder 167 Junior Poster

Question 1: Is this easily reversable?

Yes. If you have the key, you can xor it and add it to get back the original plaintext.

Version 2) Then I thought that it might be more secure to do the subtracting stage in (2 bytes, 16 bits) rather than in (1 byte, 8 bits) like above.
Question 2: Is this more secure? Would it provide even better security if I used (4 bytes, 32 bits) on the subtraction stage?

It is not really more secure in any practical sense. You can still break the algorithm using the same idea used to break plain xor.

Version 3) Lastly I thought that maybe I could expand the key, so it looks like the key is random (assumung the origonal key was truly random) and is the same size as the text. Something like below maybe?

1. Load the key into two variables: first key and second key.
2. Encrypt a keylength of text with the first key.
3. Rotate the first key 5 bits left.
4. Use version 2 (or 1, if the security is the same) on both keys, store on second key.
5. Encrypt the next keylength of text with the second key.
6. Rotate the second key 5 bits right.
7. Loop all but the first step until there is no more text.

That's no good because the way the keys change isn't depending on the plaintext at all. If you encrypt multiple things with the same …

thoughtcoder 167 Junior Poster

What I need to do is build a type of database. Firstly have a few questions, whether what I have done it right...and how to do something else.

This is my algebraic type for the database (correct me if its wrong)

data Film = Film String String Int String

with this as the data.

testDatabase :: [Film] 
testDatabase = [("Casino Royale", "Martin Campbell",2006, "Garry, Dave, Zoe")]

That's broken. The expression ("Casino Royale", "Martin Campbell", 2006, "Garry, Dave, Zoe") is of type (String,String,Int,String) if we say that 2006 is of type Int. You want an expression of type Film. You need to use the Film data constructor instead of a tuple.

the last set of strings are the fans to the film. I want to be able to add a new fan, but not sure how to specifically insert it to there

If you're encoding information into a String by separating words with commas, you'd be better off using a [String] in its place.

this is what I have so far:

becomeFan :: String -> String -> [Film] -> [Film]
becomeFan = do putStr "Which film are you a fan of: "
filmTitle <- getLine
do putStr "What is your name: "
fanName <- getLine
(if filmTitle == filmName then fanName : [Film])

You should review some of the basics of how Haskell works and get comfortable with things using simpler problems.

thoughtcoder 167 Junior Poster

But what if your worldview (with your [insane?] notion of universal freedom) is wrong instead?

Point? You can't really tell someone that their world-view is "wrong". It can't be "wrong". It's an opinion.

Yes, they can be. They can be logically inconsistent. That makes it wrong. Also, worldviews where the holder of the view hasn't drilled down their ideas to the bare axioms and understand what influenced them to support such axioms (and perhaps accepted the fact that they have no real control over the decision-making process) are also wrong, because for most humans if they were to engage in such a process they would engage in a futile series of self-affirming rationalizations.

thoughtcoder 167 Junior Poster

Its not physical therft, its theft of intellectual property and breach of contract.

You obviously have trouble understanding what I'm saying. I'm saying that your worldview (with your insane notion of "intellectual property") is wrong.

thoughtcoder 167 Junior Poster

Pretty much you just have to count how many instructions get run and convert that to O notation.

thoughtcoder 167 Junior Poster

C decides whether to sign extend or zero-extend when you cast an integer type based on whether it's signed or unsigned.

thoughtcoder 167 Junior Poster

Piracy isn't theft, because arrangements of letters are not property. Copyright is an immoral violation of freedom. The moral path of existence is to pirate everything.

John A commented: +1 for trolling. +20
scru commented: -1 for being a douche. -1
thoughtcoder 167 Junior Poster

Why don't you write it yourself?

thoughtcoder 167 Junior Poster

You're simulating the TI-1706 SV so do whatever that does?

thoughtcoder 167 Junior Poster

So why is he using their product when he clearly feels that they can't support him?

You have to pay for support for all other products. Why not Microsoft products too?