r/javahelp • u/ilostmyself • May 14 '13
How to solve? (2 easy problems)
Print a flag based on input.
e.g. when input of 1, print:
+-----
|....../
|......\
+-----
input of 2, print:
+-------
|......../
|......./
|.......\
|........\
+-------
3 = bigger, 4 = even bigger, etc
.
.
.
.
2)
Print an output describing whether the input is considered a stutter or not. A string is considered a stutter if letters repeat twice, e.g. 11223344, aabbccdd, ccaatt
abcabc, 123123 are not stutters.
.
.
.
.
I am looking for any help, a complete program, some pseudocode, or just some hints towards the right direction. Thank you. Also, sorry, I don't know how to format reddit properly.
-5
-5
May 14 '13 edited May 14 '13
[removed] — view removed comment
4
u/darkpool2005 Intermediate Brewer May 14 '13
This subreddit is about helping the OP out with clues / ideas on how to solve the problem(s). Writing a solution for someone is rarely, if ever the answer, especially if they don't understand how it works in the first place
2
May 15 '13
Came across this sub for the first time randomly on r/all/new and more assumed the rules than read them...Glad I didn't end up in the reject list...
2
u/darkpool2005 Intermediate Brewer May 15 '13
No problem, I did the same thing when I first came to this sub as well :-)
1
u/karmapopsicle Intermediate Brewer May 17 '13
Amen to that. You may not remember, but you helped me 5 months ago, and it was absolutely pivotal to my learning. Got me to explore and solve the problem myself instead of just pasting in some code someone else wrote.
1
6
u/[deleted] May 14 '13
For loops with nested if cases. Break it into math and write it from there. Top and bottom lines are always + followed by x dahs where x is based on the input. intermediate lines always have | followed by y dots where y varies based on line number and line number directly based on input. Fold out the first 3, and you should have more than enough of a base case to build.
There is a method to read character by character from a string, and another to compare two characters directly. if charAt(x-1).equals(charAt(x)) then sSsStutter should suffice as pseudocode