/* Weddingdates.kt Copyright (c) Kari Laitinen http://www.naturalprogramming.com 2020-10-31 File created. */ import java.time.LocalDate import java.time.Period fun main() { var date_to_increment = LocalDate.now() var number_of_dates_printed = 0 print( "\n These are easy-to-remember dates for weddings and" + "\n other important events because the days and months" + "\n consist of the digits used in the year: \n" ) while ( number_of_dates_printed < 60 ) { val day_as_string = String.format( "%02d", date_to_increment.getDayOfMonth() ) val month_as_string = String.format( "%02d", date_to_increment.getMonth().getValue() ) val year_as_string = "" + date_to_increment.getYear() if ( year_as_string.indexOf( day_as_string[ 0 ] ) != -1 && year_as_string.indexOf( day_as_string[ 1 ] ) != -1 && year_as_string.indexOf( month_as_string[ 0 ] ) != -1 && year_as_string.indexOf( month_as_string[ 1 ] ) != -1 ) { // Now we have found a date that meets our requirements. if ( number_of_dates_printed % 5 == 0 ) { print( "\n" ) } print( " " + date_to_increment ) number_of_dates_printed ++ } // Here we create a new LocalDate object that contains the date of // the following day. date_to_increment = date_to_increment.plusDays( 1 ) } print( "\n\n" ) }