Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Scripting (Python,R,etc): Write a function, min_date(string), that has the input of XXXX-XX-XX where: The string represents a date in YYYY-MM-DD format. So, 1234-56-7 is invalid

Scripting (Python,R,etc):

Write a function, min_date(string), that has the input of XXXX-XX-XX where:

  1. The string represents a date in YYYY-MM-DD format. So, 1234-56-7 is invalid
  2. There is no need to check that this value is a valid date. So, 1234-56-78 is valid
  3. Only valid date inputs will be used to test this function (so you do not need to handle non-date inputs if you dont want to). So, your function will not have to run a value with 1234-56-78 as an input (unless you want it to).

This function gives the output of YYYY-MM-DD, where the output is the closest real date given the following rules:

  1. The digits are 0 to 7. So, the date 3456-09-12 is invalid
  2. No number is repeated. So, the date 1234-09-15 is invalid
  3. The output date is a valid date. So, the date 6035-12-40 is invalid

You are given the following functions (but are free to not use them):

Examples of output:

min_date(7654-01-22)

> 7654-01-23

min_date(2020-12-24)

> 2345-06-17

min_date(0001-01-01)

  • 1345-06-27

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

Students also viewed these Databases questions

Question

=+A3-5 Analysis ofincome and cash flows

Answered: 1 week ago

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago

Question

LO5 Illustrate the steps in developing a base pay system.

Answered: 1 week ago

Question

LO3 Outline strategic compensation decisions.

Answered: 1 week ago