Questions tagged [formatting]
For programs that are concerned with producing meaningful or clearer output. A typical example would be the transformation of a decimal into a particular currency format with the correct number of decimal places. (Note that code layout is always in scope for answers, so this tag is not used to indicate perceived issues with that).
586
questions
7
votes
8
answers
2k
views
Convert string name to uppercase
As part of an assignment, I wrote this helper function to convert a specified name to a required format. This function simply converts a string in the format "this-string" to "This ...
6
votes
2
answers
357
views
To markup a C++ std::ostream and delegate formatting of markuped text
I want to create a system that marks up text with tags inserted into a stream. Each tag frames a part of the text, creating a tree-like structure, just as in classic markup languages (HTML, XML...). I ...
3
votes
1
answer
104
views
Listing first 50 big files in directory and print relative paths and sizes
I use this Powershell command to recursively list first 50 big files in current directory and print relative paths and sizes in MiB. :
...
3
votes
1
answer
88
views
Multiline string concatenation
Problem Description
Printing the result of adding two numpy arrays together is very ugly.
Here we will use these numpy arrays as an example:
...
4
votes
2
answers
244
views
This is a simple stopwatch cli application with a few options
My goal of this when I started writing it was simply that it be able to record thousandths of a second in a very performant and accurate way. I'm not sure I have achieved the performance aspect of ...
4
votes
2
answers
136
views
Python (API requests)
I'm somewhat new to python and I'm creating a script that requests to a certain API and then uses the response to populate a ...
3
votes
4
answers
3k
views
Output a Python dictionary as a table with a custom format
I have a Python directory containing some str: int key-value pairs, and my goal is to display that data in a tabular format.
I am unable to use the ...
0
votes
1
answer
248
views
code to format text input to 2 decimal places before computation
I have this piece of code that checks the input of a text box before I compute for my main logic. This looks like it should be refactored but I'm currently stumped how to do so. The only thing that ...
2
votes
2
answers
380
views
Calculate the price of fruits in a trade (for a game)
I'm making a calculator that is supposed to calculate the price of fruits in a trade (for a game)
omg, my code is so bad and messy that its embarrassing. I'm so sorry for anyone who has to look at ...
1
vote
2
answers
124
views
Optimizing - formatting a person's name
I need to take a user's name and format it 'lastName, firstName middleName'. If firstName and middleName are not present then the comma should not be included with lastName. Below is what I came up ...
2
votes
1
answer
171
views
Clean up improperly formatted phone numbers
This is a problem from Exercism here, the goal is to clean up badly formatted phone numbers. The rules are:
If the phone number is less than 10 digits assume that it is a bad number
If the phone ...
0
votes
1
answer
247
views
Short Text Pre-processing
For educational purpose I am preprocessing multiple short texts containing the description of the symptoms of cars fault.
The text is written by humans and is rich in misspelling, capital letters and ...
4
votes
2
answers
1k
views
Logger that writes to text file with std::vformat
This class has a Log function that appends text to a log text file. It takes a format string and a variable amount of arguments, much like a ...
2
votes
1
answer
122
views
Multithreaded segmented Sieve of Eratosthenes
I am fairly new to Rust and thought a good way to practice would be to write a multithreaded segmented Sieve of Eratosthenes. It performs ok (searches ten-billion numbers in about 11 seconds on my ...
2
votes
1
answer
86
views
Build a message string depending on the type of signature of an invoice
The following method was meant to build a message depending on the type of signature of an invoice. It contains some if-else statements and code duplication.
The original method :
...