|
Not two unknown values...that's what confused me at first until I realized that the second unkonwn can be expressed as a relationship to the first unknown, in this case, (137 - a), thus giving the equation:
(2.00 * a) + 2.25 * (137 - a) = 386.5
this works out to a = 87, so b = 50.
the equation in code from an earlier post is this:
totalQuantity = 137
totalCost = 286.50
a = 0
b = 0
standardPrice = 2.00
premiumPrice = 2.25
a = (totalCost - (premiumPrice * totalQuantity)) / (standardPrice - premiumPrice)
b = totalQuantity - a
This is really starting to remind of aa algebra problem with apples, oranges, and farmer Brown!
"Go forth into the source" - Neal Morse
|
|
|
|
|
there really is no need for you to explain me an elementary math problem, you are the one who had a problem with two unknown values (count1 and count2) and two linear equations (totalCount and totalPrice), not me. And from your reply, it is clear to me you now know how to get to a solution without really understanding the general methodology.
Maybe you should now try and figure out the counts of tree types of objects (apples, oranges, pears) with known prices (1,2,3) and weights (2,3,5), when the total item count (247), total price (472) and total weight (801) are known.
|
|
|
|
|
Sorry Luc, I certainly did not mean to offend. I admit, reposting the solution was a bit overboard. While getting the solution through whatever means was my original intent, getting a solution based on pure math was my goal, understanding the methodology would be a bonus. It's not often that I have to solve these kinds of problems, but it has been refreshing.
I could not resist the challenge, though I must admit it through brute force. I really would like to see the correct mathematical approach to this.
Apples: 104 : Oranges: 61 : Pears: 82
"Go forth into the source" - Neal Morse
|
|
|
|
|
No problem.
And your result is correct; you should have done it by hand though in order to learn something.
There basically are two approaches (although they do in essence the same thing):
1. Manually, write down the three (or N) equations. Then replace one by a linear combination of (some of) the others in such a way that one variable disappears; if you do that for all but one of the original equations, always getting rid of the same variable, you end up with n-1 equations in n-1 unknown values (and one of the original equations); you solve that in the same way, so iteratively you get at a single equation, a single unknown.
2. Theoretically, and progrsammatically, you would formulate the set of N equations using a N*N matrix (in the example the coefficients would be 1,1,1, 1,2,3, 2,3,5) and a size-N array with the known values. Then solve that with one of the known algorithms, Gauss-Seidel is one way, LU-decomposition another (it basically does what the manual approach does, with the added benefit that the intermediate steps get recorded in the L- and U-triangle you obtain. Using those, you could quickly solve any similar problem having the same matrix coefficients but different known values.
|
|
|
|
|
As we all know passwords0 should be encrypted (using an approriate one way algorithm) before they are stored anywhere and when we need to validate a second value against it we should use the same algo to encypt the second value and compare that.
My question is where in the architectural model do you believe is the best place to perform this encyption?
a) UI Tier
b) Business Tier
c) Data Tier
0This is applicable to any sensitive data
|
|
|
|
|
I have a custom password text box which hashes the password as soon as the user has entered it right in the UI layer, and I pass the hashed password through the application. This ensures that no one can see the original password at all.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
This is good - for a website. But what if I have a client that connects over a webservice? Then the control and the entire code for hashing or encrypting are in the client's assembly and can be examined by a potential attacker.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
I don't do websites. I mainly do WPF Desktop Apps , and the hashing is done inside a custom MarkUpExtension. My apps do connect to the DataBase via WCF services, but the client apps are obfuscated and compiled assemblies. Yes, they could probably be easily reverse engineered, and they could perhaps find the hashing algorithms used, but still I don't think it possible to actually reverse any particular password that has been hashed, and this way there is no where in the assembly where the password is not hashed. Personally I don't see any other way of doing it, that is safer. If you have any better ideas, I will love to hear them.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I also prefer clients, that's why I also had to give this some thought. Or, if it has to be a website, I still do the administrative part with a client. But you are right, there is no better solution and securing the webservice is much more important. I would suggest using https and, if you are really paranoid, additional encryption with the help of SOAP extensions.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
CDP1802 wrote: and securing the webservice is much more important
You hit the nail on the head there.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
If you look at my question at the top of the page, it is about my private little monster. It spreads over two clients and four webservices and now even has its own XNA UI
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
CDP1802 wrote: monster
Indeed
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
It's my version of a model train
The goal is to see how far I can go when building it and where my limits are. The fun stuff which my bosses would never allow me to do.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
I am lucky enough to work for myself - so I don't have any bosses. Most of my clients couldn't care less about the actual structure of their apps, or what goes into them, they just want to print Invoices and look at pretty graphs of how much money they are making. That gives me the freedom to use the technologies that I like, and I love WPF - it's the dog's danglies as Nagy would say.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
WPF is great. But, as you may have guessed, my little project is a game. Webpages are very limited and can make the whole thing just exciting as Excel. Going over to a client and Windows Forms helped a little. We could integrate an XNA window into a control and at least have something moving on the screen. If only the UI was not so ugly...
WPF offered a UI with great options for designing, but getting along with XNA (or DirectX) was not easy. This slowly seems to be changing with Silverlight and the Windows Phone 7, but then still it would be two different applications which run at the same time and somehow have to communicate.
So, if the prophet does not come to the mountain, I added my own UI to the graphics engine and now am porting the game client to use it. At the moment it is in a very interesting state. It already is far enough to be used seriously, but every step of the way is delayed by graphics bugs, oversights and things I had put off until 'later'.
My bosses would die instantly when trying to calculate what this evolution has cost, but it's my time and it's hard to put a price tag on the things I have learned
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
Sounds like you are really enjoying what you do. Is it a commercial game, or will you release it to the public? My life sounds really boring in comparison. My apps are only complicated by deadlines, otherwise they are just bog standard data applications
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
At work it is just as boring for me. If the stuff which bosses or customers want was so much fun, they would probably charge us a fee instead of paying us
This[^] is an older screenshot of my test program for the graphics engine and the UI. In the picture you can see me blowing up one of my first (and worst) 3D models. I guess, I'm not really talented as an artist. Luckily I found one just last week who is interested in helping.
So no, it's not commercial. I work on it in my spare time, but I do intend to install it on a server and offer the client for download. Then we shall see what happens.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
CDP1802 wrote: At work it is just as boring for me
Sorry to hear that. I like the controls that you have made for your UI, really cool. You're character names are nice, especially their friends(James Bond - Walther PPK, Vodka - Q - None) You should keep us posted on what is happening with the project.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
What you are talking about is hashing and not encryption. Putting it in the UI layer as Wayne suggested will ensure that the real password does not pass through all parts of the application.
|
|
|
|
|
I don't know if this is frowned upon, but the way I set my last server up was:
On the Sql Server instance, I setup a main database, and an ID database. The passwords are entered into the ID database, hashed. Outside of local access, the only access to the ID database was through stored procedures. I used a generic user and password to access the ID database, so a program could send the ID and password entered by the operator, and the stored procedure would do the hash & compare. If there's a match, then a user ID and password to the main database was returned. Again, this ID only has access to stored procedures, and is changed periodically.
I'm sure there's a better way to do it, but this meets our needs.
|
|
|
|
|
Bert Mitton wrote: so a program could send the ID and password
That however is a problem. It presumes that the "send" is secure enough. While hashing in the client precludes the need to care.
|
|
|
|
|
|
Hi There,
I have to develop a program (winform) that extracts data from the queries on a DB MSSQL2008 and data are written to a text file in the default locations.
The customer asks me to build something dynamic in the sense that if he must add an information to the file or change the value of a field should do so only by adding or modifying the appropriate query.
The initial idea is to save in a table the queries needed to extract the value of any information and execute one, then place it in a database the result of support where the tables have the same layout of records in the file to be produced.
According to you, wanting to use an approach object-Orientes rather than structural way, how should I organize the source?
If you can think of even a better solution to get the result and what is well pleasing.
Thanks
|
|
|
|
|
Rephrasing....
What you want to do is the following
1. Query a database
2. Write the results to a file.
Based on that a simple solution is based on the following - the query is a single sql select.
If so then you do the following.
1. The sql statement (select) is read from a configuration source.
2. The database layer sequences through the result set columns using a 'get string' api. It also checks for nulls appropriately.
3. An appropriate text output form is defined. It should be capable of dealing with nulls and things like embedded quotes. I would suggest:
a. Use tab for a delimiter
b. For each string value strip out all tabs, and end of line characters and replace with spaces.
4. You put 1, 2, 3 together to write to the file.
Additional items - I suggest that you allow for a configurable file location and file name.
Trying to generalize to more complex examples is probably pointless. Too much generalization ends up recreating things that already exist such a programming languages and report generators.
|
|
|
|
|
Not sure you are still looking for an answer.
You can do something like a Key and value(payload),ie sql will be for just fetching the value for the given key.
Here the value will be a payload(a XML string). You will have template for the xml format. whenever you want to add something you just add it the template. while writing to file you
first fetch the payload, then parse the XML, put the parsed values to a file, in what format you want.
|
|
|
|
|