Sunday, August 11, 2013

Problem 4 - FALSE

I used Ruby on problem 4 before - it seemed like a good idea at the time, because I did not know any Ruby, other than the fact that I knew it had nice string functions, so testing for being a palindrome was as simple as x.to_s = x.to_s.reverse. However, Ruby is a "real" language that can actually do a lot of things, so I decided to revisit problem 4 with a ...different language.

FALSE was developed in 1993 with obfuscation and minimalism in mind - it is the language that inspired the development of brainfuck. Luckily, however, FALSE was not as bad as brainfuck, its a stack-based language, kind of like Postscript, except it takes the J-like approach to naming functions, so everything is done with crazy characters. Luckily, I didn't have to use the two characters in the language which are not on my keyboard, ß and ø . If I had needed to use those, writing the code would have been just a bit harder.

For this problem, the main difficulty came in actually running an interpreter - I could only find two interpreters on the language's homepage http://strlen.com/false-language. One was for 68000 assembly, and the other was for MS-DOS. So, I ran the dos interpreter on my computer through dosbox, which caused some complications, but worked out fine in the end. I got the answer, even if it took a while (the whole having to run the code in an emulator bit hurts), and I have used yet another esoteric language to clean up my early problems...maybe soon I will go forth and solve problems 21-25.

My Solution:
100a:100b:0q:[1000a;>][[1000b;>][a;b;*c:0d:0e:[5a;b;*100000>[1+]?e;>][
c;c;10/10*_+d;10*+d:c;10/c:e;1+e:]#a;b;*c:c;d;=c;q;>&[c;q:]?
1b;+b:]#a;b:a;1+a:]#q;.

No comments:

Post a Comment