|
What is IsAllowed defined as?
|
# ? Apr 4, 2009 21:57 |
|
|
# ? May 14, 2024 18:41 |
|
tef posted:What is IsAllowed defined as? It returns true if the pair is allowed, and false if the pair is forbidden.
|
# ? Apr 5, 2009 00:47 |
|
What exactly happens in the computer when a process waits for a certain amount of time? As in, what's done to ensure that the processor continues its execution at the appropriate time? I came up with the idea of an automatically sorted list of (long) system times in milliseconds linked to what process would be woken up, incrementing every millisecond and checking the first value to see if it was time (and the second if that worked and so on in case there are ties) but I'm sure that's not how it's done.
|
# ? Apr 5, 2009 15:17 |
|
Fruit Smoothies posted:It returns true if the pair is allowed, and false if the pair is forbidden. You really have a knack for answering a question without any substance. This is I think the third time I've asked for your constraints and either you present a different set to the one you want to implement (primes), or in this case you manage to tell me "isallowed" is whether a pair is allowed. When someone asks for the definition, the mean the code.
|
# ? Apr 5, 2009 15:29 |
|
Patashu posted:What exactly happens in the computer when a process waits for a certain amount of time? As in, what's done to ensure that the processor continues its execution at the appropriate time? I came up with the idea of an automatically sorted list of (long) system times in milliseconds linked to what process would be woken up, incrementing every millisecond and checking the first value to see if it was time (and the second if that worked and so on in case there are ties) but I'm sure that's not how it's done. http://en.wikipedia.org/wiki/Scheduling_(computing) Or if you really want depth, /usr/src/linux/kernel/sched.c e: on second thought a bsd kernel is probably way more readable, so i guess grab a fbsd image and poke around /usr/src/sys/ for something that looks like a scheduler if you're interested Blotto Skorzany fucked around with this message at 15:43 on Apr 5, 2009 |
# ? Apr 5, 2009 15:37 |
|
tef posted:You really have a knack for answering a question without any substance. The problem I am having, is working out how to loop through the tree. It makes no difference to the problem what the IsAllowed() function does, or how it works. All it does, is confirm whether or not a pair is valid based on a set of constraints. If you want the code, here it is with some of the constraints not yet added, because it's harder to debug with them all in initially. code:
|
# ? Apr 5, 2009 17:24 |
|
Fruit Smoothies posted:If you want the code, here it is with some of the constraints not yet added, because it's harder to debug with them all in initially. Now I'm really curious what your problem domain is, because that's a wacky set of constraints. That said, visual inspection can give us a solution without too much trouble. We reformulate the constraints as allowed pairs rather than unallowed pairs: pre:1: 6 7 8 9 10 11 12 2: 8 9 10 3: 5 7 8 9 10 12 4: 5 8 12 5: 3 4 6 7 8 9 12 6: 1 5 8 9 10 12 7: 1 3 5 8 9 12 8: 1 2 3 4 5 6 7 8 9 10 11 12 9: 1 2 3 4 5 6 7 8 9 10 11 12 10: 1 2 3 4 5 6 7 8 9 10 11 12 11: 1 2 3 4 5 6 7 8 9 10 11 12 12: 1 2 3 4 5 6 7 8 9 10 11 12 pre:2: 8 9 10 3: 5 7 8 9 10 12 4: 5 8 12 5: 3 4 7 8 9 12 7: 3 5 8 9 12 8: 2 3 4 5 7 8 9 10 11 12 9: 2 3 4 5 7 8 9 10 11 12 10: 2 3 4 5 7 8 9 10 11 12 11: 2 3 4 5 7 8 9 10 11 12 12: 2 3 4 5 7 8 9 10 11 12 pre:3: 5 7 9 10 12 4: 5 12 5: 3 4 7 9 12 7: 3 5 9 12 9: 3 4 5 7 9 10 11 12 10: 3 4 5 7 9 10 11 12 11: 3 4 5 7 9 10 11 12 12: 3 4 5 7 9 10 11 12 pre:4: 12 7: 9 12 9: 4 7 9 10 11 12 10: 4 7 9 10 11 12 11: 4 7 9 10 11 12 12: 4 7 9 10 11 12 pre:7: 9 9: 7 9 10 11 10: 7 9 10 11 11: 7 9 10 11 pre:10: 10 11 11: 10 11 The only pair I'm not sure of is (10,11), because you didn't provide enough constraints. Edit: [(1,11),(4,8),(6,12),(7,5),(3,9),(2,10)] is a solution that exists entirely within the constraints you specified. ShoulderDaemon fucked around with this message at 18:18 on Apr 5, 2009 |
# ? Apr 5, 2009 18:10 |
|
ShoulderDaemon posted:Now I'm really curious what your problem domain is, because that's a wacky set of constraints. I'm really not going to go into the problem, because it really is complicated. Those are some of the constraints. My concern is that making all these lists, and lists of lists isn't the best way to implement the backtracking. Also, with the complexity of the full-scale problem, human attempts would be rendered useless, because you'd have to permanently look these things up.
|
# ? Apr 6, 2009 20:43 |
|
Fruit Smoothies posted:I'm really not going to go into the problem, because it really is complicated. Those are some of the constraints. Yeah, you're doing something crazy in there with parentOf and recursing up the search tree instead of down and I don't really understand what you want that code to do. Backtracking would normally be done sort of like this: code:
Fruit Smoothies posted:Also, with the complexity of the full-scale problem, human attempts would be rendered useless, because you'd have to permanently look these things up. I'm not sure I believe you, because so far everything you've posted has been really trivially easy to solve by hand, and I'm having trouble accepting that it's any easier to express your wacky constraints in code, debug the code, etc.
|
# ? Apr 6, 2009 21:33 |
|
ShoulderDaemon posted:I'm not sure I believe you, because so far everything you've posted has been really trivially easy to solve by hand, and I'm having trouble accepting that it's any easier to express your wacky constraints in code, debug the code, etc. I don't know why you'd think I'd lie about this. It's not difficult to do by hand, but it's lengthy. Additionally, the constraints change on a (fairly) regular bases, sometimes resulting in pairs within pairs and all sorts of complications that can be considered (if at all) after the backtracking is sorted. I know what your code does there, and I have considered doing it myself, but a lot of this is about a learning curve, so I'd like to have a backtracker, rather than a list of permutations.
|
# ? Apr 6, 2009 23:14 |
|
ShoulderDaemon posted:Now I'm really curious what your problem domain is, because that's a wacky set of constraints. "Homework"
|
# ? Apr 6, 2009 23:20 |
|
Avenging Dentist posted:"Homework" I do a chemistry degree. I wish there was something this mentally challenging in there, and not scheme after scheme of organic mechanisms. Incidentally, if you can write a program that calculates the best way to synthesize a compound from starting materials (or even better, picks starting materials) you will be very rich. That problem also involves tree-structures, and backtracking too.
|
# ? Apr 6, 2009 23:23 |
|
Fruit Smoothies posted:That problem also involves tree-structures, and backtracking too. For a problem that involves abstract tree structures and backtracking, you really ought to take a closer look at prolog. (I don't get to say this often, prolog is useless at nearly everything else) What you're trying to do sounds like an Expert System, and people have been writing them in prolog for years. Constrained search is what prolog excels at, and what compilers optimize for. There is also a strongly typed variant if you want excellent performance. If you've done a little programming before, "The Art of Prolog" is an excellent guide to the language.
|
# ? Apr 7, 2009 01:26 |
|
Fruit Smoothies posted:I don't know why you'd think I'd lie about this. It's not difficult to do by hand, but it's lengthy. With the constraints you've been posting, it's been taking me less than a minute to find solutions each time. There's only twelve elements. Seriously, computers are overkill sometimes, if you can't solve these problems yourself faster than you can write a program, something is very wrong. Fruit Smoothies posted:Additionally, the constraints change on a (fairly) regular bases, sometimes resulting in pairs within pairs and all sorts of complications that can be considered (if at all) after the backtracking is sorted. So, what you're saying is, you'd have to spend even more time writing an even more complicated program, and you'd have to change the program frequently to account for new rules, which may be difficult to express in your algorithm. These do not sound like good reasons for using a program. Fruit Smoothies posted:I know what your code does there, and I have considered doing it myself, but a lot of this is about a learning curve, so I'd like to have a backtracker, rather than a list of permutations. First of all, I didn't do anything involving permutations in that pseudocode. Secondly, backtracking is, exactly and precisely, the act of building a list of results at one level, then transforming that into a list of results from the next-highest level. To transform "idealized" backtracking code into a single-result form, you simply change the algorithm to only return the first element (if there is one) of the result list, and optimize away any calculations that would thus be redundant. In this case, such a transformation is trivial, because we have the nice property that if the recursive call returns any results, then they are all equally valid - in particular, the first one is valid, so we can eliminate list management altogether. This trivially changes the pseudocode into the reduced form: code:
This is, honestly, the kind of problem I'd expect to see in an intro data structures class. It's about 100 lines of C with no need for dynamic allocation, is easy to verify by hand, and is operating on an incredibly tiny problem with questionable utility.
|
# ? Apr 7, 2009 01:50 |
|
Fruit Smoothies posted:I'm really not going to go into the problem, because it really is complicated. Jesus Christ, give it up already. For serious how much more can you possibly drag this out....
|
# ? Apr 7, 2009 03:43 |
|
ShoulderDaemon posted:This is, honestly, the kind of problem I'd expect to see in an intro data structures class. It's about 100 lines of C with no need for dynamic allocation, is easy to verify by hand, and is operating on an incredibly tiny problem with questionable utility. So, I said this, and then I started thinking to myself that I should be prepared to be called-out on a statement like this. My first try was 99 lines, but I like round numbers, so here's a 50 line version: code:
|
# ? Apr 7, 2009 05:35 |
|
ShoulderDaemon posted:So, I said this, and then I started thinking to myself that I should be prepared to be called-out on a statement like this. My first try was 99 lines, but I like round numbers, so here's a 50 line version: Man, look at those strict aliasing violations.
|
# ? Apr 7, 2009 06:07 |
|
floWenoL posted:Man, look at those strict aliasing violations. I wanted to make it even less defined, but any other changes I was making to it confused gcc enough to make it stop working on my laptop. If you drop the number of elements to 10 from 12, I have a version that works and uses code space to store the result list instead of reusing the initial elements list; I guess I could use an asm call to pad out this one and put that trick back in... actually, now that I think about it, there should be enough room in find_pairs instead of main where I was sticking them, so I could claim it was "broken memoization" or something...
|
# ? Apr 7, 2009 06:15 |
|
ShoulderDaemon posted:With the constraints you've been posting, it's been taking me less than a minute to find solutions each time. There's only twelve elements. Seriously, computers are overkill sometimes, if you can't solve these problems yourself faster than you can write a program, something is very wrong. Perhaps I should have said, near the beginning, that I don't have a huge amount of programming experience, especially when it comes down to the nitty-gritty way of algorithms. I can usually work out what's going on, but never the best way of doing it, which is why I posted in this thread. Truly, and although it sounds like an exaggeration, this problem really can't be tackled manually in the long run. It will get to the stage when there are hundreds of numbers (which refer to categories) that need to be sorted in the most ridiculously lengthy constraints. Besides that, it will no doubt be translated into PHP, and stuck within our management panel. ShoulderDaemon posted:So, what you're saying is, you'd have to spend even more time writing an even more complicated program, and you'd have to change the program frequently to account for new rules, which may be difficult to express in your algorithm. These do not sound like good reasons for using a program. You have said yourself, in your 50 lines of code, that it is not a complicated problem. Changing the IsAllowed() function is easy. At the moment, it involves sets. I have a vague expression parser that will be able to change these without recompiling. There are no "good reasons to program" per ce. There are programs that help with drug development, and there are programs / websites to show random lolcats. ShoulderDaemon posted:First of all, I didn't do anything involving permutations in that pseudocode. Your initial code considered all possibilities from a starting point. ShoulderDaemon posted:Secondly, backtracking is, exactly and precisely, the act of building a list of results at one level, then transforming that into a list of results from the next-highest level. This is what my (messy and lengthy) code did. It made a list, until it couldn't, and then it went to the parent. Thanks for the pseudocode, I will have a play with it, and hopefully have more success. ShoulderDaemon posted:This is, honestly, the kind of problem I'd expect to see in an intro data structures class. It's about 100 lines of C with no need for dynamic allocation, is easy to verify by hand, and is operating on an incredibly tiny problem with questionable utility. I haven't done an intro data structure class, but I have watched the university of Berkley's webcast on comp sci. I'm working my way through their java lecture course now. wrok posted:Jesus Christ, give it up already. For serious how much more can you possibly drag this out.... I am not dragging it out, I am trying to understand, and get help which is what this thread it about. The main reason it's turned into a saga, is because most people have been trying to find out WHY i need the code. I desperately don't want to go into this, because I feel I have already littered the thread enough. If you're saying that I should give up, and stop asking for help because I haven't yet understood it, then you should rethink how you learn things.
|
# ? Apr 7, 2009 14:13 |
|
It's just that people usually find it easier to help you with your problems if you present them in a wider context instead of just letting them see them through a small hole by witholding as much information about them as possible.
|
# ? Apr 7, 2009 14:25 |
|
Bonus posted:It's just that people usually find it easier to help you with your problems if you present them in a wider context instead of just letting them see them through a small hole by witholding as much information about them as possible. I agree that in order to solve a problem you need to know about it. However, in this case, it would only confuse people if I gave the whole subject matter. The reason I have neglected to give the details, is because the problem as a whole doesn't look like it can be solved this way. It has to do with correlating. It was a true eureka moment when I realized the patterns could be found by "organising" the data, and not by initially trying to find a formula. Luckily, the organisation results in categories, which can then be filled with more data, in order to help us.
|
# ? Apr 7, 2009 16:03 |
|
Fruit Smoothies posted:I agree that in order to solve a problem you need to know about it. However, in this case, it would only confuse people if I gave the whole subject matter. In the worst case, people might get a glimpse into an area that they don't know anything about.
|
# ? Apr 7, 2009 16:12 |
|
Dijkstracula posted:Did it occur to you that maybe people are simply curious about what the problem domain is? You have a lot of people spending a nontrivial amount of time writing code for you and the least you could do is provide a bit of context for their interest. I know people are curious, and I appreciate the time and effort they're putting in. I might just post this in the "tiny custom app" thread, because I don't want to plague this thread with any more of my ignorance, or anymore of people's Dr. House syndrome, where they're fixated on the wrong part of the puzzle.
|
# ? Apr 7, 2009 17:02 |
|
Fruit Smoothies posted:where they're fixated on the wrong part of the puzzle. How do you know it's the wrong part of the puzzle? Maybe you're looking at the wrong piece and that's what's confusing people. Something to consider, that's all. It's like asking a silly question like "how can I enable random access on a linked list?"* The premise is awkward and the question can't be taken at face value because the OP is on the road to mistakenville. * i'm so sorry i couldn't think of a better example
|
# ? Apr 7, 2009 17:14 |
|
Posted as a thread in SH/SC. I figure it can't hurt to ask here as well. My family is opening a Hotel for Dogs. I have been tasked with implementing a system to manage reservations. First, We need to collect data about the "guest" (dog) and owner. Guest's call name, weight, breed, owner's name and contact info, special needs, meal plan, exercise plan, preferred feeding schedule, length of stay, suite (standard, double, penthouse). Next, our caregivers must be able to see a status report for each day... a list of all guests, feeding schedules, exercise schedules, etc. We need to be able to enter value added services to a guest's package (24/7 webcam access, treats, food, special water). We also need to be able to update notes on a guests stay each day to update the owners. When the owners return to pick up their dog, they will receive a summary of the stay at the hotel with caregivers' (room service) notes. Now I don't expect a single piece of software to offer all of this functionality out of the box. We currently use Quickbooks for accounting. Can QB Premier do this? Is there an extension that adds this type of functionality? Should I look into custom coding? What would be the cost to do this from scratch?
|
# ? Apr 7, 2009 17:30 |
|
Jam2 posted:Posted as a thread in SH/SC. I figure it can't hurt to ask here as well. It looks like a pretty straightforward Web application, to me. You guys locally have a certain login that lets you add guests, administrate, etc, and your caregivers each have a login they use to mark what they did or whatever, and then you give your guests a login (one login per guest) and turn on special features on their account like webcam access or whatever.
|
# ? Apr 7, 2009 19:52 |
|
In VBScript, I have a url-encoded string which I have parsed together. In order to pass it to a 3rd party website I need to create a secure hash using the HMAC-SHA256 algorithm, and a secret code word that they gave me. I have no idea how to do this and my googling hasn't been very helpful. All I can find are downloads that I don't trust. Surely there is a way to do this with some vbscript code, it sounds like a fairly common task. Help?
|
# ? Apr 8, 2009 19:56 |
|
frumpus posted:In VBScript, I have a url-encoded string which I have parsed together. Please do not implement cryptographic primitives on your own, you will do it wrong. If you find a third-party which you do not trust, post a link in here and I can do some tests on the implementation for you and tell you if it's at least outwardly correct.
|
# ? Apr 8, 2009 20:08 |
|
ShoulderDaemon posted:Please do not implement cryptographic primitives on your own, you will do it wrong. If you find a third-party which you do not trust, post a link in here and I can do some tests on the implementation for you and tell you if it's at least outwardly correct. I was just looking at this. http://www.example-code.com/vbscript/crypt_hash_algorithms.asp It has no documentation though so I really don't even know what I'm looking at or how to implement it.
|
# ? Apr 8, 2009 20:10 |
|
frumpus posted:I was just looking at this. http://www.example-code.com/vbscript/crypt_hash_algorithms.asp That page does not demonstrate HMAC. However, it links to http://www.chilkatsoft.com/refdoc/xChilkatCrypt2Ref.html which is a reference to the library in question, which does support HMAC, and appears quite complete. The license for the library seems reasonable enough for commercial software. This evening I can throw together a few tests to make sure the HMAC implementation isn't completely insane, if you want.
|
# ? Apr 8, 2009 20:21 |
|
ShoulderDaemon posted:That page does not demonstrate HMAC. However, it links to http://www.chilkatsoft.com/refdoc/xChilkatCrypt2Ref.html which is a reference to the library in question, which does support HMAC, and appears quite complete. The license for the library seems reasonable enough for commercial software. This evening I can throw together a few tests to make sure the HMAC implementation isn't completely insane, if you want. I would appreciate that greatly.
|
# ? Apr 8, 2009 20:23 |
|
Anyone know how to program PIC devices with C? Reason I ask is because my teacher gave us the option to use C rather than ASM and I want to jump at that since I hate ASM. Do you know of any websites that have some sort of basic guide to it? Such as pin names and such. To be more specific, it's a PIC16F887. Thanks
|
# ? Apr 8, 2009 20:40 |
|
ShoulderDaemon posted:That page does not demonstrate HMAC. However, it links to http://www.chilkatsoft.com/refdoc/xChilkatCrypt2Ref.html which is a reference to the library in question, which does support HMAC, and appears quite complete. The license for the library seems reasonable enough for commercial software. This evening I can throw together a few tests to make sure the HMAC implementation isn't completely insane, if you want. Update, I am playing around with it and it seems to function ok. I just have no idea if the hash is right. This is the code I'm using to test it. code:
frumpus fucked around with this message at 21:03 on Apr 8, 2009 |
# ? Apr 8, 2009 20:55 |
|
That should be producing the hash 0ec3b4c8fcd83aee68a2df5e5133cce6f3eec86ca3df2c7a9f0a5557e11eae85. A few more tests for you to run: sigString="", key="", result=b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad sigString="foo", key="", result=0c0d98f7e3d9d45e72e8877bc1b104327efb9c07b18f2ffeced76d81307f1fff sigString="", key="foo", result=683716d9d7f82eed174c6caebe086ee93376c79d7c61dd670ea00f7f8d6eb0a8 sigString="foo", key="foo", result=08ba357e274f528065766c770a639abf6809b39ccfd37c2a3157c7f51954da0a sigString="1234567890"(repeated 100 times), key="foo", result=162816456de17fa0f2373ac6336589d5ce74365eccd3b670e7154937946fc3ea sigString="foo", key="1234567890"(repeated 100 times), result= 2952c50875e93839fdda25a08a85429094d870d131775ac41ffe3919e7ddc9c1 sigString="1234567890"(repeated 100 times), key="1234567890"(repeated 100 times), result=5c04621ef25e277d0541e670f5ade49ee6b2d72004857874509edf897021ee2d You can also examine the standard test vectors in RFC 4231.
|
# ? Apr 8, 2009 21:23 |
|
ShoulderDaemon posted:That should be producing the hash 0ec3b4c8fcd83aee68a2df5e5133cce6f3eec86ca3df2c7a9f0a5557e11eae85. So far they look good! Thanks a bunch!
|
# ? Apr 8, 2009 21:55 |
|
Cizzo posted:Anyone know how to program PIC devices with C? Our class used Hi-Tech C compiler, which has an unoptimized free version: http://www.htsoft.com/downloads/demos.php#freeware Integrates into MPLAB, which I assume you'd be doing your ASM in anyways. It has it's quirks if you're not used to building software in C. I forget everything about it, but good luck. No idea about using GNU tools.
|
# ? Apr 9, 2009 04:37 |
|
I believe SDCC has rather good support for PIC
|
# ? Apr 9, 2009 04:48 |
|
OK, I'll try here first. setup: I have a WPF form Window1 class that contains a textbox. On Load, this creates a new ServiceHost for my WCF service, adds the endpoint, and opens it. I have a WCF service class with a couple events triggered by requests from a client. They currently exist in the same project and same namespace. How do I update the textbox.text property from the WCF service class? I can't create a static update method in the Window1 class that does a 'textbox.txt = updateString' because of the control. I don't want to create a new instance of the Window1 class in the WCF service method (rules out a public textbox property.) I'm guessing that I can do this with delegates, but I'm not sure how. Is there any way to just do a Window1.MethodName(updateString); call from my WCF service class to update the textbox property? Bonus points for a solution that can let me do this when I move the WCF service to a separate project. Fetko fucked around with this message at 13:09 on Apr 9, 2009 |
# ? Apr 9, 2009 06:47 |
|
Next time try in the specific megathread first, and the answer is to pass a reference to your Window1 object to the ServiceHost.code:
|
# ? Apr 9, 2009 15:07 |
|
|
# ? May 14, 2024 18:41 |
|
Okay, I don't think the Excel megathread is active anymore, so I'll ask here. I have a table of values that are grades, so let's say that I have a list of values that are values for quizzes, where the maximum score is 5. Let's say that I wanted to remove the bottom two values from the average, now, for this, I know about the SMALL command. So right now, my average cell in my excel table's formula is: =((SUM(B7:B32) - SMALL(B7:B32,1) - SMALL(B7:B32,2))/(COUNT(B7:B32)-2)) / B6 * 100 Would it be possible to have the cells be removed based off of another cell? So, let's say that I had another cell that was just labeled "2" and it would chop off the bottom two values. I would think this would be done in a for loop but I can't seem to find anything about for loop support in Excel. Also, I wanted to format it so that my bottom two values that were removed were highlighted in red. If I use the bottom 10 conditional formatting it highlights the bottom two values but it also highlights all values that are tied. I tried using the formula conditional formatting but I can't quite seem to get it to work, if I use SMALL(B7:B32,1) it highlights all of the values, I think it's because it's simply looking for the formula to be 'true' and it always is true.
|
# ? Apr 10, 2009 16:09 |