Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > "Small" Program Challenge.

Reply
Thread Tools

"Small" Program Challenge.

 
 
Daniel Pitts
Guest
Posts: n/a
 
      06-15-2012
On 6/14/12 11:04 AM, Stefan Ram wrote:
> Daniel Pitts<(E-Mail Removed)> writes:
>> I've got mine down to 61 characters. See if you can match that.

>
> Here is a new variant of the above challenge:
>
> Write a java program (source code) with less than 4000
> characters and a java command line with less than 1000
> characters that writes ╗Hello Worldź followed by a newline
> character and nothing else, but does so in a somewhat
> surprising or unusual way.
>
> My entry:
>
> public class Main
> { public static void main( final java.lang.String[] args )
> { System.out.println(); System.out.print( '\n' ); }}
>
> java -Dline.separator="Hello World" Main
>

Any one more:
enum Hello{Hello,World;public static void
main(String[]a){System.out.println(String.valueOf(java.util.Arr ays.asList(values())).replaceAll("\\p{Punct}","")) ;}}
 
Reply With Quote
 
 
 
 
Sachindra Sachindra is offline
Junior Member
Join Date: Jun 2012
Posts: 1
 
      06-15-2012
class HelloWorld{static{System.out.println("HelloWorld") ;}}
 
Reply With Quote
 
 
 
 
Kevin McMurtrie
Guest
Posts: n/a
 
      06-16-2012
In article <zZ6Cr.4514$(E-Mail Removed)>,
Daniel Pitts <(E-Mail Removed)> wrote:

> I saw a challenge Roedy posted on cljh, and I thought I might have a
> slightly more interesting one.
>
> Write a Java program which outputs "Hello World" followed by a new line
> (and nothing else).
>
> Now, do it using as few characters in the .java source code as possible.
>
> I've got mine down to 61 characters. See if you can match that.


Without putting "Hello World" in the environment or using assembly:

class A{static{System.out.println("Hello World");System.exit(0);}}
--
I will not see posts from Google because I must filter them as spam
 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      06-16-2012
On 6/15/12 10:13 PM, Kevin McMurtrie wrote:
> In article<zZ6Cr.4514$(E-Mail Removed)>,
> Daniel Pitts<(E-Mail Removed)> wrote:
>
>> I saw a challenge Roedy posted on cljh, and I thought I might have a
>> slightly more interesting one.
>>
>> Write a Java program which outputs "Hello World" followed by a new line
>> (and nothing else).
>>
>> Now, do it using as few characters in the .java source code as possible.
>>
>> I've got mine down to 61 characters. See if you can match that.

>
> Without putting "Hello World" in the environment or using assembly:
>
> class A{static{System.out.println("Hello World");System.exit(0);}}

Note, that doesn't work on Java 7.

You can get rid of the static with a few other tricks. You can also trim
the usage of System. to something shorter.

 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      06-17-2012
On 6/17/12 6:22 AM, Wanja Gayk wrote:
> In article<zZ6Cr.4514$(E-Mail Removed)>,
> http://www.velocityreviews.com/forums/(E-Mail Removed) says...
>
>> Write a Java program which outputs "Hello World" followed by a new
>> line (and nothing else).
>>
>> Now, do it using as few characters in the .java source code as possible.
>>
>> I've got mine down to 61 characters. See if you can match that.

>
> Yoda says:
> claim everything you can, prove you must.

I will post my solution, once everyone else has had a chance to attempt
the problem.


 
Reply With Quote
 
javax.swing.JSnarker
Guest
Posts: n/a
 
      06-17-2012
On 17/06/2012 6:24 PM, Daniel Pitts wrote:
> On 6/17/12 6:22 AM, Wanja Gayk wrote:
>> In article<zZ6Cr.4514$(E-Mail Removed)>,
>> (E-Mail Removed) says...
>>
>>> Write a Java program which outputs "Hello World" followed by a new
>>> line (and nothing else).
>>>
>>> Now, do it using as few characters in the .java source code as possible.
>>>
>>> I've got mine down to 61 characters. See if you can match that.

>>
>> Yoda says:
>> claim everything you can, prove you must.

> I will post my solution, once everyone else has had a chance to attempt
> the problem.


"Everyone else"? As in, all seven billion of us?!

--
public final class JSnarker
extends JComponent
A JSnarker is an NNTP-aware component that asynchronously provides
snarky output when the Ego.needsPuncturing() event is fired in cljp.
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      06-18-2012
On 6/17/2012 6:25 PM, javax.swing.JSnarker wrote:
> On 17/06/2012 6:24 PM, Daniel Pitts wrote:
>> On 6/17/12 6:22 AM, Wanja Gayk wrote:
>>> In article<zZ6Cr.4514$(E-Mail Removed)>,
>>> (E-Mail Removed) says...
>>>
>>>> Write a Java program which outputs "Hello World" followed by a new
>>>> line (and nothing else).
>>>>
>>>> Now, do it using as few characters in the .java source code as
>>>> possible.
>>>>
>>>> I've got mine down to 61 characters. See if you can match that.
>>>
>>> Yoda says:
>>> claim everything you can, prove you must.

>> I will post my solution, once everyone else has had a chance to attempt
>> the problem.

>
> "Everyone else"? As in, all seven billion of us?!


In theory if he wait X days, then a good chunk of those 7 B would
have had a chance to go on the internet, read and reply.

In practice it will be a very small subset, but ...

Arne



 
Reply With Quote
 
javax.swing.JSnarker
Guest
Posts: n/a
 
      06-18-2012
On 17/06/2012 8:31 PM, Arne Vajh°j wrote:
> On 6/17/2012 6:25 PM, javax.swing.JSnarker wrote:
>> On 17/06/2012 6:24 PM, Daniel Pitts wrote:
>>> I will post my solution, once everyone else has had a chance to attempt
>>> the problem.

>>
>> "Everyone else"? As in, all seven billion of us?!

>
> In theory if he wait X days, then a good chunk of those 7 B would
> have had a chance to go on the internet, read and reply.
>
> In practice it will be a very small subset, but ...


The problem is, he said "everyone else" rather than "almost everyone
else". So "a good chunk" won't cut it.

--
public final class JSnarker
extends JComponent
A JSnarker is an NNTP-aware component that asynchronously provides
snarky output when the Ego.needsPuncturing() event is fired in cljp.
 
Reply With Quote
 
Arne Vajh°j
Guest
Posts: n/a
 
      06-18-2012
On 6/13/2012 11:52 PM, Roedy Green wrote:
> On Wed, 13 Jun 2012 13:45:18 -0700, Daniel Pitts
> <(E-Mail Removed)> wrote, quoted or indirectly
> quoted someone who said :
>
>>
>> I've got mine down to 61 characters. See if you can match that.

>
> here's the obvious solution at 88 chars:
>
> public class C{public static void main(String[]
> a){System.out.println("Hello World");}}


Daniel already posted the obvious solution.

Arne




 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      06-18-2012
On 6/17/12 5:55 PM, javax.swing.JSnarker wrote:
> On 17/06/2012 8:31 PM, Arne Vajh°j wrote:
>> On 6/17/2012 6:25 PM, javax.swing.JSnarker wrote:
>>> On 17/06/2012 6:24 PM, Daniel Pitts wrote:
>>>> I will post my solution, once everyone else has had a chance to attempt
>>>> the problem.
>>>
>>> "Everyone else"? As in, all seven billion of us?!

>>
>> In theory if he wait X days, then a good chunk of those 7 B would
>> have had a chance to go on the internet, read and reply.
>>
>> In practice it will be a very small subset, but ...

>
> The problem is, he said "everyone else" rather than "almost everyone
> else". So "a good chunk" won't cut it.
>

Well, while you took me literally, my intent was to wait "for enough
people that wished to contribute to this conversation to do so."

Or for someone to find the same (or better) solution.

I suppose that a date deadline would have been more appropriate.

In any case, I think the other challenge was more interesting. My
solution to the "shortest" source is 60 characters long. The first two
lines are simply a ruler, and not part of the source code.

1 2 3 4 4 6
12345678901234567890123456789012345678901234567890 1234567890
enum H{W;System s;{s.out.println("Hello World");s.exit(0);}}

You would compile whatever file H was in (it needn't be in H.java since
it isn't public). Then execute with "java H"

Note, this no longer works in Java 7. It appears a method with the
signature "public static void main(String[])" is now required, where it
could have been omitted in the past (as in my example).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to javac a java program w/ another java program which is w/o a main method cjeffwang@yahoo.com Java 1 10-31-2005 04:25 AM
System program/ Application program ?? Parvsandhu Java 2 07-11-2005 09:08 AM
how to convert a java program to an exe program ola Java 3 02-16-2004 09:42 AM
Calling Java program in another Java program Rey Java 4 12-12-2003 10:18 PM
passing data between Java program and C program--help pipi Java 1 07-21-2003 05:02 AM



Advertisments