Skip to main content

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).

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 ...
Linny's user avatar
  • 10.3k
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 ...
Jerome Demantke's user avatar
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. : ...
SebMa's user avatar
  • 131
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: ...
mikeLundquist's user avatar
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 ...
lull's user avatar
  • 43
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 ...
Aldimar J's user avatar
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 ...
David Gard's user avatar
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 ...
jumping_bear's user avatar
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 ...
Lhinger's user avatar
  • 31
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 ...
Samuel's user avatar
  • 21
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 ...
Josh Friedlander's user avatar
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 ...
Andrea Ciufo's user avatar
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 ...
vince.smdt's user avatar
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 ...
knots427's user avatar
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 : ...
l0r3nz4cc10's user avatar

15 30 50 per page
1
2 3 4 5
40