flat assembler
Message board for the users of flat assembler.

Index > Heap > Esoteric Programming Challenges!

Goto page Previous  1, 2, 3 ... 8, 9, 10, 11, 12  Next
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
Pinecone_ wrote:
Ok. I'm pretty sure this is uniform Smile 92 bytes.
Code:
>?<  >>?0^>++:7vv>#<
@1>1v01>1^ v`+6<> .
#>?<>?^#  *! >:!#^_^
^0>0^^v*8<2>#^_$  
\ +*4\<#  ^    
Accept. But it could be 90 bytes if you remove the two spaces after the '$' Wink

BTW:It gives a stack overflow error if you run it continuously by replacing the '@' with a '^'.
Post 07 Sep 2009, 10:37
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
I have just made a generator that uses only one "?".
Code:
>01>:93+`#v_2*\2*v
$  ^         \+<0?<
|   `+39:$<    ^1<
>1+.@    

It also is universal. If you want it to generate random number in range from A to B (both A and B inclusive), replace the "93+" and "+39" sequences with the ones that would push value B-A onto the stack, and the "1" value just before the final "+.@" code with the value of A.
Post 07 Sep 2009, 11:54
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
Tomasz Grysztar wrote:
I have just made a generator that uses only one "?".
Code:
>01>:93+`#v_2*\2*v
$  ^         \+<0?<
|   `+39:$<    ^1<
>1+.@    
Accept.
Post 07 Sep 2009, 12:02
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
Pinecone_ wrote:
Code:
         v
@.+01<       >10+.@
@.+02? <   > ?20+.@
@.+03<       >30+.@
@.+04<       >40+.@
@.+05?<?<?>?>?50+.@
@.+06<       >60+.@
@.+07<       >70+.@
@.+08? <   > ?80+.@
@.+09<       >90+.@
@.+91<       >19+.@
@.+92? < ? > ?29+.@
@.+93<   v   >39+.@
@.+94<   ?   >49+.@    
To see just how much of an effect a simple random walk has on the probability distribution I setup an empirical test on the above code. The code has one place where there are two '?'s that can transfer control to each other on a random basis. After ~2.4 million trials here are the results:
  1. 200479
  2. 199717
  3. 199723
  4. 199832
  5. 200583
  6. 199707
  7. 200440
  8. 199733
  9. 200076
  10. 148876
  11. 150605
  12. 150192
  13. 149739
Post 07 Sep 2009, 15:11
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
You should compare those results with the same test without the random walk.

And nice work on challenge 4 Tomasz.

How bout this revolution: Challenge 4, 57 bytes
Code:
^>0v@.+1$     <
>?1>\1-:!#v_
4^v+*4\*8$<
^ >\2*++:75+`#^_    
A few bytes less than your Tomasz (Yours is 63). Yours looks alot cleaner though.

Edit: What if we update chalenge 3 to say that the same ? cannot be used more than once? That way we can keep both challenge 3 and 4 without 3 becoming pointless by being beaten by 4. Your call revolution.


Last edited by Pinecone_ on 07 Sep 2009, 15:41; edited 1 time in total
Post 07 Sep 2009, 15:34
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
Pinecone_ wrote:
You should compare those results with the same test without the random walk.
~2.6 million trials:
  1. 209534
  2. 210233
  3. 209557
  4. 209881
  5. 210017
  6. 210058
  7. 209842
  8. 209866
  9. 210056
  10. 209202
  11. 209829
  12. 210570
  13. 210082
Post 07 Sep 2009, 15:38
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
Pinecone_ wrote:
How bout this revolution: Challenge 4, 57 bytes
Code:
^>0v@.+1$     <
>?1>\1-:!#v_
4^v+*4\*8$<
^ >\2*++:75+`#^_    
Accept.

BTW: Your interpreter has a bug. I tried my new empirical test with this one and I get stack overflow again. See my post further up on this page for the same problem there also.
Pinecone_ wrote:
Edit: What if we update chalenge 3 to say that the same ? cannot be used more than once? That way we can keep both challenge 3 and 4 without 3 becoming pointless by being beaten by 4. Your call revolution.
Okay.
Post 07 Sep 2009, 15:53
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
revolution wrote:
BTW: Your interpreter has a bug. I tried my new empirical test with this one and I get stack overflow again. See my post further up on this page for the same problem there also.
Are you sure there isn't something being left on the stack in each loop of your test? Also, could you provide the code for your test please?

revolution wrote:
Pinecone_ wrote:
Edit: What if we update chalenge 3 to say that the same ? cannot be used more than once? That way we can keep both challenge 3 and 4 without 3 becoming pointless by being beaten by 4. Your call revolution.
Okay.
In that case.. Here's a cleaned up version of the one i made earlier which was supposed to confuse you (but didn't) Razz 67 bytes.
Code:
v#2\+*4\*8<<|!`+57:++*
v>0v>1v>0v10>
>?<>?<>?<>?^>+.@
^>1^>0^>1^^ 1    


Last edited by Pinecone_ on 07 Sep 2009, 16:16; edited 2 times in total
Post 07 Sep 2009, 16:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
I just now had a look at the code. A few things to note.

I think you need jbe:
Code:
                       Cmp Eax, 255
                        Jle @F
                              Call Instruction_NotImplimented
                             Jmp .Next
                   @@:    


I assume you want to use jle and jge for proper bounds checking?
Code:
        Proc GetInstruction, X, Y
           
            Cmp [X], -1
         Jl .OOB
             Cmp [Y], -1
         Jl .OOB
             
            Cmp [X], SCRIPT_COLUMNS
             Jg .OOB
             Mov Eax, [ScriptLines]
              Cmp [Y], Eax
                Jg .OOB

...

      Proc SetInstruction, X, Y, NewInstruction
           
            Cmp [X], -1
         Jl .Return
          Cmp [Y], -1
         Jl .Return
          
            Cmp [X], SCRIPT_COLUMNS
             Jg .Return
          Mov Eax, [ScriptLines]
              Cmp [Y], Eax
                Jg .Return    
Post 07 Sep 2009, 16:09
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
Pinecone_ wrote:
Also, could you provide the code for your test please?
Code:
>?<  >>?0^>++:7vv>#<
^1>1v01>1^ v`+6<> .
#>?<>?^#  *! >:!#^_^
^0>0^^v*8<2>#^_$
\ +*4\<#  ^    
I just replaced the '@' with a '^', otherwise this is exactly your code from the post above.
Post 07 Sep 2009, 16:13
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
revolution wrote:
I just now had a look at the code. A few things to note.

I think you need jbe:
That has been fixed in the current version, but no note of it was made. There was about 5 minutes where the version you have was avaliable for download. I thought nobody would've noticed.

revolution wrote:
I assume you want to use jle and jge for proper bounds checking?
Thank you. I will update and re-upload in a few minutes.

Edit: The script you mentioned in your above post left something on the stack each loop, but i thought it would be insignifigant and not really needed to pop it off the stack because it would waste 2 bytes and would never be a problem if the @ was left as is, but you changed it to a loop so each loop one more thing was left on the stack.. resulting in a stack overflow Smile here's the fixed version (with an added line feed for your convenience)
Code:
>?<  >>?0^>++:7vv>#<
^1>1v01>1^ v`+6<> . $ 91+,
#>?<>?^#  *! >:!#^_^
^0>0^^v*8<2>#^_$  
\ +*4\<#  ^    
Post 07 Sep 2009, 16:15
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
Pinecone_ wrote:
In that case.. Here's a cleaned up version of the one i made earlier which was supposed to confuse you (but didn't) Razz 67 bytes.
Code:
v#2\+*4\*8<<|!`+57:++*
v>0v>1v>0v10>
>?<>?<>?<>?^>+.@
^>1^>0^>1^^ 1    
Accept.

I think you have the method mastered now.

As for the stack problem, it was my mistake. I somehow missed that extra value on the stack. Also the single '?' version you posted leaves 4 values on the stack I can now get it to run in a loop with 4 pops after printing.
Post 07 Sep 2009, 16:28
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
Your bugfix has been updated and is now avaliable for download. Thanks.
Edit: I uploaded the wrong version of the interpreter before (No idea how...). If you downloaded it between the time this message was posted and the time it was last edited, please go and re-download the "real" update. Sorry everyone.

revolution wrote:
I think you have the method mastered now.
So do I. It was a great challenge though. Got any more? Smile

revolution wrote:
As for the stack problem, it was my mistake. I somehow missed that extra value on the stack.
It's an easy mistake. I had no idea I'd left a value on the stack until you posted saying that making it into a loop caused a stack overflow.

revolution wrote:
Also the single '?' version you posted leaves 4 values on the stack I can now get it to run in a loop with 4 pops after printing.
Doesn't it only leave one?

Edit: It seems to loop fine like this:
Code:
v#2\+*4\*8<<|!`+57:++*
v>0v>1v>0v10>$
>?<>?<>?<>?^>+.91+,
^>1^>0^>1^^ 1    


Last edited by Pinecone_ on 07 Sep 2009, 21:39; edited 1 time in total
Post 07 Sep 2009, 16:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
That doesn't have a single '?', that has 4 '?'s Razz Try the single '?' version.
Post 07 Sep 2009, 16:46
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
Wow, i must be going blind. It's probably all these 3-5AM nights I've been having lately.
Post 07 Sep 2009, 17:01
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Argh, somehow that adding spaces to the end of numbers update completely ruined my C to F conversion.....F to C still works fine.....I'll mess with it later. After I find out why the added space completely ruins it, I'll just have to put an "8," after every number and it will be back to normal.

*FACEPALM*
....1 misaligned ">" was causing the C to F to be off....I don't know how that happened....Ok, time to just throw in some "8,"s(backspaces) and it will be back to good.


Here's the updated Befunge code for anyone too lazy to look through the last page for it.
Requires the latest version of Pinecone_'s interpreter.
Code:
<>:#,_v#:"To C or F?"+55
`"b":~<v"f":_@#`"e":_v#`"c":_@#
      v>`#@_$"F":,55v>$"C":,
v     >:12p55+,902pv>+,:12p502p9&:09-9-1-`   #v_
v  -*48_v#`-1*48:&5< @~,,,,,"-0.4F"_v#!`-9-90:<
v       >:84*1-\`#v_"C5.0-",,,,,~@  >
>*:02g%v          >84*-
0\%g20:_02g/\:"E"`#v_\   >.8,,~@~,,8.<   _v#`-10:,".",8.<    _   v#`\"E"g21/g2
                   >\84*+^           ^*-10< v_v#`\*48:   \*2\+*48<
                     \++19\-1         _v#`0:< >         ^
                                       >                ^
    


It's probably accurate on any whole number from -238609294 to 238609294 for C to F, and from -429496729 to 429496729 for F to C.....lol, who cares if it can handle VERY unrealistically low numbers.

_________________
----> * <---- My star, won HERE
Post 08 Sep 2009, 17:17
View user's profile Send private message Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
Nice work windwakr. I haven't yet done anything that complex in befunge, so i applaud you. I might try writing one in brainfuck over the holidays if i get more bored than normal. Smile
Post 09 Sep 2009, 14:35
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
Size-optimized version of my one-? random number generator:
Code:
>10>\:93+`v
*v +v+39:$_2*\2
>?0^>`#v_1+.@
v>1^   >$    
Post 09 Sep 2009, 15:08
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17269
Location: In your JS exploiting you and your system
revolution
Tomasz Grysztar wrote:
Size-optimized version of my one-? random number generator:
Code:
>10>\:93+`v
*v +v+39:$_2*\2
>?0^>`#v_1+.@
v>1^   >$    
Accept.
Post 09 Sep 2009, 15:16
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
Pinecone_ wrote:
What if we update chalenge 3 to say that the same ? cannot be used more than once? That way we can keep both challenge 3 and 4 without 3 becoming pointless by being beaten by 4. Your call revolution.

As I see it, all the programs we've made so far (including the one that received the star) DO use the same ? more than once. Clearly, if you have this kind of instruction block in your code:
Code:
>?<    

then this ? instruction is the most probably going to be executed more than once.
Post 09 Sep 2009, 15:18
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3 ... 8, 9, 10, 11, 12  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.