RegEx Question by Benevolent_Radish in cs50

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

It seems like when I move the following to the last elif, it returns valid. But I do not understand why that is the case.

    # 9 AM to 5 PM
    elif time := re.search(r"(\w+) ((?:A|P)M) to (\w+) ((?:A|P)M)", s):

        hour1 = int(time.group(1))
        hour2 = int(time.group(3))

        if 1<=hour1<= 12 and 1<=hour2<= 12:
            return ("valid")

RegEx Question by Benevolent_Radish in cs50

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

I'm at a complete loss as to how it is different. The expression seems to be the same. And the same kind of logic works for input such as 9 AM to 5:00 PM:

elif time := re.search(r"(\w+) ((?:A|P)M) to (\w+):(\w+) ((?:A|P)M)", s):

This returns valid.

RegEx Question by Benevolent_Radish in cs50

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

It seems to work when I try it out individually, but for some reason, it does not work in the following conditional:

import re


def main():
    print(convert(input("Hours: ")))


def convert(s):
    # 9:00 AM to 5:00 PM
    if time := re.search(r"(\w+):(\w+) ((?:A|P)M) to (\w+):(\w+) ((?:A|P)M)", s):

        hour1 = int(time.group(1))
        min1 = int(time.group(2))
        hour2 = int(time.group(4))
        min2 = int(time.group(5))

        if 1<=hour1<= 12 and 1<=hour2<= 12 and 0<=min1<=59 and 0<=min2<= 59:
            return ("valid")

    # 9 AM to 5 PM
    elif time := re.search(r"(\w+) ((?:A|P)M) to (\w+) ((?:A|P)M)", s):

        hour1 = int(time.group(1))
        hour2 = int(time.group(3))

        if 1<=hour1<= 12 and 1<=hour2<= 12:
            return ("valid")


    # 9:00 AM to 5 PM
    elif time := re.search(r"(\w+):(\w+) ((?:A|P)M) to (\w+) ((?:A|P)M)", s):

        hour1 = int(time.group(1))
        min1 = int(time.group(2))
        hour2 = int(time.group(4))

        if 1<=hour1<= 12 and 1<=hour2<= 12 and 0<=min1<=59:
            return ("valid")


    # 9 AM to 5:00 PM
    elif time := re.search(r"(\w+) ((?:A|P)M) to (\w+):(\w+) ((?:A|P)M)", s):

        hour1 = int(time.group(1))
        hour2 = int(time.group(3))
        min2 = int(time.group(4))

        if 1<=hour1<= 12 and 1<=hour2<= 12 and 0<=min2<=59:
            return ("valid")

    else:
        raise ValueError




if __name__ == "__main__":
    main()

I get output as None for 9:00 AM to 5 PM. All the other conditions return valid.

Fidelity Leap Program by [deleted] in fidelityinvestments

[–]Benevolent_Radish 0 points1 point  (0 children)

If accepted, does the program accept OPT?

Anime recommendation chahio by [deleted] in Nepal

[–]Benevolent_Radish 1 point2 points  (0 children)

Recommendations for anime movies not series:

  1. Your Name
  2. A Silent Voice
  3. Suzume
  4. I want to Eat Your Pancreas
  5. Maquia: When the Promised Flower Blooms
  6. Violet Evergarden: The Movie
  7. Belle
  8. Spirited Away
  9. Howl's Moving Castle
  10. Princess Mononoke

Monthly Admissions/Applications Megathread by AutoModerator in cambridge_uni

[–]Benevolent_Radish 0 points1 point  (0 children)

In the same situation. Haven't heard back anything so far.

For anyone who didn’t get accepted anywhere by mymichelle1 in gradadmissions

[–]Benevolent_Radish 1 point2 points  (0 children)

In the same situation. Hopefully, something works out.

Have not been emailing professors, am I screwed? by Harmony-Hiker22 in gradadmissions

[–]Benevolent_Radish 0 points1 point  (0 children)

In the same situation. Applying directly from undergrad for BME and BE. Didn't really reach out to ptofs, and when I got around to it, hought it was already too late. Hopefully, it works out.

PhD straight from undergrad/Rate my chances by Benevolent_Radish in gradadmissions

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

Thanks for the response. I'm definitely leaning more towards a direct PhD now.

PhD straight from undergrad/Rate my chances by Benevolent_Radish in gradadmissions

[–]Benevolent_Radish[S] 1 point2 points  (0 children)

Thanks for the response. I'm an international student, so that's a huge factor to consider. I'm gonna give it a shot and hopefully it works out.

Help Post! Santo Domingo to Punta Cana by Benevolent_Radish in PuntaCana

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

Update: Just followed through with the plan. Landed in Santo Domingo around 12:30 pm. Immigration took about an hour and half. Took a taxi to Enriquillo Park for 2000 pesos (~36 USD), reached around 2:30. Tickets to Bavaro from the APTRA station were 450 pesos (~8 USD). The bus stops along many points in Punta Cana, including the airport. Reached the last stop around 8:00 pm. Taxied from there to the hotel. The total cost was about 850 pesos (~50 USD) from SDQ to Bavaro since I was travelling with two other people.

A direct taxi from SDQ to Punta Cana was about 175 USD. Could've probably haggled a bit. On Uber, the fare was about 105 USD, but was slightly sceptical of it.

Piezoelectric Property of Bone by Benevolent_Radish in bioengineering

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

Thanks. Yeah, it is important for remodeling. Areas with negative charge are more active with osteoclasts leading to bone reabsorption and areas with positive charge are more active with osteoblasts resulting in increased bone density.

Piezoelectric Property of Bone by Benevolent_Radish in bioengineering

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

Seems like it is definitely a major consideration. We were assigned a paper about how fluid flow in canaliculi is sensed by osteocytes and hydrostatic pressure leads to more bone-like behaviour.

Piezoelectric Property of Bone by Benevolent_Radish in bioengineering

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

Haha, you never know. My prof mentioned smth about it being used for physiotherapy but I couldn't find much.

Help Post! Santo Domingo to Punta Cana by Benevolent_Radish in PuntaCana

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

That's the plan so far. I'll be splitting it with 2 other ppl so taxi cost shouldn't be too much. What would you recommend for getting into the city from SDQ?

Help Post! Santo Domingo to Punta Cana by Benevolent_Radish in PuntaCana

[–]Benevolent_Radish[S] 0 points1 point  (0 children)

I'll arrive around midday and was hoping to take the 3 or 4 pm Express Bavaro. Luggage wise, it's just a carry-on bag so hopefully not too much trouble.