logic

Logic Dots puzzle problems with SWI-Prolog

霸气de小男生 提交于 2019-12-23 03:39:14
问题 I am working on a logic game named "Logic Dots". The game is a 3*3 grid with numbers surrounding each row and column. The rule is easy that the sum of each row and column should equal to those numbers. Below is my code, it is changed from clpfd sokoku. But result is something wrong. Code: :- use_module(library(clpfd)). kakuro(Rows) :- length(Rows, 3), maplist(length_list(3), Rows), append(Rows, Vs), Vs ins 0..1, Rows = [A,B,C], sum(A,#=,1), sum(B,#=,1), sum(C,#=,1), transpose(Rows, Columns),

Geb & Spock - If/Then/Else logic - How to check for a record and do one thing if it exists but continue on if it doesn't

蓝咒 提交于 2019-12-23 01:42:03
问题 I'm testing the creation and then removal of a record on my site using Geb/Spock. However I can't create the record if it already exists and so I check for the existence of the record and remove it if it exists in the beginning of the test. The problem occurs when the record does not exist, causing the test to fail. Is there a way to incorporate some if/then/else logic so the test will continue if it does not find the record in the beginning and remove it if it does find it? Edit for example

OWL instance participation logic

时间秒杀一切 提交于 2019-12-23 00:52:32
问题 In OWL: There is a class X and the properties P1, P2, and P3, each of which has domain X. I want to say: Every instance of X must at least participate in a relation with one of the properties P1 or P3. Every instance of X which participates in a relation with P2 must also participate in a relation with P1. But every instance of X may only participate in relations with P1 and P2 or in relations with P3. Maybe it is easier to understand with some syntax and labels: :Chronology a owl:Class ;

How to create dynamic color list for charts

爱⌒轻易说出口 提交于 2019-12-22 09:07:32
问题 How to create dynamic color list for charts Basically i have a different value in my database or each values contain each percentage and i need to show this percentages in pie chart with different colors .... This is the example code of pie chart in static way <color value="#99CDFB"/> <color value="#3366FB"/> <color value="#0000FA"/> <color value="#F8CC00"/> <color value="#F89900"/> <color value="#F76600"/> but i need dynamic way using PHP ( for loop / foreach loop ) like this $color = "";

Rails expire password within 24 hours

谁说我不能喝 提交于 2019-12-22 08:35:21
问题 In my rails 3.1 application, I want to create and expire random password for users.I am using devise gem for that.Any plugin available for expiring password withing some duration? Or else Please give me some logical advice to implement this feature. Please consider me as a newbie. 回答1: It sounds like you just want to expire the password once. If you're looking to do it at regular intervals (e.g. every couple of months) or if you want to prevent users from re-using passwords, it gets more

Curry's paradox in Haskell?

放肆的年华 提交于 2019-12-22 06:59:37
问题 Curry's paradox (named after the same person as the present programming language) is a construction possible in a faulty logic that allows one to prove anything. I know nothing about logic, but how hard can it be? module Main where import Data.Void import Data.Function data X = X (X -> Void) x :: X x = fix \(X f) -> X f u :: Void u = let (X f) = x in f x main :: IO () main = u `seq` print "Done!" It certainly does loop. (How does GHC know?!) % ghc -XBlockArguments Z.hs && ./Z [1 of 1]

How do the digits 1101004800 correspond with the number 20?

断了今生、忘了曾经 提交于 2019-12-22 04:56:27
问题 I'm trying to learn how to modify memory locations using C++ and when messing with MineSweeper, I noticed that when the clock's value in memory was 1101004800, it was 20 seconds into the game. The digits 1101529088 correspond with 21 seconds into the game. Can someone please explain to me how to convert between those 10-digit long numbers to base-10? 回答1: They are using floats to represent the timer. Here is a program that converts your integers to floats: #include <stdio.h> int main() { int

All possible words

前提是你 提交于 2019-12-22 03:55:50
问题 I want to create all possible 5 letter words using a-z.Please suggest any good and fast algorithms. I have tried creating one and it looks something like this... byte[] allchar=new byte[] {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; int lengthOfAllChar=allchar.length; System.out.println(lengthOfAllChar); for (int i = 0; i < lengthOfAllChar; i++){ for(int j = 0; i < lengthOfAllChar; j++){ StringBuffer finalWordBuffer = new

Categorizing the list of array in python

╄→гoц情女王★ 提交于 2019-12-21 20:57:52
问题 i was helping my friend to do logic algorithm in python but i haven't come with best solution yet. first of all, i have a list of array: x = array[0,1,2,3,4,3,2,3,-2,-4,-7,2,2] and he wanted to categorize the x so the output become like this: array([0,1,2,3,4]) # increasing value array([4,3,2]) #decreasing value array([2,3]) # increasing value array([3,-2,-4,-7]) #decreasing value array([-7,2]) # increasing value array([2,2]) # remain_the_same_value the rule is simple: if the value keep

Propositional Logic - Reducing the Number of Operations

点点圈 提交于 2019-12-21 20:37:57
问题 In short, I'm wondering if, given two propositional formulas, whether there is a standard method for finding the shortest sequence of operations that still have the same output as the two formulas. For example if we have the following formulas: and we can reduce the number of operations by introducing a new proposition: and then Q becomes: This reduced the number of operations (unary and binary) from 19 to 14 . The new logic circuit for Q is: Ideally I would like there to be only negations