Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #15252 > unrolled thread
| Started by | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| First post | 2012-06-13 13:45 -0700 |
| Last post | 2012-06-20 21:19 -0400 |
| Articles | 20 on this page of 88 — 17 participants |
Back to article view | Back to comp.lang.java.programmer
"Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 13:45 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 13:52 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 16:17 -0700
Re: "Small" Program Challenge. glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-06-14 00:16 +0000
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 16:19 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-13 16:24 -0700
Re: "Small" Program Challenge. markspace <-@.> - 2012-06-13 17:40 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-13 21:28 -0400
Re: "Small" Program Challenge. Roedy Green <see_website@mindprod.com.invalid> - 2012-06-13 20:52 -0700
Re: "Small" Program Challenge. "Hiram Hunt" <hiramhunt@verizon.net> - 2012-06-14 08:23 -0400
Re: "Small" Program Challenge. "Hiram Hunt" <hiramhunt@verizon.net> - 2012-06-14 08:30 -0400
Re: "Small" Program Challenge. Arne Vajhøj <arne@vajhoej.dk> - 2012-06-17 21:17 -0400
Re: "Small" Program Challenge. Paul Cager <paul.cager@googlemail.com> - 2012-06-14 02:32 -0700
Re: "Small" Program Challenge. Bent C Dalager <bcd@pvv.ntnu.no> - 2012-06-14 11:29 +0000
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-14 12:50 -0700
Re: "Small" Program Challenge. Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-14 15:49 -0500
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-14 14:56 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-14 17:02 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-14 17:09 -0700
Re: "Small" Program Challenge. Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2012-06-15 22:13 -0700
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-16 12:11 -0700
Re: "Small" Program Challenge. Wanja Gayk <brixomatic@yahoo.com> - 2012-06-17 15:22 +0200
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-17 15:24 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-17 18:25 -0400
Re: "Small" Program Challenge. Arne Vajhøj <arne@vajhoej.dk> - 2012-06-17 20:31 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-17 20:55 -0400
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-17 20:40 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-17 23:43 -0400
Re: "Small" Program Challenge. Lew <noone@lewscanon.com> - 2012-06-17 21:25 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 00:45 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 12:47 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 15:57 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 13:31 -0700
Re: "Small" Program Challenge. Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-18 16:05 -0500
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 14:18 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 19:50 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 19:48 -0400
Re: "Small" Program Challenge. David Lamb <dalamb@cs.queensu.ca> - 2012-06-19 08:07 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 15:26 -0400
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-18 09:04 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 13:09 -0400
Re: "Small" Program Challenge. markspace <-@.> - 2012-06-18 11:06 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 14:46 -0400
Re: "Small" Program Challenge. markspace <-@.> - 2012-06-18 13:22 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 19:51 -0400
Re: "Small" Program Challenge. Wanja Gayk <brixomatic@yahoo.com> - 2012-06-20 13:11 +0200
Re: "Small" Program Challenge. Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-22 12:54 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-22 18:30 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-25 12:59 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-25 16:49 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 12:44 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 16:01 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 13:36 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 20:01 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-18 18:25 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 22:01 -0400
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-18 19:04 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-18 22:12 -0400
Re: "Small" Program Challenge. Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-06-19 12:36 +0000
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 15:28 -0400
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-19 09:12 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 15:30 -0400
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-19 15:04 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 18:23 -0400
Re: "Small" Program Challenge. Gene Wirchenko <genew@ocis.net> - 2012-06-19 15:32 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 19:09 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 19:10 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-19 17:19 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 20:42 -0400
Re: "Small" Program Challenge. Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-19 20:01 -0500
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-19 21:12 -0400
Re: "Small" Program Challenge. Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-06-19 20:32 -0500
Re: "Small" Program Challenge. Lew <noone@lewscanon.com> - 2012-06-19 22:01 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-20 21:15 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-20 21:05 -0400
Re: "Small" Program Challenge. Wanja Gayk <brixomatic@yahoo.com> - 2012-06-23 13:42 +0200
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-23 12:12 -0400
Re: "Small" Program Challenge. Wanja Gayk <brixomatic@yahoo.com> - 2012-06-23 23:10 +0200
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-23 17:14 -0400
Re: "Small" Program Challenge. Lew <noone@lewscanon.com> - 2012-06-19 22:15 -0700
Re: "Small" Program Challenge. Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-06-20 10:34 +0000
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-20 10:45 -0700
Re: "Small" Program Challenge. Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2012-06-21 08:13 +0000
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-21 17:18 -0400
Re: "Small" Program Challenge. Lew <lewbloch@gmail.com> - 2012-06-21 15:30 -0700
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-21 20:28 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-20 21:22 -0400
Re: "Small" Program Challenge. "javax.swing.JSnarker" <gharriman@boojum.mit.edu> - 2012-06-20 21:19 -0400
Page 1 of 5 [1] 2 3 4 5 Next page →
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-13 13:45 -0700 |
| Subject | "Small" Program Challenge. |
| Message-ID | <zZ6Cr.4514$v14.839@newsfe06.iad> |
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.
[toc] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-13 13:52 -0700 |
| Message-ID | <k47Cr.4544$yL6.142@newsfe04.iad> |
| In reply to | #15252 |
On 6/13/12 1:45 PM, Daniel Pitts 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.
Hint, the following is 82 characters, if you remove line wrapping. Where
do I trim the 21 characters?
"class M{public static void main(String[]args){System.out.println("Hello
World");}}"
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-13 16:17 -0700 |
| Message-ID | <Ob9Cr.208$u71.159@newsfe07.iad> |
| In reply to | #15253 |
On 6/13/12 2:06 PM, Stefan Ram wrote:
> Daniel Pitts<newsgroup.nospam@virtualinfinity.net> writes:
>>> Write a Java program which outputs "Hello World" followed by a new line
> (...)
>> "class M{public static void main(String[]args){System.out.println("Hello World");}}"
>
> »System.out.println("Hello World");« does not output "Hello
> World" followed by a new line, but "Hello World" followed by
> the line separator string. The line separator string is
> defined by the system property line.separator, and is not
> necessarily a single newline character ('\n').
>
I didn't say a "new line" character. However, print("Hello World\n") is
the same length. My intent was line separator, however if you choose to
interpret it the other way, there is no benefit or penalty.
[toc] | [prev] | [next] | [standalone]
| From | glen herrmannsfeldt <gah@ugcs.caltech.edu> |
|---|---|
| Date | 2012-06-14 00:16 +0000 |
| Message-ID | <jrbagc$kh7$1@speranza.aioe.org> |
| In reply to | #15258 |
Daniel Pitts <newsgroup.nospam@virtualinfinity.net> wrote:
(snip)
> I didn't say a "new line" character. However, print("Hello World\n") is
> the same length. My intent was line separator, however if you choose to
> interpret it the other way, there is no benefit or penalty.
Note that there is no requirement that the host system even use
a newline character. There are systems that keep track of lines
by length.
Now, the C tradition of using '\n' as a line terminator, even
on systems that don't store files that way, isn't completely gone
in Java. Writing a "\n" will likely generate a new line even on
systems that don't use a newline character.
-- glen
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-13 16:19 -0700 |
| Message-ID | <de9Cr.217$u71.76@newsfe07.iad> |
| In reply to | #15253 |
On 6/13/12 2:29 PM, Stefan Ram wrote: > Daniel Pitts<newsgroup.nospam@virtualinfinity.net> writes: >> Where do I trim the 21 characters? > > You can trim the »args« to »a«. Ah, yes. That was just habit on my part. > Possibly, some earlier JDKs allowed > omission of the main method, but a recent JDK seems to require it. > The JDK doesn't require anything of a class. java on the other hand goes through a specific sequence when asked to "run" a Java program. My smallest program is still 61 characters long, the example I posted, after replacing args with a, is 79.
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-13 16:24 -0700 |
| Message-ID | <Wi9Cr.232$u71.150@newsfe07.iad> |
| In reply to | #15259 |
On 6/13/12 4:19 PM, Daniel Pitts wrote: > On 6/13/12 2:29 PM, Stefan Ram wrote: >> Daniel Pitts<newsgroup.nospam@virtualinfinity.net> writes: >>> Where do I trim the 21 characters? >> >> You can trim the »args« to »a«. > Ah, yes. That was just habit on my part. > >> Possibly, some earlier JDKs allowed >> omission of the main method, but a recent JDK seems to require it. >> > > The JDK doesn't require anything of a class. java on the other hand goes > through a specific sequence when asked to "run" a Java program. Ah, although now I see reports that Java 7 does some validation before some of that sequence. So, my 61 character source compiles fine, but won't run on Java 7. I wonder why they bothered.
[toc] | [prev] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2012-06-13 17:40 -0700 |
| Message-ID | <jrbbth$sok$1@dont-email.me> |
| In reply to | #15253 |
On 6/13/2012 1:52 PM, Daniel Pitts wrote:
> On 6/13/12 1:45 PM, Daniel Pitts 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.
>
> Hint, the following is 82 characters, if you remove line wrapping. Where
> do I trim the 21 characters?
>
> "class M{public static void main(String[]args){System.out.println("Hello
> World");}}"
This is a good one, although the options for really trimming things down
in surprising ways is absent in Java.
Another good one is to write a Java program that prints its own source
text. No fair using an external file, of course.
[toc] | [prev] | [next] | [standalone]
| From | "javax.swing.JSnarker" <gharriman@boojum.mit.edu> |
|---|---|
| Date | 2012-06-13 21:28 -0400 |
| Message-ID | <jrbenr$sep$1@speranza.aioe.org> |
| In reply to | #15252 |
On 13/06/2012 4:45 PM, Daniel Pitts 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.
class X{static{System.out.println("Hello World");for(;;);}}
is 59 characters.
Hey, you didn't say it has to actually *terminate*! ;)
--
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.
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2012-06-13 20:52 -0700 |
| Message-ID | <jqnit7pv9phoig3t2il0s4jf4s19ot7p3i@4ax.com> |
| In reply to | #15252 |
On Wed, 13 Jun 2012 13:45:18 -0700, Daniel Pitts
<newsgroup.nospam@virtualinfinity.net> 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");}}
--
Roedy Green Canadian Mind Products
http://mindprod.com
Controlling complexity is the essence of computer programming.
~ Brian W. Kernighan 1942-01-01
.
[toc] | [prev] | [next] | [standalone]
| From | "Hiram Hunt" <hiramhunt@verizon.net> |
|---|---|
| Date | 2012-06-14 08:23 -0400 |
| Message-ID | <4fd9d7d1$0$1727$c3e8da3$aae71a0a@news.astraweb.com> |
| In reply to | #15266 |
"Roedy Green" <see_website@mindprod.com.invalid> wrote in message
news:jqnit7pv9phoig3t2il0s4jf4s19ot7p3i@4ax.com...
> On Wed, 13 Jun 2012 13:45:18 -0700, Daniel Pitts
> <newsgroup.nospam@virtualinfinity.net> 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");}}
No need for public on class.
-- Hiram Hunt (hiramhunt@verizon.net)
[toc] | [prev] | [next] | [standalone]
| From | "Hiram Hunt" <hiramhunt@verizon.net> |
|---|---|
| Date | 2012-06-14 08:30 -0400 |
| Message-ID | <4fd9d942$0$1403$c3e8da3$e408f015@news.astraweb.com> |
| In reply to | #15275 |
"Hiram Hunt" <hiramhunt@verizon.net> wrote in message
news:4fd9d7d1$0$1727$c3e8da3$aae71a0a@news.astraweb.com...
>
> "Roedy Green" <see_website@mindprod.com.invalid> wrote in message
> news:jqnit7pv9phoig3t2il0s4jf4s19ot7p3i@4ax.com...
>> On Wed, 13 Jun 2012 13:45:18 -0700, Daniel Pitts
>> <newsgroup.nospam@virtualinfinity.net> 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");}}
>
> No need for public on class.
>
> -- Hiram Hunt (hiramhunt@verizon.net)
Sorry, I think I missed your point that this was just the obvious
solution. Other posts are already public-less on class.
-- Hiram Hunt (hiramhunt@verizon.net)
[toc] | [prev] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2012-06-17 21:17 -0400 |
| Message-ID | <4fde818f$0$292$14726298@news.sunsite.dk> |
| In reply to | #15266 |
On 6/13/2012 11:52 PM, Roedy Green wrote:
> On Wed, 13 Jun 2012 13:45:18 -0700, Daniel Pitts
> <newsgroup.nospam@virtualinfinity.net> 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
[toc] | [prev] | [next] | [standalone]
| From | Paul Cager <paul.cager@googlemail.com> |
|---|---|
| Date | 2012-06-14 02:32 -0700 |
| Message-ID | <1b91287c-a822-4ea7-9da8-b6c4a7ea077f@eh4g2000vbb.googlegroups.com> |
| In reply to | #15252 |
On Jun 13, 9:45 pm, Daniel Pitts <newsgroup.nos...@virtualinfinity.net> 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. You may also find some of the challenges on http://codegolf.stackexchange.com/ interesting.
[toc] | [prev] | [next] | [standalone]
| From | Bent C Dalager <bcd@pvv.ntnu.no> |
|---|---|
| Date | 2012-06-14 11:29 +0000 |
| Message-ID | <slrnjtjios.5m7.bcd@microbel.pvv.ntnu.no> |
| In reply to | #15252 |
On 2012-06-13, Daniel Pitts <newsgroup.nospam@virtualinfinity.net> 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.
How much are you permitted to offload to the launcher?
Trivial example of offloading:
class A{public static void main(String[] a){System.out.print(a[0]);}}
(69 chars)
with launch instructions:
run like this (bash command line example shown, other launch
environments will have other ways of expressing the newline)
$ java A "Hello World
> "
$
And how much can you offload to a hypothetical "library" function that
just happens to do exactly what you want?
class B{public static void main(String[] a){L.f();}}
(52 chars)
Cheers,
Bent.
--
Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd
powered by emacs
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-14 12:50 -0700 |
| Message-ID | <agrCr.13738$qf3.4173@newsfe12.iad> |
| In reply to | #15252 |
On 6/14/12 11:04 AM, Stefan Ram wrote:
> Daniel Pitts<newsgroup.nospam@virtualinfinity.net> 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
>
A slightly obfuscated program which illustrates a few surprising things.
public class Hello {
static Object left = "Top", right = "Bottom";
static Object top = "Left";
static Object bottom = "Right";
public static void main(String[] args) throws Exception {
for (int i = 0; i < 2; ++i) {
s.out.print(new Hello());
y(left, right, top, bottom);
}
}
public String toString() {
try {
top = "value";
bottom = "count";
return "enumeration" + top + bottom;
} finally {
return getClass().getName();
}
}
static <T extends java.lang.reflect.AccessibleObject> T t(T t) {
t.setAccessible(true); return t;}
static <T> void y(T l, T r, T... os) throws Exception {
for (Object o : os) {
x(l, o).set(l, x(l, o).get(r));
}
}
private static java.lang.reflect.Field x(Object l, Object o) throws
NoSuchFieldException {
return t(l.getClass().getDeclaredField(o.toString()));
}
{
left = toString();
right = " W" + b + 'r' + a + "d\n";
}
static Object a = "l";
static Object b = "o";
static System s;
}
[toc] | [prev] | [next] | [standalone]
| From | Leif Roar Moldskred <leifm@dimnakorr.com> |
|---|---|
| Date | 2012-06-14 15:49 -0500 |
| Message-ID | <0IWdnRcOaL-g00fSnZ2dnUVZ7oqdnZ2d@giganews.com> |
| In reply to | #15252 |
Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> Daniel Pitts <newsgroup.nospam@virtualinfinity.net> 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
>
Well, mine doesn't have the same compactness, but here goes.
Run with plain "java HW":
import java.io.PrintStream;
import java.math.BigInteger;
public class HW {
static boolean debug = false;
final static Long l_44 = 044L;
public static void main(String[] args) {
if( debug&doDebugLogging() ) {
System.out.println( "World hello!" );
}
long ll1 = 42068934;
long ll2 = 12834282;
System.out.print(ll1++-ll2);
System.out.print( " " );
System.out.println(ll1+++ll2);
}
private static boolean doDebugLogging( ) {
System.setOut( new PrintStream( System.out ) {
public void print( long l ) {
print( BigInteger.valueOf( l ).toString(l_44.intValue()) );
}
public void print( String s ) {
super.print( s.toUpperCase().charAt(0) + s.substring(1) );
} });
return false;
}
}
--
Leif Roar Moldskred
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-06-14 14:56 -0700 |
| Message-ID | <cankt7lf33rq22e7sd3mrin3dgk0ahh0l5@4ax.com> |
| In reply to | #15252 |
On 14 Jun 2012 18:04:46 GMT, ram@zedat.fu-berlin.de (Stefan Ram)
wrote:
>Daniel Pitts <newsgroup.nospam@virtualinfinity.net> 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
The IOCCC (International Obfuscated C Code Contest) has been
running yearly for twenty years. Is someone trying to start an IOJJJ
(International Obfuscated Java Jungle of Junk?)?
Sincerely,
Gene Wirchenko
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-14 17:02 -0700 |
| Message-ID | <iYuCr.2555$7y4.1282@newsfe23.iad> |
| In reply to | #15252 |
On 6/14/12 11:04 AM, Stefan Ram wrote:
> Daniel Pitts<newsgroup.nospam@virtualinfinity.net> 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
>
Another lesson: Exceptions, and the deprecated (and highly dangerous)
Thread.stop(Throwable) method.
import java.awt.EventQueue;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
public class Hello extends Exception {
public static void main(String[] args) throws Exception {
Thread.setDefaultUncaughtExceptionHandler(
new Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace(System.out);
}
});
final Thread thread = Thread.currentThread();
EventQueue.invokeAndWait(new Runnable() {
public void run() {
thread.stop(new Hello());
}
});
}
public void printStackTrace(PrintStream s) {
s.print("Hello World");
}
}
[toc] | [prev] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2012-06-14 17:09 -0700 |
| Message-ID | <F2vCr.14193$GJ4.12529@newsfe16.iad> |
| In reply to | #15252 |
On 6/14/12 11:04 AM, Stefan Ram wrote:
> Daniel Pitts<newsgroup.nospam@virtualinfinity.net> 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.Arrays.asList(values())).replaceAll("\\p{Punct}",""));}}
[toc] | [prev] | [next] | [standalone]
| From | Kevin McMurtrie <mcmurtrie@pixelmemory.us> |
|---|---|
| Date | 2012-06-15 22:13 -0700 |
| Message-ID | <4fdc1603$0$86760$742ec2ed@news.sonic.net> |
| In reply to | #15252 |
In article <zZ6Cr.4514$v14.839@newsfe06.iad>,
Daniel Pitts <newsgroup.nospam@virtualinfinity.net> 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
[toc] | [prev] | [next] | [standalone]
Page 1 of 5 [1] 2 3 4 5 Next page →
Back to top | Article view | comp.lang.java.programmer
csiph-web