lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On 2019-06-28 6:03 p.m., Egor Skriptunoff wrote:
On Fri, Jun 28, 2019 at 1:42 PM Xavier Wang wrote:


    Dirk Laurie 于2019年6月28日周五 下午6:22写道:

        I can do 41 bytes.

        x=3 while 1 do x=math.log(C,x)print(x)end

    Thanks! combine with your method, I finally have a 34 bytes solution:
    ::a::x=math.log(C,x)print(x)goto a


Nice!  You are the first person posted a solution.
And I should note that it was Dirk who has solved the mathematical half of the task.

BTW, my own program was longer than 34 bytes because I wasn't aware of the idea of using non-initialized X.


But this is not the end of the story.
There is a bonus task: *"dijkstrify" the code*
Edsger Dijkstra considered "goto" statement harmful.
Rewrite the code preserving its length of 34 bytes but without using "goto".


::a::x=math.log(C,x)print(x)goto a
repeat x=math.log(C,x)until print(x)

uh well, 2 bigger. I tried.