Showing posts with label Order string series. Show all posts
Showing posts with label Order string series. Show all posts

Wednesday, November 15, 2017

Order string (VII)

Nov. 15, 2017

I like to write a blog about this C# practice, using Linq IList.Sort method. The link is here.

Order string (VI)

Nov. 15, 2017


Algorithm Study and Code Review


Here is the code related to the algorithm. I like to write a blog on the code. The main idea is to use primitive type string, just add index to the first element of string array, avoid a struct or a class definition. Kind of tricky. 


Follow up study 

Nov. 16, 2017

It is always a good idea to search code review to read IComparable<T> code review. I sepnt over 20 minutes to read the algorithm: Dynamically sorting with IComparer. And one of statement in the code review reads like the following:

This
public int CompareTo(ProductSortAttribute other)
{
    if (this.Index == other.Index)
    {
         return 0;
    }

    if (this.Index > other.Index)
    {
         return 1;
    }

    return -1;
}
can be shortened to
public int CompareTo(ProductSortAttribute other) {
    return this.Index.CompareTo(other.Index);
}
Since Int32 also implements Comparable<T>.

What is Int32?



Here are a list of things Julia starts to her independent study:
1. What is Int32? A structure
2. What interfaces does Int32 implements? IComparable<T>, IFormattable, IConvertible.
3. Where is the source code of Int32 in mscorlib? Link is here.

Comparable <T>  study



Sometimes, it is so easy to find an excellent lecture notes, and then I can follow quickly how to write basic comparer. Here is the one.

Order strings (V)

Nov. 4, 2017

Introduction

It is fun to continue to work on C# practice on this algorithm called order strings.

I reviewed the code and made some change, C# code is here for me to review later.

Tuesday, November 14, 2017

Order string (IV)

Nov. 14, 2017


Introduction


It is my favorite C# code to study, through the code, I can tell that the player has more C# coding experience compared to me, and also the trick used to do numeric comparison to make code so simple and only take one line of code, referring to line 44.

I just could not believe that the experience the player has and it makes coding so enjoyable experience, like a competing sports.

I could not express more enjoyment to read other people's code. When I read those excellent engineering idea, creative idea to solve the problem, I cannot believe that it makes coding such a challenging sports and I am just glad to be a follower.

Code study


I reviewed the code and rewrite the code, here is the code. I have to push myself to get LINQ to my daily coding practice, so I am ready one day to write a web application with much better code using LINQ.


Relax your mind 


I like to use this video to relate to read an excellent engineering idea to deal with solving problem.


Order string (III)

Nov. 14, 2017


Introduction


It is the best time to learn C# programming using one of medium algorithm in the Morgan Stanley codesprint. The design of algorithm includes using BigInteger class and also LINQ OrderBy and OrderByDescending.


Code study

I reviewed the code first, and then I rewrite the code. C# code is here.

Order strings (II)

Nov. 14, 2017

Introduction


It is time for me to learn how to write a C# program and also review other's code. The second study code is written using SortedDictionary. DescendingComparer class and DescendingComparerI class are defined.


Code design talk 


Here is the C# code after I review the code.


Order strings (I)

Nov. 14, 2017

Introduction


It is the time for me to study code submission using C#. This is the first C# code submission I studied, delegate is the keyword used in code, and also string.TrimStart.

Here is the C# code after I reviewed the code.


Code design talk 


The structure is used and called OrderString.

structure  OrderString
{
    public int      Index;
    public string Lexicographic;
}