logic

Boolean Logic & gate delays

杀马特。学长 韩版系。学妹 提交于 2019-12-13 03:39:47
问题 Assuming 2 gate-delays for a Sum or Carry function, estimate the time for ripple-through carry addition for adders with the following word lengths:- i) 4-bit ii) 8-bit iii) 16-bit In my notes I have written: "delay is the word width times each bit stage delay (2 gate delays)". Therefore: i) 2*4 = 8 ii) 2*8 = 16 iii) 2*16 = 32 Looking at the ripple carry adder wikipedia page: http://en.wikipedia.org/wiki/Ripple_carry_adder#Ripple-carry_adder The formula used here is different, can anyone

Program to generate iterations

纵然是瞬间 提交于 2019-12-13 03:35:28
问题 I have set myself a task to code this algorithm, however, since i haven't had a full experience in C, I was hoping there might be an easier method. Ok, Take 2 numbers, a , b We take the sum of these and add to the sequence, then add on the second term. So we get a , b , a+b , b For the next term, we take the 2nd and 3rd values (Before we did 1st and 2nd) and do it again. so we now get a , b , a+b , b , a +2b , a+b (continued) a+2b , b , a+3b , a+2b , 2a+3b , a+b This continues on until

How to check for win in custom sized tic-tac-toe diagonals

余生颓废 提交于 2019-12-13 02:47:10
问题 I'm making a simple tic tac toe game, where user can specify the size of the grid (amount of columns and rows). I need to create a function, that could check for a win in all the diagonals in the grid. For the grid, I'm using a 2-dimensional list, that looks like this (3x3 example): grid = [['x', '-', 'o'], ['o', 'x', '-'], ['-', '-', 'x']] grid[row][col] This should be a winning situation I have already created a check for the vertical and horizontal win, but I can't quite figure out, how to

OOP Modelled Objects in a Database Driven App?

筅森魡賤 提交于 2019-12-13 02:30:05
问题 I've built an entire banking app based on a SQLite database. Today I'm having a panic moment. I've been reading all sorts of articles on OOP, I believe I understand the concept and it's importance, however, I can't understand its place in an app like mine. So far, perhaps ignorantly, my logic for dealing with data has been as follows (example pseudo code for editing a banking form for a new account application): Within EditAccountApplication Activity, define a public Cursor, this Cursor will

MYSQL - How to join two queries to omit elements found in the second query (or perhaps any better solution?)

一世执手 提交于 2019-12-13 02:11:40
问题 I have a wordpress database with a number of custom fields/metadata. --------- wp_postmeta --------- post_id meta_key meta_value I want to find all the posts with a meta_key of 'Start Date' and a value of 'NOW()', but not the posts that have the meta_key 'Ongoing' and value of 'Yes'. I'm a bit confused of how to join the queries: SELECT * FROM wp_posts, wp_postmeta WHERE wp_posts.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = 'Start Date' AND wp_postmeta.meta_value > NOW() with SELECT *

Simplify expressions with nested ∃ and an equality

孤者浪人 提交于 2019-12-13 02:01:39
问题 I came across a proof that I could not easily automate until I threw this lemma into Isabelle’s simplifier set: lemma ex_ex_eq_hint: "(∃x. (∃xs ys. x = f xs ys ∧ P xs ys) ∧ Q x) ⟷ (∃xs ys. Q (f xs ys) ∧ P xs ys)" by auto Now I am wondering: Is there a good reason why the simplifier or the classical reasoner is not able perform this simplification in general and automatically? Is there a more general form of this lemma that could be added to the default simpset to achieve this? 回答1: In

Reverse the logic of two “or” statements in JavaScript if query

我们两清 提交于 2019-12-13 01:44:40
问题 I have an if test in JavaScript which achieves what I want but not as elegantly as possible. It goes like this: if (x > y || p < q) { // don't do anything } else { doSomeFunction(); } If there any way to flip the logic of this so there's only a single if statement without having to have a dummy if-condition as well as the else condition? 回答1: You can use the ! operator to invert the condition: if (!(x > y || p < q)) { doSomeFunction(); } Or simply rewrite the condition like this: if (x <= y &

How to get distance matrix from Adjacency matrix matlab

有些话、适合烂在心里 提交于 2019-12-13 01:37:09
问题 I have adjacency matrix let it be called A size n*n Where A(k,j)=A(j,k)=1 if k,j are connected in 1 hop. Now it look that if I take Dist=double(A)*double(A)>0 %getting all two hops connectivity Dist=double(Dist)*double(A)>0 %getting all three hops connectivity Dist=double(Dist)*double(A)>0 %getting all four hops connectivity Is this right at all? I tried it with some simple graphs and it looks legit Can I use this fact to create distance matrix? Where distance matrix will show the minimum

formal axiomatic def of an example Kripke model in terms of ∀, ∃

倾然丶 夕夏残阳落幕 提交于 2019-12-13 01:35:21
问题 I am looking for a formal axiomatic definition of an example Kripke model in terms of ∀, ∃ assuming knowledge of simple predicate logic, boolean logic,... All descriptions of Kripke models I encounter simply introduce new notations through paraphrasing to english linguistic concepts (i.e. ☐ = "necessity"). While certainly both helpfull and motivating, it does not assure that I will have the same interpretation of what a Kripke model is as someone else. (this question is the result from good

Find Max Value of 10 Threads

荒凉一梦 提交于 2019-12-13 01:24:32
问题 I have a program that sorts though a text file and pulls out the maximum value using 10 threads. How can I then sort through the 10 threads and find the highest value of those 10? My logic would be to store each result in an array and compare that result to the previous, but I'm unsure on how to properly implement it with threading. I added this for loop but it's not correct.Any help would be greatly appreciated! for (int x = 0; max <=max; x++) { max = worker.getMax(); System.out.println(