A generic term meaning the process by which text transformed into a more 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.
4
votes
1answer
31 views
Format an Unsigned Byte to a Three ASCII Digits
I'm working on a game for the Atari VCS and have been dusting off my 30+ year old skills in writing MOS 6502 assembly language.
The VCS runs at 1.19 MHz and is based on a MOS 6507 chip with some ...
5
votes
1answer
52 views
C program for whitespace normalization
I have made a beginner program using C that uses file handling and formats the given file. Formatting includes removing trailing blank spaces, replacing one or more blanks by a single blank and also ...
3
votes
3answers
199 views
Transforming tuple with (int month, int year) in string “mm/yyyy”
I would like to improve the following code:
...
4
votes
1answer
63 views
Print fragment of multiplication table
I am learning Python online on Stepik platform, and unfortunately I don't have any opportunity to get reviews from the tutor. The platform only checks the correctness of the answer that my program ...
1
vote
1answer
51 views
Generating a sequence number based on last item of a list
I wrote this method in order to generate a sequence number based on a specific pattern:
...
8
votes
2answers
112 views
entab program which replaces 4 spaces with a tab
I wrote an entab program which needs to replace every \$n\$ spaces with 1 tab. I picked \$n\$ to be 4, so every 4 spaces should be 1 tab. I have a feeling that my code is far too complicated than it ...
2
votes
1answer
65 views
JSON pretty print
Here is my simple program to pretty print a JSON object. I'm looking for advice of better pretty print solutions, functional bugs, code style and algorithm time/space complexity improvements.
BTW, I ...
1
vote
2answers
81 views
13
votes
6answers
806 views
Format RGB Long as hex string in VB6
This is how I convert e.g. RGB(255, 0, 0) (where red is stored in the least significant byte of a Long) to a 6-digit hex string <...
5
votes
1answer
63 views
Converting a 12h clock to 24h clock
I started picking up Rust on my free time, and I'm curious about what style errors have I made and where should I improve as a programmer.
The problem is from HackerRank and very simple: there is a ...
7
votes
3answers
95 views
6
votes
2answers
109 views
Formatting a phone number as groups of 3 digits, with no lone digits
I have a method that takes a String and returns the phone number in certain format. It will return the numbers with dash ("-") in every 3 digits and at least keep 2 digits together. For example, it ...
7
votes
2answers
127 views
Justify text from a file using a LaTeX method
I wrote a bit of code that takes a file, justifies the text and writes to another file.
It uses a DP approach to minimise a badness metric, which is the amount of under or overshoot of the line ...
4
votes
1answer
109 views
ISO 8601 dates & times format into a more human readable format
I wrote from the ground up this small piece of code which transforms dates and times formatted in ISO 8601 format into a more human readable format, client-side. The main goal is that you can create ...
1
vote
1answer
52 views
Python program for testing the Collatz Conjecture
This is a simple program to test if integers will follow an interesting, improvable statement that if disproven, calls for a bravo.
But, ignoring the pretentious poetry, this code allows the user to ...
2
votes
2answers
66 views
Printing log messages with varying length fit into screen width
I'm writing a simple sanity tool for a simple USB driver.
The customer is directly facing the output so I have to care about how it looks.
The log messages that I need to print are varying length, ...
4
votes
1answer
102 views
Efficiently creating a list of formatted hex values
My background is in C, and I'm finally learning this new-fangled "Python" that all the cool kids are talking about.
I want to create a list of formatted hexadecimal values like so:
...
1
vote
2answers
80 views
Concatenate strings (originally binary) in 8-character chunks, 2 per row
Here is the code I would like reviewed:
...
3
votes
1answer
42 views
Mad Libs using recursive IO for user input
I'm writing my first small programs in Haskell and still getting a feel for the syntax and idioms. I've written this Mad Libs implementation using recursive IO. I've used IO actions throughout and I'm ...
2
votes
4answers
49 views
Displaying nested arithmetic expressions as a string using Scala pattern matching
I am learning the concepts of pattern matching in Scala. Following is an exercise for the same. The task is to define a show function that outputs an expression as ...
1
vote
1answer
32 views
Prettifying PHP's Exception stacktraces
I have always disliked the way PHP printed stacktraces, coming from a Java world. So I decided to implement my own ExceptionFormatter, a class that will format ...
4
votes
2answers
86 views
Create and print a tic-tac-toe board
Write a program by creating an array of 9 integers that represent the
positions in the tic-tac-toe board. Once the array is created, assign
values to the board and print the contents of the board ...
0
votes
1answer
48 views
Displaying a timetable
The following code displays a Timetable, but the code needs too long finish the whole process.
...
14
votes
2answers
161 views
Python ASCII-Art Table
As a part of a console utilities module, I created a function that takes a table in the form of an array of arrays, and generates an ASCII table with the given contents.
I've also added the options ...
2
votes
1answer
39 views
Right justified table printer function
A challenge in the beginner book "Automate the boring stuff":
...
2
votes
1answer
42 views
Comparing XML string with different formats
I need to compare 2 xml strings where the formatting may be different. The approach is to use the XmlWriterSettings to format both strings and compare the formatted ...
-1
votes
1answer
55 views
Construct: (un)dumping bytes to hex
This code is part of the Construct library. Docstrings explain what the code is supposed to do.
...
3
votes
2answers
58 views
5
votes
3answers
96 views
Reverse input program in C99
I am writing simple program to reverse its input and output the reversed version. I came up with this code. So how can I improve it? Something tells me that ...
2
votes
2answers
67 views
Spaces-to-tabs converter, updated version
I recently posted Spaces To Tabs Converter but it had lots of bugs, so I rewrote the code. I wanted to ask, is it good code? I didn't find any bugs.
...
3
votes
0answers
34 views
Recursively list files in provided directory in the style of `npm ls`
I've written a small CLI node program to list the contents of a directory with an output similar to that provided by npm ls but listing both files and directories, ...
1
vote
1answer
63 views
Spaces to tabs converter
I wrote a program to convert spaces to tabs. If there are 4 spaces it should convert them to tab. Please let me know how to improve it.
...
5
votes
1answer
67 views
Integer-to-ASCII algorithm (x86 assembly)
This is my best effort at converting a 32 bit integer in EAX, to an 8 character ascii string (result in RDI). It will work ...
3
votes
0answers
41 views
Formatting XML strings in JavaScript for readability
I've created a vanilla JS function to indent XML strings so they can be more easily read. It uses some pretty nasty regex...yes, I know it's a cardinal sin for XML/HTML, but it works. For instance, ...
7
votes
0answers
58 views
A Version 4 UUID Implementation
I've been toying around with writing a decentralized, P2P application in REBOL 2, and one of the things I need to do is generate a universally unique identifier for users. I have written a function ...
0
votes
1answer
36 views
colorprint - part 2
This is a followup of the last review to comply with meta's rules.
In the last, I posted a small library called colorprint and got some helpful pointers from chux ...
3
votes
1answer
29 views
colorprint - An ANSI Escape sequence console writer mini-library
I wrote this a long time ago. I came back to it and decided to clean it up a little.
It uses the preprocessor and C99 anon structs to make a flexible python-like ...
6
votes
3answers
410 views
Wrapping single line string to multiple lines with specific length
Problem
A single line should be separated by Environment.NewLine so that each row has a length of columns (expect for the last ...
1
vote
3answers
83 views
Haskell function to format a floating-point number with some precision
I have not yet developed a satisfying coding style in Haskell. In the code snippet below, there is a lot wrong to my taste:
Helper functions which should be local to ...
3
votes
1answer
51 views
Using a MutationObserver to reformat numbers in the user's locale
I mostly just want to make sure I've understood the specs correctly with this code, but here goes:
...
5
votes
1answer
92 views
Create monthly calendar with number of days and offset (day of week) as user input
I am taking a beginning programming class and have been given the assignment to create a calendar as described in the title. Per the assignment the user entering offset of 0 will begin the calendar ...
5
votes
1answer
35 views
Customized date and time display
A simple reworking of the Bash date command to my own personal liking. Possibly a rather trivial task; I just wanted the date and time to be in the form of:
...
4
votes
3answers
107 views
Convert length of time to appropriate unit
I have a time, in seconds, which has the possibility to be very large. I wish to convert said time into the "appropriate" rounded, readable format.
I already have code which achieves this, however it'...
4
votes
2answers
276 views
Output two columns
Output formatting:
Input Format
Every line of input will contain a String followed by an integer.
Each String will have a maximum of 10 alphabetic characters, and each integer will be in the ...
3
votes
2answers
136 views
Formatting seconds as days hours minutes seconds
I have the below and it gives me the desired output (ie; 1 day 12:05:33) but it looks overly complicated, is there a more straight forward way of doing this with the least amount of string ...
3
votes
1answer
81 views
Formatting a phone number
I have a program that will format a phone number in this format: (###)###-####
...
9
votes
1answer
192 views
Custom string formatters
Some time ago I was experimenting with an Extendable format provider but I wasn't satisfied with the implementation. It didn't feal very SOLID so I've rewritten it to this:
The base class is the <...
9
votes
1answer
219 views
Poor man's f-strings in Python 2.6
f-strings is a new feature in the upcoming python release which basically lets you do this:
>>> s = 'qwerty'
>>> f'{s} {1+2}'
'qwerty 3'
Not ...
6
votes
3answers
81 views
Table printing code using a fluent interface
Let's say you want to display something like:
One Two Three Four
1 2 3 4
And since you hate the idea of predefining the widths of the columns you ...
3
votes
3answers
75 views
Java number formatting in accountant style
I have written a string number formatter. I would like to know if this can be improved and any suggestions with how it's done.
The purpose of this function is to convert a double that has been ...