How print code128 barcode without digit, just image of barcode?
my example with digits:
^FO20,20
^BCN,50,Y,N
^FD1234567890^FS
You need to reference the ZPL II Programming Guide
^BC is for printing Code 128 Bar Codes
Format: ^BCo,h,f,g,e,m
o = orientation
h = height
f = interpretation line
g = interpretation line above code
e = UCC check digit
m = mode
You are setting f to Y, change that to N.
^BCN,50,N,N
I'm new to boolean expressions.
I've been given the task to simplify
F(w,x,y,z) = xy’ + x’z’ + wxz + wx’y by using K map.
I've done it and the result is wx’+w’y’+xyz.
Now I have to "Write it in a standard SOP form. You need to provide the steps through which you get the standard SOP".
And i have no idea how to do it. I thought result after k map is sop.
Yes, you already have it in SOP form. But the second question is about Standard (aka canonical) SOP form. That's much simpler to find than having to use K-maps (but it's often long), it's just the sum of minterms.
I think your solution does not cover all ones. These Karnaugh maps show the original expression, the simplified version (minimal SOP) and the canonical SOP, where every product contains all literals (all given variables or their negation).
The original expression is
F(w,x,y,z) = x·¬y + ¬x·¬z + w·x·z + w·¬x·y
– there are two fours and two pairs circled in the corresponding (first one) K-map.
The original expression simplified using K-map (shown in the second one):
F(w,x,y,z) = x·¬y + ¬x·¬z + w·y·z
is different than yours, but you can check for example with wolframalpha online tool, that it is the simplified original expression.
It is also the minimal DNF, but not a sum of minterms (where the output is equal to 1), because there are not all variables in every product of the sum.
The third K-map shows ten minterms circled. They form the canonical DNF:
F(w,x,y,z) = m0 + m2 + m4 + m5 + m8 + m10 + m11 + m12 + m13 + m15 =
= ¬w·¬x·¬y·¬z + ¬w·¬x·y·¬z + ¬w·x·¬y·¬z + ¬w·x·¬y·z + w·¬x·¬y·¬z
+ w·¬x·y·¬z + w·¬x·y·z + w·x·¬y·¬z + w·x·¬y·z + w·x·y·z
I checked your simplified expression, but there are not all ones covered (even if there were some useful do not care states (marked X)). Maybe you made a typo. Or could there be a typo in the original expression?
We can implement the K-Map algorithm in python for 4 variables, as shown below. The function accepts the Boolean function in SOP (sum of products) form and the names of the variables and returns a simplified reduced representation. Basically you need to create rectangular groups containing total terms in power of two like 8, 4, 2 and try to cover as many elements as you can in one group (we need to cover all the ones).
For example, the function can be represented F(w,x,y,z) = xy’ + x’z’ + wxz + wx’y in SOP form as f(w,x,y,z)=∑(0,2,4,5,8,10,11,12,13,15), as can be seen from the below table:
As can be seen from the output of the next code snippet, the program outputs the simplified form x¬y + ¬x¬z + wyz, where negation of a boolean variable x is represented as ¬x in the code.
from collections import defaultdict
from itertools import permutations, product
def kv_map(sop, vars):
sop = set(sop)
not_covered = sop.copy()
sop_covered = set([])
mts = [] # minterms
# check for minterms with 1 variable
all_3 = [''.join(x) for x in product('01', repeat=3)]
for i in range(4):
for v_i in [0,1]:
if len(not_covered) == 0: continue
mt = ('' if v_i else '¬') + vars[i]
s = [x[:i]+str(v_i)+x[i:] for x in all_3]
sop1 = set(map(lambda x: int(x,2), s))
if len(sop1 & sop) == 8 and len(sop_covered & sop1) < 8: # if not already covered
mts.append(mt)
sop_covered |= sop1
not_covered = not_covered - sop1
if len(not_covered) == 0:
return mts
# check for minterms with 2 variables
all_2 = [''.join(x) for x in product('01', repeat=2)]
for i in range(4):
for j in range(i+1, 4):
for v_i in [0,1]:
for v_j in [0,1]:
if len(not_covered) == 0: continue
mt = ('' if v_i else '¬') + vars[i] + ('' if v_j else '¬') + vars[j]
s = [x[:i]+str(v_i)+x[i:] for x in all_2]
s = [x[:j]+str(v_j)+x[j:] for x in s]
sop1 = set(map(lambda x: int(x,2), s))
if len(sop1 & sop) == 4 and len(sop_covered & sop1) < 4: # if not already covered
mts.append(mt)
sop_covered |= sop1
not_covered = not_covered - sop1
if len(not_covered) == 0:
return mts
# check for minterms with 3 variables similarly (code omitted)
# ... ... ...
return mts
mts = kv_map([0,2,4,5,8,10,11,12,13,15], ['w', 'x', 'y', 'z'])
mts
# ['x¬y', '¬x¬z', 'wyz']
The following animation shows how the above code (greedily) simplifies the Boolean function given in SOP form (the basic goal is to cover all the 1s with minimum number of power-2 blocks). Since the algorithm is greedy it may get stuck to some local minimum, that we need to be careful about.
puts "Let's get started calculating your parabola. What is your A value?"
a = gets.chomp
puts "What is your B value?"
b = gets.chomp
puts "What is your C value?"
c = gets.chomp
x = x
2x = (x.to_i**2)
puts "Your parabola equation is 'y = " + a.to_s + 2x.to_s + " + " + b.to_s + x + " + " + c.to_s + "'. Would you like to go back to the beginning?"
In Ruby variable names can't start with a number, but you did it, 2x = (x.to_i**2). Write it as x2 = (x.to_i**2). Then replace all 2x with x2 in your code.
Another error will be x=x, this is also invalid. Hope you mistyped. Correct it also.
Read this Local Variable Names
A local variable name must start with a lowercase US-ASCII letter or a character with the eight bit set. Typically local variables are US-ASCII compatible since the keys to type them exist on all keyboards.
(Ruby programs must be written in a US-ASCII-compatible character set. In such character sets if the eight bit is set it indicates an extended character. Ruby allows local variables to contain such characters.)
A local variable name may contain letters, numbers, an _ (underscore or low line) or a character with the eighth bit set.
print("How old are you")
c = input()
d = 1
The question is - how to add d + c together
Or how to add 1 + c together
I'm only a beginner and I've been at this for hours it's really confusing
If you mean c to be an input number ,then convert it to integer using int(c)
So you have d + int(c)
So I'm creating a Activation class for a VB6 project and I've run into a brain fart. I've designed how I want to generate the Serial Number for this particular product in a following way.
XXXX-XXXX-XXXX-XXXX
Each group of numbers would be representative of data that I can read if I'm aware of the matching document that allows me to understand the codes with the group of digits. So for instance the first group may represent the month that the product was sold to a customer. But I can't have all the serial numbers in January all start with the same four digits so there's some internal math that needs to be done to calculate this value. What I've landed on is this:
A B C D = digits in the first group of the serial number
(A + B) - (C + D) = #
Now # would relate to a table of Hex values that would then represent the month the product was sold. Something like...
1 - January
2 - February
3 - March
....
B - November
C - December
My question lies here - if I know I need the total to equal B(11) then how exactly can I code backwards to generate (A + B) - (C + D) = B(11)?? It's a pretty simple equation, I know - but something I've just ran into and can't seem to get started in the right direction. I'm not asking for a full work-up of code but just a push. If you have a full solution available and want to share I'm always open to learning a bit more.
I am coding in VB6 but VB.NET, C#, C++ solutions could work as well since I can just port those over relatively easily. The community help is always greatly appreciated!
There's no single solution (you have one equation with four variables). You have to pick some random numbers. Here's one that works (in Python, but you get the point):
from random import randint
X = 11 # the one you're looking for
A_plus_B = randint(X, 30)
A = randint(max(A_plus_B - 15, 0), min(A_plus_B, 15))
B = A_plus_B - A
C_plus_D = A_plus_B - X
C = randint(max(C_plus_D - 15, 0), min(C_plus_D, 15))
D = C_plus_D - C
I assume you allow hexadecimal digits; if you just want 0 to 9, replace 15 by 9 and 30 by 18.
OK - pen and paper is always the solution... so here goes...
Attempting to find what values should be for (A + B) - (C + D) to equal a certain number called X. First I know that I want HEX values so that limits me to 0-F or 0-15. From there I need a better starting place so I'll generate a random number that will represent the total of (A + B), we'll call this Y, but not be lower than value X. Then subtract from that number Y value of X to determine that value that will represent (C + D), which we'll call Z. Use similar logic to break down Y and Z into two numbers each that can represent (A + B) = Y and (C + D) = Z. After it's all said and done I should have a good randomization of creating 4 numbers that when plugged into my equation will return a suitable result.
Just had to get past the brain fart.
This may seem a little hackish, and it may not take you where you're trying to go. However it should produce a wider range of values for your key strings:
Option Explicit
Private Function MonthString(ByVal MonthNum As Integer) As String
'MonthNum: January=1, ... December=12. Altered to base 0
'value for use internally.
Dim lngdigits As Long
MonthNum = MonthNum - 1
lngdigits = (Rnd() * &H10000) - MonthNum
MonthString = Right$("000" & Hex$(lngdigits + (MonthNum - lngdigits Mod 12)), 4)
End Function
Private Function MonthRecov(ByVal MonthString As String) As Integer
'Value returned is base 1, i.e. 1=January.
MonthRecov = CInt(CLng("&H" & MonthString) Mod 12) + 1
End Function
Private Sub Form_Load()
Dim intMonth As Integer
Dim strMonth As String
Dim intMonthRecov As Integer
Dim J As Integer
Randomize
For intMonth = 1 To 12
For J = 1 To 2
strMonth = MonthString(intMonth)
intMonthRecov = MonthRecov(strMonth)
Debug.Print intMonth, strMonth, intMonthRecov, Hex$(intMonthRecov)
Next
Next
End Sub