VBScript Simple Program – Problem in CodeForces

In order to learn a language, the best way is to practise it! Thus, I have decided to challange myself to solve a task on CodeForces with VBScript.  As far as VBScript is not one of the official CodeForces languages (no doubt about it), I thought it would be a good idea to solve the program in C# first and then change it to VBScript, thus making sure that it works as expected.

The problem:

Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.

Her problem is following: for given string, consisting of only 0 and 1, tell if it’s possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisible by 64, in the binary numerical system.

Input

In the only line given a non-empty binary string s with length up to 100.

Output

Print «yes» (without quotes) if it’s possible to remove digits required way and «no» otherwise.

 Where actually is the real problem in the so shown question – it really looks a bit trivial – if we can make sure that the input has at least six zeroes, it is already passing. Well, I thought of this initially, but it may be that the input is “000000” and it should be a wrong one. Then I thought of parsing to an integer number, but … well the length of the input is up to 100, which is about twice as much as BigInteger. At the end, a simple loop and rewriting the string, if it starts with a zero was the solution! String concatenating should be built with string builder usually, but this time it was not a problem. Thus, the solution has passed the 98 tests of the site:

Now the VBScript. Let’s take a look how to “translate” it there.

First of all – open a text file and save it as “main.html”. Then the party starts. Actually, many browsers are somehow against VBScript. Probably for a reason. Thus, in order to see it running, you should do the following troubleshooting with Internet Explorer:

  • Press F12 to open developer tools
  • In left toolbar scroll down until you see “Emulation” settings page
  • Change Document Mode from default (“Edge”) to 10
  • Try using the following code

It’s pretty fun:

Some of the tricks with VBA tricks work there and once you start working even a small task with VBScript you somehow start liking and appreciating the VBEditor (which is not updated since more than 10+ years.)

At the end, this is the code of the CodeForces.Com task:

The interesting part is that I even managed to do it with one loop and not with two as in the original problem. This is how it looks in the browser:

Pretty much that is it! The inspiration to try something today with VBScript came from the tutorial of guru99 for VBScript! It is quite interesting if you are fans of “old stuff”. If not, there are other tutorials on the site as well!

Cheers! 🙂

Tagged with: , , ,