Skip to content

minitask

Programming competition and a small Java task

Last week we had a programming competition at work which consisted of some small tasks. One of them was to check, if we can make a given string palindrome by adding one letter in any place. Shame on me, I didn’t manage with this task in time. However I got the third place in this competition. 🏆😁

So the task:
Your app should check, if it’s possible to make a palindrome by adding a lowercase English letter to a given string in any position. If it is, the application should return an index which points to where to put a character, otherwise the app should return -1.
The given string contains only lowercase Latin characters.

What is a palindrome? Palindrome is a word or a number, which reads the same backward and forward. For example:

  • Was it a car or a cat I saw?
  • 1234321
  • Step on no pets

See the solution.

Read More →

JavaScript scope mini-task

What we will see in the console?

var obj = {
    heroName: "Gandalf",
    func: function() {
        var that = this;
        console.log("outer func:  this.heroName = " + this.heroName);
        console.log("outer func:  that.heroName = " + that.heroName);
        (function() {
            console.log("inner func:  this.heroName = " + this.heroName);
            console.log("inner func:  that.heroName = " + that.heroName);
        }());
    }
};
obj.func();

 

The result will be:

Read More →