flat assembler
Message board for the users of flat assembler.

Index > Heap > Esoteric Programming Challenges!

Goto page Previous  1, 2, 3 ... 6, 7, 8 ... 10, 11, 12  Next
Author
Thread Post new topic Reply to topic
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
Just to give you something to begin with, here's my solution to challenge 3:
Code:
v <          >   v
v ?>         ^> v
  ^       >   ?v
 >?       ^> v
  ^ >      ?v
> ?>?<  > v
  v >   ?v
^ ?<>  v
  > ? v       9999
    >v        1234
     123456789++++
^    >>>>>>>>>>>>>.",",    

Not very elegant, but works.
(See? I'm coding not only in the languages created by myself! Wink)
Post 02 Sep 2009, 17: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: 17270
Location: In your JS exploiting you and your system
revolution
Tomasz Grysztar wrote:
Just to give you something to begin with, here's my solution to challenge 3:
Code:
v <          >   v
v ?>         ^> v
  ^       >   ?v
 >?       ^> v
  ^ >      ?v
> ?>?<  > v
  v >   ?v
^ ?<>  v
  > ? v       9999
    >v        1234
     123456789++++
^    >>>>>>>>>>>>>.",",    

Not very elegant, but works.
(See? I'm coding not only in the languages created by myself! Wink)
Tomasz wins his second prize.

*

Congrats.

But I think this method would be tricky to do using only one '?' in the play field.
Post 02 Sep 2009, 18:09
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



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

(See? I'm coding not only in the languages created by myself! Wink)


Cool. Cool

revolution wrote:
Tomasz wins his second prize.

*

Congrats.


I KNEW IT!!! THOUGHT YOU COULD TRICK US, EH??? I KNEW IT WAS A DUMB STAR!!! Razz
Post 02 Sep 2009, 18:39
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: 17270
Location: In your JS exploiting you and your system
revolution
rugxulo wrote:
I KNEW IT!!! THOUGHT YOU COULD TRICK US, EH??? I KNEW IT WAS A DUMB STAR!!! Razz
Oh no, this is not just some dumb star. This is a very special official winner's star only issued by revolution to real winners for excellence in problem solving. If it is not issued by revolution then it is not official and is therefore a fake and is meaningless (or so I say anyway Neutral).
Post 02 Sep 2009, 18:44
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Another useless snippet that I wrote myself, Celsius to Fahrenheit:

Code:
"F"& 9* : 5%          v
,,,"."+*68*2%5.+*84/5:_5/84*+.,@
    


Quote:

[ Vista ] - Wed 09/02/2009 >bef -q c2f.bef
30
86 F
[ Vista ] - Wed 09/02/2009 >bef -q c2f.bef
33
91 .4F
[ Vista ] - Wed 09/02/2009 >scrndump
Post 02 Sep 2009, 23:23
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
After seeing rugxulo's post, it makes me want to make a converter that handles both, but it's a pain to compare.

Am I doing something wrong, or is comparing unnecessarily complicated?

Code:
<>:#,_v#:"To C or F?"+55
`"e":~<@_v#`"f":_  v#
v        <v_@#`"b":<
v         >:"c"`#@_v
>"F",@             >"C",@
    


That just detects whether you pressed "c" or "f", and prints out "C" or "F" respectively.

I mean, geeze, once you throw in checking for capitals, and actually implement the converting, this thing would be HUGE.

_________________
----> * <---- My star, won HERE
Post 03 Sep 2009, 02:26
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Checks for alphabetical chars, aka isalpha():

Code:
v              >"A"1-`v
>     ~:"z"1+\`|      !
               @      _"!sey",,,,
    


EDIT: Oops, forgot about the stuff between 'Z' and 'a':

91 =[ 92 =\ 93 =] 94 =^ 95 =_ 96 =`

Ah well, maybe I'll fix it later (not at home right now). Razz

BTW, the main annoying part of the C to F (or vice versa) conversion to me was the lack of floating point (loss of precision), but luckily it seemed within my extremely limited grasp to handle (I hope!).
Post 03 Sep 2009, 04:33
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
First post has been updated with Tomasz's success, including a note about him winning his new star. Smile

Would you like me to add Celsius / Fahrenheit converter as challenge 7 to keep track of your efforts rugxulo and windwakr? If so, what should the minimum requirements for it be?
Post 03 Sep 2009, 06:30
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Here's my degree converter. Type lower-case "c" or "f" for what you want to convert to. Then type the number you're converting and press enter.


Here's the working, horribly unoptimized ugly code. DOES NOT HANDLE NEGATIVE NUMBERS.
I give up on this, too many errors with bigger numbers, no negatives, ugly unreadable code.
Code:
<>:#,_v#:"To C or F?"+55
`"e":~<@_ v#`"f":_  v#
          vv_@#`"b":<
           >:"c"`#@ _v
v         >         v>"C":03p:,55+,5902p&84*-
v&p2059,+55,:p30:"F"<
>*:02g%v
 \/g20:_02g/\:"D"`#v_\   >.,@,,,"."+*68*2%g20.<   \_v#`\"D"g30
                   >\84*+^                    ^+*48\<
    


Sample output:
Code:
[BLEH] befunge degree_conv.bef
To C or F?
C
576
302.4C
[BLEH] befunge degree_conv.bef
To C or F?
F
576
1068.8F
[BLEH] befunge degree_conv.bef
To C or F?
C
32
0C
[BLEH] befunge degree_conv.bef
To C or F?
F
0
32F
    

_________________
----> * <---- My star, won HERE
Post 03 Sep 2009, 19:24
View user's profile Send private message Reply with quote
rugxulo



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

Would you like me to add Celsius / Fahrenheit converter as challenge 7 to keep track of your efforts rugxulo and windwakr? If so, what should the minimum requirements for it be?


Not sure there's enough interest, even from windwakr (nil?) and me (low). However, if you insist Razz , I'd say it has to minimally handle 0-100 C and 32-212 F with reasonable accuracy (+- 5 degrees). Anything else is optional (one way conversion, both ways, etc).

EDIT: If it doesn't handle negative numbers, just make it print "cold!!!" or similar instead. At least anybody seeing it will understand the gist of it. Wink
Post 03 Sep 2009, 22:34
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Okay, this one is mostly for revolution's amusement. Cool Laughing

Code:
<v"! #   #!  # #!#######!  # #! #   #!"0
 >:!#@_:"!"-v
 ^         ,_91+,$
    
Post 03 Sep 2009, 22:57
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
Hmmm... Nice star.

And no I don't insist.

Edit:
Code:
<v";>;;;>%;;>;>%>>>>>>>%;;>;>%;>;;;>"
3<_@#:,-*9    
Post 04 Sep 2009, 01:00
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Here's my idea for revolutions second challenge, maybe someone smarter than me can use it. Ok, you have just one "?" and somewhere in the codespace you have 3 empty spots to hold data. There are 3 main loops. Around the "?" are code like " ">"11p, but the ">" replaced with the direction from the "?" and the "11p" replaced with where the data slots are. Then you fill in Tomasz's code like this:


Code:
v <          >   v
v 3>         ^> v
  ^       >   3v
 >2       ^> v
  ^ >      3v
> 1>2<  > v
  v >   3v
^ 2<>  v
  > 3 v       9999
    >v        1234
     123456789++++
^    >>>>>>>>>>>>>.",",
    


See the numbers? You put the first direction choice replacing the "1", the second direction choice replacing the "2"s, and the same for 3. Then you let your code run into his with the direction choices. The only problem would be if your code chose something like up, down, down. You'd be stuck in a loop.

Maybe I'm over-complicating this?

_________________
----> * <---- My star, won HERE
Post 04 Sep 2009, 04:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
Try to analyse Tomasz's algorithm. Rather than copy the code as it is, extract the algorithm from it and write new code.
Post 04 Sep 2009, 04:42
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
Ya, I don't really see it....

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



Joined: 28 Apr 2008
Posts: 180
Pinecone_
79 bytes challenge 2 befunge Smile
Code:
<v"\]^_`abc%u;d%t;e%s;f%r;g%q;h%ponmlkji"
:<_@#:,-*93_v#-";"
:::,,,,,,$:^>84*::    
Post 04 Sep 2009, 07:40
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Pinecone_ wrote:
79 bytes challenge 2 befunge Smile


I don't know if this counts since it's technically different output, but it at least "looks" the same!! 71 bytes (including *nix LFs):

Code:
<v-"!":_@#:<"ABCDEFGH!Z   I!Y    J!X    K!W    L!V    M!UTSRQPON"0
,_91+,$    ^
    


P.S. I'm not sure the code shows up correctly, but I basically used a hard tab (0x9) and backspace (0x8) instead of spaces. Shocked
Post 04 Sep 2009, 14: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
You don't need the zero at the end.
Post 04 Sep 2009, 14:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
rugxulo wrote:
Okay, this one is mostly for revolution's amusement. Cool Laughing

Code:
<v"! #   #!  # #!#######!  # #! #   #!"0
 >:!#@_:"!"-v
 ^         ,_91+,$
    
Razz, fake, folks that is a forged star, do you see the lengths people will go to make make their own stars!
rugxulo wrote:
EDIT: If it doesn't handle negative numbers, just make it print "cold!!!" or similar instead. At least anybody seeing it will understand the gist of it. Wink
If the input is below -273.15C then it should print "outside the realm of known science!", if it is above 10^99 it should print "where are you, starting up the big bang?"

Also it should accept K (as well as C and F).
Post 04 Sep 2009, 14:48
View user's profile Send private message Visit poster's website Reply with quote
Pinecone_



Joined: 28 Apr 2008
Posts: 180
Pinecone_
Rugxulo, I think the code tags destroy your tabs: Lets test: The following code section should contain one tab:
Code:
         
Edit: It was replaced with 8 spaces.

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: (57 bytes)
Code:
<v"\]^_`abc%u$#d%t$#e%s$#f%r$#g%q$#h%ponmlkji"
3<_@#:,-*9    
You may have noticed i thought of the idea of subtracting a constant from each character earlier today, it seems like a great way of encoding strings with special characters in them in befunge, it just takes a little bit more work to write the string in the script because you need to check the ascii value of the character you want and add your constant. Eg, you want LF and your using 27 as a constant (I picked 27 because its the most simple to work with in befunge) so you need character 37 (10 + 27) which is %. http://asciitable.com/ is great for checking character values.

Also, as Windwakr said, you push 0 to the stack before you push your strings, so that your loop will read 0 and exit. Poping something off the stack when there is nothing on it returns zero, therefore the 0 can be removed Smile

Edit: Tomasz wrote a brainfuck interpreter in Framed Challenger, which I have added to the first post under challenge 5.


Last edited by Pinecone_ on 06 Sep 2009, 08:34; edited 2 times in total
Post 04 Sep 2009, 15:09
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 ... 6, 7, 8 ... 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.