Anyone can learn to code. I firmly believe that, and as a long time tutor, educator, and mentor I have yet to be proven wrong. Yes, it is difficult. You are learning to think in a way you have never had to before. It takes time and struggle. If you can channel that frustration into determination you will do just fine. But don't expect to ever not have to google most things, that's just part of the game. Eventually you'll google some things so many times you won't have to google them anymore. Then a few months will go by where you haven't seen that thing, and you'll have to google it all over again. It's a tough thing to learn for everybody, but there's nothing in this world that can't be learned for the motivated. But you can't take frustration personally, its just part of the learning process. Others will feel that same frustration towards something you understood right away. Answer from illkeepcomingback9 on reddit.com
🌐
CodingBat
codingbat.com › java
CodingBat Java
Welcome to Codingbat. See help for the latest. Java Example Solution Code · Java String Introduction (video) Java Substring v2 (video) Java String Equals and Loops · Java String indexOf and Parsing · Java If and Boolean Logic · If Boolean Logic Example Solution Code 1 (video) If Boolean Logic Example Solution Code 2 (video) Java For and While Loops ·
Python
Welcome to Codingbat. See help for the latest · Python HelpPython Example CodePython StringsPython ListsPython If BooleanCode Badges
CodingBat Python Warmup-1 sleep_in
The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return True if we sleep in · sleep_in(False, False) → True sleep_in(True, False) → False sleep_in(False, True) → True
Python Example Code
Code Help and Videos > Python Example Code · This page shows a few Python example functions to go with the CodingBat Python problems. Examples: If Boolean Strings Lists None result If Boolean
Java Example Solution Code
The examples are geared to help with the CodingBat java coding problems.
🌐
Quora
quora.com › Are-CodingBat-problems-too-easy
Are CodingBat problems too easy? - Quora
Answer: Difficulty is relative. The only thing you need to worry about as far as difficulty is concerned is how much effort you had to put in. If you feel like you didn’t need any effort to solve those problems, they were too easy. Otherwise, they weren’t. It’s that simple!
Discussions

CodingBat - Java - Warmup-2 - "stringYak" algorithm - Stack Overflow
I'm presently trying to understand a particular algorithm at the CodingBat platform. Here's the problem presented by CodingBat: *Suppose the string "yak" is unlucky. Given a string, retur... More on stackoverflow.com
🌐 stackoverflow.com
I need help with codingbat questions..
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full - best also formatted as code block You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnjava
3
4
November 3, 2023
Are exercises on codingbat a realistic representation of what you would see in job interviews, or just good practice?
Leetcode seems to be the de facto winner for studying problems that are actually used in interviews. Different problems are tagged with company names where users have been asked that problem. I'm not familiar with codingbat, but from a cursory overview, seems like leetcode seems better - more full featured site plus much larger problem set. That said, unless you're studying for interviews per se, the best way to learn is to build something, not do toy problems. A "todo" app is a pretty standard "build something" project. See TodoMVC, for instance, for lots of examples in different languages that you can learn from. More on reddit.com
🌐 r/learnprogramming
3
2
July 1, 2022
Codingbat authoring java problems with 2D array test cases - Stack Overflow
I am teaching java programming and frequently assign Codingbat.com problems. Codingbat is a great tool for students to get practice. I have authored some simple problems successfully, but I am st... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/learnprogramming › is this normal or am i not suitable for learning how to program? how do i know if i am suitable for this or not?
r/learnprogramming on Reddit: Is this normal or am I not suitable for learning how to program? How do I know if I am suitable for this or not?
December 10, 2021 -

I am learning Java and I am at the very beginning of my programming journey. I am using CodingBat for practicing and I am having a very hard time while solving the easiest tasks. I feel already burnout trying to solve questions and I almost can't do anything without using google. It has been just a few days since I started so I don't know if it's normal or not. What do you think? Is it normal? How do I know if I am suitable for this or not?

Edit: Thank you so much, you've been very helpful :))

Top answer
1 of 47
309
Anyone can learn to code. I firmly believe that, and as a long time tutor, educator, and mentor I have yet to be proven wrong. Yes, it is difficult. You are learning to think in a way you have never had to before. It takes time and struggle. If you can channel that frustration into determination you will do just fine. But don't expect to ever not have to google most things, that's just part of the game. Eventually you'll google some things so many times you won't have to google them anymore. Then a few months will go by where you haven't seen that thing, and you'll have to google it all over again. It's a tough thing to learn for everybody, but there's nothing in this world that can't be learned for the motivated. But you can't take frustration personally, its just part of the learning process. Others will feel that same frustration towards something you understood right away.
2 of 47
64
I often wonder if learning programming is the first time a lot of people encounter a "hard" subject that they don't pick up right away. That would explain why so many people are insecure about how slowly they learn at first. Possibly the number one most common thread on this sub besides "where do I start?" is "is it normal for me to not get it/learn slowly/feel stupid?". The truth is, learning programming is hard. It's not something you pick up in a couple of days. Expect to struggle with it. It's introducing a lot of new concepts that you've never really encountered before. It will take some time for those to really gel in your mind. This is a path that takes months or years, not days.
🌐
GitHub
github.com › mirandaio › codingbat
GitHub - mirandaio/codingbat: Solutions to CodingBat problems
Solutions to CodingBat problems. Contribute to mirandaio/codingbat development by creating an account on GitHub.
Starred by 257 users
Forked by 237 users
Languages   Java 86.4% | Python 13.6%
🌐
GitHub
github.com › jdegand › codingbat-java
GitHub - jdegand/codingbat-java: Coding Bat Java Solutions
Coding Bat Java Solutions . Contribute to jdegand/codingbat-java development by creating an account on GitHub.
Forked by 2 users
Languages   Java
🌐
Digital Technologies Hub
digitaltechnologieshub.edu.au › search › coding-bat
Coding bat
CodingBat is a free site of live coding problems for students to build their skills in Java and Python. CodingBat emphasises building and practicing small code problems as a means of developing these skills.
Find elsewhere
Top answer
1 of 1
1

String concatenation

In order to be on the same page, let's recap how string concatenation works.

When at least one of the operands in the expression with plus sign + is an instance of String, plus sign will be interpreted a string concatenation operator. And the result of the execution of the expression will be a new string created by appending the right operand (or its string representation) to the left operand (or its string representation).

String str = "allow";
char ch = 'h';
Object obj = new Object();
    
System.out.println(ch + str);      // prints "hallow"
System.out.println("test " + obj); // prints "test java.lang.Object@16b98e56"

Explanation of the code-logic

That said, I guess you will agree that this statement concatenates a character at position i in the str to the resulting string and assigns the result of concatenation to the same variable result:

result = result + str.charAt(i);

The condition in the code provided by coding bat ensures whether the index i+2 is valid and then checks characters at indices i and i+2. If they are equal to y and k respectively. If that is not the case, the character will be appended to the resulting string. Athowise it will be discarded and the indexed gets incremented by 2 in order to skip the whole group of characters that constitute "yak" (with a which can be an arbitrary symbol).

So the resulting string is being constructed in the loop character by characters.

Flavors of substring()

Method substring() is overload, there are two flavors of it.

A version that expects two argument: the starting index inclusive, the ending index, exclusivesubstring(int, int).

And you can use it to achieve the same result:

// an equivalent of result = result + str.charAt(i);

result = result + str.substring(i, i + 1);

Another version of this method, that expects one argument will not be useful here. Because the result returned by str.substring(i) will be not a string containing a single character, but a substring staring from the given index, i.e. encompassing all the characters until the end of the string as documentation of substring(int) states:

public String substring(int beginIndex)

Returns a string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string.

Examples:

 "unhappy".substring(2) returns "happy"
 "Harbison".substring(3) returns "bison"
 "emptiness".substring(9) returns "" (an empty string)

Side note:

  • This coding-problem was introduced in order to master the basic knowledge of loops and string-operations. But actually the simplest to solve this problem is by using method replaceAll() that expects a regular expression and a replacement-string:
return str.repalaceAll("y.k", "");
🌐
Walmart
walmart.com › books › all books
Mastering Codingbat (Java): Mastering CodingBat (Java), Vol. 1: Basics (Paperback) - Walmart.com
Mastering Codingbat (Java): Mastering CodingBat (Java), Vol. 1: Basics (Paperback)
Mastering CodingBat (Java), Vol. 1: Basics is the first book in a series on the Java sequence of problem sets on the website CodingBat.com. It is a competent guide that will help you learn the ropes of fundamental programming concepts. This book contains problem descriptions, hints, solutions, and discussions on all problems of the following categories: Warmup-1, String-1, Array-1, and Logic-1. Its 326 pages cover 121 problems with a total of 357 code listings.
Price   $19.99
🌐
Reddit
reddit.com › r/learnjava › i need help with codingbat questions..
r/learnjava on Reddit: I need help with codingbat questions..
November 3, 2023 -

Hi, so i've been trying to learn java for 2 months now, and im going good with the concepts and multiple choice questions from several recrouses, but i'm still strugging to solve questions from codingbat, and find myself spending too much time trying to come up with a solution. I was wondering if there is any additional resource I can use to master my skills and time efficentally solve questions, such as the ones presented in codingbat.

Top answer
1 of 3
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full - best also formatted as code block You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2 of 3
1
You have learnt the vocabulary and grammar but cannot write a book - kind of normal. Multiple-choice questions are the wrongest things to learn programming. Do a proper course, like the MOOC Java Programming with all the exercises and you will learn both, Java (the programming language) and programming. Then, you will have no problem solving the Codingbat problems.
🌐
Reddit
reddit.com › r/learnprogramming › are exercises on codingbat a realistic representation of what you would see in job interviews, or just good practice?
r/learnprogramming on Reddit: Are exercises on codingbat a realistic representation of what you would see in job interviews, or just good practice?
July 1, 2022 -

Hi all I'm attending a university taught boot camp in the fall, but I'm taking the summer to self learn and educate myself as much as possible. I've started with python and after becoming comfortable with the basics I learned about codingbat. I'm able to do a lot of the exercises on there (but not all), and I was just curious as to how accurate a representation the questions on there are compared to what you would see in a real world interview?

🌐
Gregor Ulm
gregorulm.com › books › mastering-coding-bat-java-vol-1-basics
Mastering CodingBat (Java), Vol. 1: Basics | Gregor Ulm
December 2, 2018 - Mastering CodingBat (Java), Vol. 1: Basics is the first book in my four-part series on the Java sequence of Coding Bat programming problems. This book covers the following sections: – Warmup-…
🌐
Quizlet
quizlet.com › 256392732 › codingbat-java-recursion-1-30-probs-flash-cards
codingbat-java-recursion-1 - 30 probs Flashcards | Quizlet
Study with Quizlet and memorize flashcards containing terms like /* Given a string, compute recursively a new string where all the adjacent * chars are now separated by a "*". */ public String allStar(String str) { if(str.length() = nums.length ...
🌐
30 Days Coding
30dayscoding.com › blog › mastering-codingbat-a-comprehensive-guide-for-beginners
Mastering CodingBat: A Comprehensive Guide for Beginners
April 27, 2024 - CodingBat is designed to help you improve your coding skills through a variety of features, including: Interactive coding environment: Write and execute code directly in the browser, with instant feedback on errors and results. Large exercise repository: Access a vast collection of exercises, ...
🌐
Gregor Ulm
gregorulm.com › codingbat-java-array-2-part-ii
CodingBat: Java. Array-2, Part II | Gregor Ulm
April 12, 2018 - You check to see if the first “3” is far enough away from the last “3” for it to be possible to have a number in between each 3. It does not actually check if there is a 3 next to any other three, however. So if the array were to be initialized to {3, 3, 1, 1, 3} your program would return true when it should return false. CodingBats never initializes the array as such, which gives the illusion that your solution is correct.
🌐
Amazon
amazon.ie › Mastering-CodingBat-Java-Vol-Basics › dp › 3942017105
Mastering CodingBat (Java), Vol. 1: Basics (1) : Ulm, Gregor: Amazon.ie: Books
Mastering CodingBat (Java), Vol. 1: Basics (1) : Ulm, Gregor: Amazon.ie: Books
Mastering CodingBat (Java), Vol. 1: Basics (1) : Ulm, Gregor: Amazon.ie: Books
Price   €29.56
🌐
CodingBat
codingbat.com › java › Logic-1
CodingBat Java Logic-1
CodingBat code practice · Logic-1 chance · Basic boolean logic puzzles -- if else && || !. New videos: If Boolean Logic 1, If Boolean Logic 2 · Java Example Solution Code · Java String Introduction (video) Java Substring v2 (video) Java String Equals and Loops ·
🌐
Amazon
amazon.com › Mastering-CodingBat-Java-Vol-Intermediate › dp › 3942017113
Mastering CodingBat (Java), Vol. 2: Intermediate A: Ulm, Gregor: 9783942017114: Amazon.com: Books
Mastering CodingBat (Java), Vol. 2: Intermediate A is the second book in a series on the Java sequence of problem sets on the website CodingBat.com. It is a competent guide that will help you learn the ropes of fundamental programming concepts.