|
||||||
| General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
Simplify the following Boolean expression. The final expression should (be logically equivalent) have a weight of four (meaning F = a + b where a and b are some literal in the expression in its complimented or uncomplimented form).
' indicates the literals complement a + b indicates a OR b ab indicates a AND b F = y’z’ + x’yz + x’y + xyz + xz’
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
Quote:
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
| Sponsored Links |
|
|
|
|||||
|
There are several methods to find the solution mine is far from the simplest but it is the most explicit.
(x + x') => 1 (1 + x) => 1 (1) F = y’z’ + x’yz + x’y + xyz + xz’ F = y’z’ +yz(x' + x) + x’y + xz’ F = y’z’ +yz + x’y + xz’ (2) F = y’z’ +yz + x’y + xz’(y + y') F = y’z’ +yz + x’y + xyz’ + xy'z’ (3) F = y’z’ +yz + x’y(z + z') + xyz’ + xy'z’ F = y’z’ +yz + x’yz + x’yz' + xyz’ + xy'z’ (4) F = y’z’ + yz + x’yz + x’yz' + xyz’ + xy'z’ F = y’z’ + (1 + x')yz + x’yz' + xyz’ + xy'z’ F = y’z’ + yz + x’yz' + xyz’ + xy'z’ (5) F = y’z’ + yz + x’yz' + xyz’ + xy'z’ F = y’z’ + yz + (x’ + x)yz' + xy'z’ F = y’z’ + yz + yz' + xy'z’ (6) F = y’z’ + yz + yz' + xy'z’ F = yz + yz' + (1 + x)y'z’ F = yz + yz' + y'z’ (7) F = yz + yz' + y'z’ + yz' (8) F = yz + yz' + y'z’ + yz' F = y(z + z') + yz' + y'z’ F = y + yz' + y'z’ (9) F = y + yz' + y'z’ F = y + z'(y + y') F = y + z' Q.E.D.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
Wow, I have no idea what the above math is.
![]() If your bored: Quote:
![]()
__________________
Emo Philips - "My computer beat me at checkers, but I sure beat it at kickboxing." |
|
|||||
|
Since you didn't specify a language, I tried that kind of game in Ruby, the most recent language I've added to my repertoire. This one not only keeps track of maximum and minimum, but leaves the user to deduce them!
Code:
class GuessGame
def initialize
@correct = rand(1000) + 1 # Correct guess.
@max = 1000 # Maximum and minimum for
@min = 1 # "homing in" on the answer.
@last = nil # The last guess.
@guesses = 0
end
def guess (x)
@guesses += 1
curr = (x - @correct).abs
if x = @correct
print "You got it!\n"
end
if @last
lastd = (@last - @correct).abs
if lastd < curr
print "Colder\n"
elsif lastd > curr
print "Warmer\n"
if x > @last && @last > @min
@min = @last # Increase the minimum.
elsif x < @last && @last < @max
@max = @last # Decrease the maximum.
end
end
if x > @max || x < @min
print "Idiot!\n" # Problem exists between keyboard and chair.
end
end
@last = x; # This guess becomes the last guess
end
attr_reader :max, :min
end
game = GuessGame.new
continue = true # Continue until the user exits.
while(continue)
print "Guess: " # Prompt.
cmd = gets
if cmd =~ /exit|quit|bye/i # Exit commands; case insensitive.
print "See ya!\n"
exit
# elsif cmd =~ /max|min/i # For testing.
# print game.max, "\n", game.min, "\n"
elsif cmd =~ /^[0-9]+/
game.guess cmd.to_i
end
end
Last edited by Aereshaa; 10-04-2008 at 01:25 AM. |
|
|||||
|
@chili5: it's formal logic.
@John: I found your solution... non-intuitive so used a Venn-diagram approach: I did a Venn diagram for each of the original 5 pieces, then the union (+) and it's trivial to observe that the result is y+z'
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Programming is a branch of mathematics. |
|
|||||
|
Quote:
![]()
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Homework help - Algorithm complexity | Pillager | Programming Theory | 3 | 09-08-2008 05:06 PM |
| I need help for my homework | RoyaLTigeR | Java Help | 2 | 05-13-2008 03:39 PM |
| HomeWork Question - VAL() | Lop | Visual Basic Programming | 2 | 07-11-2007 09:32 AM |
| Homework Help | John | Java Help | 12 | 11-02-2006 05:50 AM |