Login
|
Signup
langref.org
-
python
,
clojure
, and
erlang
add..
all
cpp
csharp
fantom
fsharp
go
groovy
haskell
java
ocaml
perl
php
ruby
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Numbers
Output
Right Space pad a number
Given the number 1024 right pad it to 6 characters
"1024 "
python
"%-6s" % 1024
"%-6s" % 1024
python
str(1024).rjust(6)
str(1024).rjust(6)
python
2.6 or later
'{0: <6}'.format(1024)
'{0: <6}'.format(1024)
clojure
(let [s (str 1024)
l (count s)]
(str s (reduce str (repeat (- 6 l) " "))))
(let [s (str 1024)
l (count s)]
(str s (reduce str (repeat (- 6 l) " "))))
erlang
Formatted = io_lib:format("~-6B", [1024]),
-module(rightspace).
-export([start/0]).
start() ->
Formatted = io_lib:format("~-6B", [1024]),
io:format("~s~n", [Formatted]).
erlang
io:format("~-6B~n", [1024]).
-module(rightspace).
-export([start/0]).
start() ->
io:format("~-6B~n", [1024]).
Submit a new solution for
python
,
clojure
, or
erlang
There are 26 other solutions in
additional
languages (
cpp
,
csharp
,
fantom
,
fsharp
...)