FAQ Database Discussion Community

## Configuring inputs for a Multiple Input Fuzzy Controller in Labview?

input,controller,logic,labview,fuzzy
I'm building a fuzzy controller in Labview using the MIMO (Multiple Input, Multiple Output) FL Fuzzy Controller.vi. I designed the fuzzy system using the Fuzzy System Designer, and the .fs file is connected as the "fuzzy system in" of the MIMO Fuzzy Controller VI. The input values are where I'm...

## horizontal movement in game (rotated player)

math,lua,logic,love2d
In my world I have a character wich is always rotated towards the mouse. It is very logical that when the player moves forward or backward, that the character's x coordinate equals it's x coordinate minus (or plus) the cosine of its x coordinate. And the same for its y...

## How to extract business logic in this example

design-patterns,logic,structure
The following method filters a data collection based on order statuses. Im wondering what would be the best way to extract the business logic held within about the order statuses. For example, say the order statuses were to change down the line i.e. ('in_transit', 'at_courier') then this method, and associated...

## Z3: Difference logic performance

logic,z3,difference
I have a problem to solve that can be translated into difference logic, and rather than implementing a decision procedure, I would like to use z3 for this purpose. Nevertheless, I run a few examples and I had exponential-like runtimes (even though there is a polytime decision procedure for it)....

## Logical Operators and Precedence

php,logic,php-5.3,logical-operators
So I just did some random test and understand the fundamentals of Precedence and the || and or operators but I'm having trouble understanding why \$f changes: \$f = 0 || 1; if (\$f === 1){ echo "TRUE - \$f"; }else{ echo "FALSE - \$f"; } \$f = 0 or...

## Excel VBA Cell Values showing up as intergers

excel,vba,for-loop,logic
I'm working on a program with Excel's VBA functionality, but ran into a very strange logic error. For SheetIndex = 1 To 6 With ActiveSheet For ColIndex = 2 To 6 For DateIndex = 0 To MinLimit datethingy = .Cells(1, ColIndex).Value If (.Cells(1, ColIndex).Value = Date_Array(DateIndex, 1)) Then For RowIndex...

## Writing 2^x in PL

java,algorithm,logic
We designed a PL that has the following syntaxes: load variableName, value inc variableName //increases the value by 1 loop variableName //loops it a certain number of times depending on variableName's value at the time. Also if variableName's value is somehow altered later on in the code, the loop cycle...

## Can Sphinx search engine do a NOT AND filter?

logic,sphinx
Suppose I have a Sphinx index with the following boolean attributes: narrow tall I want to filter all the documents that are NOT (narrow AND tall). Can this be done with Sphinx? If it makes any difference I'm using the Python sphinxapi.py....

## I want to count frequency or occurrence of a every letter in a string C program

c,string,logic
Suppose if I pass a string like "I am Programmer". If a letter has occurred one time it should print "I has occurred 1 time", or else if a letter appears twice in the string it should print "a has occurred 2 times", "m has occurred 3 times" and so...

## Tricky data entry validation SQL query

sql,sql-server-2008,while-loop,cursor,logic
I'm trying to develop a query to validate user data entry and I'm stuck. Basically, we're working with information about a daily 24 hour composite water sample. The user will enter the "COLDATE" which is the end of the composite and is stored in DATETIME format like "2015-03-02 04:00:00.000". Then...

php,mysql,logic
I would like to split a single address field into a street and housenumber field. This is some example data: Examplestreet 1 Examplestreet 1A Examplestreet 1 B The Examplest street 2 1st Example street 3A 1st Example street 13 A Now, I was thinking that I start from the right...

## Does all conditions get checked in an if statement even if the first one is false?

logic,short-circuiting
If I have: bool foo = false; bool bar = true; If(foo && bar) Doea the if-statement check if bar is true or does it skip it because foo already is false?...

## continous max sum in array -Dynamic programming

c++,arrays,logic,dynamic-programming
I am following a tutorial on dynamic programming.and following this link : http://www.8bitavenue.com/2011/11/dynamic-programming-maximum-contiguous-sub-sequence-sum/ they have derived a relation : M[j] = Max (A[j], A[j] + M[j-1]) but in the actual code while implementing this i cant undersatnd how they are using it .here is their implementation //Initialize the first value...

## How does this code print odd and even?

c,if-statement,macros,logic
#define MACRO(num, str) {\ printf("%d", num);\ printf(" is");\ printf(" %s number", str);\ printf("\n");\ } int main(void) { int num; printf("Enter a number: "); scanf("%d", &num); if (num & 1) { MACRO(num, "Odd"); } else { MACRO(num, "Even"); } return 0; } Please explain the above code (if/else condition and how...

## Can't Get Program To Recognize Card Values

java,exception,arraylist,javafx,logic
My program won't go inside of this block of code if(card1.CardValue() == (int)expInput.get(0) && card2.CardValue() == (int)expInput.get(1) && card3.CardValue() == (int)expInput.get(2) && card4.CardValue() == (int)expInput.get(3)) { if(express == 24){ display.setText("Correct"); } else display.setText("Incorrect"); } I think it is because I am trying to get the card value of card1 when...

## What are the basic steps from a hardware circuit to a transitionssystem

logic,computer-science,transitions,boolean-logic
What are the basic steps when I want to get a hardware circuit into a transitionssystem? I don't get the arrows between the nodes. The arrows from/to the same node are simple. But How do I get the arrows between node {r} and node {x,r,y} for example? and what can...

## Unable to compare two strings in IF statement in PHP

php,xml,logic
okay, so I've been trying to build the server-side for a web app that needs to get information from 2 XML files and compare them, one element at a time. For some reason my code will do everything except compare the 2 nodes. The code: function getCoursesByRole(\$role){ s("role is "....

## Best way to find the most maximum sum of a range in array

python,arrays,sum,logic,range
What is, in Python, the best way to find the maximum sum of elements in a range of an array? e.g. one array [1,-3,2,5,-5] What is the range that the sum of elements is the most positive of any other range in the array? The result has to be the...

So I wrote this file reader method that should return a string of everything that is in the file, but it isn't working properly. Writing into the file works perfectly, but this reading method doesn't. What the method does currently is it reads the last string/text added, but it does...

## How do I approach logic questions? [closed]

php,logic
I have been given this question for an interview. I am to show my logic working in PHP: John, Alex, Jay, Thomson and May live on different floors of an apartment house that contains only five floors. John does not live on the top floor. Alex does not live on...

## Is it possible in Python to write a sort of truth table to simplify the writing of if statements?

python,if-statement,logic,truthtable
Let's say I'm trying to print out the orientation of a tablet device using its accelerometer that provides acceleration measurements in the horizontal and vertical directions of the display of the device. I know that such a printout could be done using a set of if statements in a form...

## logic AND function on array with arbitrary/variable N values

php,arrays,recursion,logic
I am stuck with a huge problem. I have a dynamic array that may contain anything between 0 and N values (for simplicity of the question, assume they are all boolean e.g. 0 or 1). Of course, once an array is defined/read, the number of values is not unknown anymore....

## loop logic can't effect every element

php,loops,order,logic
thanks in advance for helping, and looking. I have a bunch of images whose paths and metadata I need to process in a web directory: e.g. 'path/to/files/u_1.jpg' \$list=array_values(\$list); foreach (\$list as &\$value) list(\$width, \$height) = getimagesize(\$dir.\$udir.\$value); \$value = \$predir.\$udir.\$value.\$wid.\$width.\$hgt.\$height.\$lft.\$end; I used scandir to get the elements into the \$list array...

## Get list of all subfolders (Aspera API)

java,algorithm,recursion,functional-programming,logic
I am using Aspera (for fast transfer of files) SDK's, and integrating it with my web application. I have a program logic question, how can i get a list of all folders on server : Lets Say, I have a folder structure as below, and i would like to get...

## overlapping of 3 intervals: what is the fastest way

javascript,python,logic,intervals,overlapping
Give 3 intervals (a,b) , (c,d) , (e,f), what is the fastest way to detect (i.e. have a yes/no answer) if exists a value t that is at the same time a<=t<b AND c<=t<d AND e<=t<f ? Is it also possible to compute the range of t that satisfies this...

## How to check a time array if the single values are in +/- 15 minute range of another time

php,time,logic,strtotime
What should I do to make a 4 digit integer/string to behave (not look) like time? Consider this code: \$t = 0430; \$timeArray = array('0400', '0415', '0420', '0430', '0440', '0450', '0500', '0600'); Now if I have to search \$timeArray for elements which are +/- 15 min from \$t I would...

## Developing a Checkers (Draughts) engine, how to begin?

algorithm,logic,artificial-intelligence,game-engine
I'm a relatively inexperienced programmer, and recently I've been getting interested in making a Checkers game app for a school project. I'm not sure where I can start (or if I should even attempt) at creating this. The project I have in mind probably wouldn't involve much more than a...

## Error in logic for year comparison tool

android,date,if-statement,logic
I'm attempting to create a tool that compares the current year to the year that an event took place and then allows the user to guess how many years it has been since that event occurred. For example, the inaugural FRC Championship took place in 1992. The current year is...

## How to add repeating occurences of elements in two lists in python

python,python-2.7,logic
I have filtered_symbolic_path = ['A', 'B', 'C', 'D', 'B', 'C'] filtered_symbolic_path_times = [ 3, 4, 5, 6, 5, 3] Here, A=3, B=4 ,C=5, D =6, B=5. C=3 I want a dictionary like, time_per_screen{A:3,B:9,C:8,D:6} ...

## If else error I don't understand this error

java,if-statement,logic
I don't understand this error is it logical error or something else here is the coding " this program should convert riyal to currency that is chosen by the user using multiway if-else import java.util.Scanner; public class Convert { public static void main (String[] args) { Scanner kb= new Scanner...

## Trying to write a function in SML

logic,sml
I am trying to write a function in sml that takes a list as its first argument and a number as its second. The result should be: greaterT [3,5,2,4,7]3; val it = [5,4,7] : int list This is my work so far but doesn't work yet. fun greaterT ([],k) =...

## Racing/ S-R Circuits?

logic,signal-processing,circuit,flip-flop,circuit-diagram
Following truth table resulted from the circuit below. SR(NOR) latch is used. I have tried several times to trace through the circuit to see how truth table values are produced but its not working. Can someone explain to me what is going on ? This circuit was introduced in conjunction...

## The logic of programming

I have a question about the logic of programming, checkout the following example: public function logout() { if (Auth::user()) { Auth::logout(); } } In the above example we first check if the user is logged in. In this function we can say that only a logged in user is able...

## Organize table avoiding redundancy

database,database-design,logic,store,database-schema
I'm trying to create a database to manage autobus data CREATE TABLE Company( Company_Name VARCHAR(12), Tel INT, PRIMARY KEY(Company_Name) ); CREATE TABLE Line( ID_Line VARCHAR(3), NCompany_Name VARCHAR(12), Desc TEXT, PRIMARY KEY(ID_Line, Company_Name), FOREIGN KEY (Company_Name) REFERENCES Company(Company_Name) ); CREATE TABLE Stop( ID_Stop VARCHAR(3), geoLat FLOAT(10,6), geoLong FLOAT(10,6), PRIMARY KEY(ID_Stop) );...

## Calculate the score of the game “GO”

algorithm,logic
Does anyone know how to calculate the score in the game of Go programmatically? I have an array of 19x19 and each element of this array can be 0 (empty point), 1 (black stone) or 2 (white stone). I don't understand how can I check the region to belong to...

## Elegant way to test list of if statements in Python

python,if-statement,logic
I have some spreadsheets represented as a list of lists in python, and I'm generating output from those. However, I end up with some really ugly code when I have to omit sections of the sheet, such as: if not "string" in currentline[index] and not "string2" in currentline[index] and not......

## Prove two algorithms are identical

algorithm,logic,tail-recursion,eiffel
I am supposed to show that two algorithms execute identical statements in identical order. One is a tail recursive version of the other. They are written in Eiffel. tail_rec(x:instance_type):result_type is local y:instance_type; do if b(x) then Result :=c(x) else y:=d(x); Result:=tail_rec(y) end end Then the non-tail recursive version. non_rec(x:instance_type):result_type is...

## Unity3D Mecanim Character stopping before turning

c#,unity3d,logic,movement
so for the past few days I've been working on a character controller in Unity3D using mecanim. It's not based off of my own code, but off of a tutorial I found online, of course that tutorial was meant for Unity 4, so I am running in to small problems...

## How is the manipulation is done on bit level?

c++,binary,logic
Assume that the size of char is 1 byte and negatives are stored in 2's complement form #include<stdio.h> int main() { char c = 125; c = c+10; printf("%d", c); return 0; } How can be the answer is -121?...

## Parse JSON on PHP and extract the particular value(s)

php,mysql,json,parsing,logic
Objective: To parse following json string and get mentioned values separately, later those separated values are going to be inserted to mysql database. I have checked my json string on JsonLint user_name, selected_date, selected_project, tasks , 4.1.task_name, 4.2 work_hours { "user_name": "USER", "selected_date": "2015-06-08", "selected_project": "Project1", "tasks": [ { "task_name":...

## PHP: Switch() If{} other control structures [closed]

php,if-statement,switch-statement,logic
How do you execute logic with out the use of Switch or If? For instance check_id_switch(\$id) function check_id_switch(\$id){ switch(\$id){ case '1': \$HW = 'Hello, World!'; break; default: \$HW = 'Goodbye, World!'; break; } return \$HW; } Or instance check_id_if(\$id) function check_id_if(\$id){ if(\$id == 1){ \$HW = 'Hello, World!'; } else{...

## How to allow more entry and return factors for Prime Checker [Java]?

java,math,numbers,logic,primes
I set out to write a Prime Number Checker: import java.util.Scanner; public class PrimeChecker { int userEntry; int even_check; int odd_check; final void run(String[] args) { Scanner jaiho = new Scanner(System.in); System.out.printf("Please enter a prime number: %n"); userEntry = jaiho.nextInt(); even_check = userEntry % 2; // This is to get...

## How to use logical functions with %>% operator (dplyr)

r,logic,dplyr,which
I was wondering how to use logical (for example which, any, all) functions with %>% operator from dplyr package in R. I have a vector of values aaa <- sample(1:5, 10, replace = TRUE) I would like to find out which of them are equal to 4. When I try...

## PHP logic to add a class to 2 rows every other 2 rows

php,logic
Can anyone help me with the logic to add a class .col-md-offset-2 to every two rows in my code below... <?php while(have_rows('report_quotes')): the_row(); ?> <div class="col-md-12 <?php // help me ?>"> <?php /* quote */ ?> <?php Post::get_template_part('sections/quote'); ?> </div> <?php endwhile; ?> So the output will look like this......

## Simulate output with 3 cases

logic,electronics,ternary
Physically is possible to simulate such situation on a board, using electronic components. I got 2 inputs A and B , with 3 possible values for each one (-1,0,1). My final aim is to achieve this following truth table A | B | result –1 | –1 | +1 –1...

## Describe a film (entity and attribute) using the first order logic

logic,semantics,semantic-web,first-order-logic
Good morning, I want to understand how can I describe something using the first order logic. For example I want to describe what is a film (an entity) and what is an attribute (for example actor: Clooney) for the film. How can I describe that using the first order logic?...

## Find how much time exists within two unix timestamps

php,logic
I need to find how many seconds exist between two different unix timestamps within a certain range. For example: Travel Start: 05:00 Site Arrival: 07:00 Standby Hours: 06:00 - 09:00 I need to find how many seconds the user is traveling and how many seconds he spends on standby. The...

## Fixed Point and Proof theory

logic,proof,logic-programming,first-order-logic
For any given logic program, proof theory of it uses SLD (Selective Linear Definite) resolution to find the satisfiablity of the query. For the same logic program, we can apply fixed point theorem to find the models. My question is, should we consider finding fixed point of logic programs as...

## SQL/C# book a trip for customers

c#,mysql,logic
I'm trying to make a VERY simple application to let customers book a trip. Basically, they enter Name, Address, Civic, Phone and then a number between 1-5 depending on which trip they want to book. So for example trip 1 equals a trip from Berlin to Paris, trip 2 from...

## if and else if do the same thing

if-statement,refactoring,logic
I'm trying to refactor an if-else chain that doesn't look particularly good. My common sense is telling me that I should be able to call my method only once but I can't figure out an elegant way to do it. Currently what I have is: if(condition1) do method1; else if(condition2)...

## Object Variables in Ruby

ruby,logic
I'm learning Ruby and I found this code example on book, it's about encapsulation. Here it: class Person def initialize(name) set_name(name) end def name @first_name + " "+ @last_name end def set_name(name) first_name, last_name = name.split(/\s+/) set_first_name(first_name) set_last_name(last_name) end def set_first_name(name) @first_name = name end def set_last_name(name) @last_name = name...

## Correctness and Logic of algorithm: minimum steps to one

c++,algorithm,logic,correctness
Problem Statement: On a positive integer, you can perform any one of the following 3 steps. Subtract 1 from it. ( n = n - 1 ) If its divisible by 2, divide by 2. ( if n % 2 == 0 , then n = n / 2 )...

## Converting tree-like map into plain map with composite keys

java,dictionary,mapping,logic
I was trying to do something in Java but I am stuck at this problem, I really dont know how to convert this. I tried for loops but I would need to make a lot of for loops and I would like to keep my code clean. I have a...

## R filtering logic

r,filter,logic,conditional-statements
Need some insight on how to fix this filtering logic. test.session <- c("A","A","A","B","B","B") test.start_flag <- c("1","0","0","1","0","0") test.url <- c("in_list","in_field","out","not_in_list","in_field","out") test.code_map <- 'tbd' test.manual_map <- c("1","1","0","0","0","0") test.df <- data.frame(test.session, test.start_flag, test.url, test.code_map, test.manual_map) I want to generate the test.code_map to match the test.manual_map vector. I have the first four lines coded,...

## Buffered Writer and Reader Proper order/use

So I'm not sure where my mistake is in the order/use of BufferedWriter and BufferedReader. See for yourself. My program works all except for these methods. Here is where I declared stuff, pretty sure error is not here. fw = new FileWriter(file, true); bw = new BufferedWriter(fw); fr = new...

## I want to create a website for polls/survey like this http://www.poll-maker.com/ [closed]

php,database,web,logic,development-environment
but did not understand The concept of generating a link & more importantly how they save the data in database,do they save it like id of poll & yes/no click or done with other logic. what will happen to the polls which are expired? will they remain in database or...

## How do I format the logic for 3 conditions and use a previous condition as well?

java,loops,if-statement,while-loop,logic
NOT ASKING FOR ANYONE TO WRITE THE PROGRAM FOR ME I am having trouble understanding how to setup the logic for a program given these following conditions: For every day late up to and including 7 days, the late fee is \$0.10/day After 7 days, for every day late up...

## Python concept. Else statement printing when it shouldn't

python,if-statement,logic
This is really a concept question from a beginning programmer. I am still working on this program. When I type in a menu option not only does the corresponding if statement print but, the else statement does at well. With this python knowledge I have I do not understand why....

## How to write a method which takes int args either 0 or 1 and gives output 1 or 0

java,logic
I want to write a method which takes int args either 0 or 1 and gives output 1 or 0. Means if I give input as 0 it should return 1 and if input is 1 is should return 0. But the problem is I cant use if else, ternary...

## Unexpected behavior in subsetting aggregate function in R

r,logic,aggregate,subset,subsetting
I have a data frame that contains with the following format: manufacturers pricegroup leads harley <2500 # honda <5000 # ... ... .. I am using the aggregate function to pull out data in the following way: aggregate( leads ~ manufacturer + pricegroup, data=leaddata, FUN=sum, subset=(manufacturer==c("honda","harley"))) I noticed this is...

## Formatting decimal places with unknown number

swift,logic
I'm printing out a number whose value I don't know. In most cases the number is whole or has a trailing .5. In some cases the number ends in .25 or .75, and very rarely the number goes to the thousandths place. How do I specifically detect that last case?...

## Project Euler Solution 8, Explanation needed

java,logic,solution
I have resolved the Problem 8 of Project Euler; The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866...

## How to animate dynamic number of items according to a array of positions

javascript,jquery,animation,jquery-animate,logic
What I trying to achieve is moving div positions according to an array of positions. Number of objects is unknown could be between 4 to 20. Only 4 elements shown at once. To be clear, I've 4 item different positions and each time (like every 4 seconds) items will change...

## How do I get my logic in this Java program to make my loop work?

java,if-statement,while-loop,int,logic
I've made this java program to find the two smallest integers as inputted by the user. I think I'm pretty much just about there except there is one issue with my logic. I'm not sure what to set values: int min, min2; to where the rest of my program would...

## What's the difference between if(A) then if(B) and if (A and B)?

algorithm,logic
if(A) then if(B) vs if(A and B) Which is better to use and why ?...

## Intro to Computation and Programming Using Python

python,logic,computation
I am trying to solve Finger Exercise 3.1, and I can't figure out what I am doing wrong here. When I enter '1' as the integer, it returns 0 and 0. I am a complete newbie to programming and Stack Overflow, so I'm not sure if I am doing this...

## win32 logic block preprocessor shows inactive

c++,winapi,logic,visual-studio-2005,preprocessor
i try to use a library on visual studio in differents way by modify its macros on preprocessor directives. However a logic block inside an #if directive is shown to me inactive as it was comment. here is the code: #if defined EBML_DLL #if defined EBML_DLL_EXPORT #define EBML_DLL_API __declspec(dllexport) #else...

## Why does 2 && 3 results in 3 (javascript)? [duplicate]

javascript,logic,logical-operators
This question already has an answer here: Logical operators in JavaScript — how do you use them? 2 answers When I type in browser's console: console.log(2 && 3) it results always with second number (in this case 3): 3 Can someone explain me why?...

## Player Movement Direction Logic

java,libgdx,logic,game-engine
Consider points A and B as walls and point O as player inside walls. So they look like A O B. I want player to move left when he touches rightPoint B. And move right when he touches leftPoint A. The screen is being rendered and player position is either...

## button click issue in Ext js

extjs,logic
i have small query i created four text fields and one button,in text fields i gave property allowblank:true if user enter shows error message,it's working perfect.If the click the button the inserted perfect,after that the textboxes becomes empty it's showing blank errormessage.If iam using Allowblank:false it's working fine.but i require...

## Call Functions Based On Query String Using JavaScript

javascript,function,logic,query-string
On my web app, the user is asked a question and can choose only one of two answers. Yes or no. A query string is created based on their answer. The following code carries the query string through the URL of every page: var navlinks = document.getElementsByClassName("qString"); \$(navlinks).prop("href", function() {...

## Random Number Game, Trouble with Min and Max

javascript,random,logic
I'm trying to write a random number game in JavaScript, but I'm having a lot of trouble with getting the random number to actually generate something in between min and max if they're changed. This is what I have so far: var min = 1, max = 10; function randomNumber()...

## Multiple values of a variable inbetween 0 and a number prolog

algorithm,variables,recursion,prolog,logic
So I've been trying to teach myself prolog and I think I'm coming along nicely. However, I'm sort of stuck at this one method I'm trying to make. toN(N,A) A is equal to the integer values between 0 and N-1, generated in ascending order. so toN(5,A) would be A =...

## Validate user's input

c#,logic
I have 3 text boxes: textbox1, textbox2, textbox3. Users only allow to fill out information in one text box. private string determineSearchParameter() { //Execute statements if ALL textboxes are empty if (string.IsNullOrWhiteSpace(textbox1.Text) && string.IsNullOrWhiteSpace(textbox2.Text) && string.IsNullOrWhiteSpace(textbox3.Text)) { return "Please Enter a Search Parameter"; } //Execute all fields have an input...

## “.use” method to add logic on each request of SuperAgent

node.js,request,logic,use,superagent
This issue in SuperAgent repository mentions the .use method to add logic on each request. For example, adding an Authorization header for JWT when a token is available: superagent.use( bearer ); function bearer ( request ) { var token = sessionStorage.get( 'token' ); if ( token ) request.set( 'Authorization', 'Bearer...

c,logic

## NASM Assembly mathematical logic

c,gcc,assembly,logic,nasm
I have a program in assembly for the Linux terminal that's supposed to work through a series of mathematical manipulations, compare the final value to 20, and then using if logic, report <, > or = relationship. Code is: segment .data out_less db "Z is less than 20.", 10, 0...

## Logical operators and their behavior in JavaScript

javascript,jquery,logic,operators,logical-operators
Why does this fail? The way I read this code is "if either a or b or c equals three, then the statement is true". But apparently JavaScript disagrees. Why? function test() { var a = 'one'; var b = 'two'; var c = 'three'; return ( ( a ||...

android,click,logic,imagebutton
I am a novice developer. Please help to create the code to count clicks on the buttons (on Android). I have three ImageButton (IB1, IB2, IB3) and I have 3 empty TextView (TV1,TV2, TV3). However, the counter should not be considered the number of clicks each of the three buttons....

## Prove that A == B, B==C, A != C

java,algorithm,logic
Can there be objects or primitive types where the transitive law can not hold true; for example A == B, B == C but A != B I am not talking about equals() method. I am interested in == operative Can we prove this ? ...

## didBeginContact logic OSX swift

osx,swift,if-statement,logic,collisions
I am having some trouble with the logic inside of didBeginContact on an OSX game i'm creating. It is written in swift, here is what the code currently is: func didBeginContact(contact: SKPhysicsContact) { let collision: UInt32 = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask if collision == PhysicsCategory.player | PhysicsCategory.wall { } else if...

## Raster Layers in JS Canvas

javascript,html5,canvas,logic
I need your help for a little paint application with layers. I'd like my program to handle different layers, but not using more than one canvas or using external libraries, in order to learn more about how this whole canvas thing works. I thought about memorizing every data in arrays...

## Find the nearest/closest value in a sorted List

java,logic
I was wondering if it is possible to find the closest element in a List for a element that is not there. For example if we had the values [1,3,6,7] and we are looking for the element closest to 4, it should return 3, because 3 is the biggest number...

## How to convert and show cell/label value from int to string

c#,asp.net,gridview,logic
I have ASP.NET project. It has GridView which is populated from my db. In the db i have column named Role and its type is integer. In DataGrid my column is TemplateField. How i can show on Admin or Guest instead of 1 or 2 ?...

## Interval Scheduling Algorithm or Activity Selection Algorithm

php,algorithm,logic,maximum-profit-problem
I'm struggling with this question for so long. There are n persons who want same room in a hotel. Each person wants to stay in the hotel for his own convenient time but only one person can stay at a time. Assume that room is available from 5AM to 11PM....

## How to minimize the use of if else if in XMLStreamReader while parsing complex XML

I have the sample XML data below which I want to convert to a simple XML form. I have to create multiple XML data based in the occurrence of certain element-value in the main XML data. The logic is embedded inside a XMLStreamReader. While doing that I have to use...

## Python: get maximum value object for unique key

python,algorithm,list,logic
I have the following list of items: [ {'country' : 'India', 'date' : '18-Mar-14'}, {'country' : 'India', 'date' : '18-Apr-14'}, {'country' : 'India', 'date' : '18-May-14'}, {'country' : 'Australia', 'date' : '18-Mar-14'}, {'country' : 'Australia', 'date' : '18-Apr-14'}, {'country' : 'Australia', 'date' : '18-May-14'}, {'country' : 'China', 'date' : '18-Mar-14'},...

## Trouble changing object value in page, but shows up in console log as working (angularjs)

javascript,html,angularjs,logic
I want to change an object variable mF depending on what the user clicks, which will assign an object from an array of objects to the variable mF, and also take them to the next "page". I am using ng-click to assign the objects to mf through a function. I'm...

## >= not working, R [duplicate]

r,if-statement,double,logic
This question already has an answer here: Why are these numbers not equal? 3 answers I am running the code below. The function Ax returtns the value 1. But the ifelse statement does not recognize that Ax==1. I've tried making the output of the function double-precision and all numeric...

## Boolean logic simplification

boolean,logic
I am trying to solve this but am having a hard time: ' means complement Y = A'B' + A'BC' + (A + C')' My attempt: A'B' + A'BC' + A'C A'(B' + BC' + C) Now this is where I am lost at. Somehow parenthesized expression evaluates to 1...

## Python is returning false to “1”==“1”. Any ideas why?

python,string,file,integer,logic
I've written a scout system for my A Level computing task. The program is designed to store information on scouts at a scout hut, including badges, have a leaderboard system, and a management system for adding/finding/deleting scouts from the list. The scout information MUST be stored in a file. File...

## Mathmatical expressions in pseudo code

python,logic,pseudocode,mathematical-expressions
I have pseudo code am trying to implement in python but I cant seem to remember what p ← 0 would mean in logic or calculus. Thanks in advance

## Having trouble picking out logic error

java,recursion,logic
I am just practicing my binary search with an int array and can not quite figure out why my logic is off. I have traced my code and it is all adding up to me. The code compiles fine however; I'm missing some logic. could I have an extra set...

## Unix - Tail Utility would open the file or not

unix,logic,tail
Can anybody help me to sort this out. What is the logic of Tail -f utility in Unix. Is it open the log file to check the updated content or is there any other way to get this information. All the implimentation of Tail utility says that it will open...

## Logic synthesis from an arbitary piece of code

logic,vhdl,verilog,synthesis
I have completed on a project making physical logic gates and am now looking for a way to turn an arbitrary program into some series of logic gates so I can use them. I need a program that can take some arbitrary function (say f= x^2 -1) directly into some...

## Java file Formatting proper order

java,file,logic,formatter
I am writing a program which requires the opening of a file, adding to it, and then closing it. For some reason when I try to do so, I get a nullPointerException. Here is what I have in the main class: public static filer f = new filer(); and then:...

## Is there a way to combine several different conditionals with a shared statement?

c,syntax,logic,structure,conditional-statements
Is there a way to combine several different conditionals with a shared statement? For example: int a; ... if (a == 1){ foo; ... return K1; } else if (a == 2){ foo; ... return K2; } ... else if (a == i){ foo; ... return Ki; } Is there...

## javascript logic returning strange results

javascript,math,logic
I have a grid that I am trying to program a cursor onto, there is a central point in the grid and I am trying to make the cursor only be able to move x amount of squares from that central point, here is the code I have var makecursor...

## Calculating number of nights in overlapping dates

c#,date,logic
I'm having an issue figuring out a logical way to solve this problem. I have a list of date ranges, say for example: 01/01/15 - 11/01/15 02/01/15 - 04/01/15 09/01/15 - 13/01/15 18/01/15 - 20/01/15 What I need to do is figure out the total number of nights covered over...

## Backwards Chaining With Variables

prolog,logic,datalog
I have been reading up about inference in Prolog/Datalog and while forward chaining seems fairly simple to grasp, I have some issues with backward chaining with any sort of complex example which isn't simply propositional or used to determine a true or false value. I was reading an article the...