| Bytes | Lang | Time | Link |
|---|---|---|---|
| 004 | Thunno 2 | 230726T110341Z | The Thon |
| 006 | Japt | 210812T132044Z | Shaggy |
| 035 | TIBasic | 221124T004414Z | Youserna |
| 020 | Juby | 221123T205512Z | Jordan |
| 016 | Gol><> | 210811T194335Z | Wheat Wi |
| 004 | Vyxal | 210812T085722Z | emanresu |
| 039 | Factor | 210811T204125Z | chunes |
| 005 | Stax | 210811T031716Z | Razetime |
| 053 | Lua | 210811T025935Z | J. А. de |
| 044 | Python 3 | 160209T133423Z | Erwan |
| 025 | Perl 5 | 160211T203046Z | msh210 |
| 012 | Dyalog APL | 160211T220422Z | Adá |
| 087 | BBC BASIC | 160226T171225Z | Darzzr |
| 006 | Dyalog APL | 160226T172551Z | marinus |
| 035 | jq 1.5 | 160225T105206Z | manatwor |
| nan | Ruby | 160225T091734Z | GregoryN |
| 5753 | beeswax | 160225T000153Z | M L |
| 008 | Seriously | 160225T180224Z | user4594 |
| 040 | Python 2 | 160225T140657Z | seequ |
| nan | Julia | 160209T173205Z | M L |
| 007 | APL | 160225T104718Z | Moris Zu |
| 036 | Groovy | 160225T103820Z | manatwor |
| 045 | Gema | 160225T102832Z | manatwor |
| 020 | Perl 6 | 160209T181151Z | Hotkeys |
| 027 | Haskell | 160210T084921Z | Michael |
| 039 | Retina | 160211T191840Z | randomra |
| 058 | Oracle SQL 11.2 | 160209T133701Z | Jeto |
| 010 | MATL | 160209T151740Z | Luis Men |
| 066 | JS | 160211T111008Z | xem |
| 041 | PHP | 160209T133443Z | aross |
| 059 | R | 160210T214639Z | mnel |
| 054 | Python 2 | 160210T061536Z | intbools |
| 1215 | 𝔼𝕊𝕄𝕚𝕟 | 160210T015424Z | Mama Fun |
| 006 | 05AB1E | 160209T133132Z | Adnan |
| 008 | Pyth | 160209T165455Z | PurkkaKo |
| 012 | Japt | 160209T165251Z | ETHprodu |
| 036 | Bash | 160209T152433Z | r3mainer |
| 058 | JavaScript ES6 | 160209T143758Z | edc65 |
| 010 | Pyth | 160209T143646Z | Maltysen |
| 052 | PowerShell | 160209T142642Z | AdmBorkB |
| 011 | Pyth | 160209T134405Z | Denker |
| 011 | CJam | 160209T124455Z | Martin E |
| 040 | Mathematica | 160209T121421Z | njpipeor |
| 023 | Brachylog | 160209T115505Z | Fatalize |
Thunno 2, 4 bytes
ı1/r
Explanation
ı1/r # Implicit input
ı # Map over [1..input]:
1/ # Divide by 1 (convert to float)
# (1 -> 1.0)
# (10 -> 10.0)
# (1234 -> 1234.0)
r # Reverse this number
# (1.0 -> 0.1)
# (10.0 -> 0.01)
# (1234.0 -> 0.4321)
# Implicit output
Japt, 6 bytes
Outputs an array of strings
õx1 mw
õx1 mw :Implicit input of integer U
õ :Range [1,U]
x1 : Force each to 1 decimal place, converting to a string
m :Map
w : Reverse
TI-Basic, 35 bytes
For(I,1,Ans
Disp sum(seq(fPart(.1int(I/₁₀^(J)))/₁₀^(J),J,0,int(log(I
End
Takes input in Ans.
J-uby, 20 bytes
:+|:*&(S|:~|:+&"0.")
Explanation
:+ | :* & (S | :~ | :+ & "0.")
:+ | # Get range 1..n, then
:* & ( ) # Map with...
S | :~ | # Convert to string then reverse, then
:+ & "0." # Append to "0."
Vyxal, 4 bytes
ƛ²√Ṙ
Outputs as a list of what I think are strings.
ƛ # 1..n mapped to...
²√ # Cast to float with √(x^2)
Ṙ # Reverse
Factor, 39 bytes
[ [1,b] [ "%d.0"sprintf reverse ] map ]
[1,b] [ ... ] mapMap over the range 1..input."%d.0"sprintf reverseString interpolate and reverse.
Python 3, 47 44 bytes
lambda n:[f'{i+1}.0'[::-1]for i in range(n)]
a shorter solution with Python 2
lambda n:['0.'+`i+1`[::-1]for i in range(n)]
Edit: gain 3 bytes using f-string interpolation from python 3.6, now we are even with python 2 solution.
Test case
>>> f(25)
['0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '0.01', '0.11', '0.21', '0.31', '0.41', '0.51', '0.61', '0.71', '0.81', '0.91', '0.02', '0.12', '0.22', '0.32', '0.42', '0.52']
Perl 5, 25 bytes
say'0.'.reverse for 1..<>
Dyalog APL, 12 bytes
{'0.',⌽⍕⍵}¨⍳
Straight-forward: the function { string '0.' before , the reversed ⌽ string-representation ⍕ of the argument ⍵ to the function } for each ¨ of the numbers 1 through n ⍳.
BBC BASIC, 89 88 87 bytes
0T=1:REP.P."0."FNR(STR$T):T=T+1:U.0
1DEFFNR(S$)IFS$="":=""EL.=FNR(MI.S$,2))+LE.S$,1)
Used abbreviations to shorten things as much as possible. Compatible with both Brandy Basic and BASIC 2 on the original machine.
For modern BBC BASICs you could also leave off the line numbers to save two more bytes.
Dyalog APL, 6
⌽¨1⍕¨⍳
This is an anonymous function that takes one argument, i.e.:
⌽¨1⍕¨⍳ 20
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.01 0.11 0.21 0.31 0.41 0.51 0.61 0.71 0.81 0.91
0.02
f←⌽¨1⍕¨⍳
f 20
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.01 0.11 0.21 0.31 0.41 0.51 0.61 0.71 0.81 0.91
0.02
Explanation:
⍳ ⍝ get the integers from 1..n
1⍕¨ ⍝ format each with 1 decimal
⌽¨ ⍝ reverse each string
jq 1.5, 40 35 characters
(34 characters code + 1 character command line option.)
range(.)|"\(.+1).0"/""|reverse|add
Sample run:
bash-4.3$ jq -r 'range(.)|"\(.+1).0"/""|reverse|add' <<< 12
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.01
0.11
0.21
On-line test (Passing -r through URL is not supported – check Raw Output yourself.)
The same with links to documentation:
range(.) | "\(. + 1).0" / "" | reverse | add
As a more readable alternative, the above could be also written like this (on-line):
range(.) | . + 1 | tostring | . + ".0" | split("") | reverse | join("")
Ruby, 46 45 40 bytes
->n{(1..n).map{|i|puts"#{i}.0".reverse}}
I'm new to golfing so any tips would be helpful :)
beeswax, 57 53 bytes
Working on the binary digit output problem for rosettacode I noticed that I could use the same short division algorithm for the van der Corput sequence, just using division and modulo by 10 instead of 2. The output is reversed in both cases.
Golfed down by 4 bytes, by mirroring the code:
`.0` XfE@~@L#;
{ %X<#dP@T~P9_
q<# N
>:'bg?b
Hexagonal prettyprint, for easier orientation:
` . 0 ` X f E @ ~ @ L # ;
{ % X < # d P @ T ~ P 9 _
q < # N
> : ' b g ? b
Explanation of one cycle through the program, using the original code:
;#L@~@EfX `0.`
_9P~T@Pb#>X% {
N #>p
d?gd':<
lstack gstack
_9P [0,0,10]• create bee, set top to 10
~T [0,10,n]• flip top and 2nd, enter n
@P [n,10,1]• flip top and 3rd, increment top
b redirect to upper left
[n,10,1]• E [n,10,1]• (2)clone bee in horizontal direction
flip lstack 1st/3rd [1,10,n]• @ f [n,10,1]• [1]• push lstack top on gstack
flip lstack 1st/2nd [1,n,10]• ~ X clone bee in all directions
flip 1st/3rd [10,n,1]• @ `0.` print "0." to STDOUT
skip if 1st>2nd [10,n,1]• L > (1)redirect
if 1st<2nd, del. bee # X clone bee in all directions
(if 1st>2nd, terminate program) ; % { [n,10,1]• 1st=1st%2nd, output lstack 1st to STDOUT
>p redirect
< redirect
: [n,10,0]• 1st=1st/2nd
' skip next instr. if 1st=0
d redirect to upper right, loop back to (1)
g [n,10,1] [1]• push gstack top on lstack 1st
d? []• pop gstack, redirect to upper right
N print newline to STDOUT
P [n,10,2] increment lstack 1st
E looped back to (2)
Example:
julia> beeswax("vandercorput.bswx",0,0.0,Int(20000))
i300
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.01
0.11
0.21
0.31
0.41
.
.
.
0.492
0.592
0.692
0.792
0.892
0.992
0.003
Program finished!
Seriously, 8 bytes
,R`K$R`M
Explanation:
,R`K$R`M
,R range(1, input()+1)
` `M map:
K ceil (cast int to float; L would also work for floor)
$R stringify and reverse
Python 2, 40 bytes
lambda n:[`i+1.`[::-1]for i in range(n)]
Example:
>>> f=lambda n:[`i+1.`[::-1]for i in range(n)]
>>> f(30)
['0.1', '0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '0.01', '0.11', '0.21', '0.31', '0.41', '0.51', '0.61', '0.71', '0.81', '0.91', '0.02', '0.12', '0.22', '0.32', '0.42', '0.52', '0.62', '0.72', '0.82', '0.92', '0.03']
Algebraic solving:
corput(x) = reversed(str(float(x+1)))
= reversed(str(x+1.))
= str(x+1.)[::-1]
= `x+1.`[::-1]
Julia, 50 38 33 31 bytes
I went for a different output format to shorten the code by 12 bytes. The function returns an array of strings now. Shortened by 5 more bytes. Thanks to Alex A. for reminding me of string interpolation and using an anonymous function (getting rid of 2 more bytes).
n->["0."reverse("$i")for i=1:n]
or alternatively
n->[reverse("$(i/1)")for i=1:n]
Test
julia> @time f(10000)
0.002260 seconds (60.01 k allocations: 2.823 MB)
10000-element Array{ASCIIString,1}:
"0.1"
"0.2"
"0.3"
"0.4"
"0.5"
"0.6"
"0.7"
"0.8"
"0.9"
"0.01"
"0.11"
"0.21"
"0.31"
"0.41"
"0.51"
"0.61"
"0.71"
"0.81"
"0.91"
"0.02"
"0.12"
"0.22"
"0.32"
⋮
"0.8799"
"0.9799"
"0.0899"
"0.1899"
"0.2899"
"0.3899"
"0.4899"
"0.5899"
"0.6899"
"0.7899"
"0.8899"
"0.9899"
"0.0999"
"0.1999"
"0.2999"
"0.3999"
"0.4999"
"0.5999"
"0.6999"
"0.7999"
"0.8999"
"0.9999"
"0.00001"
APL, 7
⌽⍎⌽1⍕⍳⎕
Explanation:
⍳⎕ creates a vector of numbers from 1 to user input
1⍕⍳⎕ formats these numbers like ##.0
⌽ inverts the whole string
⌽⍎ transforms back to numbers and inverts order
Groovy, 36 characters
{(1..it).collect{"$it.0".reverse()}}
Sample run:
groovy:000> ({(1..it).collect{"$it.0".reverse()}})(12)
===> [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.01, 0.11, 0.21]
Gema, 45 characters
*=@set{i;0}@repeat{*;@incr{i}0.@reverse{$i} }
Sample run:
bash-4.3$ gema '*=@set{i;0}@repeat{*;@incr{i}0.@reverse{$i} }' <<< 12
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.01 0.11 0.21
Perl 6, 24 22 20 bytes
{"0."X~(^$_)».flip}
Thanks Aleks-Daniel Jakimenko-A. for yet another two bytes
old version
{("0."~.flip for ^$_)}
# Alternate below, same byte count
{map ^$_: "0."~*.flip}
EDIT: Thanks raiph for extra 2 bytes
usage
> my &f = {"0."X~(^$_)».flip}
-> ;; $_? is raw { #`(Block|333498568) ... }
> f(25)
(0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.01 0.11 0.21 0.31 0.41 0.51 0.61 0.71 0.81 0.91 0.02 0.12 0.22 0.32 0.42)
Haskell, 36, 27 bytes
f n=reverse.show<$>[1.0..n]
Two bytes saved by nimi and an additional 7 by Lynn.
Oracle SQL 11.2, 64 62 58 bytes
SELECT REVERSE(LEVEL||'.0')FROM DUAL CONNECT BY LEVEL<=:1;
Old version
SELECT '0.'||REVERSE(TRIM(LEVEL))FROM DUAL CONNECT BY LEVEL<=:1;
Concatenating '' to a number casts it to a string. It is 2 bytes shorter than using TRIM(), which is shorter than TO_CHAR().
Since concatenating a string to a NUMBER results in a string, it is possible to use that string to manage the '0.' part of the result.
MATL, 10 bytes
:"'0.'@VPh
: % implicit input. Generate vector [1,2,...,input]
" % for each
'0.' % push string '0.'
@ % push loop variable (that is, 1,2,3,... in each iteration)
V % convert to string
P % reverse
h % concatenate horizontally
% implicit end of loop
% implicit display of all stack contents
JS, 66
T=101; // set T to the number of iterations wanted
for(o=[],i=0;i<T;i++)o[i]="0."+(""+i).split("").reverse().join("") // 66b
Output is the array called "o"
PHP, 45 41 bytes
for(;$i++<$argv[1];)echo strrev(",$i.0");
Takes the input argument from CLI. Run like this:
php -r 'for(;$i++<$argv[1];)echo strrev(",$i.0");' 100
- Saved 3 bytes by concatenating the string before reversing
R, 59 Bytes
example(strsplit);cat(strReverse(sprintf('%s.0',1:scan())))
explanation
example(strsplit) creates the function strReverse (then it should be obvious)
Using IRanges::reverse, this could be golfed to 47 bytes
cat(IRanges::reverse(sprintf('%s.0',1:scan())))
Python 2, 54 Bytes
def f(i):
for i in range(1,i):print("."+str(i)[::-1])
Explanation:
Iterate through the set [1,input) and appends the reversed i to ..
Still an be golfed more.
𝔼𝕊𝕄𝕚𝕟, 12 chars / 15 bytes
⩤⁽1ï⒨ß)Ė⍞.0ᴙ
It's... okay.
Explanation
⩤⁽1ï⒨ creates a range [1,ï] to map over, ß) converts mapitem (number) to string, Ė⍞.0 concats .0 to the end, and ᴙ reverses the whole string.
05AB1E, 6 bytes
Code:
>GNÞR,
Explanation:
> # Increment, pushes input + 1
G # For N in range(1, input + 1):
N # Push N
Þ # Convert to double, which appends `.0` at the end of an integer
R # Reverse top of the stack
, # Pop and print with a newline
Uses CP-1252 encoding.
Pyth, 8 bytes
m_`cd1SQ
This is really just a combination of this and this answer. Therefore I'm making it a community wiki.
Japt, 12 bytes
Uò1 ®+".0" w
How it works
// Implicit: U = input integer
Uò1 ® // Create the inclusive range [1..U], and map each item Z to:
+".0" w // Z + ".0", reversed.
// Implicit: output last expression
Bash, 36 bytes
for i in `seq $1`;do rev<<<$i.0;done
Takes a number as a command line argument, and outputs each term on a separate line. For example:
$ ./vdc.sh 12
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.01
0.11
0.21
JavaScript (ES6), 58
An anonymous function returning a string with comma separated values
n=>[...[...Array(n)].map(_=>n--+'.0')+''].reverse().join``
TEST
f=n=>[...[...Array(n)].map(_=>n--+'.0')+''].reverse().join``
function test() { R.textContent = f(+I.value) }
test()
N:<input id=I type=number value=20 oninput="test()"><br><pre id=R></pre>
PowerShell, 52 bytes
while($a++-$args[0]){"0."+-join"$a"["$a".Length..0]}
A little longer than I'd like, but uses a couple of neat tricks.
The while loop is obvious, but the conditional is a little tricky - we have $a (which starts as $null when first referenced) and then subtract our input number $args[0]. In PowerShell, math operations on $null treat it as zero, so for input 20 for example this will result in -20. Since any non-zero number is $true, the loop conditional will be $true right up until $a equals our input number (at which point the subtraction will equal 0 or $false). The trick comes from the post-increment ++, which doesn't execute until after the subtraction is calculated, so handling input of 1 will correctly output 0.1 and then stop the loop on the next iteration.
Each time in the loop, we just create a string literal which gets left on the pipeline and output accordingly. We construct this from "0." concatenated with the result of the unary -join operator that has acted on the char-array created from taking the string "$a" backwards (by indexing via the range "$a".length..0).
Test Runs
PS C:\Tools\Scripts\golfing> .\van-der-corput-sequence.ps1 1
0.1
PS C:\Tools\Scripts\golfing> .\van-der-corput-sequence.ps1 20
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
0.01
0.11
0.21
0.31
0.41
0.51
0.61
0.71
0.81
0.91
0.02
Pyth, 11 bytes
m+"0."_`dSQ
Explanation
m+"0."_`dSQ # Q = input m SQ # Map the range(1,Q) to... + # ...the concatenation of: "0."_`d # "0." and the reversed element
CJam, 14 11 bytes
Thanks to Sp3000 for saving 3 bytes.
ri{)d`W%S}/
Explanation
ri e# Read input and convert to integer N.
{ e# For each i from 0 to N-1...
) e# Increment.
d e# Convert to double.
` e# Get string representation (which ends in ".0").
W% e# Reverse.
S e# Push a space.
}/
Mathematica, 40 bytes
"0."<>StringReverse@ToString@#&~Array~#&
Test case
%[20]
(* {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.01,0.11,0.21,0.31,0.41,0.51,0.61,0.71,0.81,0.91,0.02} *)
Brachylog, 23 bytes
:0re:""rcr:"0."rcw,@Sw\
This takes a number as input and outputs the result to STDOUT, separated by spaces.
Fairly straightforward. Unfortunately we have to concatenate the number with an empty string to convert this number to a string (:""rc), because there is no built-in conversion predicate yet.
The conversion to string is necessary, because if we reverse the digits of the number, then the leading zeros (e.g. 10 becomes 01) would be lost.