hamidmolareza / queraproblems Goto Github PK
View Code? Open in Web Editor NEWپاسخ سوالات کوئرا به زبانهای مختلف مثل سیشارپ، پایتون، جاوااسکریپت و غیره
License: GNU General Public License v3.0
پاسخ سوالات کوئرا به زبانهای مختلف مثل سیشارپ، پایتون، جاوااسکریپت و غیره
License: GNU General Public License v3.0
When an error occurs, the whole program stops.
We must have error handling to retry failed operations.
An example error:
Unhandled exception. System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
at Quera.Program.GetQuestionTitle(String link) in /home/runner/work/QueraProblems/QueraProblems/Quera/Program.cs:line 82
at Quera.Program.CreateReadmeAsync(IEnumerable`1 branches) in /home/runner/work/QueraProblems/QueraProblems/Quera/Program.cs:line 64
at Quera.Program.Main(String[] args) in /home/runner/work/QueraProblems/QueraProblems/Quera/Program.cs:line 23
at Quera.Program.<Main>(String[] args)
Processing branch 3029...
Error: Process completed with exit code 134.
A good idea is to add the name or photo of the contributors in the row of each problem. This helps to determine which people are involved in solving the problem.
](https://quera.org/problemset/158168) 158168
The time of all commits is the same!
Until now, activities have been personal. Maybe it's better to move the repo on Payadel.
Display the most important questions on the main page and refer the rest of the questions in a separate file.
When the number of solved questions is high, the main page becomes long.
On the other hand, not all questions are important. It is better to list easier questions or questions that do not have a special point on a separate page.
To generate the README file, the title of the questions is received from the Quera site every time. It is better to save the titles in a file to increase the speed of work and less disturbance for the Quera site.
Show the number of commits when the mouse hovers over a contributor's photo.
Question Link: Link
The solution gets 71 points while everything seems to be right!
using System;
using System.Collections.Generic;
using System.Linq;
namespace Quera {
public static class Program {
public static void Main() {
var input = GetInput();
var validChars = input.ValidCode.ToCharArray().Distinct();
var validations = input.Codes.Select(code => code.IsCodeValid(validChars));
foreach (var isValid in validations) {
Console.WriteLine(isValid ? "Yes" : "No");
}
}
private static bool IsCodeValid(this string code, IEnumerable<char> validChars) =>
code.All(validChars.Contains);
private static Input GetInput() {
var firstLine = GetInputs<string>(' ');
var n = Convert.ToInt32(firstLine[0]);
return new Input {
ValidCode = firstLine[1],
Codes = GetInputs<string>(n)
};
}
private static List<T> GetInputs<T>(int count) {
var result = new List<T>(count);
for (var i = 0; i < count; i++) {
result.Add((T) Convert.ChangeType(Console.ReadLine(), typeof(T)));
}
return result;
}
private static List<T> GetInputs<T>(char separator) =>
Console.ReadLine()
?.Trim()
.Split(separator)
.Select(item => (T) Convert.ChangeType(item, typeof(T))).ToList();
}
public class Input {
public string ValidCode { get; set; }
public List<string> Codes { get; set; }
}
}
A readme
file should be added to the Templates folder and mention things such as:
در این سوال از شما میخواهیم یک decorator بنویسید که مانند کلید واژه synchronized در جاوا عمل کند.
این دکوراتور باید به گونهای باشه که اگر در بالای تابعی نوشته شد، تردهای مختلف نتوانند به صورت همزمان آن را صدا کنند؛ یعنی با استفاده از یک شی Lock باید کاری کند که در هر زمان فقط یک ترد درون تابع باشد و چند تردی که آن را صدا میکنند به ترتیب اجرا شوند.
سلام میشه سوال مدیریت دارو خانه و ناقل و مدیریت کارکنان را بزارید
The program fails but the exit code is 0 and other programs think it was successful.
For example, although the operation failed in GitHub Action, no error was reported.
It is better to use the Microsoft library for the command line. It has been a good experience in other projects.
Tests 5 and 9 are failed in Quera.
I think I did not understand the meaning of the question correctly.
To find the last commit date, we don't need to get the last commit date of each solution. Just check the solution directory.
Quera question index:
108666
Related Code
using System;
using System.Collections.Generic;
using System.Linq;
namespace Golestan
{
interface IInputType
{
string Type { get; set; }
List<string> Data { get; }
}
class InputType : IInputType
{
public string Type { get; set; }
public List<string> Data { get; }
public InputType(string type, List<string> data)
{
Type = type;
Data = data;
}
}
interface IInput
{
List<IInputType> Commands { get; }
void GetCommands();
}
class Input : IInput
{
public List<IInputType> Commands { get; }
public Input()
{
Commands = new List<IInputType>();
}
public void GetCommands()
{
var notFinished = true;
while (notFinished)
{
var input = Console.ReadLine().Split(' ').ToList();
if (input.Count != 0)
{
var type = input[0];
input.RemoveAt(0);
Commands.Add(new InputType(type, input));
notFinished = type != "end";
}
}
}
}
interface IOutput
{
List<string> Messages { get; }
void Add(string message);
void Print();
}
class Output : IOutput
{
public List<string> Messages { get; }
public Output()
{
Messages = new List<string>();
}
public void Add(string message)
{
Messages.Add(message);
}
public void Print()
{
foreach (var message in Messages)
Console.WriteLine(message);
}
}
// same interfaces
interface IName
{
string Name { get; set; }
}
interface IId
{
string Id { get; set; }
}
interface IField
{
string Field { get; set; }
}
interface IEnteringYear
{
int EnteringYear { get; set; }
}
interface IGrade
{
int Grade { get; }
bool HasMarked { get; }
void UpdateGrade(int grade);
void ResetGrade();
}
interface IStudentGrade : IName, IGrade { }
class StudentGrade : IStudentGrade
{
const int NotMarked = -1;
public string Name { get; set; }
int grade = NotMarked;
public int Grade
{
get { return grade; }
}
public bool HasMarked
{
get { return grade != NotMarked; }
}
public void UpdateGrade(int grade)
{
this.grade = grade;
}
public void ResetGrade()
{
grade = NotMarked;
}
public StudentGrade(string className)
{
Name = className;
}
}
interface IAverage
{
List<int> Grades { get; }
int SumOfGrades { get; }
int GradesCount { get; }
double Average { get; }
}
interface ICommon : IName, IId, IField, IAverage { }
interface IPerson : ICommon
{
List<string> ClassNames { get; }
bool HasClassByName(string name);
}
interface IStudent : IPerson, IEnteringYear
{
void AddClass(string name);
bool HasClass { get; }
bool HasGradedByClassName(string className);
IStudentGrade LastStudentGrade(string className);
bool HasGraded { get; }
}
class Student : IStudent
{
public int EnteringYear { get; set; }
public string Name { get; set; }
public string Id { get; set; }
public string Field { get; set; }
public List<IStudentGrade> StudentGrades { get; }
public List<string> ClassNames
{
get
{
var names = new List<string>();
foreach (var studentGrade in StudentGrades)
names.Add(studentGrade.Name);
return names;
}
}
public List<int> Grades
{
get
{
var names = new List<int>();
foreach (var studentGrade in StudentGrades)
names.Add(studentGrade.Grade);
return names;
}
}
public bool HasClassByName(string className)
{
return ClassNames.Contains(className);
}
public int SumOfGrades
{
get
{
var sum = 0;
foreach (var grade in Grades)
sum += grade;
return sum;
}
}
public int GradesCount
{
get { return Grades.Count; }
}
public bool HasGraded
{
get { return GradesCount != 0; }
}
public double Average
{
get { return HasGraded ? Convert.ToDouble(SumOfGrades / GradesCount) : 0.0; }
}
public void AddClass(string name)
{
StudentGrades.Add(new StudentGrade(name));
}
public bool HasClass
{
get { return StudentGrades.Count != 0; }
}
public bool HasGradedByClassName(string className)
{
var hasClass = HasClassByName(className);
return hasClass && LastStudentGrade(className).HasMarked;
}
public IStudentGrade LastStudentGrade(string className)
{
var studentGrade = StudentGrades.Find(_studentGrade => _studentGrade.Name == className);
return studentGrade;
}
public Student(string name, string identical_num, int entering_year, string field)
{
Name = name;
Id = identical_num;
EnteringYear = entering_year;
Field = field;
StudentGrades = new List<IStudentGrade>();
}
}
interface IProfessor : ICommon
{
List<IClass> Classes { get; }
List<string> ClassNames { get; }
void AddClass(IClass _class);
bool HasClass { get; }
bool HasGradeStudents { get; }
bool HasClassByName(string name);
}
class Professor : IProfessor
{
public string Name { get; set; }
public string Id { get; set; }
public string Field { get; set; }
public List<IClass> Classes { get; }
public void AddClass(IClass _class)
{
Classes.Add(_class);
}
public bool HasClass
{
get { return Classes.Count != 0; }
}
public List<string> ClassNames
{
get
{
var classNames = new List<string>();
foreach (var _class in Classes)
classNames.Add(_class.Name);
return classNames;
}
}
public bool HasClassByName(string name)
{
return ClassNames.Contains(name);
}
public List<int> Grades
{
get
{
var grades = new List<int>();
foreach (var _class in Classes)
grades.Add(_class.SumOfGrades);
return grades;
}
}
public int SumOfGrades
{
get
{
var sum = 0;
foreach (var grade in Grades)
sum += grade;
return sum;
}
}
public int GradesCount
{
get
{
var count = 0;
foreach (var _class in Classes)
count += _class.GradesCount;
return count;
}
}
public bool HasGradeStudents
{
get { return GradesCount != 0; }
}
public double Average
{
get { return HasGradeStudents ? Convert.ToDouble(SumOfGrades / GradesCount) : 0.0; }
}
public Professor(string name, string identical_num, string field)
{
Name = name;
Id = identical_num;
Field = field;
Classes = new List<IClass>();
}
}
interface IClass : ICommon
{
List<IStudent> Students { get; }
List<string> StudentsNames { get; }
List<IStudentGrade> StudentGrades { get; }
IProfessor ProfessorClass { get; set; }
bool HasStudentById(string identical_num);
bool HasProfessor { get; }
bool HasStudent { get; }
bool HasGraded { get; }
int TopMark { get; }
}
class Class : IClass
{
public string Name { get; set; }
public string Id { get; set; }
public string Field { get; set; }
public IProfessor ProfessorClass { get; set; }
public List<IStudent> Students { get; }
List<string> StudentIds
{
get
{
var ids = new List<string>();
foreach (var student in Students)
ids.Add(student.Id);
return ids;
}
}
public List<string> StudentsNames
{
get
{
var ids = new List<string>();
foreach (var student in Students)
ids.Add(student.Name);
return ids;
}
}
public bool HasStudentById(string identical_num)
{
return StudentIds.Contains(identical_num);
}
public bool HasProfessor
{
get { return ProfessorClass != null; }
}
public bool HasStudent
{
get { return Students.Count != 0; }
}
public List<IStudentGrade> StudentGrades
{
get
{
var studentGrades = new List<IStudentGrade>();
foreach (var student in Students)
{
var studentGrade = student.LastStudentGrade(Name);
if (studentGrade != null)
studentGrades.Add(studentGrade);
}
return studentGrades;
}
}
public List<int> Grades
{
get
{
var grades = new List<int>();
foreach (var studentGrade in StudentGrades)
if (studentGrade.HasMarked)
grades.Add(studentGrade.Grade);
return grades;
}
}
public int SumOfGrades
{
get
{
var sum = 0;
foreach (var grade in Grades)
sum += grade;
return sum;
}
}
public int GradesCount
{
get { return Grades.Count; }
}
public bool HasGraded
{
get { return GradesCount != 0; }
}
public double Average
{
get { return HasGraded ? Convert.ToDouble(SumOfGrades / GradesCount) : 0.0; }
}
public int TopMark
{
get
{
var sortedStudentGrades = new List<int>(Grades);
sortedStudentGrades.Sort();
sortedStudentGrades.Reverse();
return sortedStudentGrades[0];
}
}
public Class(string name, string class_id, string field)
{
Name = name;
Id = class_id;
Field = field;
Students = new List<IStudent>();
}
}
/// <summary>
/// high to low sorting
/// </summary>
class AverageComparer : Comparer<IAverage>
{
public override int Compare(IAverage x, IAverage y)
{
var result = 0;
if (x.Average < y.Average)
result = 1;
else if (x.Average > y.Average)
result = -1;
return result;
}
}
/// <summary>
/// low to high sorting
/// </summary>
class EnteringYearComparer : Comparer<IEnteringYear>
{
public override int Compare(IEnteringYear x, IEnteringYear y)
{
var result = 0;
if (x.EnteringYear < y.EnteringYear)
result = -1;
else if (x.EnteringYear > y.EnteringYear)
result = 1;
return result;
}
}
// Golestan
class GolestanManager
{
IInput input;
IOutput output;
public List<IStudent> Students { get; }
public List<IProfessor> Professors { get; }
public List<IClass> Classes { get; }
public List<string> StudentIds
{
get
{
var ids = new List<string>();
foreach (var student in Students)
ids.Add(student.Id);
return ids;
}
}
public List<string> ProfessorIds
{
get
{
var ids = new List<string>();
foreach (var professor in Professors)
ids.Add(professor.Id);
return ids;
}
}
public List<string> ClassIds
{
get
{
var ids = new List<string>();
foreach (var _class in Classes)
ids.Add(_class.Id);
return ids;
}
}
public bool HasStudent(string id)
{
return StudentIds.Contains(id);
}
public bool HasProfessor(string id)
{
return ProfessorIds.Contains(id);
}
public bool HasClass(string id)
{
return ClassIds.Contains(id);
}
public bool HasPerson(string id)
{
return HasStudent(id) || HasProfessor(id);
}
// part 1
public string RegisterStudent(IStudent student)
{
if (HasPerson(student.Id))
{
throw new Exception("this identical number previously registered");
}
else
{
Students.Add(student);
return "welcome to golestan";
}
}
public string RegisterProfessor(IProfessor professor)
{
if (HasPerson(professor.Id))
{
throw new Exception("this identical number previously registered");
}
else
{
Professors.Add(professor);
return "welcome to golestan";
}
}
public string MakeClass(IClass _class)
{
if (HasClass(_class.Id))
{
throw new Exception("this class id previously used");
}
else
{
Classes.Add(_class);
return "class added successfully";
}
}
// part 2
public string AddStudentToClass(string identical_num, string class_id)
{
if (HasStudent(identical_num))
{
var student = Students.Find((_student) => _student.Id == identical_num);
if (HasClass(class_id))
{
var _class = Classes.Find((_class_) => _class_.Id == class_id);
if (student.Field == _class.Field)
{
if (_class.HasStudentById(identical_num))
{
throw new Exception("student is already registered");
}
else
{
_class.Students.Add(student);
student.AddClass(_class.Name);
return "student added successfully to the class";
}
}
else
{
throw new Exception("student field is not match");
}
}
else
{
throw new Exception("invalid class");
}
}
else
{
throw new Exception("invalid student");
}
}
public string AddProfessorToClass(string identical_num, string class_id)
{
if (HasProfessor(identical_num))
{
var professor = Professors.Find((_professor) => _professor.Id == identical_num);
if (HasClass(class_id))
{
var _class = Classes.Find((_class_) => _class_.Id == class_id);
if (professor.Field == _class.Field)
{
if (_class.HasProfessor)
{
throw new Exception("this class has a professor");
}
else
{
_class.ProfessorClass = professor;
professor.AddClass(_class);
return "professor added successfully to the class";
}
}
else
{
throw new Exception("professor field is not match");
}
}
else
{
throw new Exception("invalid class");
}
}
else
{
throw new Exception("invalid professor");
}
}
public string StudentStatus(string identical_num)
{
if (HasStudent(identical_num))
{
var student = Students.Find((_student) => _student.Id == identical_num);
var space = student.ClassNames.Count == 0 ? "" : " ";
return $"{student.Name} {student.EnteringYear} {student.Field}{space}{string.Join(" ", student.ClassNames)} ";
}
else
{
throw new Exception("invalid student");
}
}
public string ProfessorStatus(string identical_num)
{
if (HasProfessor(identical_num))
{
var professor = Professors.Find((_professor) => _professor.Id == identical_num);
var space = professor.Classes.Count == 0 ? "" : " ";
return $"{professor.Name} {professor.Field}{space}{string.Join(" ", professor.ClassNames)} ";
}
else
{
throw new Exception("invalid professor");
}
}
public string ClassStatus(string class_id)
{
if (HasClass(class_id))
{
var _class = Classes.Find((_class_) => _class_.Id == class_id);
var professorName = _class.HasProfessor ? _class.ProfessorClass.Name : "None";
var space = _class.Students.Count == 0 ? "" : " ";
return $"{professorName}{space}{string.Join(" ", _class.StudentsNames)} ";
}
else
{
throw new Exception("invalid class");
}
}
// part 3
public string SetFinalMark(
string professor_identical_num,
string student_identical_num,
string class_id,
int mark
)
{
if (HasProfessor(professor_identical_num))
{
var professor = Professors.Find(
(_professor) => _professor.Id == professor_identical_num
);
if (HasStudent(student_identical_num))
{
var student = Students.Find((_student) => _student.Id == student_identical_num);
if (HasClass(class_id))
{
var _class = Classes.Find((_class_) => _class_.Id == class_id);
if (professor.HasClassByName(_class.Name))
{
if (student.HasClassByName(_class.Name))
{
var lastGrade = student.LastStudentGrade(_class.Name);
lastGrade.UpdateGrade(mark);
return "student final mark added or changed";
}
else
{
throw new Exception("student did not registered");
}
}
else
{
throw new Exception("professor class is not match");
}
}
else
{
throw new Exception("invalid class");
}
}
else
{
throw new Exception("invalid student");
}
}
else
{
throw new Exception("invalid professor");
}
}
public string MarkStudent(string identical_num, string class_id)
{
if (HasStudent(identical_num))
{
var student = Students.Find((_student) => _student.Id == identical_num);
if (HasClass(class_id))
{
var _class = Classes.Find((_class_) => _class_.Id == class_id);
if (student.HasClassByName(_class.Name))
{
// if(_class.HasGraded && studentGrade.HasMarked)
// {
// return studentGrade.Grade.ToString();
// }
if (student.HasGradedByClassName(_class.Name))
{
var studentGrade = student.LastStudentGrade(_class.Name);
return studentGrade.Grade.ToString();
}
else
{
throw new Exception("None");
}
}
else
{
throw new Exception("student did not registered");
}
}
else
{
throw new Exception("invalid class");
}
}
else
{
throw new Exception("invalid student");
}
}
public string MarkList(string class_id)
{
if (HasClass(class_id))
{
var _class = Classes.Find((_class_) => _class_.Id == class_id);
if (_class.HasProfessor)
{
if (_class.HasStudent)
{
var grades = new List<string>();
foreach (var studentGrade in _class.StudentGrades)
grades.Add(
studentGrade.HasMarked ? studentGrade.Grade.ToString() : "None"
);
return string.Join(" ", grades);
}
else
{
throw new Exception("no student");
}
}
else
{
throw new Exception("no professor");
}
}
else
{
throw new Exception("invalid class");
}
}
public string AverageMarkProfessor(string identical_num)
{
if (HasProfessor(identical_num))
{
var professor = Professors.Find((_professor) => _professor.Id == identical_num);
if (professor.HasGradeStudents)
{
return string.Format("{0:0.00}", professor.Average);
}
else
{
throw new Exception("None");
}
}
else
{
throw new Exception("invalid professor");
}
}
public string AverageMarkStudent(string identical_num)
{
if (HasStudent(identical_num))
{
var student = Students.Find((_student) => _student.Id == identical_num);
if (student.HasGraded)
{
return string.Format("{0:0.00}", student.Average);
}
else
{
throw new Exception("None");
}
}
else
{
throw new Exception("invalid student");
}
}
public string TopStudent(string field, int entering_year)
{
var sameStudents = new List<IStudent>();
foreach (var student in Students)
if (
student.Field == field
&& student.EnteringYear == entering_year
&& student.HasGraded
)
sameStudents.Add(student);
var count = sameStudents.Count;
if (count == 0)
{
throw new Exception("None");
}
else if (count == 1)
return sameStudents[0].Name;
else
{
var sortedByAverageStudents = new List<IStudent>(sameStudents);
sortedByAverageStudents.Sort(new AverageComparer());
var topAverageStudent = sortedByAverageStudents[0];
var sameAverageStudents = new List<IStudent> { topAverageStudent };
for (int i = 1; i < count; i++)
{
var student = sortedByAverageStudents[i];
if (student.Average == topAverageStudent.Average)
sameAverageStudents.Add(student);
}
var newCount = sameAverageStudents.Count;
if (newCount > 1)
{
sameAverageStudents.Sort(new EnteringYearComparer());
topAverageStudent = sameAverageStudents[0];
}
return topAverageStudent.Name;
// else
// return
}
}
public string TopMark(string class_id)
{
if (HasClass(class_id))
{
var _class = Classes.Find((_class_) => _class_.Id == class_id);
if (_class.HasGraded)
return _class.TopMark.ToString();
else
{
throw new Exception("None");
}
}
else
{
throw new Exception("invalid class");
}
}
public GolestanManager()
{
input = new Input();
output = new Output();
Students = new List<IStudent>();
Professors = new List<IProfessor>();
Classes = new List<IClass>();
}
public void Run()
{
input.GetCommands();
foreach (var command in input.Commands)
{
var data = command.Data;
switch (command.Type)
{
case "register_student":
var register_student_name = data[0];
var register_student_identical_num = data[1];
var register_student_entering_year = Convert.ToInt32(data[2]);
var register_student_field = data[3];
try
{
var student = new Student(
register_student_name,
register_student_identical_num,
register_student_entering_year,
register_student_field
);
var response = RegisterStudent(student);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "register_professor":
var register_professor_name = data[0];
var register_professor_identical_num = data[1];
var register_professor_field = data[2];
try
{
var professor = new Professor(
register_professor_name,
register_professor_identical_num,
register_professor_field
);
var response = RegisterProfessor(professor);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "make_class":
var make_class_name = data[0];
var make_class_class_id = data[1];
var make_class_field = data[2];
try
{
var _class = new Class(
make_class_name,
make_class_class_id,
make_class_field
);
var response = MakeClass(_class);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "add_student":
var add_student_identical_num = data[0];
var add_student_class_id = data[1];
try
{
var response = AddStudentToClass(
add_student_identical_num,
add_student_class_id
);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "add_professor":
var add_professor_identical_num = data[0];
var add_professor_class_id = data[1];
try
{
var response = AddProfessorToClass(
add_professor_identical_num,
add_professor_class_id
);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "student_status":
var student_status_identical_num = data[0];
try
{
var response = StudentStatus(student_status_identical_num);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "professor_status":
var professor_status_identical_num = data[0];
try
{
var response = ProfessorStatus(professor_status_identical_num);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "class_status":
var class_status_class_id = data[0];
try
{
var response = ClassStatus(class_status_class_id);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "set_final_mark":
var set_final_mark_professor_identical_num = data[0];
var set_final_mark_student_identical_num = data[1];
var set_final_mark_class_id = data[2];
var set_final_mark_mark = Convert.ToInt32(data[3]);
try
{
var response = SetFinalMark(
set_final_mark_professor_identical_num,
set_final_mark_student_identical_num,
set_final_mark_class_id,
set_final_mark_mark
);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "mark_student":
var mark_student_identical_num = data[0];
var mark_student_class_id = data[1];
try
{
var response = MarkStudent(
mark_student_identical_num,
mark_student_class_id
);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "mark_list":
var mark_list_class_id = data[0];
try
{
var response = MarkList(mark_list_class_id);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "average_mark_professor":
var average_mark_professor_identical_num = data[0];
try
{
var response = AverageMarkProfessor(
average_mark_professor_identical_num
);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "average_mark_student":
var average_mark_student_identical_num = data[0];
try
{
var response = AverageMarkStudent(average_mark_student_identical_num);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "top_student":
var top_student_field = data[0];
var top_student_entering_year = Convert.ToInt32(data[1]);
try
{
var response = TopStudent(top_student_field, top_student_entering_year);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
case "top_mark":
var top_mark_class_id = data[0];
try
{
var response = TopMark(top_mark_class_id);
output.Add(response);
}
catch (System.Exception e)
{
output.Add(e.Message);
}
break;
default:
break;
}
}
output.Print();
}
}
internal class Program
{
static void Main(string[] args)
{
var golestan = new GolestanManager();
golestan.Run();
}
}
}
```
**Additional Context**
سلام
حل جاوااسکریپتی این سوال 👇
https://quera.org/contest/assignments/50132/problems/171742
رو لطف میکنید بذارید. من هرچقدر تلاش کردم ، خطا میده . در حالی که سوال هم واقعا سادس،
احساس میکنم طریقه ورودی گرفتن یا خروجی دادن رو اشتباه میکنم.
این جواب منه
let num
while (true) {
num = +readline()
if (!num) break
let result = reverseSquare(num)
console.log(result);
}
function reverseSquare(n){
const square = n ** 2
let reverseNum = String(square)
reverseNum = reverseNum.split('').reverse().join('')
return reverseNum
}
Quera question index:
8939
Related Code
`import re
inp = input()
num1, pls, num2, eql, num3 = inp.split()
numhave, numfind, numnotfind = "", "", ""
if num1.contains("#"):
numfind = str(int(num3) - int(num2))
numnotfind = num1
numhave = num2
else:
numfind = str(int(num3) - int(num1))
numnotfind = num2
numhave = num1
x = str(len(numfind) - len(numnotfind) + 1)
numnotfind = numnotfind.replace("#", "\d{" + x + "}")
if re.fullmatch(numnotfind, numfind):
print(inp)
else:
print(-1)`
Additional Context
Quera question index:
https://quera.org/problemset/158165/
Related Code
nums = [] count = int(input()) for i in range(count): nums.append(int(input())) for num in nums: if num <= 1023: print(f"{num}B") continue num /= 1023 if num <= 1023: print(f"{int(num)}KiB") continue num /= 1023 print(f"{int(num)}MiB")
Additional Context
When the user clicks on the solution link (on the main page of GitHub), he/she should see the README in solutoion folder.
https://quera.org/problemset/33034/
چرا برای حل این سوال وقتی من کد اولی رو میدم ۰ میده ولی دومی ۱۰۰ میده (اگر صلاح دونستید میتونید کد دومم رو به کدهای حلیتون اضافه کنید :) )
def coloring(ls):
alent = len(ls)
blent = len(ls[0])
clent = len(ls[0][0])
mls = []
for i in range(alent):
tls1 = []
for j in range(blent):
tls2 = []
for k in range(clent):
if (
(i != 0 and i != alent - 1)
and (j >= 1 and j <= blent - 2)
and (k >= 1 and k <= clent - 2)
):
tls2.append(0)
else:
tls2.append(1)
tls1.append(tls2)
mls.append(tls1)
return mls
def coloring(ls):
alent = len(ls)
blent = len(ls[0])
clent = len(ls[0][0])
for i in range(alent):
for j in range(blent):
for k in range(clent):
if (
(i != 0 and i != alent - 1)
and (j >= 1 and j <= blent - 2)
and (k >= 1 and k <= clent - 2)
):
ls[i][j][k] = 0
else:
ls[i][j][k] = 1
return ls
It is not necessary, but it seems better to use versioning. Also put the changes in the changelog file.
Currently, versioning includes changes in the ReadmeGenerator project and the Templates folder.
Quera question index:
294
Related Code
a = float(input())
b = float(input())
c = float(input())
delta = b**2 - 4*a*c
if a != 0:
if delta < 0:
print("IMPOSSIBLE")
elif delta == 0:
x = - (b / (a * 2))
print("%.3f" % x)
else:
x1 = (-b + math.sqrt(delta)) / (a * 2)
x2 = (-b - math.sqrt(delta)) / (a * 2)
if x1 > x2:
print("%.3f" % x2 + "\n" + "%.3f" % x1)
else:
print("%.3f" % x1 + "\n" + "%.3f" % x2)
elif b != 0:
print("%.3f" % (-c / b))
else:
print("IMPOSSIBLE")
Additional Context
همه رو درست میده جز یدونه حالت
Compiled Successfully
Test 1
ACCEPTED
Test 2
ACCEPTED
Test 3
ACCEPTED
Test 4
ACCEPTED
Test 5
ACCEPTED
Test 6
ACCEPTED
Test 7
ACCEPTED
Test 8
WRONG ANSWER
Test 9
ACCEPTED
Many Iranians search in Farsi, so it is better to have a readme file in Farsi.
In order for Google to index this file, it is better to add a link to it at the beginning or end of the main readme file.
We have to update the readme generator program to update the Persian file as well.
Maybe it is better to create a structure for multilingualism.
Solutions
.readme generator
.master
README.md file and its templatemaster
readme and table)Utility
branch and document in readmeCreate a directory named web
:
Create a shell file for create web template:
How it works:
$solutionsDir/$queraId
There may be additional folders such as .vscode, venv, etc. in the solutions directory.
These folders must be ignored.
``# Support Question
https://github.com/HamidMolareza/QueraProblems/blob/master/Solutions/18310/python3/program.py
سلا م برای این قسمت من راه حل زیر رو زدم و کار کرد و من یک سوال داشتم که راه حل من تمیزتر حساب میشه یا شانسی
s = input()
p = input()
s += s * 50
if p in s:
print("Yes")
else:
print("No")
It is better to save the text of Quera problems.
برای این سوال شما یه راه حل سی شارپ دادید من هم گفتم با یه روش دیگه پایتونش رو بنویسم و براتون بفرستم که اگر صلاح دونستید بفرستید. با تشکر
line1 = input()
line2 = input()
line3 = input()
len_lines = len(line1)
Taxlangs = {}
for i in range(0, len_lines, 5):
new_code = line1[i : i + 5]
count_star = new_code.count("*")
Taxlangs[i] = [count_star]
for i in range(0, len_lines, 5):
new_code = line2[i : i + 5]
count_star = new_code.count("*")
Taxlangs[i] += [count_star]
for i in range(0, len_lines, 5):
new_code = line3[i : i + 5]
count_star = new_code.count("*")
Taxlangs[i] += [count_star]
ans_code = ""
for value in Taxlangs.values():
if value == [5, 1, 1]:
ans_code += "T"
elif value == [1, 3, 2]:
ans_code += "A"
elif value == [2, 1, 2]:
ans_code += "X"
elif value == [4, 3, 2]:
ans_code += "M"
else:
ans_code += "N"
print(ans_code)
See this link.
سوالم حل شد فقط بلد نبودم چطور حذف کنم این بخش رو
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.