logic

How should i deal with the card assigment of my game ?

I've checked most of the question that was display regarding my title but they were not related to what i am looking for, so i am starting my own question. The game i am trying to re-create as an online game is called Buraco not sure if most or any of you know of it. I already have the basic functions of my game such as: shuffle the ...

apply best fitted discount package on items automatically

I have created some discount packages: Package1(Item1,Item2,Item5) Discount-5%. Package2(Item2,Item5,Item8) Discount-8% Package3(Item1,Item2) Discount3%. When a Person buy Items Online(for Ex. he buys Item1,Item2,Item5, Item10), while I show him the total price, I need to apply the best fitted discount on the items automatically. I...

Python Logic Help:

I am writing a game where there are two losing conditions: Forming a word longer than 3 letters. Bee is okay, Beer is not. Forming a word that can't be made into a longer word. Zebra is okay, Zebras is not. Wordlist is a list of words, frag is the previous fragment and a is the new letter a player enters. so frag may look like 'app'...

Does the logic behind objects matter?

When working on the early stages of a console-based Python remake of snakes, someone submitted a patch to spawn food at random locations. The code defined a Food class which worked fine, but the logic behind it seemed a little weird. I think we should delete the food once it's been consumed, then create another one. However, this person...

PHP - If something is the case, do nothing.

Is this a proper way to say: if something is the case, do nothing? if ( ($hostNameInfo == $hostNameInput) && ($hostAddressInfo == $hostAddressInput) ) { return; } Update: I'm not inside a function. :( So the return is just nonsense. Here is more code: //if the input fields are equal to database values, no need to update and waste...

Logic programming help

A = if infos !empty and inputs empty - do remove; B = if infos empty and inputs !empty - do add; C = if infos !empty and inputs !equal to infos - do add; We can have like: if B //it's the most common operation, so at the beginning. { //add } else { //remove } elseif(c) { //the same add } I believe this can be better think...

Logic Programming Help - II

A if ( ( empty($infoA) || empty($infoB) ) && ( !empty($inputA) && !empty($inputB) ) ) { //add } B if ( ( !empty($infoA) || !empty($infoB) ) && ( empty($inputA) && empty($inputB) ) ) { //remove } C if ( ( !empty($infoA) || !empty($infoB) ) && ( ($inputA != $infoA) || ($inputB != $infoB) ) ) { //add } So, in order...

Can we suppress the Main report records, If the Subreport returns No Data in Crystal report?

I am Using Remedy AR ODBC DataSource, where We can not use Joins, as AR ODBC does not support join, So I am Using SubReport in Detail section(Used Proper Link) when I am running the Report: i.e., Main Report has 3000 Records and Maching Records in SubReport has 1000 records when I am running the Report, It shows all 3000Records and Blan...

Liskov Substitution Principle and the directionality of the original statement

I came across the original statement of the Liskov Substitution Principle on Ward's wiki tonight: What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is subs...

Scala - Prefix Unary Operators

I've recently given Scala a second chance, and started with the project I always implement (in functional or pseudo-functional languages): an automated reasoner for propositional logic (and later predicate logic). Now, I've tried to get the notation of propositional logic in the language itself as pretty as possible, and I've gotten thi...

Can this conditional tree be simplified?

Context: I have a box (objA) and want to compare it to surrounding boxes. If two surrounding boxes in any of 10 configurations share a property with objA I want to add them along with objA to a list. Preferably no box would be added to the list more than once, though it is non-essential. Current logic: (x is a boolean for whether or not...

How to get started

First off, I really do apologize if this is not appropriate to ask here. I see links that are marked subjective and moved to a wiki but I can't find it. My question is this: How do I start to do things? I love programming languages and trying to think of logical solutions to problems. A lot I have been reading on C# and the underw...

File Upload with Web.Client class...?

I am Using Active X control and using WebClient class to upload file to server. what we are doing is:: at client end, in ActiveXcontrol, we opened a Server Located DocX file . and Once we done the authoring in File, we pressed Save, here on Save Click, we Used Webclient Class to Save Document to Server...The Problem is that at times the ...

What is the logic for solving this sequence?

The sequence goes like this.. 7,8,77,78,87,88,777,778,787,788 and so on.. What can be the logic for finding the nth number of the sequence? I tried that by dividing it by 2 and then by 4 and hence, but it doesn't seem to work. ...

how to find date difference when dates are places in different rows in same table?

I have a table:: ItemID VersionNo CreatedDate ------------------------------- 1 3 7/9/2010 1 2 7/3/2010 1 1 5/3/2010 1 0 3/3/2010 2 0 4/4/2010 3 1 4/5/2010 3 0 3/4/2010 ...where Version 0 means .. its a newly produced item. Here ...

bitwise not (~) operator, clarification needed

Suppose you have the following C code unsigned char a = 1; printf("%d\n", ~a); // prints -2 printf("%d\n", a); // prints 1 I am surprised to see -2 printed as a result of ~1 conversion: Opposite of 0000 0001 is 1111 1110 --> anything but -2 What am i missing here? please advise ...

Reverse Integer Values

I have a scenario which I think I can convey giving PC Monitor example (not real though). Assume I have two monitors both of different resolution and properties. One monitor draws mouse cursor on screen from top (0) to bottom (max-value) and other draws mouse from bottom (0) to top (max-value). In other words both have reverse y-axis of...

Number of Items in a Column inside a grid

Hi, How do you find number of items in a column inside a grid? I have a grid (listview control to be specific), and have some items. Some times a given row might not be full. ANd can have values in fewer than maximum columns. I need to find Number of items in a given Column. If the grid is like 1 2 3 4 5 6 7 and if i...

IF Not taking any decision?

Look at this: foreach(Object Item in comboBox1.Items) { if (Convert.ToString(Item) == Convert.ToString(dsGirasol.Tables["DatosGirasol"].Rows[contador][0])) { repetido = true; break; } else { repetido = false; } }​ Note that both of the possible outputs have a messagebox. However when I ...

C# data processing logic help

Hi Guys, I have a DataTable like this, AccessDateTime | Direction 2010-09-15 12:12:49 | IN 2010-09-15 12:36:03 | OUT 2010-09-15 12:53:05 | IN 2010-09-15 14:04:19 | OUT 2010-09-15 14:17:35 | IN 2010-09-15 16:07:57 | OUT 2010-09-15 16:10:57 | OUT 2010-09-15 18:43:18 | OUT I need a fast logic to convert the data into this format...