easiest mathematical scripting tool

Post Reply
sjoemelfreek
Posts: 15
Joined: Sun Sep 14, 2008 4:49 pm

easiest mathematical scripting tool

Post 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
canine
Posts: 190
Joined: Sun Sep 14, 2008 5:38 am

Re: easiest mathematical scripting tool

Post 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.
tails
Posts: 191
Joined: Tue Jun 10, 2008 7:51 pm
Location: Tokyo

Post 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
canine
Posts: 190
Joined: Sun Sep 14, 2008 5:38 am

Post 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
tails
Posts: 191
Joined: Tue Jun 10, 2008 7:51 pm
Location: Tokyo

Post by tails »

canine wrote:wat
A joke. You know we have to use HVM to solve some challenges.
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post 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
canine
Posts: 190
Joined: Sun Sep 14, 2008 5:38 am

Post 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.
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post 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.
tails
Posts: 191
Joined: Tue Jun 10, 2008 7:51 pm
Location: Tokyo

Post 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.
canine
Posts: 190
Joined: Sun Sep 14, 2008 5:38 am

Post 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.
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post 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).
canine
Posts: 190
Joined: Sun Sep 14, 2008 5:38 am

Post 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.
Post Reply