Artem's blog

Mainly .NET (C#, ASP.NET) and my projects

artemlos

This user hasn't shared any biographical information

C# Fundamentals – Logical and Conditional operators [2]

C# Fundamentals – Introduction (Getting started) [1]

Parse mathematical expressions using C#.NET

Express exponential functions in base e

In order to express an exponential function in terms of e, we need to do as follows:

logarithms1

This was simple, but it might be used to prove the compound formula in calculus.

logarithms2

First, we convert the expression into base e.

logarithms3

Secondly, we know that the D(e^x)=e^x. So,

logarithms4

But, this is the same as:

logarithms5

QED

Software Protector [Identical key generation]

Mathos Project website updating

Mathos Project websites, http://mathosproject.com/ and http://mathosproject.info/ are for the moment under a big update, and hence not available for the moment. This will be fixed 31/1, but it might take longer time depending on several factors.

Please check back soon! 🙂

Update of SKGL API 2.0.4.1

For approximately one week ago, I released a newer version of the SKGL API. This update has no significance to the way you’ve used Software Protector and SKGL before, however, keys generated in the previous versions will not be validated in this release.

This is mainly because of the change to a part of the algorithm that caused a small bug, which was mentioned here.

Fortunately, this bug is fixed, so you can continue to protect your ideas with Software Protector! 🙂

P.S. Please check out the Facebook page at https://www.facebook.com/SoftwareProtector

Interesting features of numerical roots

Imagine following: you ask your fellow to pick any number they like, and later multiply it by your number. Once they have the result, you will ask them to circle one digit in their answer (except zero). Finally, you ask them to tell you digits that are left in any order, and you will be able to tell the circled digit.

This is simply done using some basic concepts of numerical roots. Once you know these, you will be able to construct different kinds of tricks, based on this principle.

Numerical root: A numerical root is calculated by summing up the digits in a number. Say we have 85732, so the numerical root will be 8+5 which gives you 13. Then, because 13 is bigger then 10, you take 1+3 to get 4, and add it to 7 (the third digit). So, 4+7 = 11, hence 1+1=2. Now 2+3=5, and 5+2=7. So, the numerical root of 85732 is 7. (if you know modulo arithmetic, you simply take the sum modulo 9, i.e. 8+5+7+3+2 mod 9 = 7, however, the described method is handy because it does not require that much calculations)

Interesting feature: If the numerical root is equal to 9, you can perform either addition and/or multiplication of any random number, and the numerical root will still stay the same. This is interesting because you can let your fellow to add or multiply your number with any number, any amount of times, and still know that the numerical root is 9. Let’s see how this works:

If I pick a number with a numerical root of 9, i.e. 54, and you pick 9876 (which I obviously do not know), and later you multiply these two together, and get 533304. I ask you to circle a number, you choose 5, and I ask you for the rest of the digits, i.e. 33304 (note, the order does not matter here). So, I know that the numerical root stays the same, so I find it for your digits, 3+3=6, 6+3=9, 9+4=13, 1+3=4 (as you might already see, this result is obtained when we subtract 9 from 13). So, the numerical root is 4, and I need to add 5 to get 9, hence 5 is the circled digit!

Reference:

Matematicheskie chudesa i tajny, M. Gardner, published in 1986, Moscow. (work in translation)

Vigenère cipher, programming contest

Yesterday I was solving an interesting question that has been used on the Swedish Computer Science contest – a programming contest, in 2010, which probably is simple, but interesting because it emphasises sequences, et cetera.

The question introduced the Vigenére cipher in a classical way, with two disks containing letters of the English alphabet. In the beginning, we know several things about the encrypted text, which are to help us when we are going to crack the message.
bokstavssnurra

  • The disks might have different number configurations, i.e. there is still a shift, which is unknown.
  • In order to “make it harder” for the enemy, each time we have obtained a letter, we continue by using a new shift, and this shift is increased by a constant value.
  • Fortunately, we get to know that each message contains the word “HEJ” – a Swedish word for “hello”, which might be used as  “bye”, I think.

Also, we get some examples as well, for instance:

Example 1:
Encrypted text: LRIJOUZRIYAQIRAG
Message: HEJVITARENFIKANU – means let’s take a “fika”

Example 2:
Encrypted text: GCGDJJI
Message: HEJHOPP – hello in an optimistic manner

There is also an example of this sequence,in Example 1, which is tells us that the difference is 9, 12, 15, 18… (common difference 3).

I’m solving this using a recurrence, and I’m not simplifying this arithmetic progression in any way, I just add d all the time.

The code below has passed all their tests, which are located at the end of this post.

        static void Main(string[] args)
        {
            /* 
             * Copyright (C) 2013 Artem Los,
             * All rights reserved.
             * 
             * This code-snippet can be found at: 
             *      http://clizware.net/
             */

            string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

            Console.Write("Enter the message: ");

            string message = Console.ReadLine();

            int H = alphabet.IndexOf("H");
            int E = alphabet.IndexOf("E");
            int J = alphabet.IndexOf("J");

            int dA = mod(alphabet.IndexOf(message[0]) - H, alphabet.Length);
            int dB = mod(alphabet.IndexOf(message[1]) - E, alphabet.Length);
            int dC = mod(alphabet.IndexOf(message[2]) - J, alphabet.Length);

            int init1 = dB - dA;
            int init2 = dC - dB;

            int dConst = init2 - init1;
            int dPrev = dC;

            Console.Write("Output message: HEJ");
            for (int i = 3; i < message.Length; i++)
            {
                init2 += dConst;
                dPrev = mod(dPrev + init2, alphabet.Length);

                int X = alphabet.IndexOf(message[i]);
                Console.Write(alphabet[mod(X - dPrev, alphabet.Length)]);
            }

            Console.ReadLine();
        }

        static int mod(int n, int b)
        {
            return n - b * (int)Math.Floor((double)n / b);
        }
    }

Example 1
RIPIWDUXRS
HEJSOVERNI

Example 2
IGNUFAKPXYVSF
HEJNUKOMMERDE

Example 3
PAJESQBIPOOPKAP
HEJKOMHITGENAST

Reference:
http://www.progolymp.se/Oldpage/arkiv/kval10.pdf
http://www.progolymp.se/Oldpage/arkiv/kvalsvar10.pdf

Privacy on the Internet

One of the topics that has been emphasised previous year is privacy – something that might turn into scarce in the nearest feature. In this article we are going to look at several factors, and investigate different aspects of this issue.

As we know, a lot of us like to share different events, emotions, what to eat, what to dress, with whom to break a relation, etc, on internet, using social networks. It has become some sort of trend during the past three years, and it seems to continue, despite campaigns that are consolidating people to stop using them, it is still more newly registered users every day. Probably, the term privacy has been vaporized, and if not, it might do that in future.

A lot of articles that support the idea that privacy is outdated, and that today everyone is more open might do that for several reasons. First, they are either convinced by this idea, or, they simply want to protect their business, and encourage more people to use it. Everything leads to profit, and this is understandable.

We have for instance seen discussions about how Google and other search companies collect information, which triggered a reaction of several people. Also, we have seen articles about Facebook, and how some people could lose their job because of things they wrote. But what everything leads to is the actual person. If that person would think about that what he writes, there would not have been a problem. This is probably not similar to when you search on internet, because you are not actually writing something in public, but, you are still giving away a lot of information, which later will be used to decide what advertisement you should see when searching. This is not necessarily wrong, because why should we see an article about politics of a country, when you actually were searching for cheep journeys. However, at some point, it might feel a bit creepy!

I think we should keep in mind that internet is a tool, which everyone should be able to use, and in the same time consider the consequences of what they do (write, publish). Internet is amazing; the way we can communicate has contributed to developments of, for instance, the English language, and also other languages. The ability to work with people on the other side of the globe, share ideas; simply – contribute to a better feature. Internet is a place that everyone should enjoy to take a part of, but in the same time, be able to understand that there will always be those who abuse it – the bad guys,  as with any innovation in the world!

Page 7 of 15:« First« 4 5 6 7 8 9 10 »Last »