This year on October 2, 2001, the date in MMDDYYYY format will be a palindrome (same forwards as backwards).
10/02/2001
when was the last date that this occurred on?
// Palindromes For this century (year same forwards as backwards) // ex. 10/02/2001
public static DateTime lastPalindrome() { // Last Palindrome string P = null; // last two digits of the full year int year = DateTime.Year.IndexOf(2, 2);
if (year => 21) { // Last PalinD. : 12/02/2021 P = reverseY(year); } else if (year => 11) { // Last PalinD. : 11/02/2011 P = reverseY(year); } else if (year => 01) { // Last PalinD. : 10/02/2001 P = reverseY(year); } return DateTime.TryParse(P);
// Reverses the year private string reverseY(string yr) { return yr.IndexOf(1, 1) + yr.IndexOf(0,1)+ "/" + "02/20" + yr; }
You are given n real numbers in an array. A number in the array is called a decimal dominant if it occurs more than n/10 times in the array. Give an O(n) time algorithm to determine if the given array has a decimal dominant.
Implement a function getbits, that returns the(right adjusted) n bits that begin at position p of an integer. Assume bit position 0 is at the right end and that n and p are sensible positive values.
// Palindromes For this century (year same forwards as backwards)
ReplyDelete// ex. 10/02/2001
public static DateTime lastPalindrome() {
// Last Palindrome
string P = null;
// last two digits of the full year
int year = DateTime.Year.IndexOf(2, 2);
if (year => 21) {
// Last PalinD. : 12/02/2021
P = reverseY(year);
}
else if (year => 11) {
// Last PalinD. : 11/02/2011
P = reverseY(year);
}
else if (year => 01) {
// Last PalinD. : 10/02/2001
P = reverseY(year);
}
return DateTime.TryParse(P);
// Reverses the year
private string reverseY(string yr) {
return yr.IndexOf(1, 1) + yr.IndexOf(0,1)+ "/" + "02/20" + yr;
}
}