-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HW_done (without task 10) #9
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please solve Task9 and also fix your implementations, cause you've got failing tests.
@@ -2,6 +2,7 @@ | |||
|
|||
public class Task1 { | |||
public static String makeTags(String tag, String text) { | |||
return ""; | |||
|
|||
return String.format("%s", "<" + tag + ">" + text + "</" + tag + ">"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use correct pattern, there is no need to concatenate whole string.
There are no restrictions for constant values in pattern, for example: <%s>
will produce <argument_value>
return s; | ||
} | ||
else { | ||
return s.substring(0, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s.substring(0,1)
will return just 1 character.
StringBuffer newstring2 = new StringBuffer(); | ||
newstring2.append(s1).append(s2).append(s1); | ||
return newstring2.toString(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for StringBuffer
in current task.
Also, StringBuffer
use synchronized
methods, so your code will be additionally slowed by synchronization.
return 0; | ||
int evenNum = 0; | ||
for (int anArr : arr) { | ||
if (anArr % 2 == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is faster way to check whether number is even or odd. Read about parity bit.
|
||
int n = 0; | ||
for (int newArr: arr) { | ||
if (newArr % 2 != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only possible values of any number % 2 are 0 and 1, so it'll be clearer if you'll check only those values.
@OlgaBerezhna your tasks do not pass all the tests, please rerun tests locally and check your implementation. |
No description provided.