数数乡亲!


30

介绍

听起来可能很奇怪,但从计数1n包含在内,我们还没有一个挑战。

这不是同一回事。那是一个(封闭的)没有充分解释的挑战。
这不是同一回事。那就是无限期地递增计数。

挑战

编写一个程序或函数来打印从1到的每个整数n

规则

  • 你可以得到n任何方式。
  • 您可以假设n它将始终是一个正整数。
  • 您可以n输入任何基数,但应始终以十进制输出。
  • 输出必须用以外的任何字符(或模式)分隔0123456789。允许使用非十进制的前导或尾随字符(例如,当使用数组时,例如[1, 2, 3, 4, 5, 6])。
  • 标准漏洞被拒绝。
  • 我们希望找到每种语言中最短的方法,而不是最短的语言,因此我将不接受任何答案。
  • 您必须在此编辑后更新您的答案,在上次编辑之前发布的答案必须符合有关标准漏洞的更改规则(我不想否认这些漏洞,但是我不想让社区怒吼,所以我否认了)。
  • 您可以使用任何约会后的语言版本(或其他语言)。您不能使用仅用于此挑战的任何语言或语言版本。

奖金

20%

  • 您的程序必须至少能够计数184467440737095516152^64-1)。例如,如果新数据类型是支持大整数的唯一方法,则必须构造它。如果您的语言没有任何方法可以支持最大2 ^ 64-1的大整数,则必须支持该特定语言的上限。

编辑:我已将限制从2^64更改2^64-1为允许更多答案。

编辑:我使2 ^ 64-1规则成为奖励,因为对此挑战没有太大兴趣。如果您的答案支持2 ^ 64-1,则现在可以对其进行编辑以包括奖金。另外,如果答案较短,则可以发布不支持该答案的答案。



“你可以得到n任何方式。” 这是否意味着我们可以假设n将其保存在变量中?
瑕疵的

@flawr 您可以得到 n任何方式。您可以将其保存在变量中,但不得对其进行硬编码。
暴民埃里克


@Ephphatha是的,这个挑战来自我完全是新手的旧时代。
g徒埃里克(Erik the Outgolfer)'17年

Answers:


60

MarioLANG,29个字节

;
)    <
+===="
>:(-[!
=====#

在线尝试!

我知道我的代码令人悲伤或愤怒:



> :(

快乐MarioLANG,46个字节

;
)       <
+======="
>  >((-[!
=:)^====#
 ===

在线尝试!

更快乐的方法:




 :)

非情感MarioLANG,41个字节

;
)     <
+====="
> >(-[!
= "===#
 :!
 =#

在线尝试!


1
最后一小段仍然有情绪,:!;)
cookie

1
@cookie在这种情况下,您可以看到很多东西作为带有幻想的图释,例如=#,,>((-[,等等。此外,不知道为什么,但是显然有一个图释列表Wikipedia页面,其中不包含:!也不我提到的任何一个。
凯文·克鲁伊森

19个字节的灵感来自另一个问题。
多利安

28

Pyth,1个字节

S

正文必须至少30个字符;您输入了14。


2
你这么说?我在争夺冠军头衔!
暴民埃里克(Erik the Outgolfer)

43
那是因为您未能添加说明。没有解释,我们应该如何理解如此复杂的代码?
Luis Mendo

10
没事 这段代码超出了我的理解范围。太长了,我无法理解如此复杂的逻辑结构:-P
Luis Mendo

7
@LuisMendo我知道... orlp必须是一个天才,才能用如此高级的逻辑理解如此冗长的代码。:P
HyperNeutrino '16

1
您仍然是当前的赢家!
暴民埃里克(Erik the Outgolfer)'16年

16

Cjam,5个字节

{,:)}

在线尝试!

这是一个未命名的块,期望n在堆栈上,并在其上留下包含范围的列表[1...n]
通过仅使用构建范围,,然后将每个范围元素递增:)来使范围基于一个来工作。


9
+1代表神秘出现在代码中的笑脸::)
user48538 '16

1
@ zyabin101笑脸是很常见的CJam事件!
西蒙斯(Simmons)

4
@ASimmons结论Cjam很高兴吗?
暴民埃里克

14

Mathematica,5个字节

Range

很简单。


33
当您必须
付费

1
@ΈρικΚωωσταντόπουλος我现在要争辩说,富人更容易,但是您设法以4个字节击败了这个答案;)
Sebb 2016年

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ我知道这是你的评论之后很长一段时间,但你不支付得起的语言,你付出语言。
NoOneIsHere

@NoOneIsHere 提供了通过付款要求对某物拥有所有权的手段。我认为您的意思是订阅是付费而不是一次性付费。
暴民埃里克(Erik the Outgolfer)

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ一次性付款大约有$ 150,但为了继续争论,我们去聊天
NoOneIsHere

14

六角形,19

$@?!{M8.</(=/>').$;

或采用扩展的六角形格式:

  $ @ ?
 ! { M 8
. < / ( =
 / > ' ) 
  . $ ;

非常感谢Martin 基本提出此程序,我只是打高尔夫球使其适合边长为3的六角形。

在线尝试!

我没有Timwi出色的Hexagony相关程序,所以这种解释不会很丰富多彩。相反,您需要阅读大量的文本。那不是很好吗?

无论如何,$如果您认为此程序的放置方向是North在地图上朝上,则IP将从左上角的,向东移动。该$使我们跳过下一条指令,这将是@,这将结束该程序。相反,我们执行?将当前存储器边沿设置为输入编号的操作。现在,我们到达该行的末尾,该行将我们带到六边形的中间行,仍然向东移动。

程序的其余大部分都是循环的。我们从.没有空缺开始。接下来,我们在...呃...六角形中遇到一个叉子。<如果当前存储边为正,该指令使IP向右旋转60度,否则将向左旋转60度。由于我们向东移动,因此要么最终向东南方向前进,要么向东北方向前进。由于输入大于零(因此为正),因此我们总是从东南开始。

接下来,我们点击a >,将我们重定向到东方;这些运算符仅在您击中分叉部分时才分叉。然后我们点击'哪个更改我们正在查看的内存边缘。然后我们点击),这会增加当前内存边的值。由于所有内存边沿都从0开始,因此第一次执行此操作时,我们获得的值为1。接下来,我们跳至第二行到第一行并执行!,打印出我们的数字。然后,我们移动到的另一边,{并存储M的ASCII值乘以10加8(778)。然后,我们跳回到六边形的倒数第二行,并点击/。这导致我们向西北移动。我们越过.中间行,然后走出;在右下角。这将当前内存边缘模块256打印为ASCII。这恰好是换行符。命中'使我们回到具有读取值的第一个边缘。命中/使我们再次向东移动。然后我们点击(哪个值减小。=使我们再次面对正确的方向,以应对未来的内存跳跃。

现在,由于该值为正(除非它为零),所以我们返回六边形的底部。在这里我们命中,.然后我们跳过,;所以什么也没有发生,然后回到循环的开始。当值为零时,我们返回到程序的开头,在该处再次发生相同的事情,但是?找不到另一个数字,我们采用了另一个分支路径。那条路径相对简单:我们点击{以改变内存边缘,但是我们不在乎,然后我们点击@以结束程序。




10

R,13个字节

cat(1:scan())

正文必须至少包含30个字符。


我无法编辑您的答案。
暴民埃里克

@ΈρικΚωωσταντόπουλος您只能以您当前的声誉建议必须被批准的编辑。并且请注意,此处不欢迎编辑代码。如果您有高尔夫建议,请写评论,以便作者在更新解决方案之前对其进行测试。
Denker

@DenkerAffe我的意思是编辑按钮以前是灰色的。
暴民埃里克

1
我希望它即使在调用脚本时也要编写它。
Masclins '16

9
我认为CAT扫描最适合查看骨骼损伤,诊断肺部和胸部问题以及检测癌症,这并不算数。
Stewie Griffin

10

的Javascript 182 177 160 154 139 138 132个字节(有效)

@ShaunH节省了1个字节

n=>{c=[e=0];for(;c.join``!=n;){a=c.length-1;c[a]++;for(;a+1;a--){c[a]+=e;e=0;if(c[a]>9)c[a]=0,e++;}e&&c.unshift(1);alert(c.join``)}}

任意精度来抢救!

因为javascript最多只能计数2 ^ 53-1(感谢@MartinBüttner指出了这一点),所以我需要创建任意精度。它将数据存储在数组中,每个“滴答”都将1添加到最后一个元素,然后经过数组,如果超过9,则将该元素设置为0,并在左侧添加1。

在这里尝试! 注意:按F12键以实际查看结果,因为我不想让您等待文本框。

顺便说一句:我是唯一一个不知道三进制运算符在codegolf中如此有用的人吗?

if(statement)executeSomething();

超过

statement?executeSomething():0;

1个字节

Javascript,28个字节(无效-不能计为2 64

n=>{for(i=0;i++<n;)alert(i)}

2
Yep, you were the only one :P
Erik the Outgolfer

Can the invalid version count up to 2^64-1? If so it's valid thanks to the new rules.
Erik the Outgolfer

@ΈρικΚωνσταντόπουλος No, only up to 2^53-1
Bálint

For if's with no else && can be useful as well, just gotta be careful about cohersion. condition&&action()
Shaun H

1
e?c.unshift(1):0 to e&&c.unshift(1) saves a byte
Shaun H

9

Java 8, 43/69/94 bytes

Crossed out 44 is still a regular 44 -- wait, I didn't cross it out I just replaced it :(

If I can return a LongStream: (43 bytes)

n->java.util.stream.LongStream.range(1,n+1)

This is a lambda for a Function<Long,LongStream>. Technically, I should use rangeClosed instead of range, as I'm cutting off one from my maximum input in this way, but rangeClosed is longer than range.

If I have to print in the function: (69 bytes)

n->java.util.stream.LongStream.range(1,n+1).peek(System.out::println)

This is a lambda for a Consumer<Long>. Technically I'm abusing peek, as it is an intermediate operation, meaning this lambda is technically returning a LongStream like the first example; I should be using forEach instead. Again, golf is not nice code.

Unfortunately, since long's range is a signed 64-bit integer, it does not reach the requested 2^64-1, but merely 2^63-1.

However, Java SE 8 provides functionality to treat longs as if they were unsigned, by calling specific methods on the Long class explicitly. Unfortunately, as Java is still Java, this is rather long-winded, though shorter than the BigInteger version that it replaces. (94 bytes)

n->{for(long i=0;Long.compareUnsigned(i,n)<0;)System.out.println(Long.toUnsignedString(++i));}

This is a Consumer<Long>, as the previous.

And just too long to avoid scroll.


2^64-1 limit changed :D
Erik the Outgolfer

1
Shouldn't the first function be n->java.util.stream.LongStream.range(1,n+1)?
Mego

2
@zyabin101 >.> you saw nothing
CAD97

1
@KevinCruijssen It would help, except the reason for using the BigInteger is that using an int (or even long) for the iterator isn't big enough.
CAD97

1
I was mistaken; J8 provides methods for using long in an unsigned manner, so utilizing those is shorter than the BigInteger approach. (It would not have been had we had to implement our own unsigned long treatment as you had to before J8.)
CAD97



7

Haskell, 10 bytes

f n=[1..n]

Usage example: f 4-> [1,2,3,4].


You must not hardcode n, you must take n.
Erik the Outgolfer

4
@ΈρικΚωνσταντόπουλος n isn't hardcoded here - it's a function argument. Haskell syntax can be strange to people used to C-like syntax.
Mego

@Mego Oh, I was confused with the usage example.
Erik the Outgolfer

7

MarioLANG, 19 bytes

;
)<
+"
:[
(-
>!
=#

Try it online!

Vertical programs are usually more golfable for simple loops in MarioLANG. I'm not sure what the interpreter does when encountering [ inside an elevator, but it seems to terminate the program when the current cell is 0. That's probably a useful trick in general.

Explanation

MarioLANG is a Brainfuck-like language (with an infinite memory tape of arbitrary-precision integers) where the instruction pointer resembles Mario walking and jumping around.

Mario starts in the top left corner and falls downward. ; reads an integer from STDIN and places it in the current memory cell. Now note that = is a ground cell for Mario to walk on, the " and # form an elevator (with # being the start) and ! makes mario stop on the elevator so that he doesn't walk off right away. The > and < set his movement direction. We can see that this gives a simple loop, containing the following code:

)   Move memory pointer one cell right.
+   Increment (initially zero).
:   Print as integer, followed by a space.
(   Move memory pointer one cell left.
-   Decrement.
[   Conditional, see below.

Now normally [ would conditionally make Mario skip the next depending on whether the current cell is zero or not. That is, as long as the counter is non-zero this does nothing. However, it seems that when Mario encounters a [ while riding an elevator and the current cell is 0, the program simply terminates immediately with an error, which means we don't even need to find a way to redirect him correctly.


It terminates the program because it "falls" I think.
Erik the Outgolfer

You chose 56 too?
Erik the Outgolfer

@ΈρικΚωνσταντόπουλος I can't seem to find any place Mario falls to. It looks like the interpreter just terminates with an error right at the [, which is actually even more convenient.
Martin Ender

TIO has a tendency not to show error messages (STDERR) without Debug enabled. It seems it is indeed an error.
Erik the Outgolfer

@ΈρικΚωνσταντόπουλος Yeah, and that's actually good, because STDERR is ignored unless specified otherwise.
Martin Ender

6

Joe - 2 or 6

While you can use the inclusive variant of the range function..

1R

..that's boring! Let's instead take the cumulative sum (\/+) of a table of ones of shape n (1~T).

\/+1~T

Can you provide a link to the language
Downgoat


4

Pyth - 3 2 bytes

1 bytes saved thanks to @DenkerAffe.

Without using the builtin.

hM

Try it online.


hM if you wanna get real fancy :)
Denker

@DenkerAffe oh yeah, true.
Maltysen

You forgot to update your byte count.
Conor O'Brien

@CᴏɴᴏʀO'Bʀɪᴇɴ -.-
Maltysen

@ΈρικΚωνσταντόπουλος orlp already did the builtin answer.
Maltysen


4

dc, 15

?[d1-d1<m]dsmxf

Input read from stdin. This counts down from n, pushing a copy of each numbers to the stack. The stack is then output as one with the f command, so the numbers get printed in the correct ascending order.

Because all the numbers are pushed to the stack, this is highly likely to run out of memory before getting anywhere near 2^64. If this is a problem, then we can do this instead:


dc, 18

?sn0[1+pdln>m]dsmx

Maybe it works with 2^64-1 (the new limit).
Erik the Outgolfer

The first one will run out of memory long before you reach 2^64-1. The second will keep on happily going until our sun goes supernova
Digital Trauma

@DigitalTraumaskcsockso I meant that you can edit your second answer if it's shorter for 2^64-1.
Erik the Outgolfer

@ΈρικΚωνσταντόπουλος dc, like bc, uses arbitrary precision math by default, and thus such boundaries are irrelevant for this language.
Digital Trauma

4

ArnoldC, 415 bytes

IT'S SHOWTIME
HEY CHRISTMAS TREE n
YOU SET US UP 0
GET YOUR ASS TO MARS n
DO IT NOW
I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY
HEY CHRISTMAS TREE x
YOU SET US UP n
STICK AROUND x
GET TO THE CHOPPER x
HERE IS MY INVITATION n
GET DOWN x
GET UP 1
ENOUGH TALK
TALK TO THE HAND x
GET TO THE CHOPPER x
HERE IS MY INVITATION n
GET DOWN x
ENOUGH TALK
CHILL
YOU HAVE BEEN TERMINATED

The only thing of interest is to use n-x (where n is the goal and x the incremented variable) to test the end of the while loop instead of having a dedicated variable, so I end up having n-x and n-(n-x) = x in each loop run

Note: I can only count to 2^31-1. Well I guess the Terminators are not a real danger after all.


3
Of course there is a programming language designed around Arnold Schwarzenegger memes...
Nzall

4

Piet, 64 Codels codelsize 1

With codelsize 20:

codelsize 20

Npiet trace images

First loop:

tracestart

Remaining trace for n=2:

traceend

Notes

  • No Piet answer yet? Let me fix that with my first ever Piet program! This could probably be shorter with better rolls and less pointer manipulation though...

  • The upper supported limit depends on the implementation of the interpreter. It would theoretically be possible to support arbitraryly large numbers with the right interpreter.

  • The delimeter is ETX (Ascii 3), however this cannot be properly displayed in this answer so I'll just leave them out. It works in the console:

enter image description here

Output

Input:  1
Output: 1

Input:  20
Output: 1234567891011121314151617181920

Input:  100
Output: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100

Undefined behaviour:

Input:  -1
Output: 1

Input:  0
Output: 1

Npiet trace for n=2

trace: step 0  (0,0/r,l nR -> 1,0/r,l lB):
action: in(number)
? 2
trace: stack (1 values): 2

trace: step 1  (1,0/r,l lB -> 2,0/r,l nB):
action: push, value 1
trace: stack (2 values): 1 2

trace: step 2  (2,0/r,l nB -> 3,0/r,l nG):
action: duplicate
trace: stack (3 values): 1 1 2

trace: step 3  (3,0/r,l nG -> 4,0/r,l dY):
action: out(number)
1
trace: stack (2 values): 1 2

trace: step 4  (4,0/r,l dY -> 5,0/r,l lY):
action: push, value 1
trace: stack (3 values): 1 1 2

trace: step 5  (5,0/r,l lY -> 6,0/r,l lG):
action: add
trace: stack (2 values): 2 2

trace: step 6  (6,0/r,l lG -> 7,0/r,l lR):
action: duplicate
trace: stack (3 values): 2 2 2

trace: step 7  (7,0/r,l lR -> 10,0/r,l nR):
action: push, value 3
trace: stack (4 values): 3 2 2 2

trace: step 8  (10,0/r,l nR -> 12,0/r,l dR):
action: push, value 2
trace: stack (5 values): 2 3 2 2 2

trace: step 9  (12,0/r,l dR -> 13,0/r,l lB):
action: roll
trace: stack (3 values): 2 2 2

trace: step 10  (13,0/r,l lB -> 14,0/r,l lG):
action: duplicate
trace: stack (4 values): 2 2 2 2

trace: step 11  (14,0/r,l lG -> 15,2/d,r nG):
action: push, value 3
trace: stack (5 values): 3 2 2 2 2

trace: step 12  (15,2/d,r nG -> 15,3/d,r dG):
action: push, value 1
trace: stack (6 values): 1 3 2 2 2 2

trace: step 13  (15,3/d,r dG -> 14,3/l,l lR):
action: roll
trace: stack (4 values): 2 2 2 2

trace: step 14  (14,3/l,l lR -> 13,1/l,r lC):
action: greater
trace: stack (3 values): 0 2 2

trace: step 15  (13,1/l,r lC -> 11,1/l,r nC):
action: push, value 3
trace: stack (4 values): 3 0 2 2

trace: step 16  (11,1/l,r nC -> 10,1/l,r lB):
action: multiply
trace: stack (3 values): 0 2 2

trace: step 17  (10,1/l,r lB -> 9,1/l,r nY):
action: pointer
trace: stack (2 values): 2 2

trace: step 18  (9,1/l,r nY -> 7,1/l,r dY):
action: push, value 2
trace: stack (3 values): 2 2 2

trace: step 19  (7,1/l,r dY -> 6,1/l,r lY):
action: push, value 1
trace: stack (4 values): 1 2 2 2

trace: step 20  (6,1/l,r lY -> 5,1/l,r nM):
action: roll
trace: stack (2 values): 2 2

trace: step 21  (5,1/l,r nM -> 4,1/l,r dM):
action: push, value 3
trace: stack (3 values): 3 2 2

trace: step 22  (4,1/l,r dM -> 3,1/l,r lG):
action: pointer
trace: stack (2 values): 2 2

trace: step 23  (3,1/d,r lG -> 2,3/l,l nG):
action: push, value 3
trace: stack (3 values): 3 2 2

trace: step 24  (2,3/l,l nG -> 2,2/u,r lY):
action: out(char)

trace: stack (2 values): 2 2
trace: white cell(s) crossed - continuing with no command at 2,0...

trace: step 25  (2,2/u,r lY -> 2,0/u,r nB):

trace: step 26  (2,0/u,r nB -> 3,0/r,l nG):
action: duplicate
trace: stack (3 values): 2 2 2

trace: step 27  (3,0/r,l nG -> 4,0/r,l dY):
action: out(number)
2
trace: stack (2 values): 2 2

trace: step 28  (4,0/r,l dY -> 5,0/r,l lY):
action: push, value 1
trace: stack (3 values): 1 2 2

trace: step 29  (5,0/r,l lY -> 6,0/r,l lG):
action: add
trace: stack (2 values): 3 2

trace: step 30  (6,0/r,l lG -> 7,0/r,l lR):
action: duplicate
trace: stack (3 values): 3 3 2

trace: step 31  (7,0/r,l lR -> 10,0/r,l nR):
action: push, value 3
trace: stack (4 values): 3 3 3 2

trace: step 32  (10,0/r,l nR -> 12,0/r,l dR):
action: push, value 2
trace: stack (5 values): 2 3 3 3 2

trace: step 33  (12,0/r,l dR -> 13,0/r,l lB):
action: roll
trace: stack (3 values): 2 3 3

trace: step 34  (13,0/r,l lB -> 14,0/r,l lG):
action: duplicate
trace: stack (4 values): 2 2 3 3

trace: step 35  (14,0/r,l lG -> 15,2/d,r nG):
action: push, value 3
trace: stack (5 values): 3 2 2 3 3

trace: step 36  (15,2/d,r nG -> 15,3/d,r dG):
action: push, value 1
trace: stack (6 values): 1 3 2 2 3 3

trace: step 37  (15,3/d,r dG -> 14,3/l,l lR):
action: roll
trace: stack (4 values): 2 3 2 3

trace: step 38  (14,3/l,l lR -> 13,1/l,r lC):
action: greater
trace: stack (3 values): 1 2 3

trace: step 39  (13,1/l,r lC -> 11,1/l,r nC):
action: push, value 3
trace: stack (4 values): 3 1 2 3

trace: step 40  (11,1/l,r nC -> 10,1/l,r lB):
action: multiply
trace: stack (3 values): 3 2 3

trace: step 41  (10,1/l,r lB -> 9,1/l,r nY):
action: pointer
trace: stack (2 values): 2 3
trace: white cell(s) crossed - continuing with no command at 9,3...

trace: step 42  (9,1/d,r nY -> 9,3/d,l nR):

Does it have null bytes between numbers?
Erik the Outgolfer

@ΈρικΚωνσταντόπουλος what do you mean? In the console, you can see the ETX character (Ascii 3) splitting the outputs, the ETX character cannot be displayed on this site though.
Marv

4

JavaScript (ES6), 77 76 63 59 58 Bytes

n=>{for(s=a=b=0;s!=n;console.log(s=[a]+b))a+=!(b=++b%1e9)}

Takes input n as a string, should support up to 9007199254740991999999999

Explained:

n=>{ //create function, takes n as input
    for( //setup for loop
        s=a=b=0; //init s, a, and b to 0
        s!=n; //before each cycle check if s!=n
        console.log(s=[a]+b) //after each cycle concat a and b into to s and print
    )
        a+=!(b=++b%1e9) //During each cycle set b to (b+1)mod 1e9, if b == 0 and increment a
} //Wrap it all up

Explanation please.
Bálint

2^64-1 is fine I've changed spec.
Erik the Outgolfer

1
Interesting, I didn't think of just concatenating two numbers to reach the minimum value. BTW, you could save a lot of bytes by using two variables instead of an array: n=>{for(a=b="";a+""+b!=n;console.log(a+""+b))++b-1e9||(++a,b=0)}
user81655

Thanks for that @user81655, my brain loves arrays for some reason
Shaun H

1
You can save a byte by changing a+""+b to [a]+b
Bassdrop Cumberwubwubwub

3

GNU bc, 23

n=read()
for(;i++<n;)i

Input read from stdin. bc handles arbitrary precision numbers by default, so the 2^64 max is no problem.


3

Actually, 1 byte

R

Boring builtin is boring. Requires a 64-bit version of Python 3 to get all the way up to 2**64.

Try it online! (due to memory and output length restrictions, the online interpreter can't go very high).

Here's a 5-byte version that doesn't require 64-bit Python 3 and is a little nicer on memory usage:

W;DWX

Try it online! (see above caveats)


@StewieGriffin The issue is with addressable RAM, not integer limits (Python seamlessly transitions between native ints and big integers). I tested it with both 32-bit Python 3 and 64-bit Python 3. 32-bit failed, 64-bit didn't.
Mego

@Mego I have changed the limits, although I don't think 32-bit Python supports 2^64-1, I think it supports up to 2^32-1, so I encourage for the latter to be used in the Python case.
Erik the Outgolfer

Why do you call Seriously Actually?
Erik the Outgolfer

@ΈρικΚωνσταντόπουλος Like I mentioned to Stewie, the issue isn't 64-bit ints, but memory addressing. Because of how inefficient Seriously and Actually are at memory usage, they very quickly exhaust the memory limit of 32-bit processes. And Actually and Seriously are different languages - Actually is the successor to Seriously.
Mego

@Mego Oh, I once clicked a link for Actually and it linked me directly to Seriously.
Erik the Outgolfer

3

Fuzzy-Octo-Guacamole, 7 bytes

^!_[+X]

Explanation:

^ get input to ToS
! set for loop to ToS
_ pop
[ start for loop
+ increment ToS (which aparently happens to be 0)
X print ToS
] end for loop

Also, X works instead of o;, for 7 bytes.
Rɪᴋᴇʀ

Wouldn't that print [n]?
Bald Bantha

rather than n
Bald Bantha

No. : prints the full stack. X is new.
Rɪᴋᴇʀ

Also, another 7 byte solution: ^!$[_;]. $ is range.
Rɪᴋᴇʀ

3

Oration, 31 bytes (non competing)

literally, print range(input())

Is this python with literally, in front of every statement? (Question 2: Pre-dates or post-dates if it's yours? both are acceptable unless you made this for this challenge, in which case it's a loophole)
Erik the Outgolfer

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I believe Oration is by ConorO'Brien. github.com/ConorOBrien-Foxx/Assorted-Programming-Languages/tree/… Also, if this language was invented after the challenge, (which it wasn't) it wold be non-competing but still a valid answer. I'm not a big fan of the "Your language must pre-date the challenge" rule. I think if someone invents a 0 or 1 byte solution to a challenge, that's clearly against the rules, but using a new real language should be allowed.
DJMcMayhem

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ this is what Dr Green Eggs said. I'm actually Easterlyirk's chatbot.
Żáłģó

So no review for you?
NoOneIsHere

@NoOneIsHere what?
Żáłģó

3

QBASIC, 43 bytes

1 INPUT a
2 FOR b=1 TO a
3 PRINT b
4 NEXT b

Do you really need INPUT e;a or INPUT a is enough? I don't see you re-using e.
Erik the Outgolfer

good point, not sure why that was there.
Michelfrancis Bustillos

Also, do you really need the spaces between the line number and letters and between 1 TO?
Erik the Outgolfer

Yes, those are necessary
Michelfrancis Bustillos

What version of QBasic is this? Can you use : between statements instead of a return and a line number? QB4.5 lets me do this: INPUT a: FOR b=1 TO a (\n) ?b:NEXT
steenbergh

3

Cubix, 17 bytes

..U;I0-!@;)wONow!

Try it here

Cubix is a 2D language created by @ETHProductions where the commands are wrapped onto a cube. This program wraps onto a cube with an edge length of 2 as follows.

    . .
    U ;
I 0 - ! @ ; ) w
O N o w ! . . .
    . .
    . .
  • I gets the integer input
  • 0 push 0 to the stack
  • - subtract top items of stack
  • ! if truthy jump the next command @ terminate
  • ; pop the subtraction result from the stack
  • ) increment top of stack
  • w move ip to the right and carry on. This causes it to drop to the next line
  • O output the top of stack as a number
  • N push linefeed (10) to the stack
  • o output a linefeed
  • w move ip to the right and carry on. This causes it to drop to the next face
  • ! because TOS truthy, jump the @ terminate
  • ; pop the linefeed from the stack
  • U uturn to the left onto the - subtraction and resume from there

2

Python 2, 37 33 32 33 bytes

for i in xrange(input()):print-~i

Presumably works up to 2**64 and beyond.

Shot down four bytes thanks to @dieter, and another thanks to @orlp. But apparently, as @Sp3000 found out, range() might have issues with higher values, so the function was changed to xrange(). Note: even xrange() might have issues, at least in 2.7.10.


1
Python 2, to be exact :)
Erik the Outgolfer

33 bytes -> for i in range(input()):print i+1
dieter

2
32 bytes -> for i in range(input()):print-~i
orlp

1
"Presumably works up to 2**64 and beyond." - doubt it in Python 2, but it might with xrange (edit: even xrange might have issues, at least in 2.7.10)
Sp3000

How does -~ work? Edit: I figured it out. Also, nice trick!
Erik the Outgolfer

2

Zsh, 12 bytes

echo {1..$1}

This works because variables are expanded before the braces.


2
I'm not sure you can count up to 2^64 (or even quite a bit less) ?
Olivier Dulac

@OlivierDulac 2^64-1 is fine now.
Erik the Outgolfer

1
zsh's maximum is 2^63 - 1
joeytwiddle

2

V, 11 Bytes

é1@añYpñdd

Since this contains nasty UTF-8 and unprintables, here is a reversible hexdump:

00000000: e931 4061 f159 7001 f164 64              .1@a.Yp..dd

V is an unfinished language I wrote, but this is working as of commit 19. This answer was a little more verbose than I'd like, but that's mostly because V has no knowledge of integers, only strings. So it's a decent answer! This will work up to 2^64, but it will probably take a very long time.

To make my explanation easier to read/write, I will work with this "Human readable form", which is actually how you would type this in vim.

<A-i>1@a<A-q>Yp<C-a><A-q>dd

Explanation:

'Implicit: register "a" == arg 1, and any generated text is printed. 

<A-i>1                       'Insert a single character: "1"
      @a                     ' "a" times, 
        <A-q>       <A-q>    'Repeat the following:
             Yp<C-a>         'Duplicate the line, and increment it
                         dd  'Delete the last line, since we have one too many.

If loopholes are allowed, here's a shorter version that prints 1 to n, but also prints a 0 (8 bytes):

é0@añYp

And in readable form:

<A-i>1@a<A-q>Yp<C-a>

This is shorter because the <A-q> at the end is implicit, so we don't need it if we don't have to delete the last line.


It can take as long as it wants. Glad to see an answer to work with 2^64, especially with an unfinished language. +1
Erik the Outgolfer

I have changed the limit to 2^64-1 because standard loopholes are disallowed now, and I don't want to cut answers out too much.
Erik the Outgolfer
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.