Page 1 of 1

easiest mathematical scripting tool

Posted: Sun Oct 12, 2008 8:14 pm
by sjoemelfreek
Hi there,

I've managed to solve 37 challenges without any knowledge about programming but now I have various ideas to solve a challenge but no experience in scripting. And I believe that the fast typing challenges teaches that there is another way...

Any recommendations on accesible scripting languages. I work with a Mac Os X...

Thanks

Re: easiest mathematical scripting tool

Posted: Sun Oct 12, 2008 9:36 pm
by canine
sjoemelfreek wrote:Hi there,

I've managed to solve 37 challenges without any knowledge about programming but now I have various ideas to solve a challenge but no experience in scripting. And I believe that the fast typing challenges teaches that there is another way...

Any recommendations on accesible scripting languages. I work with a Mac Os X...

Thanks
BC is an excellent calculator language that can be used to solve mathematical problems, and for things that require a bit more general capabilities, I'd suggest python.

Posted: Sun Oct 12, 2008 10:58 pm
by tails
I know the best language!

All the top hackers here use it when solving challenges.
It's available for free.
It can run on web browsers, so it must work on Mac OS X.
As well as simple calculation, by using it you can count string length, do fast modulus, generate messages, and even solve a maze!

Its program is like this: 23+p

Posted: Sun Oct 12, 2008 11:34 pm
by canine
tails wrote:I know the best language!

All the top hackers here use it when solving challenges.
It's available for free.
It can run on web browsers, so it must work on Mac OS X.
As well as simple calculation, by using it you can count string length, do fast modulus, generate messages, and even solve a maze!

Its program is like this: 23+p
wat

Posted: Mon Oct 13, 2008 9:13 am
by tails
canine wrote:wat
A joke. You know we have to use HVM to solve some challenges.

Posted: Mon Oct 13, 2008 10:50 am
by gfoot
I prefer dc to bc, and tails's program runs fine in dc as well as hvm. :)

They're pretty similar, but you can use the differences between them in interesting ways, e.g. this rather long program prints a different message depending which one you run it in:

Code: Select all

9 3+9*4-4 8*dP9 4+9*1+4 5*5*dP9 3+9*1+9 2+9*dP4 8*P9 3+9*6+P9 3+9*3+P9 2+9*P9 3+9*1-P9 3+9*7+P9 1+P

Posted: Mon Oct 13, 2008 1:02 pm
by canine
tails wrote:
canine wrote:wat
A joke. You know we have to use HVM to solve some challenges.
Elaborate. I am not sure what you mean by `HVM'.
gfoot wrote:I prefer dc to bc, and tails's program runs fine in dc as well as hvm. :)

They're pretty similar, but you can use the differences between them in interesting ways, e.g. this rather long program prints a different message depending which one you run it in:

Code: Select all

9 3+9*4-4 8*dP9 4+9*1+4 5*5*dP9 3+9*1+9 2+9*dP4 8*P9 3+9*6+P9 3+9*3+P9 2+9*P9 3+9*1-P9 3+9*7+P9 1+P
I'm not such a fan of dc. It's terse and complicated and I find polish notation unnatural. Furthermore, bc has alot more features, such as functions.

Posted: Mon Oct 13, 2008 2:20 pm
by gfoot
hvm is a virtual machine similar to dc. http://www.hacker.org/hvm/

I know what you mean about dc, and reverse-polish notation. But dc does have functions - any string between square braces can be stored in a variable and executed later.

Posted: Mon Oct 13, 2008 2:33 pm
by tails
gfoot, a great code!

I remember I sometimes wrote "d", intending "0^", when I was not used to it. :D
canine wrote:Elaborate. I am not sure what you mean by `HVM'.
canine, you should know the HVM, the Challenge Hack VM.

Posted: Mon Oct 13, 2008 2:42 pm
by canine
gfoot wrote:hvm is a virtual machine similar to dc. http://www.hacker.org/hvm/

I know what you mean about dc, and reverse-polish notation. But dc does have functions - any string between square braces can be stored in a variable and executed later.
Hmm...

The bracket thing in dc is actually a macro, which functions similarly to a function, but is not quite the same thing.

Compare functions in C and macros in C.

Do any challenges actually require hvm? Anyhow, it looks interesting. I may churn out a C implementation sometime, for the fun of it.

Heh. This reminds me of brainfuck.

Posted: Mon Oct 13, 2008 4:10 pm
by gfoot
canine wrote:Compare functions in C and macros in C.
Although dc calls them macros, they're effectively functions. I can't think of anything a function can do that a dc macro can't. They can recurse indefinitely, and they're not actually expanded until they're executed - the macro is (usually) loaded onto the stack and executed from there. You can return early from a macro (with the quirk that you also kill your parent).

Posted: Mon Oct 13, 2008 5:33 pm
by canine
gfoot wrote:
canine wrote:Compare functions in C and macros in C.
Although dc calls them macros, they're effectively functions. I can't think of anything a function can do that a dc macro can't. They can recurse indefinitely, and they're not actually expanded until they're executed - the macro is (usually) loaded onto the stack and executed from there. You can return early from a macro (with the quirk that you also kill your parent).
Hmm...

Indeed.