CFG of w != w^R
Given L={w in {a,b}* | w != w^R}
I want to find its CFG. Please do not tell me the answer for that.
What is the intuition of solving these kind of questions?
I tried doing it for about 1 hour, with no luck.
Thanks!
do you know?
how many words do you know
See also questions close to this topic
-
Output the Tuesday 6 weeks in the future in Python?
UPDATE: post edited to add answer to end of post
Core Question
Using Python, how do I output the date of the Tuesday that occurs 6 weeks after a certain date range?
Context
I work at a SaaS company in a customer facing role. Whenever I do an implementation for a client, the client receives a survey email on the Tuesday that occurs in the 6th week after our initial interaction.
To know which Tuesday to be extra nice on, we currently have to reference a chart that says if the interaction falls in date range x, then the client receives their survey solicitation on Tuesday y.
An example of this would be: if the interaction happened sometime within Apr. 18 - Apr. 22, then the survey goes out on May 31.
I would prefer for this to be done without having to hard code the date ranges and their corresponding Tuesdays into my program (just because I'm lazy and don't want to update the dates manually as the months go by), but I'm open to that solution if that's how it has to be. :)
Code Attempt
I can use datetime to output a particular date x weeks from today's date, but I'm not sure how to get from here to what I want to do.
import time from datetime import datetime, timedelta time1 = (time.strftime("%m/%d/%Y")) #current date time2 = ((datetime.now() + timedelta(weeks=6)).strftime('%m/%d/%Y')) #current date + six weeks print(time1) print((datetime.now() + timedelta(weeks=6)).strftime('%m/%d/%Y'))
Disclaimer: I am a beginner and although I did search for an answer to this question before posting, I may not have known the right terms to use. If this is a duplicate question, I would be thrilled to be pointed in the right direction. :)
~~~UPDATED ANSWER~~~
Thanks to @Mandias for getting me on the right track. I was able to use week numbers to achieve my desired result.
from datetime import datetime, timedelta, date today = date.today() #get today's date todays_week = today.isocalendar()[1] #get the current week number based on today's date survey_week = todays_week + 6 #add 6 weeks to the current week number todays_year = int(today.strftime("%Y")) #get today's calendar year and turn it from a str to an int survey_week_tuesday = date.fromisocalendar(todays_year, survey_week, 2) #(year, week, day of week) 2 is for Tuesday print("Current Week Number:") print(todays_week) print("Current Week Number + 6 Weeks:") print(todays_week + 6) print("Today's Year:") print(todays_year) print("The Tuesday on the 6th week from the current week (i.e. survey tuesday):") print(survey_week_tuesday.strftime('%m-%d-%Y')) #using strftime to format the survey date into MM-DD-YYYY format because that's what we use here even though DD-MM-YYYY makes more sense
-
insert bulk documents into mongo db
I need to insert multiple docs into mongo db at once. cannot directly import a csv file or use insertMany since there are nested objects inside each document. for outer object, one key's value will change every time while the rest of the key's value remain the same and need to generate random values for two of the other keys. for inner object, values change every time. this seems complicated to me and if anyone could help me breakdown the problem statement and help me automate it to avoid the tedious manual work, it'd be very helpful. I'm using Studio 3T and node.js to code.
{ "_id" : ObjectId("626f6f7b4199350845746a54"), "isApproved" : false, "msgStatus" : false, "name" : "IN", "createdBy" : "BAA0704", "customerId" : "HH00012", "villageId" : "1848", "ans" : { "responseID" : "5f440bc3-c76c-411a-b1e4-6a25a5f2aba3", "submittedTime" : "31-03-2022 16:45", "syncedTime" : "31-03-2022 16:45", "formRevisionSubmittedIn" : "2", "tags" : "NA", "timeSpent" : "0:16:12", "name" : "shruthi", "villagePopulation" : "10000", "age" : "28", "bankAccount" : "yes", "familyMembers" : "7", "maritalStatusYes" : "Yes", "maritalStatusNo" : "No", "kids" : "3", "socialMediaHandles" : "facebook" }, "createdAt" : ISODate("2022-05-02T13:22:19.630+0000"), "updatedAt" : ISODate("2022-05-02T13:22:19.630+0000"), "__v" : NumberInt(4325), "nId" : NumberInt(11)
-
How to determine if a BasicBlock is controled by a `if`
I want to use LLVM to analyze if a basic block is affected by a control flow of an
if
(i.e.,br
instruction). "A basic blockBB
is NOT affected bybr
" means that no matter which of two blocks thebr
goes toBB
will be executed for sure. I use an example to briefly show what I want:My current rule to determine if a basic block
BB
is affected is (iftrue
, affected.)¬(postDominate(BB, BranchInst->leftBB) && postDominate(BB, BranchInst->rightBB))
Since I can not exhaustively test the rule above to all possible CFGs, I want to know if this rule is sound and complete.
Thanks!
Further question
I am also confused if I should use
dominate
rather thanpostDominate
like (I know the difference between post-dominance and dominance, but which should I use? Both rules seems work in this example, but I am not sure which one will/won't work in other cases):Dominate(BranchInst->leftBB, BB) || Dominate(BranchInst->rightBB, BB)
-
TOC Problem : Context Free Grammar Design
I want to design CFG for a language that is defined by
L= { w | {a,b,c}* where w= a^i b^j c^k and i+j>k }
Case where i+j=k was easy, however I cannot figure how the case for i+j>k.
-
.cfg file to read window environment variable
I have a .cfg file and want to read Windows environment variables, what is the syntax of reading environment variables like ${VAR:default_value} in .yml file?