logic

Not member rule doesn't work as expected in Prolog

那年仲夏 提交于 2019-12-02 18:11:50
问题 I am attempting to create a maze program in Prolog, whereby the aim is to find a route from the start of the maze to a point in the centre of the maze called m. The maze consists of squares which are connected using one of four colours: Blue, Green, Purple or Orange. The route from start to the centre follows a repeating pattern of the four colours. I have created the following code: link2(A, Colour, B) :- link(A, Colour, B). link2(A, Colour, B) :- link(B, Colour, A). changecolour(blue,green)

excel search for multiple items

自作多情 提交于 2019-12-02 17:54:09
问题 I am trying to search for multiple items in a cell. If any of the terms I am looking for is present, I want cell D to display "Laptop", otherwise, display "Desktop". I can get the following to work, with just one term to search for: =IFERROR(IF(SEARCH("blah",A2),"Laptop",""),"Desktop") But I want to search for the presence of blah, blah2, and blah3. I don't know how to get Excel to search for any of the following terms. (Not all of them mind you, just any of the following. I did see that

Why are products called minterms and sums called maxterms?

匆匆过客 提交于 2019-12-02 17:19:25
Do they have a reason for doing so? I mean, in the sum of minterms, you look for the terms with the output 1; I don't get why they call it "minterms." Why not maxterms because 1 is well bigger than 0? Is there a reason behind this that I don't know? Or should I just accept it without asking why? Rubenulis The convention for calling these terms "minterms" and "maxterms" does not correspond to 1 being greater than 0. I think the best way to answer is with an example: Say that you have a circuit and it is described by X̄YZ̄ + XȲZ . "This form is composed of two groups of three. Each group of

(Game of Life) How to loop through outer layer of a matrix without checking outside of it, simultaneously checking for neighbors?

陌路散爱 提交于 2019-12-02 17:09:34
问题 Each point in the matrix represents a cell, living or dead. I have to count how many ALIVE neighbors each cell has. I have a function that does the job, but it checks for cells outside its boundary.I don't know how I can simultaneously check for neighbors and keep track of edges without doing a massive amount of if-else statements. void Neighbours(int rows, int cols, cell world[rows][cols], int neighbors[rows][cols]) { //Loop through each cell in the matrix. for(int rCell = 0; rCell < rows;

How can I get “thinner” graph for my coordinate system?

北城余情 提交于 2019-12-02 16:53:49
问题 Following up with this, I have a bunch of coordinates and I draw them on a bitmap image as a coordinate system. Now, I would like to get rid of all the noise, and filter coordinates to give a "clearer" or "cleaner" path and "less" or "better" data to work on. To explain more, I will need to expose my awesome painting skills as follows: Current: Desired: Notice: I will need to delete coordinates I might need to add coordinates I might need to ignore shortest neighbor in some cases The only

Python - Pandas Dataframe - data not matching source

南笙酒味 提交于 2019-12-02 16:35:28
问题 I'm trying to use monthly stock data from yahoo to analyze patterns. For some reason, the monthly returns the program is spitting out in a dataframe for a particular stock (ATVI) do not match the returns from the actual yahoo site. I compared monthly returns for the 2015 period and included columns for average increases and decreases as well as the # of occurrences of each. Yahoo link: https://finance.yahoo.com/q/hp?s=ATVI&a=00&b=1&c=2015&d=11&e=31&f=2015&g=m My code: from datetime import

Recursively loop through multidimensional to create flat array

落花浮王杯 提交于 2019-12-02 16:04:22
问题 I have a multidimensional array that looks like this: $trees = array( array( 'name' => 'Parent', '__children' => array( array( 'name' => 'Child' ), array( 'name' => 'Second Child' ) ) ) ); The depth of the array is unknown and I need to recursively flatten it. So it looks more like this: array( array( 'name' => 'Parent' ), array( 'name' => 'Child' ), array( 'name' => 'Second Child' ) ) I thought something like this might work: public function flattenTree($trees, $tree = array()) { foreach(

How to download file having spaces in it's name from azure by java service?

给你一囗甜甜゛ 提交于 2019-12-02 15:59:21
问题 I am creating application where I upload, download files in my azure storage account through java services. When I upload files with name having no space in their name(example : "image.png"), program returned me token successfully. But when I try to get token while uploading or downloading for file names having spaces in between them like "new image.png" , it gives me error at particular line. My code is : CloudFile cloudFile = directory.getFileReference(fileNameWithExtension); String

Why is it saying that there is a syntax error for the if/else statement I wrote?

和自甴很熟 提交于 2019-12-02 15:56:15
问题 I'm trying to write a program that calculates the sum of a geometric series on a TI-84. Prompt A Prompt R Prompt N If N=100 and abs(R)<1 Disp (A/1-R) Else Disp (A(1-R^N))/(1-r) It says that there is a syntax error at the Else line. 回答1: Else can only be paired with an If .. Then construct, not a plain If . So: Prompt A,R,N If N=100 and abs(R)<1 Then Disp A/(1-R Else Disp (A(1-R^N))/(1-R In general the If.. Then .. Else .. End construct should be closed by End but in this case the program

VBScript Number Guessing Game

心已入冬 提交于 2019-12-02 15:01:33
问题 I am at a complete loss here. I have been beating my head against a wall all weekend and I cannot for the life of me figure out how to make my program work. This is a college class assignment and it is my first programming assignment ever, so this is a real challenge for me. I have Googled until my fingers were bleeding (not really) and I have only come across marginally helpful information. Here is my assignment (I am deeply sorry if I get the formatting wrong): 'Initialization Section