View Problem

Right Space pad a number

Given the number 1024 right pad it to 6 characters "1024  "
DiskEdit
python
"%-6s" % 1024
DiskEdit
python
str(1024).rjust(6)
DiskEdit
python 2.6 or later
'{0: <6}'.format(1024)
DiskEdit
clojure
(let [s (str 1024)
l (count s)]
(str s (reduce str (repeat (- 6 l) " "))))
ExpandDiskEdit
cpp C++/CLI .NET 2.0
String^ formatted = Convert::ToString(1024)->PadRight(6);
ExpandDiskEdit
cpp C++/CLI .NET 2.0
String^ formatted = String::Format("{0,-6:D}", 1024);
ExpandDiskEdit
cpp
std::printf("%-6d\n", 1024);
ExpandDiskEdit
cpp
std::ostringstream os;
os << std::setw(6) << std::setfill(' ') << std::left << 1024 << std::ends;
std::cout << os.str() << std::endl;
ExpandDiskEdit
cpp
std::cout << boost::format("%|-6|") % 1024 << std::endl;
ExpandDiskEdit
erlang
Formatted = io_lib:format("~-6B", [1024]),
ExpandDiskEdit
erlang
io:format("~-6B~n", [1024]).

Submit a new solution for python, clojure, cpp, or erlang
There are 21 other solutions in additional languages (csharp, fantom, fsharp, go ...)