Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Last active June 15, 2023 23:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odrobnik/baa204ba6c32ae889f93f9cc03d014cb to your computer and use it in GitHub Desktop.
Save odrobnik/baa204ba6c32ae889f93f9cc03d014cb to your computer and use it in GitHub Desktop.
GPT4 Problem Solving with functions

I've provided these functions:

  • date()
  • dateDiff(date1, date2)
  • birthday(user)

Oliver

"Let's think this through step by step and please list each step and give your thinking. Evaluate the statement made in every step if it sounds logical. Let's assume it's the 1st of December 2023. Is mine or Sylvia's birthday next? How many days apart are they?"

Assistant

-> calling date()

Function date Result

"Thursday, 15. June 2023 at 17:44:56 Central European Summer Time"

Assistant

"Alright. Here is how we can evaluate this:

Step 1: Identify the current date.

  • The given date is the 1st of December, 2023. Given that it's presently June 15, 2023, we are assuming a future date. This makes sense because hypothetical scenarios can be considered.

Step 2: Determine when Oliver's and Sylvia's birthdays are.

  • We need to know your birthdays in order to determine whose comes next.

Step 3: Compare the birthdays to the current date.

  • Once we have the data for birthdays, we can compare them against the given current date (December 1, 2023) to establish whose birthday is upcoming.

Step 4: Calculate the days separating the two birthdays.

  • We will calculate the difference in days between both birthdays.

Let's move forward with these steps, starting with determining the birthdays of Oliver and Sylvia.

For Step 2, I'll need to invoke the birthday function twice, one for each name. Let's start with Oliver."

-> calling birthday(user: "Oliver")

Function birthday Result

"July 24, 1974"

Assistant

"Now, let's determine Sylvia's birthday as part of Step 2."

-> calling birthday(user: "Sylvia")

Function birthday result

"September 17, 1978"

Assistant

"Now, we have both Oliver's and Sylvia's birthdates:

  • Oliver's birthday - July 24, 1974
  • Sylvia's birthday - September 17, 1978

We're interested in the dates, not the years, so we'll use those to determine whose birthday comes next.

Step 3: Compare the birthdays to the current date, December 1, 2023.

For this step, we will extract the day and month from the given birthdays and compare them with the hypothetical current date, the 1st of December 2023.

By just looking at the months, it could be deduced that Oliver's birthday (July 24) has passed and Sylvia's birthday (September 17) has also passed by December 1, 2023. It means both birthdays will come next in 2024.

And the birthday that will come first in 2024 would be Oliver's birthday on July 24, 2024.

Let's move to the last step, calculating the number of days between the two birthdays.

Step 4: We'll bypass any complexities with the shift to a new year by converting each birthday to 2024 dates: Oliver's to 24th July 2024 and Sylvia's to 17th September 2024. Then we can calculate the difference.

Let's perform this calculation now."

-> calling dateDiff(date1: "2024-07-24", date2: "2024-09-17")

Function dateDiff Result:

"55"

Assistant

"Step 4 result: There are 55 days between Oliver's birthday (July 24, 2024) and Sylvia's birthday (September 17, 2024).

To summarize:

  • Given the hypothetical date of December 1, 2023, both Oliver's and Sylvia's birthdays for that year have passed.
  • The next birthday to occur is Oliver's on July 24, 2024.
  • There are 55 days between Oliver's and Sylvia's birthdays in 2024.

This meets our objectives and is logically consistent. All steps are completed."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment