flat assembler
Message board for the users of flat assembler.

Index > Heap > Esoteric Programming Challenges!

Goto page Previous  1, 2, 3 ... 7, 8, 9, 10, 11, 12  Next
Author
Thread Post new topic Reply to topic
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Is it a bug that you're interpreter doesn't let you divide negative numbers, but lets you multiply them? The official interpreter handles it fine. This is why my degree converter doesn't handle negatives right.


91+-.~@
Shows "-10"

But
91+-2/.~@
Shows 2147483643



When I multiply:
91+-2*.~@
It shows "-20", like it should.

_________________
----> * <---- My star, won HERE
Post 04 Sep 2009, 19:46
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Pinecone_: my BF interpreter is in Framed Challenger, not a Pure one. Writing it in Pure would be much harder.
Post 04 Sep 2009, 19:55
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
windwakr wrote:
Is it a bug that you're interpreter doesn't let you divide negative numbers, but lets you multiply them? The official interpreter handles it fine. This is why my degree converter doesn't handle negatives right.
Yes. Thanks. [s]I'll fix it probably tonight.[/s] Edit: Didn't happen. Razz Edit #2: Gahh I'm leaving those [s] tags there to show my support for adding [s] tags (strikethrough) to this board. Smile Edit #3: Windwakr provided a bugfix. The fixed version can be downloaded from the befunge interpreter project thread.

Tomasz Grysztar wrote:
Pinecone_: my BF interpreter is in Framed Challenger, not a Pure one. Writing it in Pure would be much harder.
Sorry! Razz I knew that, just wrote the wrong word Razz (in quite a few places)
Post 05 Sep 2009, 05:16
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Pinecone_ wrote:

I also think that i should not accept your solution because (as you said) it does not produce the same output, and also because I don't think control characters should be used in the source file. (CR/LF/TAB being exceptions)

You could improve it to be a little less iffy (and show up right in the forums) by doing this: (58 bytes)


I admit it's a weird solution, and I was a little surprised that it worked and was smaller than yours at the time! Sure, it was kinda cheating the rules, but hey, it's the kind of thing IOCCC would've accepted probably. Wink Anyways, I don't care about the challenges honestly, I just like good ideas. And you obviously beat me both in size, readability, and ingenuity, so bravo! Laughing

Anyways, just for the record (71 bytes w/ *nix LFs):

Quote:

[ Vista ] - Sat 09/05/2009 >sed -n l blah.bef
<v-"!":_@#:<"ABCDEFGH!Z\t\bI!Y\t\bJ!X\t\bK!W\t\bL!V\t\bM!UTSRQPON"0$
,_91+,$ ^$

[ Vista ] - Sat 09/05/2009 >befunge blah.bef | sed -n l
ABCDEFGH$
Z\t\bI$
Y\t\bJ$
X\t\bK$
W\t\bL$
V\t\bM$
UTSRQPON$

[ Vista ] - Sat 09/05/2009 >befunge blah.bef
Code:
ABCDEFGH
Z      I
Y      J
X      K
W      L
V      M
UTSRQPON
    

[ Vista ] - Sat 09/05/2009 >scrndump


And you also beat me on my "star" (though you removed opening/closing LFs), but I improved mine too (though not as good). Hence, I hate to even post it here, it's "obsolete", but whatever:

Code:
<v-"!":_@#:<"! #   #!  # #!#######!  # #! #   #!"0
,_91+,$    ^
    
Post 05 Sep 2009, 21:35
View user's profile Send private message Visit poster's website Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Wait, I need to check my code over again, ignore this post for now.....

EDIT:
Here's the code:
Code:
<>:#,_v#:"To C or F?"+55
`"b":~<v"f":_@#`"e":_v#`"c":_@#
      v>`#@_$"F":,55v>$"C":,
v     >:12p55+,902pv>+,:12p502p9&
v            -*48&5<
>*:02g%v
0\%g20:_02g/\:"E"`#v_\   >.,@,.<   _v#`-10:,".".<_       v#`\"E"g21/g2
                   >\84*+^     ^*-10<           ^\*2\+*48<
    


If you trace through it by hand you'll see that it should work. But try, for example, "c" then "99", which would convert 99F to C. The output is "37.-2C". For some reason the sign is being set on the part after the decimal.


Here's the bit of code that is supposed to fix any negative after the decimal:
Code:
.<   _v#`-10:
 ^*-10<
    

It enters from the right and travels left. The number that gets duplicated is the number after the decimal point. If the number is 0 or higher it SHOULD just travel left and print, but it doesn't. No matter what the number is, it always gets multiplied by -1. What's wrong?


It works on the official one....are you sure you use signed jumps on the compares? I haven't checked, but I assume that may be the problem.

_________________
----> * <---- My star, won HERE


Last edited by windwakr on 06 Sep 2009, 01:40; edited 5 times in total
Post 06 Sep 2009, 00:10
View user's profile Send private message Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
Your're right, negative values cause a problem.
Code:
<v5p009
         <v" is greater than 2"0
 >1-::.2`|>:#,_$00g1-:00p!#@_91+,
         <^" is lower than or equal to 2"0    
produces
Code:
4 is greater than 2
3 is greater than 2
2 is lower than or equal to 2
1 is lower than or equal to 2
0 is lower than or equal to 2
-1 is greater than 2
-2 is greater than 2
-3 is greater than 2
-4 is greater than 2    


I've fixed the bug, you can download the fix from the befunge interpreter thread in projects and ideas.


Last edited by Pinecone_ on 06 Sep 2009, 02:06; edited 2 times in total
Post 06 Sep 2009, 01:05
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
EDIT: Muahahahaha, rounding has been fixed, please test it. It was simple!
EDIT 2: Special cases fixed. 31F to C now correctly shows "-0.5C" instead of "0.5C", same fix with -18C to F. Luckily, fractional numbers can't be input, so these are the only two cases here where you'd get a "-0" output.
EDIT 3: Made changes to compensate for the added space after number printing.
If the number being converted to F had to pass 0 going up I just had to subtract 1 from it and invert the number after the decimal (10-n). If it did get to this point, then the number after decimal would be negative(this is before the negative fixing for that), so I just do (10+n). The other way(F to C) shouldn't need this kind of fix, because when it passes the 0 point there is nothing after the decimal point to screw it up(you can't input fractional numbers, only whole).


Please test this for inaccuracies.


OK, now to present.....windwakr's ALL POWERFUL degree converter!
While creating it I found and helped fix two pretty serious bugs in Pinecone_'s interpreter, so I guess it wasn't a waste of time.

To use it, enter what you're converting to and the number. To convert from F to C type "c", and vice versa. Then type in the number you are converting and press enter. And through the magic of Befunge you get the converted degree with up to 1 number after the decimal point.

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:< >         ^
                                       >                ^
    


You need the latest version of Pinecone_'s interpreter if you want to test it in his.

_________________
----> * <---- My star, won HERE


Last edited by windwakr on 08 Sep 2009, 17:26; edited 14 times in total
Post 06 Sep 2009, 01:50
View user's profile Send private message Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
Very good work windwakr, and thanks for all your help with my interpreter Smile

Edit: Aw, I thought I'd try the chess game again with these bugfixes, but no dice. There must still be some bugs to iron out... It does an infinite loop now after showing the board.

Edit#2:I've done a few more updates:

  • Stack overflows show an error instead of causing it to crash.
  • Division by zero now asks the user for what they want (strange, but thats what it's supposed to do according to the language specifications...)
  • A help message if the executable is run with no paramaters.


All avaliable for download in it's thread.

Edit#3:
rugxulo wrote:
Sure, it was kinda cheating the rules, but hey, it's the kind of thing IOCCC would've accepted probably.
That has been on my mind since you posted it, and i've decided to accept your solution Smile I'll add my solution to the first post with credits for the genius idea to you.

Challenge 2 Befunge 57 bytes:
Code:
<v"\]^_`abc%u$#d%t$#e%s$#f%r$#g%q$#h%ponmlkji"
3<_@#:,-*9    
Thanks to rugxulo.
Post 06 Sep 2009, 01:59
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Here is a solution to challenge 3. It is not a record breaker. But it is perfectly symmetrical. I couldn't resist posting it here.
Code:
             v
    v        ?        v
    v        v        v
 v  ?  v  v  ?  v  v  ?  v
 v  v  v  v  v  v  v  v  v
v?vv?vv?vv?vv?vv?vv?vv?vv?v
0000000009999 9999000000000
1234567891234 4321987654321
+++++++++++++ +++++++++++++
............. .............
@@@@@@@@@@@@@ @@@@@@@@@@@@@    
Post 06 Sep 2009, 10:04
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
wow pretty Razz How about this?
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+.@    
Edit: Nope doesn't look as impressive as yours for some reason.
Post 06 Sep 2009, 17:27
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Pinecone_ wrote:
How about this?
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+.@    
Your version doesn't guarantee uniform distribution. Can you see why?
Post 07 Sep 2009, 02:33
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
revolution wrote:
Your version doesn't guarantee uniform distribution. Can you see why?

Nope. I tried to copy the flow of yours... Why?
Post 07 Sep 2009, 02:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
You have a mini random walk in there: '?' <----> '?'
Post 07 Sep 2009, 03:04
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
Aha i see it Razz

Here's what it should be then Razz
Code:
         v
@.+01<       >10+.@
@.+02? <   > ?20+.@
@.+03<       >30+.@
@.+04<       >40+.@
@.+05?<?<?>?>?50+.@
@.+06<       >60+.@
@.+07<       >70+.@
@.+08? < v > ?80+.@
@.+09<       >90+.@
@.+91<       >19+.@
@.+92? < ? > ?29+.@
@.+93<   v   >39+.@
@.+94<   ?   >49+.@    
Edit: Wouldn't that also still have a random walk? If the lower ? goes south, it wraps back to the top ?. Same thing in your one.



I also made another update to my interpreter.

Previously the entire fungespace was stored as 8 bit cells. It didn't occur to me until today that the p and g instructions should be able to store/get much greater values from the fungespace because the stack is 32 bit. The fungespace is now stored in 32 bit cells, so that wont be a problem anymore (even though we never noticed it before).

Again, avaliable for download in the interpreter's thread.
Post 07 Sep 2009, 07:20
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Pinecone_ wrote:
Wouldn't that also still have a random walk? If the lower ? goes south, it wraps back to the top ?. Same thing in your one.
This is a very important aspect. Without the wrapping the distribution cannot be guaranteed to be uniform. It is not a random walk, it is very much controlled and is definitely needed.
Post 07 Sep 2009, 07:34
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
How are you always so sure of yourself with these things? I'm going to make it a personal goal to make you uncertain about one of these (just for fun) Razz Although i don't think I'll have much luck... Edit: Anyone feel like helping? Smile


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


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Pinecone_ wrote:
How are you always so sure of yourself with these things? I'm going to make it a personal goal to make you uncertain about one of these Razz Although i don't think I'll have much luck...
Hehe, maybe I just fake it?

Anyhow, I wish you the best of luck in your quest. I don't mind being shown to be wrong, because then I can learn something.
Post 07 Sep 2009, 08:28
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
I never said I'd show you wrong... I just want to make you uncertain of something Smile
Post 07 Sep 2009, 08:30
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
Okay, sorry, I didn't mean to put words in your mouth.

I would be happy to analyse any contribution you have for the puzzle. If I am uncertain then I will say so.
Post 07 Sep 2009, 08:36
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
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\<#  ^    
Post 07 Sep 2009, 10:04
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3 ... 7, 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.