Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to print all the pallindromic days in a year  RSS feed

 
Kislaya Pant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I want To ask a method how to print no of pallindromic days in year ??
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since, I believe, the term "palindrome" applies to strings and not to dates, I am assuming that you want a specific string representation of the dates?

Anyway, what have you tried? A straightforward implementation would be to go through all the days of the year, convert to string, and check if it is a palindrome. Of course, that's a very high level description -- please clarify the specific problem you are having.

Henry
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too have no idea what a palindromic day of the year is. Are you just talking about the day and the month as numbers?

E.g 01/10 is the first of October (or the 10th of January if you're American). This is a palindrome.

Whatever your definition of a palindromic day of the year is you need to break the problem down into smaller parts. You can have a method that checks if a String is a palindrome, and a method that loops through all the days of the year and passes them to the palindrome checker.
 
Liutauras Vilda
Marshal
Posts: 4650
318
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kislaya Pant wrote:pallindromic days in year
As guys already mentioned, most important part is to define unambiguous requirements first. By reading your post I understand, that you need to find how many pallindropic dates days are in the year. Being a bit silly, per month you can have 2 pallindromic days: 11 and 22. This number multiplied by amount of month you'd get 24. But this is surely is not what could guarantee you a good mark. I believe guys were correct by saying that likely it needs to look similar to 01/10.

1. So, first step is clearly identify the problem what do you call pallindromic day and provide couple of examples: one pallindromic day and another non pallindromic day.
2. Bear in mind, it will be important how you write your date 10.01 or 10/01 or 10-01 or 1001, maybe 10 January (this question should be answered along with provided examples).
3. After you clearly understand requirements, you start describing your program in plain english by omitting any technical terminology. This FAQ (<- link to click on) will help you to achieve that.

I believe you've been tought how to write pseudo code, so, probably would be a good idea if you'd come up with it first and post here, so you could convince everyone that you understand fully what your problem you need to solve is.

And welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!