C# program to check an item’s price against available credit

This is a working program to check an item’s price against available credit. I’m trying to simplify this program to the bare min. it would require to run so I’ll be better able to understand each part of the ‘if’ and ‘else’ processes. Is there a simpler way to write a program that accomplishes the task below? I’m new to C#, just trying to figure this stuff out.

Write a program named CheckCredit that prompts users to enter a purchase price for an item. If the value entered is greater than a credit limit of $ 8,000, display you have exceeded the credit limit; otherwise, display Approved.

using static System.Console;  namespace CheckCredit {     class Program     {         static void Main(string[] args)         {             const double CreditCheck = 8000;             string userInput;             double price;              WriteLine("This is a program designed to check an item's price              against your amount of available credit.");             WriteLine("Your credit limit is $  8,000.00.\n");              do             {                 Write("Please type the item's price:");                 userInput = ReadLine();                 if (!double.TryParse(userInput, out _))                 {                     WriteLine("Invalid input, please enter a whole or decimal number.");                     userInput = null;                 }             } while (!double.TryParse(userInput, out price));              if (price > CreditCheck)             {                 WriteLine(" You have exceeded the credit limit", price);             }              else if             (price == CreditCheck)             {                 WriteLine(                 "Approved.(*)\n\n\n"                 +                 "(*) It is exactly your credit limit.");             }             else             {                 WriteLine("Approved.");             }             ReadKey();         }     } } 

Running a git-based program (Bup) on Ubuntu WSL gives error “[Errno 38] Function not implemented”

My Ubuntu setup is running great and things to seem to be working well for other things I’m doing but with one particular program (Bup) which is a backup solution built on top of git.

Running this command gives the errors [Errno 38] Function not implemented

bup save -n InitialCommit /mnt/c/BackupTest 

From basic Googling it seems to be Python or git related and possibly related to multithreaded processing not being supported, but I’m not sure if that is what’s happening here.

How to make best performance to test CPU time of my java program

I am using

ubuntu 18.04 lts.  Intellij Ultimate 2019  Oracle Jdk 1.8.0_211 

I have to test N-Queen solver with java of single-thread.It consumes a lot memory usage.I want to get fastest result of CPU time.

My benchmark machine is
i7 4th gen 3.6ghz with 8 cores.
Ram 8 Gb

I have changed the jvm options in intellij to xmx7000mb.And what ways I need to do to optimize best CPU time ?

Krygen XL program also mixes “Krygen XL

Krygen XL program also mixes "Krygen XL Complete Xtreme Diet Manual" which outfits clients with tips to watching Krygen XL opportunity to be especially thin and fit with Krygen XL assistance of a sound Mediterranean eating routine to help Krygen XL without getting done with harming throbs. It continues running with "Krygen XL Gourmet Diet Cookbook" which contains solid and delightful conditions. Weight watchers will feel fulfilled and fortified in Krygen XL wake of trying specific…

Krygen XL program also mixes "Krygen XL

Why not program our video text terminals/terminal emulators to use something JSON or XML on the backend instead of ANSI escape sequences? [on hold]


Backstory (You can skip)

Awhile back I was developing a console toolkit for displaying debug messages and the like: enter image description here It gives me colour coding, blinking, underlines, bold, italic, etc.

While developing this library, I quickly learned that nesting with ANSI escape sequences was impossible, but assumed that good reasons existed why this was the case.

Of course working with other document types, nesting is more or less trivial:

<foo> the <bar> quick </bar> brown </foo> 

or with JSON

{         type=foo,         text=[                 "the",                 {type=bar, text="quick",},                 "brown",         ] } 

But with Ansi, its something like this:

\e[1m the \e[2m quick \e[1m brown 

giving an output like this:

enter image description here

Basically meaning that you would need to manually track the formatting, and explicitly construct escape sequences to represent all output moving forward. You can obviously make due, but it complicates things. Before complaining about this, I’d like to clarify what reasons exist that would necessitate an escape sequence model over say, a structured document style.

Questions:

Is it purely due to legacy reasons why displaying text on our video terminals is done with ANSI escape sequences and not another framework such as JSON, Yaml, XML, or something else?

Is ANSI escape sequences in video terminal, simply an old technology similar to say, X11 that sticks around solely due to how embedded it is within the computing paradigm?

If not, why don’t developers switch from an escape sequence style to something that would support nesting?

Are there any proposals to do away with ANSI escapes in terminals and replace it with something else?

Why not program our video text terminals/terminal emulators to use something JSON or XML on the backend instead of ANSI escape sequences? [on hold]


Backstory (You can skip)

Awhile back I was developing a console toolkit for displaying debug messages and the like: enter image description here It gives me colour coding, blinking, underlines, bold, italic, etc.

While developing this library, I quickly learned that nesting with ANSI escape sequences was impossible, but assumed that good reasons existed why this was the case.

Of course working with other document types, nesting is more or less trivial:

<foo> the <bar> quick </bar> brown </foo> 

or with JSON

{         type=foo,         text=[                 "the",                 {type=bar, text="quick",},                 "brown",         ] } 

But with Ansi, its something like this:

\e[1m the \e[2m quick \e[1m brown 

giving an output like this:

enter image description here

Basically meaning that you would need to manually track the formatting, and explicitly construct escape sequences to represent all output moving forward. You can obviously make due, but it complicates things. Before complaining about this, I’d like to clarify what reasons exist that would necessitate an escape sequence model over say, a structured document style.

Questions:

Is it purely due to legacy reasons why displaying text on our video terminals is done with ANSI escape sequences and not another framework such as JSON, Yaml, XML, or something else?

Is ANSI escape sequences in video terminal, simply an old technology similar to say, X11 that sticks around solely due to how embedded it is within the computing paradigm?

If not, why don’t developers switch from an escape sequence style to something that would support nesting?

Are there any proposals to do away with ANSI escapes in terminals and replace it with something else?

Python program to find a word ladder transforming “four” to “five”

I saw this Puzzling problem and thought I would try to write a Python program to solve it. The task is to transform “four” to “five”, forming a new four-letter word at each step, replacing one letter at each step, in as few steps as possible.

But turns out I don’t know how to optimize recursion, so I’m posting here for help. I’m mostly just confused on why the code to change the past needs to be at the top of the function, but I would also like advice on how to speed this up in general. Right now it takes about 10x as long for each step up max_depth gets on my computer.

There won’t be any matches until you change max_depth – I didn’t want anyone copy-pasting and lagging out. There should be a solution at depth 5, according to Puzzling. However, my words file doesn’t have the Foud or the word Fous, which that answer uses. Bumping up to max_depth six will take my computer ~10 minutes, which I don’t want to try yet.

def hamming(string1, string2):     assert len(string1) == len(string2)     return sum(char1 != char2 for char1, char2 in zip(string1, string2))  max_depth = 3 start_word = "five" end_word = "four" all_words = open("/usr/share/dict/words", "r").read().lower().splitlines() all_words = list(filter(lambda word: word.isalpha(), all_words)) all_words = list(filter(lambda word: len(word) == len(start_word), all_words))  sequences = []  def search(current_word, past = []):     # Needs to be first to be fast for some reason     past = past[:]     past.append(current_word)      if len(past) > max_depth:         sequences.append(past)         return      for word in all_words:         if hamming(word, current_word) == 1 and word not in past:             search(word, past)  search(start_word)  sequences = [sequence[:sequence.index(end_word) + 1] for sequence in sequences if end_word in sequence]  if len(sequences) == 0:     print("No matches") else:     print(min(sequences, key=len))  

Class timetable generation program in C#

As a “fun” project for school, I am attempting to create a timetable generation program which will automatically assign students and teachers to lessons and those lessons to one of 5 periods within a day, with a maximum value for how many periods can have a lesson assigned to them. It will then calculate the timetable for each person and assign them a timetable based off of the main lesson timetable. In my school, each class of students has two lessons for each subject with a different teacher, and there may be multiple sets of classes depending on the number of students.

The data is all housed in a School class, which does all the initial sorting after being constructed. The constructor takes an array of teachers, students, lessons offered by the school and a preferred class size (there will likely be more variables added as more constraints are added). The list of teachers is provided in a format where each teacher has a name and an array of subjects they can teach. The list of students is provided in a similar format, but instead of the array of subjects they can teach, they have an array of subjects they want to learn.

To sort the data initially after the School has been constructed, the subjects offered by the school are looped through and on each loop the teachers or students are looped through, checking whether they can teach/want to learn the said subject. If they can/do, they are added to the subject’s teacher/student lists, and for each teacher teaching the subject a new lesson is created for them to teach.

To log all this data, I loop through each subject and their teacher/student lists, printing each person to the console. I then loop through the lessons for each subject and print those too.

So, I have all the teachers and students sorted, now what do I do next? I know I need to somehow assign each student to a lesson with a teacher and make sure they don’t clash or anything, but I’m finding the whole task a little daunting and haven’t a clue how to tackle this next bit.

Thanks for any help or advice, you can rest assured you’ll have made this 16-year old’s headache a little more manageable.

My C# console project can be found at https://github.com/jacobcxdev/UTC-TimetableGenerator.

Kubuntu 19.04 don’t open program normally

I have installed the program 4K Video Downloader on Kubuntu 19.04 and the .deb package seems to be OK, as shown on the picture bellow. Image 1

But when I research for the program on Kubuntu menu and click to open it, it simply doesn’t open. On terminal, he opens normally, but the following Qt related messages appear: Image 2

Currently, I use the same program on Ubuntu 19.04 with Gnome and it opens normally. But I wish to migrate to KDE because is so much better. Does anyone know how to fix this kind of problem with Qt? And also: are those errors common on KDE?