示例#1
0
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!

                return("My answer");
            };

            Task1.CheckSolver(TaskSolver);
        }
示例#2
0
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!
                float sickPeople = float.Parse(task.City.Population) * float.Parse(task.City.SickPercentage);
                float deadPeople = sickPeople * float.Parse(task.Virus.KillProbability);

                return($"There are {Math.Truncate(sickPeople)} people sick with {task.Virus.Name} in the city of {task.City.Name}, {Math.Truncate(deadPeople)} of which died");
            };

            Task1.CheckSolver(TaskSolver);
        }
示例#3
0
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                float population     = System.Single.Parse(task.City.Population);
                float sickPercentage = System.Single.Parse(task.City.SickPercentage);
                float letality       = System.Single.Parse(task.Virus.KillProbability);
                int   sickNumber     = (int)(Math.Truncate(population * sickPercentage));
                int   deathNumber    = (int)(Math.Truncate(population * sickPercentage * letality));

                return($"There are {sickNumber} people sick with {task.Virus.Name} in the city of {task.City.Name}, {deathNumber} of which died");
            };

            Task1.CheckSolver(TaskSolver);
        }
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                //Andrii Nevidomyi solution

                //Example
                //[task.City.Name] = "Virtualiev"
                //[task.City.Population] = 1400
                //[task.City.SickPercentage] = 0.3
                //[task.Virus.Name] = "Hlomanda"
                //[task.Virus.KillProbability] = 0.2

                //"There are 420 people sick with Hlomanda in the city of Virtualiev, 84 of which died"

                //------------------------------------------------------------------------------------
                //parse
                float population, sickPersentage, killProbability;

                //result
                float sickPeople = 0, peopleDied = 0;

                try
                {
                    population      = Convert.ToSingle(task.City.Population);
                    sickPersentage  = Convert.ToSingle(task.City.SickPercentage);
                    killProbability = Convert.ToSingle(task.Virus.KillProbability);

                    sickPeople = population * sickPersentage;
                    peopleDied = sickPeople * killProbability;
                }
                catch (FormatException)
                {
                    Console.WriteLine("FormatException");
                }


                return($"There are {Math.Truncate(sickPeople)} people sick with {task.Virus.Name} in the city of {task.City.Name}, {Math.Truncate(peopleDied)} of which died");
            };

            Task1.CheckSolver(TaskSolver);
        }
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!
                float numberOfSickPeople = float.Parse(task.City.Population) * float.Parse(task.City.SickPercentage);
                float numberOfDeath      = float.Parse(task.Virus.KillProbability) * numberOfSickPeople;

                string answer = "There are " + Math.Truncate(numberOfSickPeople)
                                + " people sick with " + task.Virus.Name
                                + " in the city of " + task.City.Name + ", "
                                + Math.Truncate(numberOfDeath) + " of which died";

                return(answer);
            };

            Task1.CheckSolver(TaskSolver);
        }
示例#6
0
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task => {
                bool parsingSuccesful = float.TryParse(task.City.Population, out float population);
                parsingSuccesful &= float.TryParse(task.City.SickPercentage, out float sickPercentage);
                parsingSuccesful &= float.TryParse(task.Virus.KillProbability, out float killProbability);
                if (!parsingSuccesful)
                {
                    throw new ArgumentException("Wasn't able to parse all of the string parameters containing floats!");
                }

                float peopleInfected = MathF.Truncate(population * sickPercentage);
                float peopleDead     = MathF.Truncate(peopleInfected * killProbability);

                return
                    ($"There are {peopleInfected} people sick with {task.Virus.Name} in the city of {task.City.Name}, {peopleDead} of which died");
            };

            Task1.CheckSolver(TaskSolver);
        }
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!
                string cityName  = task.City.Name;
                string popul     = task.City.Population;
                string sickPerc  = task.City.SickPercentage;
                string virusName = task.Virus.Name;
                string killProb  = task.Virus.KillProbability;

                float sickNum = float.Parse(popul) * float.Parse(sickPerc);
                float diedNum = float.Parse(killProb) * sickNum;

                return($"There are {Math.Truncate(sickNum)} people sick with {virusName} in the city of {cityName}, {Math.Truncate(diedNum)} of which died");
            };

            Task1.CheckSolver(TaskSolver);
        }
示例#8
0
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                int   population      = int.Parse(task.City.Population);
                float sickPercentage  = float.Parse(task.City.SickPercentage);
                float killProbability = float.Parse(task.Virus.KillProbability);

                float sickPopulation    = (float)population * sickPercentage;
                int   sickPopulationInt = (int)Math.Truncate(sickPopulation);

                float diedPopulation    = killProbability * sickPopulation;
                int   diedPopulationInt = (int)Math.Truncate(diedPopulation);

                string result = $"There are {sickPopulationInt} people sick with {task.Virus.Name} in the city of {task.City.Name}, {diedPopulationInt} of which died";

                return(result);
            };

            Task1.CheckSolver(TaskSolver);
        }
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                if (float.TryParse(task.City.SickPercentage, out float sickPercentage) &&
                    float.TryParse(task.Virus.KillProbability, out float killProbability) &&
                    int.TryParse(task.City.Population, out int population))
                {
                    float numberOfSick         = population * sickPercentage;
                    float numberOfKilledPeople = numberOfSick * killProbability;

                    double roundedNumberOfSick       = MathF.Truncate(numberOfSick);
                    double roundedNumberKilledPeople = MathF.Truncate(numberOfKilledPeople);

                    return($"There are {roundedNumberOfSick} people sick with {task.Virus.Name} in the city of {task.City.Name}, {roundedNumberKilledPeople} of which died");
                }
                return("Error: Wrong data");
            };

            Task1.CheckSolver(TaskSolver);
        }
示例#10
0
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!
                float population      = Single.Parse(task.City.Population);
                float sickPercentage  = Single.Parse(task.City.SickPercentage);
                float killProbability = Single.Parse(task.Virus.KillProbability);

                float sickValue = population * sickPercentage;
                float deadValue = sickValue * killProbability;

                string answer = "There are " + Math.Truncate(sickValue) + " people sick with " +
                                task.Virus.Name + " in the city of " + task.City.Name +
                                ", " + Math.Truncate(deadValue) + " of which died";

                return(answer);
            };

            Task1.CheckSolver(TaskSolver);
        }
示例#11
0
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!
                float cityPopulation = float.Parse(task.City.Population);
                float sickPercentage = float.Parse(task.City.SickPercentage);
                float deathRate      = float.Parse(task.Virus.KillProbability);

                float sickPeopleCount = cityPopulation * sickPercentage;
                float deadPeopleCount = sickPeopleCount * deathRate;

                string result = $"There are {Math.Truncate(sickPeopleCount)}" +
                                $" people sick with {task.Virus.Name} in the city of {task.City.Name}," +
                                $" {Math.Truncate(deadPeopleCount)} of which died";

                return(result);
            };

            Task1.CheckSolver(TaskSolver);
        }
        public static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                float population = 0.0f, sickPercentage = 0.0f, killProbability = 0.0f;

                bool isParseSucceed = float.TryParse(task.City.Population, out population) &&
                                      float.TryParse(task.City.SickPercentage, out sickPercentage) &&
                                      float.TryParse(task.Virus.KillProbability, out killProbability);

                if (!isParseSucceed)
                {
                    Console.Error.WriteLine("Parse error.");
                }

                float sickPeopleCount = population * sickPercentage;
                float deadPeopleCount = killProbability * sickPeopleCount;

                return($"There are {Math.Truncate(sickPeopleCount)} people sick with {task.Virus.Name} in the city of {task.City.Name}, {Math.Truncate(deadPeopleCount)} of which died");
            };

            Task1.CheckSolver(TaskSolver);
        }
        static void Main(string[] args)
        {
            Func <Task1, string> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!

                int   total          = Int32.Parse(task.City.Population);
                float sickPercentage = float.Parse(task.City.SickPercentage);
                float mortality      = float.Parse(task.Virus.KillProbability);

                float sick = total * sickPercentage;
                float dead = sick * mortality;

                string virus = task.Virus.Name;
                string city  = task.City.Name;

                return("There are " + Math.Truncate(sick) + " people sick with " + virus + " in the city of " + city + ", "
                       + Math.Truncate(dead) + " of which died");
            };

            Task1.CheckSolver(TaskSolver);
        }