I have solved a substantial fraction of the Project Euler
problems and I believe that using J to solve these
problems is not cheating.  According to the Project
Euler culture, "cheating" is:

- using more than 1 minute of computer time to
compute the answer; or
- finding the exact problem and answer in Sloane; or
- finding the exact problem and answer in some book
or some website; or ...

Since the main objective of Project Euler is to derive
satisfaction from solving a problem, and solving it 
neatly, when you "cheat", the main negative effect 
is your depriving yourself  of this satisfaction.

There are Project Euler problems which are rendered
rather easy by J facilities.  For example, problem 20 is

 2520 is the smallest number that can be divided 
 by each of the numbers from 1 to 10 without any remainder.

 What is the smallest number that is evenly divisible 
 by all of the numbers from 1 to 20?

There is a 9-character J solution.  Your friend may
argue that this is cheating, but I believe that even 
he would agree, however grudgingly, that the idea
in the J solution is rather neat.  And if you did not
have the required J primitives, the J expression
would nevertheless be a good guide for what
subroutines you have to write.

The number of Project Euler problems of this kind is
rather small.  Nearly all of the problems require some
mathematical insight as well as writing a non-trivial
program, even when you use J.  The people who
construct the problems are skilled, esp. in frustrating
the attempts of people who "cheat" in the ways
outlined above (brute force; Sloane; Google search; etc.)

p.s. Why stop at assembler or sqrt or primes?  Are you 
"cheating" by not writing your own routines for addition?
Or by not building your own computer, or by not directly
manipulating quantum effects in the diodes?



----- Original Message -----
From: Ian Gorse <[email protected]>
Date: Saturday, September 26, 2009 8:57
Subject: [Jchat] Is J Cheating
To: [email protected]

> Hello list,
> 
> A few weeks ago I had a conversation with a programmer friend of mine
> about solving problems. I tend to use J alot now (but do have
> experience in several imperative programming languages) , and my
> friend is a c/c++ coder all the way.
> 
> I stated to him that I had just solved another Project Euler, by using
> J and pasted the J code for him to see, even though I know for a fact
> he wont read the - in his own words - "gibberish" text that was
> presented infront of him. To my suprise, he said that J was "cheating"
> 
> I obviously defended his statement and asked how could J be cheating,
> and his response was that J was using pre-made algorithms.
> 
> So it is true that J has some brilliant pre-built verbs, such 
> as  1 p:
> y   and   q: y   which greatly 
> helps with some of the problems I tend
> to solve, but I still wouldn't class it as "cheating"
> 
> My counter argument was that when he writes his own prime check
> function, he will re-use that same code in all his projects,
> essentially using a pre-built algorithm.
> Here is a snippet of our conversation
> 
> Ian:    I just solved 187
> Steve:  in J?
> Ian:    yea
> Steve:  J is cheating in my opinion
> Steve:  because your using pre-made algorithms
> Ian:    when you write a prime class, do you re-
> use it everytime?
> Steve:  when *I* write a prime-class
> Steve:  not when J writes the class for you
> Ian:    no difference, I could write one up if I 
> wanted too, like I have
> many of times. But there is no point in importing mine when its an
> exact copy of the existing one
> Steve:  that's called stealing, lol
> Ian:    you could say the same as sqrt
> Ian:    you use a pre-made sqrt function
> Ian:    or you could write your own
> Ian:    but you wont
> Steve:  I have in the past
> Ian:    yes I know, but I bet you don't use it
> Ian:    for example, if I want to sqrt in J, i 
> would type %: 50.... you
> would type math.sqrt(50); or whatever
> Ian:    we both using pre-existing functions
> 
> By his definition of "cheating", everybody will "cheat" unless they
> completely write their code in assembly, where there is no such thing
> as sqrt, is_prime etc (that I know of anyway)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to