I need to create a finite automata - finite-automata

Consider the language L of all strings made of the symbols 0, 1 and 2 (Σ = {0, 1, 2}) where the last symbol is not smaller than the first symbol. E.g., the strings 0, 2012, 01231 and 102 are in the language, but 10, 2021 and 201 are not in the language.
As 0 is in the language and I don't understand why, I can't figure out if strings 1 and 2 are in the language?
So could someone please tell me if 1 and 2 as a string themselves are in the language and why?
Thank you

'0' is in the language because the first symbol and last symbol in '0' are both '0'. This satisfies the requirements that the last is not smaller than the first.
This means that the same applies for '1', '2', and for the empty string ''.

Related

How do i convert an integer to an index in an "if" function?

My first question on this forum and im completely new to programming, so apologies if i do something wrong.
So im trying to program something to do a collatz sequense on a number i put in. To do that i have to check if the number i put in is even or odd. The easy fix would be to use the built in % 2 function but i want to do it "dirty" to learn better.
So my plan was to check if the last number in said input number is in the list (0, 2, 4, 6, 8) since an even number ends on those and is odd otherwise. Problem is how to check the very last index in the number to see if its in that list. I tried the following code
def Collatz(input_number):
input_number_num = int(input_number)
lenght = len(input_number_num)
position = lenght - 1
if [position] in input_number_num is in (0, 2, 4, 6, 8)
return (input_number_num / 2)
else:
return (input_number_num * 3 + 1)
This gives me a syntax error, im guessing since it reads [lenght] as an tuple rather than the index.
You could convert the number to a string and then use the -1 index to extract the last character:
if input_number[-1] in ('0', '2', '4', '6', '8'):
But to be completely honest, I can't see any advantage of doing this over just using % 2.

Regular expression (0+1)*1(0+1)*0 DFA

I'm trying to understand the regular expression: (0+1)*1(0+1)*0 Could you provide examples that matches this pattern?
Let me explain :
1 - (0+1) mean any number of 0, then a 1
2 - (0+1)* means the previous line any number of times (can be 0)
3 - (0+1)*1 mean the previous line and a 1
4 - (0+1)*0 means line 2 and a 0
10 works : 0 times (0+1), then a 1, then 0 times (0+1), then a 0.
00000000000100000000000110 works : eleven 0 and a 1, twice (this is (0+1)*). Then, a 1. Then, no (0+1), and the last 0. A few other examples :
10
00001000010000110000100001000010
01010110
0110
I hope you understood (I'm not english, my english is bad, sorry)
EDIT : There are a lot of websites that can help you with regular expressions, whether it is learning or testing regex.

Reportviewer VB.NET about Switch Expression

Hello everyone can anyone correct my codes in rdlc tables
i have 1 tables and on that table there was a Field!ans1 that was computing for the average of the column(RED CIRCLE in IMAGE) then i want that average to filter to an if statement to identify if that average is Agree , disagree or Stronglyagree(BLACK CIRCLE IN THE IMAGE)
Here's the Picture of my RDLC Table
the Black Circle is the If Statement that will identify if the Average Below in the Red Circle if is Agree,Disagree,or Strongly Agree
but i am having a problem because the statement always stock on Disagree even its value is 3
// Here is my Code in the Black Circle in the IMAGE
=Switch(Fields!ans1.Value < 1, "Strongly Disagree ",
Fields!ans1.Value > 2, " Disagree",
Fields!ans1.Value > 3, "Agree",
Fields!ans1.Value > 4, "Strongly Agree"
)
//Here is the Code in the RedCircle
=Avg(CDbl(Fields!ans1.Value))
Remember that a switch statement of any kind is evaluated top-down. Is 3.00 greater than 2? Yes it is, so the result is " Disagree" (why you haven't noticed and removed that rogue space, I don't know). If you are going to compare using the 'greater than' operator then you need to compare the largest value first this:
=Switch(Fields!ans1.Value < 1, "Strongly Disagree",
Fields!ans1.Value > 4, "Strongly Agree",
Fields!ans1.Value > 3, "Agree",
Fields!ans1.Value > 2, "Disagree"
)
should work. That's just basic logic that you should have learned in maths class. Note that I have removed that rogue space too.
By the way, that is still going to ignore any values in the range 1.0 - 2.0.

Anyone feel like a Gematria numeric challenge in EXCEL VBA?

To explain: I’m in EXCEL and need a genius formula in VBA, where each letter in the alphabet (except j) is given a SPECIFIC numeric value (as listed below), so that as you type LETTERS in one cell, the SUM OF THE NUMERIC VALUES appear in the cell next to it.
a=1 b=2 c=600 d=4 e=5 f=500 g=3 h=8 i=10
k=20 l=30 m=40 n=50 o=70 p=80 q=9 r=100 s=200
t=300 u=400 v=200 w=800 x=60 y=700 z=7
(Note: It should also apply to CAPS and a space should count zero)
e.g: If I type the words lady asks help in cell A1, the value 1279 should appear in cell B1
(Seeing that l=30, a=1, d=4, y=700, a=1, s=200, k=20, s=200, h=8, e=5, l=30, p=80)
The same formula should apply to the rest of Columns A and B.
In case it’s important, I need it for Greek Gematria. As I type “abc” on the keyboard, the Greek letters “αβχ” appear on the screen (by use of the Tyndale House keyboard code). Each Greek letter has a set numeric value, confirming numeric patterns found in Greek Bible Texts.
I’ve found fixed programs using Greek Gematria (e.g. DAVAR4), but none are editable text and I don’t know how to get into their ‘brains’ to transfer it to EXCEL. Frankly, I’m really clueless when it comes to programming and don’t even know if what I’m asking is possible. Local programmers referred me to Stack Overflow, so ANY help or directive would be much appreciated!
I looked at this question & answer, asked Jul 7 '14 by data_garden, but alas, I’m a dummy!
Please say if any more info is needed. Thanks
You're in luck. There are votes for this to be closed as you've made no apparent effort to write the code yourself. I've written something similar myself recently so all that was needed was to replace the array with your scoring system and it is below:
Function gem(txt As String) As Long
gem = 0
Dim i As Long, c As Integer
Dim arr()
arr = Array(0, 1, 2, 600, 4, 5, 500, 3, 8, 10, 0, 20, 30, 40, 50, 70, 80, 9, 100, 200, 300, 400, 200, 800, 60, 700, 7)
For i = 1 To Len(txt)
c = Asc(Mid(UCase(txt), i, 1)) - 64
If c > 0 And c <= 26 Then gem = gem + arr(c)
Next
End Function

Determinant Finite Automata (JFLAP)

I have a DFA question (Determinant Finite Automata) . We are using JFLAP to construct the automata. I cannot figure this question out to save my life! Here it is
"DFA to recognize the language of all strings that have an even number of zeros and an odd number of ones."
So the alphabet is {0,1} and only using 0,1. So I need to build an automata that recognizes an even number of zeros and an odd number of ones.

			
				
I don't know whether my understanding is right.
I could give you the description in Grail format that generate an even number of zeros and an odd number of ones.
START 1
1 1 2
2 1 1
1 0 3
3 0 4
4 0 3
FINAL 3