This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding the number is having pairs and also number is in sequence/consecutive

 
sandeshas naik
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can anyone help me to write a program to find out the given number is having pairs and also number is in sequence?
example: 11223344 is having pair 11 22 33 44 and also number is in sequence.

Please help
 
fred rosenberger
lowercase baba
Bartender
Posts: 12147
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HELP you? of course - we love doing that.

but nobody here is going to do it FOR you.

so..show us what you've got. Where are you stuck? Ask specific questions and you will get specific feedback. Ask general questions, and you'll get general feedback.
 
sandeshas naik
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The above code will give the count for each number but it will fails when we try for 12332144 - (Its not a sequence). Please help.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49442
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am afraid there is a piece of hardware which is obstructing your progress. It is black and long and thin and it runs from the back of your computer to the wall. Remove it.

Get a sheet of paper a pencil and an eraser (the latter should be large, because you will use it a lot ‍). Write down in words of one syllable how you intend to do your exercise. Then you will be able to see how to convert it to code.
Two things to remind yourself of:-
  • 1: You are not dealing with a number, but a String. You can prove you are not dealing with numbers by converting your input to hexadecimal, and it will not work.
  • 2: You can do arithmetic with chars. They are not letters, but numbers hidden behind characters.
  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic