POV-Ray : Newsgroups : povray.off-topic : Really epic Server Time
11 Oct 2024 09:20:00 EDT (-0400)
  Really epic (Message 6 to 15 of 55)  
<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Nicolas Alvarez
Subject: Re: Really epic
Date: 14 Feb 2008 10:20:45
Message: <47b45c4d$1@news.povray.org>

> Warp wrote:
> 
>>   What language is that?
> 
> It parses as valid Haskell. I have no idea what in the name of God it 
> actually does...
> 

Well, if you look at it from a distance, it reads "RSA". So that gives 
you a hint.


Post a reply to this message

From: Invisible
Subject: Re: Really epic
Date: 14 Feb 2008 10:21:53
Message: <47b45c91$1@news.povray.org>
>> It parses as valid Haskell. I have no idea what in the name of God it 
>> actually does...
>>
> 
> Well, if you look at it from a distance, it reads "RSA". So that gives 
> you a hint.

Sure. But given that it defines a bunch of functions called "un", "po" 
and so on... uh...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Really epic
Date: 14 Feb 2008 10:30:05
Message: <47b45e7d$1@news.povray.org>

>>> It parses as valid Haskell. I have no idea what in the name of God it 
>>> actually does...
>>>
>>
>> Well, if you look at it from a distance, it reads "RSA". So that gives 
>> you a hint.
> 
> Sure. But given that it defines a bunch of functions called "un", "po" 
> and so on... uh...
> 

It's not obfuscated if it has readable function names.


Post a reply to this message

From: Invisible
Subject: Re: Really epic
Date: 14 Feb 2008 10:35:15
Message: <47b45fb3$1@news.povray.org>
OK, so I had a go at unscrambling this...



cox n = foldr (\x y -> 128 * y + x) 0 n

de n = un (\x -> (x `mod` 128, x `div` 128), (==0)) n

coll = un (\zs -> (take 35 zs, drop 35 zs), (==""))

pe (n,m) x = s (p (n `div` 2, m) x) `mod` m

p (n,m) x = if n==0
               then 1
               else (if even n then pe (n,m) x else po (n,m) x)

po (n,m) x = (x * p (n-1, m) x) `mod` m

un (f,p) n = if p n then [] else (let (a,b) = f n in a : un (f,p) b)

(g,s) = (\x -> x, \x -> x*x)



That last line is the best. I didn't even realise you could *do* that! 
Very odd...

Right, so, let's do some analysis here.

- "g" is the identity function, and "s" is the square function.

- Apparently "un" is a list unfold function. It takes an integer and a 
pair of functions. The second function tells it when to stop unfolding; 
the first one actually does the unfold.

-- "coll" uses "un" to split a text string into blocks of 25 characters. 
So idea why.

-- "cox" appears to be using a list fold to convert a list into a giant 
code number. (Note that it works with arbitrary precision integers.) 
"de" looks like it's trying to do the reverse operation.

- The "p" function appears to be trying to decide whether to call "pe" 
or "po" depending on whether n is odd or even.

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Jim Henderson
Subject: Re: Really epic
Date: 14 Feb 2008 12:18:15
Message: <47b477d7$1@news.povray.org>
On Thu, 14 Feb 2008 13:07:07 -0200, Nicolas Alvarez wrote:

> Invisible escribió:
>> I have no idea whether this is actually executable or whether it does
>> anything interesting, but somebody *clearly* has a lot of free time on
>> their hands....
>> 
>> 
> You haven't seen the International Obfuscated C Code Contest, have you?

Do they still hold that?  I remember examples from the past of things 
like a morse code translator and a source "picture" that was an ASCII 
train.

Jim


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Really epic
Date: 14 Feb 2008 12:20:38
Message: <47b47866$1@news.povray.org>
Jim Henderson escribió:
> On Thu, 14 Feb 2008 13:07:07 -0200, Nicolas Alvarez wrote:
> 
>> Invisible escribió:
>>> I have no idea whether this is actually executable or whether it does
>>> anything interesting, but somebody *clearly* has a lot of free time on
>>> their hands....
>>>
>>>
>> You haven't seen the International Obfuscated C Code Contest, have you?
> 
> Do they still hold that?  I remember examples from the past of things 
> like a morse code translator and a source "picture" that was an ASCII 
> train.
> 

I remember one that read data from stdin, and outputted it reversed 
(last character first). And the sourcecode of the program compiled if 
you reverted its characters.


Post a reply to this message

From: Jim Henderson
Subject: Re: Really epic
Date: 14 Feb 2008 12:50:55
Message: <47b47f7f$1@news.povray.org>
On Thu, 14 Feb 2008 15:20:37 -0200, Nicolas Alvarez wrote:

> Jim Henderson escribió:
>> On Thu, 14 Feb 2008 13:07:07 -0200, Nicolas Alvarez wrote:
>> 
>>> Invisible escribió:
>>>> I have no idea whether this is actually executable or whether it does
>>>> anything interesting, but somebody *clearly* has a lot of free time
>>>> on their hands....
>>>>
>>>>
>>> You haven't seen the International Obfuscated C Code Contest, have
>>> you?
>> 
>> Do they still hold that?  I remember examples from the past of things
>> like a morse code translator and a source "picture" that was an ASCII
>> train.
>> 
>> 
> I remember one that read data from stdin, and outputted it reversed
> (last character first). And the sourcecode of the program compiled if
> you reverted its characters.

I remember a couple that were like that - one that when compiled and was 
fed the source code generated another program (in another language, IIRC) 
that could then be compiled and run to translate the code into a third 
language.

Jim


Post a reply to this message

From: Warp
Subject: Re: Really epic
Date: 14 Feb 2008 14:07:47
Message: <47b49182@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> Warp wrote:

> >   What language is that?

> It parses as valid Haskell.

  I asked because 'let' sounded to me like an assignment, which is not
functional. (In many languages, eg. afaik lisp and scheme, 'let' is an
explicit variable assignment, and an admitted deviation from pure
functionality.)

-- 
                                                          - Warp


Post a reply to this message

From: Orchid XP v7
Subject: Re: Really epic
Date: 14 Feb 2008 14:40:01
Message: <47b49911@news.povray.org>
Warp wrote:

>   I asked because 'let' sounded to me like an assignment, which is not
> functional.

I'm pretty sure you're right about Lisp. But in Haskell, it's not an 
assignment - although it does look like one.

In Haskell, "let" introduced local variables. For example,

   solve2 a b c =
     let det2 = b*b - 4*a*c
         det  = sqrt det2
         a2   = 2*a
     in  [(0-b-det)/a2, (0-b+det)/a2]

Now that looks pretty damn identical to the following JavaScript fragment:

   function solve2(a, b, c)
   {
     var det2 = b*b - 4*a*c;
     var det  = Math.sqrt(det2);
     var a2   = 2*a;
     return Array((0-b-dat)/a2, (0-b+det)/a2));
   }

So what's the difference? Well, let's try this:

   function solve2(a, b, c)
   {
     var det  = Math.sqrt(det2);
     var det2 = b*b - 4*a*c;
     var a2   = 2*a;
     return Array((0-b-dat)/a2, (0-b+det)/a2));
   }

Hmm, that's not going to work properly... However, the corresponding 
Haskell works exactly as before:

   solve2 a b c =
     let det  = sqrt det2
         det2 = b*b - 4*a*c
         a2   = 2*a
     in  [(0-b-det)/a2, (0-b+det)/a2]

So in Haskell, the ordering doesn't matter. But maybe you're not 
convinced yet. OK, well try this:

   foo x y =
     let xs = x : ys
         ys = y : xs
     in  xs

Notice how these definitions are muturally recursive. No matter which 
way round you write this in JavaScript, it won't work properly:

   function foo(x,y)
   {
     var xs = new Node(x, ys);
     var ys = new Node(y, xs);
     return xs;
   }

But in Haskell it works just fine, and returns a circular linked list. 
This works exactly because it's a definition, not an assignment.

(You'll also be unsurprised to hear that you're not allowed to define 
the same name twice in a single let-block. But I wanted to emphasize 
that the difference is much deeper than that.)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: nemesis
Subject: Re: Really epic
Date: 14 Feb 2008 14:50:00
Message: <web.47b49a919e92b6c266f20de80@news.povray.org>
whoa!  Haskell is becoming another Perl or Brainf*ck.


Post a reply to this message

<<< Previous 5 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.