Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #11177 > unrolled thread
| Started by | Ian Osgood <iano@quirkster.com> |
|---|---|
| First post | 2012-04-11 16:23 -0700 |
| Last post | 2012-05-02 01:44 +0200 |
| Articles | 20 on this page of 71 — 15 participants |
Back to article view | Back to comp.lang.forth
Google CodeJam? Ian Osgood <iano@quirkster.com> - 2012-04-11 16:23 -0700
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-12 00:43 -0700
Re: Google CodeJam? hughaguilar96@yahoo.com - 2012-04-21 15:13 -0700
Re: Google CodeJam? Bernd Paysan <bernd.paysan@gmx.de> - 2012-04-22 02:19 +0200
Re: Google CodeJam? "WJ" <w_a_x_man@yahoo.com> - 2012-04-22 04:03 +0000
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-22 23:08 -0700
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-22 23:17 -0700
Re: Google CodeJam? "WJ" <w_a_x_man@yahoo.com> - 2012-04-23 19:27 +0000
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-23 22:08 -0700
Re: Google CodeJam? "WJ" <w_a_x_man@yahoo.com> - 2012-04-24 08:30 +0000
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-24 23:00 -0700
Re: Google CodeJam? "WJ" <w_a_x_man@yahoo.com> - 2012-04-26 09:19 +0000
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-26 03:17 -0700
Re: Google CodeJam? vandys@vsta.org - 2012-04-26 16:45 +0000
Re: Google CodeJam? Paul Rubin <no.email@nospam.invalid> - 2012-04-26 10:47 -0700
Re: Google CodeJam? Paul Rubin <no.email@nospam.invalid> - 2012-04-27 02:26 -0700
Re: Google CodeJam? vandys@vsta.org - 2012-04-27 16:37 +0000
Re: Google CodeJam? Paul Rubin <no.email@nospam.invalid> - 2012-04-27 10:17 -0700
Re: Google CodeJam? vandys@vsta.org - 2012-04-27 18:15 +0000
Re: Google CodeJam? Rugxulo <rugxulo@gmail.com> - 2012-04-26 16:00 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-22 12:12 +0200
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-22 14:11 +0200
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-22 14:17 +0200
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-25 14:25 +0200
Re: Google CodeJam? mhx@iae.nl (Marcel Hendrix) - 2012-04-22 18:23 +0200
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-22 22:24 +0200
Re: Google CodeJam? mhx@iae.nl (Marcel Hendrix) - 2012-04-23 20:59 +0200
Re: Google CodeJam? Paul Rubin <no.email@nospam.invalid> - 2012-04-23 13:56 -0700
Re: Google CodeJam? mhx@iae.nl (Marcel Hendrix) - 2012-04-22 18:29 +0200
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-22 21:36 +0200
Re: Google CodeJam? Bernd Paysan <bernd.paysan@gmx.de> - 2012-04-22 23:08 +0200
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-22 23:06 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-23 23:19 +0200
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-23 22:35 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-25 01:59 +0200
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-24 22:16 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-25 14:25 +0200
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-25 11:58 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-26 00:23 +0200
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-25 11:58 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-26 00:23 +0200
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-25 11:58 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-26 00:23 +0200
Re: Google CodeJam? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-04-26 12:36 +0000
Re: Google CodeJam? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-04-25 13:39 +0000
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-04-25 10:05 -0700
Re: Google CodeJam? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-04-26 16:30 +0000
Re: Google CodeJam? Bernd Paysan <bernd.paysan@gmx.de> - 2012-04-27 15:21 +0200
Re: Google CodeJam? Paul Rubin <no.email@nospam.invalid> - 2012-04-24 00:51 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-25 01:59 +0200
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-25 01:59 +0200
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-27 14:15 +0200
Re: Google CodeJam? hughaguilar96@yahoo.com - 2012-04-30 23:54 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-05-02 01:44 +0200
Re: Google CodeJam? Hugh Aguilar <hughaguilar96@yahoo.com> - 2012-05-01 20:45 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-05-02 23:38 +0200
Re: Google CodeJam? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2012-04-24 12:50 +0100
Re: Google CodeJam? Paul Rubin <no.email@nospam.invalid> - 2012-04-24 08:22 -0700
Re: Google CodeJam? mhx@iae.nl (Marcel Hendrix) - 2012-04-24 22:28 +0200
Re: Google CodeJam? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2012-04-25 09:50 +0100
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-25 01:59 +0200
Re: Google CodeJam? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2012-04-25 09:49 +0100
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-04-27 18:28 +0200
Re: Google CodeJam? Bruno Gauthier <bgauthier@free.fr> - 2012-05-01 17:59 +0200
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-05-01 19:12 +0200
Re: Google CodeJam? Bruno Gauthier <bgauthier@free.fr> - 2012-05-01 20:39 +0200
Re: Google CodeJam? mhx@iae.nl - 2012-05-01 16:00 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-05-02 02:29 +0200
Re: Google CodeJam? Paul Rubin <no.email@nospam.invalid> - 2012-05-01 19:18 -0700
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-05-02 05:14 +0200
Re: Google CodeJam? awegel@arcor.de (Alex Wegel) - 2012-05-02 01:44 +0200
Page 3 of 4 — ← Prev page 1 2 [3] 4 Next page →
| From | awegel@arcor.de (Alex Wegel) |
|---|---|
| Date | 2012-04-26 00:23 +0200 |
| Message-ID | <1kj4t70.ubrsi214cmw9iN%awegel@arcor.de> |
| In reply to | #11627 |
Hugh Aguilar <hughaguilar96@yahoo.com> wrote: > On Apr 25, 6:25 am, awe...@arcor.de (Alex Wegel) wrote: > > But i know that you're on an agenda (as you repeatedly stated here): To > > bring down Forth Inc. > soso
[toc] | [prev] | [next] | [standalone]
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-04-25 11:58 -0700 |
| Message-ID | <fb11ade5-4d2e-4108-baca-0c7cb9e1d62b@r9g2000yqd.googlegroups.com> |
| In reply to | #11606 |
On Apr 25, 6:25 am, awe...@arcor.de (Alex Wegel) wrote: > But i know that you're on an agenda (as you repeatedly stated here): To > bring down Forth Inc. The world is full of sleazy salespeople selling garbage to unsuspecting customers. I don't interfere with them --- caveat emptor. Elizabeth Rather has spent her entire career telling everybody about how she knew Chuck Moore back in the 1970s. That is just name- dropping. Now she tells us that she personally knows many members of Barack Obama's family. That is just more name-dropping. If people are dumb enough to believe this baloney, then they deserve to get ripped off. Elizabeth Rather attacked my code. When Passaniti said that it "sucks" and was "pulled out of my ass," she described this as: "perceptive and technically sound." She herself said that my novice package was "written by a novice." She stepped over the line! She can't expect me to not interfere with her sleazy SwiftForth scam after saying such things about my code. Of course I'm going to point out the gross problems with SwiftForth --- she shouldn't have attacked my code --- people who live in glass houses shouldn't throw stones. When I'm driving my cab, people often tell me about how they hob-nob with celebrities, and then when we get to the destination they say that they have to go inside to get the money (presumably from their buddy Barack) --- I don't let them get away with this --- I have put people in jail for this --- and I have given them a beating first, before handing them over to the police. I can spot phonies a mile away --- Elizabeth Rather is a complete phony, attaching herself like a leach to Chuck Moore --- I am amazed that the comp.lang.forth crowd fails to see this (or, pretends not to see it). SwiftForth really is a glass house. I paid almost $500 for it, and it has serious bugs. For example, (LOCAL) doesn't work and will crash the system. Also, it does essentially no optimization at all --- it just pastes the code from sub-functions into the calling function --- all that this saves is the CALL and RET, which isn't much, and it bloats out the code so that it no longer fits in the cache. In SwiftForth, ALIGN and ALIGNED are no-ops, so we don't even get aligned data, which is a very basic optimization that even the most novice assembly- language programmers know about. SwiftForth gives the Forth community a bad name --- this is especially true because it comes from Forth Inc. --- casual observers assume that Forth Inc. defines Forth, because Forth Inc. owns the name "Forth" (and because Elizabeth Rather learned Forth directly from Chuck Moore in the 1970s, yada yada).
[toc] | [prev] | [next] | [standalone]
| From | awegel@arcor.de (Alex Wegel) |
|---|---|
| Date | 2012-04-26 00:23 +0200 |
| Message-ID | <1kj4t7c.1j1gctm8krqygN%awegel@arcor.de> |
| In reply to | #11628 |
Hugh Aguilar <hughaguilar96@yahoo.com> wrote: > On Apr 25, 6:25 am, awe...@arcor.de (Alex Wegel) wrote: > > But i know that you're on an agenda (as you repeatedly stated here): To > > bring down Forth Inc. Maybe you could get a job as a software insultant?
[toc] | [prev] | [next] | [standalone]
| From | Albert van der Horst <albert@spenarnc.xs4all.nl> |
|---|---|
| Date | 2012-04-26 12:36 +0000 |
| Message-ID | <m3370s.d9w@spenarnc.xs4all.nl> |
| In reply to | #11634 |
In article <1kj4t7c.1j1gctm8krqygN%awegel@arcor.de>, Alex Wegel <awegel@arcor.de> wrote: >Hugh Aguilar <hughaguilar96@yahoo.com> wrote: > >> On Apr 25, 6:25 am, awe...@arcor.de (Alex Wegel) wrote: >> > But i know that you're on an agenda (as you repeatedly stated here): To >> > bring down Forth Inc. > >Maybe you could get a job as a software insultant? Rolling on the floor with laughter! Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2012-04-25 13:39 +0000 |
| Message-ID | <2012Apr25.153938@mips.complang.tuwien.ac.at> |
| In reply to | #11592 |
Hugh Aguilar <hughaguilar96@yahoo.com> writes:
>When I run alien.4th under Gforth, Gforth aborts with this message:
>gforth: ./main.c.1188 optimize_bb: Assertion `ninsts<128' failed
That's a limitation in Gforth 0.6.*. Gforth 0.7.* does not have that
limitation. BTW, this means that your program has a sequence of 128
primitives without intervening control flow (no call to a colon
definition or somesuch). Not many people complained about that
limitation while 0.6.* was current, but I came across (IIRC) one
program where it caused a problem, so I removed the limitation.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2011: http://www.euroforth.org/ef11/
[toc] | [prev] | [next] | [standalone]
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-04-25 10:05 -0700 |
| Message-ID | <8feb1ad3-d808-439f-9c1b-48afd64c83fd@v22g2000yqm.googlegroups.com> |
| In reply to | #11615 |
On Apr 25, 7:39 am, an...@mips.complang.tuwien.ac.at (Anton Ertl) wrote: > Hugh Aguilar <hughaguila...@yahoo.com> writes: > >When I run alien.4th under Gforth, Gforth aborts with this message: > >gforth: ./main.c.1188 optimize_bb: Assertion `ninsts<128' failed > > That's a limitation in Gforth 0.6.*. Gforth 0.7.* does not have that > limitation. BTW, this means that your program has a sequence of 128 > primitives without intervening control flow (no call to a colon > definition or somesuch). Not many people complained about that > limitation while 0.6.* was current, but I came across (IIRC) one > program where it caused a problem, so I removed the limitation. > > - anton > -- > M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html > comp.lang.forth FAQs:http://www.complang.tuwien.ac.at/forth/faq/toc.html > New standard:http://www.forth200x.org/forth200x.html > EuroForth 2011:http://www.euroforth.org/ef11/ What possible purpose could there be in limiting the length of the functions? That seems like an arbitrary and contrived limitation. Your limitation was in the number of primitives without any intervening control-flow (calls or jumps). Well, this is pretty common with generated functions. The idea is to unwind loops. The loop is executed at compile-time rather than run-time and it generates a long function without any internal jumps. This makes my program faster, as jumps are typically the slowest aspect of any program. Also, it makes my program simpler because I have fewer nested loops, which a lot of programmers (me anyway) find confusing. I have a two-stage process: first I generate the pattern-check functions, then I execute all of them on all of the target strings. I'm a big fan of the idea of simplifying a program by making it multi-stage in order to avoid a lot of nested complexity --- this is also why we have pipes in Unix (plus they save memory, which was an issue on the 64K PDP-11). If your students weren't complaining about this limitation, it is because they are bad Forthers --- but I can't be blamed for that! Well, you got rid of this limitation in the latest version of Gforth (I haven't actually tested this, but I'll believe you) --- so that is a big step forward --- good job!
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2012-04-26 16:30 +0000 |
| Message-ID | <2012Apr26.183026@mips.complang.tuwien.ac.at> |
| In reply to | #11624 |
Hugh Aguilar <hughaguilar96@yahoo.com> writes:
>On Apr 25, 7:39=A0am, an...@mips.complang.tuwien.ac.at (Anton Ertl)
>wrote:
>> Hugh Aguilar <hughaguila...@yahoo.com> writes:
>> >When I run alien.4th under Gforth, Gforth aborts with this message:
>> >gforth: ./main.c.1188 optimize_bb: Assertion `ninsts<128' failed
>>
>> That's a limitation in Gforth 0.6.*. =A0Gforth 0.7.* does not have that
>> limitation. =A0BTW, this means that your program has a sequence of 128
>> primitives without intervening control flow (no call to a colon
>> definition or somesuch).
...
>What possible purpose could there be in limiting the length of the
>functions? That seems like an arbitrary and contrived limitation.
This limitation makes the storage management of optimal selection of
static superinstructions and static stack caching easier. IIRC it's
still there, but now it just breaks too-long basic blocks into parts
that are 128 primitives in length.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2011: http://www.euroforth.org/ef11/
[toc] | [prev] | [next] | [standalone]
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Date | 2012-04-27 15:21 +0200 |
| Message-ID | <jne6gi$s4o$1@online.de> |
| In reply to | #11592 |
Hugh Aguilar wrote: > Your program is incredibly ugly. Bernd Paysan calls this "plain Forth" Do you know what a plain bread is? Can you even speak plain English? Alex Wegel immediately understood what it means: Without anything on top of it. But then, Alex is just as German as I am, so we both speak the same dialect of English: The one taught in German schools. He's pretty good at it, coining terms like "Software insultant". :-) -- Bernd Paysan "If you want it done right, you have to do it yourself" http://bernd-paysan.de/
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-04-24 00:51 -0700 |
| Message-ID | <7xwr554les.fsf@ruckus.brouhaha.com> |
| In reply to | #11551 |
awegel@arcor.de (Alex Wegel) writes: > One thing keeping me from using CELLxy words is that the number 4 > doesn't really relate to the systems/cpus cell size, but rather to the > size (in AU) of the bit-set representation (26 bits). I think the Forth spirit is "solve the problem you have". The 32-bit representation is just fine for the problem as stated. > So, using CELLxy wouldn't be the right answer for smaller cpus or larger > bit-sets (what if scientists find out that the aliens use 65 characters > on tuesday?). And if there were a million patterns to check instead of 500, you would have wanted a totally different structure such as a decision tree, if you cared about speed. Similarly the aliens might skip over 65 chars and go directly to Unicode (Aliencode?) so again you'd need a totally different approach. That's ok too.
[toc] | [prev] | [next] | [standalone]
| From | awegel@arcor.de (Alex Wegel) |
|---|---|
| Date | 2012-04-25 01:59 +0200 |
| Message-ID | <1kj22yk.rnlwowhht11nN%awegel@arcor.de> |
| In reply to | #11558 |
Paul Rubin <no.email@nospam.invalid> wrote: > I think the Forth spirit is "solve the problem you have". The 32-bit > representation is just fine for the problem as stated. After some more thinking, i tend to agree. :-)
[toc] | [prev] | [next] | [standalone]
| From | awegel@arcor.de (Alex Wegel) |
|---|---|
| Date | 2012-04-25 01:59 +0200 |
| Message-ID | <1kj32wv.bjuk8i1utlkq5N%awegel@arcor.de> |
| In reply to | #11521 |
For those interested: I took some more time to make some changes to the
first version of my program.
Summary:
- Runs in pipe now, invoke like:
alien.fs <A-large-practice.in.txt >out.txt
or
gforth-fast alien.fs <A-large-practice.in.txt >out.txt
- Uses <80KB dictionary space now (was >300KB before), and even
de-allots the dict after running
- The source is smaller than 1000 bytes now, still using only plain
forth (ok, i admit that stdin isn't standard)
- Processes the large example in around 0.3sec, with apx. 0.27sec utime
on an 1.8GHz powerpc.
- Produces correct output (i.e. accepted by google codejam result check)
- Removed some of the 4*ish stuff, or changed to CELL..
- Switched from variables to values, mostly to make the code less
@-cluttered
- No comments (but that's no news)
Here it comes, enjoy:
#! /usr/local/bin/gforth-fast
create B 424 allot
: getl B dup 422 stdin read-line throw drop ;
0 value L
0 value D
0 value N
: read-head getl evaluate to N to D to L ;
: ord [char] a - ;
: word, bounds do i c@ ord c, loop ;
: read-dic align here D 0 do getl word, loop ;
create P 16 cells allot
-1 dup 1 rshift xor constant msb
: >msk msb swap rshift ;
: ccl) 0 >r
begin
char+ dup c@ ord
dup [ char z ord 1+ ] literal u<
while
>msk r> or >r
repeat
drop r> ;
: read-pat
P swap 0 do
>r dup c@ dup [char] ( = if
drop ccl)
else
ord >msk
then
invert r@ !
char+ r> cell+
loop 2drop ;
: check1
cells P + P do
i @ over c@ lshift
0< if unloop drop false exit then
char+
cell +loop
drop true ;
: matches 0 over D L * bounds do i L check1 1 and + L +loop ;
: .m ." Case #" 1 .r ." : " 1 .r cr ;
: chk-all N 0 do getl drop L read-pat matches i 1+ .m loop ;
' noop is bootmessage
read-head read-dic chk-all
here - allot
bye
[toc] | [prev] | [next] | [standalone]
| From | awegel@arcor.de (Alex Wegel) |
|---|---|
| Date | 2012-04-27 14:15 +0200 |
| Message-ID | <1kj7r60.3aht9b1sk2bgbN%awegel@arcor.de> |
| In reply to | #11587 |
For those still there - here's a final(?) version of my approach to the
alien program.
Now it's down to 150 words of source - i think that's how i leave it.
#! /usr/local/bin/gforth-fast
\ : key pad dup 1 stdin read-file throw drop c@ ; ( fast vsn. of KEY)
: <n> 0 begin key [char] 0 - dup 10 u< while swap 10 * + repeat drop ;
0 value L
: <dims> <n> to L <n> <n> ;
: ord [char] a - ;
: az? ord dup 26 u< ;
: az* begin key az? while c, repeat drop ;
: <dic> 0 do az* loop align ;
: >msk [ -1 dup 1 rshift xor ] literal swap rshift invert ;
: az*) -1 begin key az? while >msk and repeat drop ;
: -pat -1 cells L * allot ;
: <pat>
begin key
az? if
>msk
else
[char] ( ord = if az*) else exit then
then ,
again ;
: m?
here dup rot cells - do
i @ over c@ lshift
0< if unloop drop false exit then
char+
cell +loop
drop true ;
: #m 0 -rot L * bounds do i L m? - L +loop ;
: .m ." Case #" 1 .r ." : " 1 .r cr ;
: chk 0 do 2dup <pat> #m -pat i 1+ .m loop 2drop ;
here <dims> over <dic> chk bye
[toc] | [prev] | [next] | [standalone]
| From | hughaguilar96@yahoo.com |
|---|---|
| Date | 2012-04-30 23:54 -0700 |
| Message-ID | <31940905.52.1335855283770.JavaMail.geo-discussion-forums@ynen8> |
| In reply to | #11684 |
On Friday, April 27, 2012 6:15:49 AM UTC-6, Alex Wegel wrote:
> For those still there - here's a final(?) version of my approach to the
> alien program.
> Now it's down to 150 words of source - i think that's how i leave it.
>
> #! /usr/local/bin/gforth-fast
> \ : key pad dup 1 stdin read-file throw drop c@ ; ( fast vsn. of KEY)
> : <n> 0 begin key [char] 0 - dup 10 u< while swap 10 * + repeat drop ;
> 0 value L
> : <dims> <n> to L <n> <n> ;
>
> : ord [char] a - ;
> : az? ord dup 26 u< ;
> : az* begin key az? while c, repeat drop ;
> : <dic> 0 do az* loop align ;
>
> : >msk [ -1 dup 1 rshift xor ] literal swap rshift invert ;
> : az*) -1 begin key az? while >msk and repeat drop ;
> : -pat -1 cells L * allot ;
> :
>
> begin key
> az? if
> >msk
> else
> [char] ( ord = if az*) else exit then
> then ,
> again ;
>
> : m?
> here dup rot cells - do
> i @ over c@ lshift
> 0< if unloop drop false exit then
> char+
> cell +loop
> drop true ;
>
> : #m 0 -rot L * bounds do i L m? - L +loop ;
> : .m ." Case #" 1 .r ." : " 1 .r cr ;
> : chk 0 do 2dup
> #m -pat i 1+ .m loop 2drop ;
>
> here <dims> over <dic> chk bye
Here is a new version of my program, including these upgrades:
1.) I implemented a SSEQ data type that is similar to my SEQ data type except that it allows for big (>255 char) strings.
2.) I replaced SEQ with SSEQ throughout the ALIEN program as needed so that the program will now handle the large sample file.
3.) I switched to bit-masks similar to Alex's program.
4.) I fixed a stack-picture comment that was incorrect.
This is not plain Forth --- I've never written a plain Forth program in my life. I find plain Forth to be largely unreadable (although I can *decipher* it given enough time). If I were offered a job maintaining plain Forth software, I would refuse and just stick with cab driving --- unless it paid a *lot* of money, but that is unrealistic because the employer would just have the program rewritten from scratch in a readable language for less money.
My program seems rather slow on the large sample file. I think this is due to my heavy use of the heap, which is quite slow on all Forth systems (I don't know why). I also compile functions at run-time, which may be slow depending upon which compiler is being used and how much optimization is being done.
This is SSEQ which will go into the novice package:
list
w field .cnt
w field .chars \ pointer to heap
constant sseq
: sseqable ( adr cnt -- new-adr cnt ) \ put string in heap for SSEQ so <KILL-SSEQ> will work on the SSEQ
>r
r@ alloc \ -- adr new-adr \r: -- cnt
tuck r@ cmove> \ -- new-adr
r> ;
: init-sseq ( adr cnt node -- node )
init-list >r
sseqable r@ .cnt ! r@ .chars !
r> ;
: new-sseq ( adr cnt -- node )
sseq alloc
init-sseq ;
: <kill-sseq> ( node -- )
dup .chars @ dealloc
dealloc ;
: kill-sseq ( head -- )
each[ <kill-sseq> ]each ;
macro: <sseq> ( node -- adr cnt )
dup .chars @ swap .cnt @ ;
: <show-sseq> ( node -- )
<sseq> type cr ;
: show-sseq ( head -- )
cr
['] <show-sseq> each ;
1000 value sseq-size \ making this too big could be a problem if such a large block can't be found in the heap
: <read-sseq> ( adr cnt -- head )
r/o <open-file> >r \ r: -- file-id
nil begin \ -- head
sseq-size 2+ alloc \ -- head chars
dup sseq-size r@ read-line abort" *** READ-SSEQ failed to read line ***"
while \ -- head chars cnt
dup >r realloc r> \ -- head new-chars cnt
new-sseq \ -- head node
link repeat 2drop
r> <close-file> ;
: read-sseq ( name -- head )
count <read-sseq> ;
: <write-sseq> ( head adr cnt -- )
w/o <create-file> swap \ -- file-id head
each[ <sseq> rover write-line abort" *** <WRITE-SSEQ> failed to write ***" ]each
<close-file> ;
: write-sseq ( head name -- )
count <write-sseq> ;
This is the new ALIEN program:
\ This is the solution to the "alien language" example problem from Google CodeJam.
\ http://code.google.com/codejam/contest/90101/dashboard#s=p0
\ Written by Hugh Aguilar --- copyright (c) 2012 --- BSD license
\ requires novice.4th and list.4th
marker alien.4th
\ ******
\ ****** input and output
\ ******
variable #letters
variable #words
variable #patterns
: sseqs ( name-str -- word-sseq pattern-sseq )
read-sseq
dup <sseq> evaluate
#patterns ! #words ! #letters !
.fore @ \ -- word-seq
dup #words @ nth \ -- word-seq pattern-seq
delink
dup #patterns @ nth \ -- word-seq pattern-seq extraneous-seq
delink kill-sseq \ -- word-seq pattern-seq
\ error checking
over length #words @ <> abort" *** bad word-sseq ***"
dup length #patterns @ <> abort" *** bad pattern-sseq ***"
over each[ .cnt @ #letters @ <> abort" *** string in word-sseq is wrong length ***" ]each ;
: dump-result ( pattern-list name-str -- )
<cstr +cstr c" .result" +cstr cstr> write-sseq ;
\ ******
\ ****** convert pattern string into any-seq list
\ ****** each node in the list represents one char in the target string
\ ****** the .LINE string of each node contains all of the character that would match
\ ******
: check-any-str { pattern-adr pattern-cnt head -- }
head length #letters @ <> if
cr ." *** any-seq is the wrong length ***"
cr pattern-adr pattern-cnt type
cr true abort" *** aborting ***
then ;
: <make-any-seq> ( head str -- head )
dup c@ if new-seq link \ str has characters in it
else drop then ;
: make-any-seq { pattern-adr pattern-cnt | group? -- any-seq }
nil <cstr
pattern-adr pattern-cnt bounds ?do \ -- head
group? if \ if inside of ( ) group
I c@ [char] ) = if false to group? cstr> <make-any-seq> <cstr
else I c@ char+cstr then
else \ else outside of ( ) group
I c@ [char] ( = if true to group?
else I c@ char+cstr cstr> <make-any-seq> <cstr then
then
loop
cstr> <make-any-seq>
pattern-adr pattern-cnt rover check-any-str ;
\ ******
\ ****** generate pattern matcher
\ ******
char & comment \ this is an example of what will get generated
:noname ( mask-adr -- match? ) \ this is for: a(bc)
dup @ 1 and 0= if drop false exit then
w + \ -- new-mask-adr
dup @ 6 and 0= if drop false exit then
w + \ -- new-mask-adr
drop true ;
&
: char>mask ( char -- mask ) \ this assumes that there are < 32 chars, and they start with 'a'
[char] a - \ -- ordinal
1 swap lshift ;
: <generate-pattern> ( node -- )
>r
s" dup @ " evaluate
0 r> .line @ count bounds do \ -- mask
I c@ char>mask or loop lit, \ --
s" and 0= if drop false exit then w + " evaluate ;
: generate-pattern ( any-seq -- xt )
>r
s" :noname ( char-adr -- match? ) " evaluate
r> ['] <generate-pattern> each
s" drop true ; " evaluate ;
\ ******
\ ****** upgrade word-seq
\ ******
list
w field .mask \ pointer to array of words
constant mask
: <kill-mask> ( node -- )
dup .mask @ dealloc
dealloc ;
: kill-mask ( head -- )
each[ <kill-mask> ]each ;
: init-mask ( word-adr word-cnt node -- node )
init-list >r
dup w * alloc \ -- word-adr word-cnt mask-array
dup r@ .mask !
-rot bounds do \ -- mask-element
I c@ char>mask over !
w + loop drop \ --
r> ;
: new-mask ( word-adr word-cnt -- )
mask alloc
init-mask ;
: upgrade-word ( word-sseq -- mask-list ) \ create a MASK list given a SSEQ list
nil swap \ -- mask-list word-sseq
each[ <sseq> new-mask link ]each ;
\ ******
\ ****** upgrade pattern-seq
\ ******
sseq \ starts out as pattern-str, later gets changed to result-str
w field .any \ pointer to any-seq
w field .xt \ xt of generated pattern matcher
w field .matches \ count of matches for this pattern
constant pattern
: <kill-pattern> ( node -- )
dup .any @ kill-seq
<kill-sseq> ;
: kill-pattern ( head -- )
each[ <kill-pattern> ]each ;
: init-pattern ( pattern-adr pattern-cnt node -- node )
init-sseq >r
r@ .chars @ r@ .cnt @ make-any-seq r@ .any !
r@ .any @ generate-pattern r@ .xt !
0 r@ .matches !
r> ;
: new-pattern ( adr cnt -- node )
pattern alloc
init-pattern ;
: upgrade-pattern ( pattern-sseq -- pattern-list ) \ create a PATTERN list given a SSEQ list
nil swap \ -- pattern-list pattern-sseq
each[ <sseq> new-pattern link ]each ;
\ ******
\ ****** pattern-match
\ ******
: <check-word> ( pattern-list-node mask-node -- pattern-list-node )
.mask @ \ -- pattern-list-node mask-adr
over .xt @ execute \ -- pattern-list-node match?
if 1 over .matches +! then ; \ -- pattern-list-node
: <check-pattern> ( mask-list pattern-list-node -- mask-list )
over ['] <check-word> each \ -- word-sseq pattern-list-node
drop ;
: check-pattern ( mask-list pattern-list -- )
['] <check-pattern> each \ -- mask-list
drop ;
\ ******
\ ****** make result strings
\ ******
: u>str ( u -- adr cnt )
u>d <# #s #> ;
: <fill-result> ( pattern# pattern-list-node -- new-pattern# )
dup .chars @ dealloc \ get rid of pattern-str
<cstr
c" Case #" +cstr
over u>str <+cstr>
c" : " +cstr
dup .matches @ u>str <+cstr>
cstr> count sseqable rover .cnt ! swap .chars ! \ -- pattern# \ set result-str
1+ ; \ -- new-pattern#
: fill-result ( pattern-list -- )
1 swap ['] <fill-result> each \ -- pattern#
drop ;
\ ******
\ ****** main program
\ ******
: alien ( name-str -- )
dup sseqs { name-str word-sseq pattern-sseq | mask-list pattern-list -- }
s" marker upgrade-pattern-stuff " evaluate \ so we can get rid of the UPGRADE-PATTERN words
word-sseq upgrade-word to mask-list
pattern-sseq upgrade-pattern to pattern-list
mask-list pattern-list check-pattern
pattern-list fill-result
pattern-list name-str dump-result
\ clean up
word-sseq kill-sseq
pattern-sseq kill-sseq
mask-list kill-mask
pattern-list kill-pattern
s" upgrade-pattern-stuff " evaluate ;
[toc] | [prev] | [next] | [standalone]
| From | awegel@arcor.de (Alex Wegel) |
|---|---|
| Date | 2012-05-02 01:44 +0200 |
| Message-ID | <1kjey9p.1sl5cgeihtkcnN%awegel@arcor.de> |
| In reply to | #11798 |
<hughaguilar96@yahoo.com> wrote: > I've never written a plain Forth program in my life. Now i'm puzzled (though not really surprised by the fact itself) - this is coming quite a long way from: > I'm the only Forther on the planet who has any chance at all. I wish you much fun with or without your package, and good luck with your copyrights. (iBrows raised..) Alex
[toc] | [prev] | [next] | [standalone]
| From | Hugh Aguilar <hughaguilar96@yahoo.com> |
|---|---|
| Date | 2012-05-01 20:45 -0700 |
| Message-ID | <5fb63e14-26be-4e73-b20a-6801033978d6@f5g2000vbt.googlegroups.com> |
| In reply to | #11811 |
On May 1, 5:44 pm, awe...@arcor.de (Alex Wegel) wrote: > <hughaguila...@yahoo.com> wrote: > > I've never written a plain Forth program in my life. > > Now i'm puzzled (though not really surprised by the fact itself) - this > is coming quite a long way from: > > > I'm the only Forther on the planet who has any chance at all. Your "plain Forth" would more accurately be called "obfuscated Forth" --- I've never written that in my life --- and I never will. I don't think that I could write a Forth program without stack-picture comments, as I would confuse myself. I think that you used stack- picture comments just like everybody else when you wrote your program, but then removed them afterward to obfuscate your code. We've been quoting poetry in this thread --- here is what another German said on the subject: "Nor are poets clean enough for me --- they muddy the water to make it appear deep." > I wish you much fun with or without your package, and good luck with > your copyrights. (iBrows raised..) I stick that copyright notice on the top of all my stuff. I don't think there is a market for alien-alphabet software. This will go into the next novice package upgrade as yet another example program --- all of that stuff is BSD license --- anybody can use it freely. Actually, there isn't any market for any kind of Forth. That was the point that I was making. It is mildly amusing to write a string pattern-matching program from scratch in Forth, but the rest of the world just uses the myriad scripting languages available for this kind of stuff --- they are trivial. It took me about 3 hours (and I screwed it up by not supporting pattern strings longer than 255 chars) --- no employer in the world is going to pay for 3 hours of work to write a program that even the office intern working for free could knock out in 30 minutes.
[toc] | [prev] | [next] | [standalone]
| From | awegel@arcor.de (Alex Wegel) |
|---|---|
| Date | 2012-05-02 23:38 +0200 |
| Message-ID | <1kjhq51.1do5gum1iy5m47N%awegel@arcor.de> |
| In reply to | #11817 |
You don't really want an answer to that crap?
[toc] | [prev] | [next] | [standalone]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2012-04-24 12:50 +0100 |
| Message-ID | <jn6425$rva$1@dont-email.me> |
| In reply to | #11508 |
On 21/04/2012 23:13, hughaguilar96@yahoo.com wrote:
> On Thursday, April 12, 2012 1:43:19 AM UTC-6, Hugh Aguilar wrote:
>> Just for fun, lets have our own comp.lang.forth contest to write the
>> best Forth solution to the "alien language" problem.
>> http://code.google.com/codejam/contest/90101/dashboard#s=p0
>> This will be a loser's consolation contest, as none of us have any
>> chance at the real contest.
>
> I've waited and waited, but nobody has come forward. To qualify for the CodeJam contest, the program had to be written in under 8 minutes. That is very fast programming; I think that a typical programmer using a modern language would take about 1/2 hour. My own Forth program took me about 3 hours, so I am 6 times slower than pretty much everybody. This is a big part of why Forth is not used in the work world. No employer is going to pay anybody to program in Forth when it takes 6 times longer to write a program than it does in any other language. Also, I had the advantage of having my novice package available. Without the novice package, I think most Forth programmers would take maybe 3 days to write a program like this (that is why nobody responded to my challenge).
>
> It seems extremely unlikely that any Forther is going to come up with a Forth program to compete against mine. I would like to see programmers of other languages, such as Lisp and Ruby and so forth, present their own programs along with a mention of how much time was required. It is okay to post non-Forth code on comp.lang.forth --- nobody is posting Forth code --- if we are going to get any code posted, it will have to be in other languages.
>
Yet another solution using simple character comparisons. Not a robust
solution as it expects perfectly formatted data, which is OK for the two
test files. Just stick the word alien as the first line of a test file
and include it.
0 value L 0 value D 0 value N
variable awords
: next-line ( -- ) refill 0= if cr ." Finished" cr quit then ;
: get-LDN ( -- ) next-line source evaluate to N to D to L ;
: load-words ( -- )
here awords !
D 0 do next-line source here over chars allot swap cmove loop
;
\ Match alternatives inside parentheses, ca points to a ( character
\ Returns ca2 which points to a ) character
: match-alts ( ch ca -- ca2 f ) \ f is true for a match
begin
char+ 2dup c@ dup [char] ) <> ( -- ch ca' ch ch2 f )
while
=
until
nip 1000 s" )" search nip \ match, skip to closing )
else
2drop nip 0 \ no match
then
;
\ ca1 is test case, ca2 is word of length L
\ returns 1 for a match else 0
: match-word ( ca1 ca2 -- 0|1 )
L chars over + swap
do ( -- ca1 )
dup c@ dup [char] ( <>
if
i c@ <> if 0= leave then
else
drop i c@ swap match-alts 0= if 0= leave then
then
char+ 1 chars
+loop
0<> negate
;
: match-all-words ( ca -- n )
0 awords @ D L chars * over + swap
do ( -- ca n )
over i match-word + ( -- ca n' )
L chars
+loop nip
;
: .case ( n i -- ) cr ." Case #" 0 .r ." : " . ;
: match-all-cases ( -- n )
N 1+ 1
do next-line source drop match-all-words i .case loop
;
: alien
cr get-LDN
load-words
match-all-cases
next-line
;
Results for the large file - do others agree?
\ -----------------
Case #1: 0
Case #2: 1
Case #3: 0
Case #4: 1
Case #5: 577
Case #6: 577
Case #7: 1
Case #8: 384
Case #9: 1
Case #10: 375
Case #11: 0
Case #12: 1
Case #13: 0
Case #14: 1
Case #15: 264
Case #16: 457
Case #17: 1
Case #18: 378
Case #19: 1
Case #20: 478
Case #21: 0
Case #22: 1
Case #23: 0
Case #24: 1
Case #25: 537
Case #26: 419
Case #27: 1
Case #28: 499
Case #29: 1
Case #30: 483
Case #31: 0
Case #32: 1
Case #33: 0
Case #34: 1
Case #35: 388
Case #36: 720
Case #37: 1
Case #38: 280
Case #39: 1
Case #40: 546
Case #41: 0
Case #42: 1
Case #43: 0
Case #44: 1
Case #45: 561
Case #46: 666
Case #47: 1
Case #48: 501
Case #49: 1
Case #50: 533
Case #51: 0
Case #52: 1
Case #53: 0
Case #54: 1
Case #55: 522
Case #56: 517
Case #57: 1
Case #58: 690
Case #59: 1
Case #60: 494
Case #61: 0
Case #62: 1
Case #63: 0
Case #64: 1
Case #65: 548
Case #66: 533
Case #67: 1
Case #68: 555
Case #69: 1
Case #70: 643
Case #71: 0
Case #72: 1
Case #73: 0
Case #74: 1
Case #75: 763
Case #76: 637
Case #77: 1
Case #78: 367
Case #79: 1
Case #80: 801
Case #81: 0
Case #82: 1
Case #83: 0
Case #84: 1
Case #85: 534
Case #86: 769
Case #87: 1
Case #88: 627
Case #89: 1
Case #90: 594
Case #91: 0
Case #92: 1
Case #93: 0
Case #94: 1
Case #95: 900
Case #96: 346
Case #97: 1
Case #98: 398
Case #99: 1
Case #100: 423
Case #101: 0
Case #102: 1
Case #103: 0
Case #104: 1
Case #105: 414
Case #106: 441
Case #107: 1
Case #108: 759
Case #109: 1
Case #110: 473
Case #111: 0
Case #112: 1
Case #113: 0
Case #114: 1
Case #115: 502
Case #116: 678
Case #117: 1
Case #118: 572
Case #119: 1
Case #120: 441
Case #121: 0
Case #122: 1
Case #123: 0
Case #124: 1
Case #125: 389
Case #126: 430
Case #127: 1
Case #128: 665
Case #129: 1
Case #130: 397
Case #131: 0
Case #132: 1
Case #133: 0
Case #134: 1
Case #135: 646
Case #136: 324
Case #137: 1
Case #138: 636
Case #139: 1
Case #140: 623
Case #141: 0
Case #142: 1
Case #143: 0
Case #144: 1
Case #145: 529
Case #146: 526
Case #147: 1
Case #148: 531
Case #149: 1
Case #150: 496
Case #151: 0
Case #152: 1
Case #153: 0
Case #154: 1
Case #155: 336
Case #156: 421
Case #157: 1
Case #158: 456
Case #159: 1
Case #160: 336
Case #161: 0
Case #162: 1
Case #163: 0
Case #164: 1
Case #165: 473
Case #166: 563
Case #167: 1
Case #168: 323
Case #169: 1
Case #170: 327
Case #171: 0
Case #172: 1
Case #173: 0
Case #174: 1
Case #175: 650
Case #176: 528
Case #177: 1
Case #178: 427
Case #179: 1
Case #180: 459
Case #181: 0
Case #182: 1
Case #183: 0
Case #184: 1
Case #185: 525
Case #186: 579
Case #187: 1
Case #188: 533
Case #189: 1
Case #190: 833
Case #191: 0
Case #192: 1
Case #193: 0
Case #194: 1
Case #195: 472
Case #196: 400
Case #197: 1
Case #198: 604
Case #199: 1
Case #200: 529
Case #201: 0
Case #202: 1
Case #203: 0
Case #204: 1
Case #205: 708
Case #206: 337
Case #207: 1
Case #208: 519
Case #209: 1
Case #210: 596
Case #211: 0
Case #212: 1
Case #213: 0
Case #214: 1
Case #215: 416
Case #216: 599
Case #217: 1
Case #218: 663
Case #219: 1
Case #220: 420
Case #221: 0
Case #222: 1
Case #223: 0
Case #224: 1
Case #225: 467
Case #226: 649
Case #227: 1
Case #228: 571
Case #229: 1
Case #230: 417
Case #231: 0
Case #232: 1
Case #233: 0
Case #234: 1
Case #235: 751
Case #236: 381
Case #237: 1
Case #238: 460
Case #239: 1
Case #240: 278
Case #241: 0
Case #242: 1
Case #243: 0
Case #244: 1
Case #245: 409
Case #246: 636
Case #247: 1
Case #248: 320
Case #249: 1
Case #250: 644
Case #251: 0
Case #252: 1
Case #253: 0
Case #254: 1
Case #255: 603
Case #256: 289
Case #257: 1
Case #258: 461
Case #259: 1
Case #260: 322
Case #261: 0
Case #262: 1
Case #263: 0
Case #264: 1
Case #265: 747
Case #266: 417
Case #267: 1
Case #268: 676
Case #269: 1
Case #270: 393
Case #271: 0
Case #272: 1
Case #273: 0
Case #274: 1
Case #275: 414
Case #276: 450
Case #277: 1
Case #278: 432
Case #279: 1
Case #280: 481
Case #281: 0
Case #282: 1
Case #283: 0
Case #284: 1
Case #285: 676
Case #286: 581
Case #287: 1
Case #288: 464
Case #289: 1
Case #290: 530
Case #291: 0
Case #292: 1
Case #293: 0
Case #294: 1
Case #295: 425
Case #296: 483
Case #297: 1
Case #298: 433
Case #299: 1
Case #300: 416
Case #301: 0
Case #302: 1
Case #303: 0
Case #304: 1
Case #305: 514
Case #306: 434
Case #307: 1
Case #308: 480
Case #309: 1
Case #310: 396
Case #311: 0
Case #312: 1
Case #313: 0
Case #314: 1
Case #315: 462
Case #316: 623
Case #317: 1
Case #318: 426
Case #319: 1
Case #320: 356
Case #321: 0
Case #322: 1
Case #323: 0
Case #324: 1
Case #325: 543
Case #326: 507
Case #327: 1
Case #328: 433
Case #329: 1
Case #330: 602
Case #331: 0
Case #332: 1
Case #333: 0
Case #334: 1
Case #335: 459
Case #336: 248
Case #337: 1
Case #338: 650
Case #339: 1
Case #340: 357
Case #341: 0
Case #342: 1
Case #343: 0
Case #344: 1
Case #345: 489
Case #346: 520
Case #347: 1
Case #348: 481
Case #349: 1
Case #350: 313
Case #351: 0
Case #352: 1
Case #353: 0
Case #354: 1
Case #355: 359
Case #356: 440
Case #357: 1
Case #358: 475
Case #359: 1
Case #360: 642
Case #361: 0
Case #362: 1
Case #363: 0
Case #364: 1
Case #365: 434
Case #366: 470
Case #367: 1
Case #368: 322
Case #369: 1
Case #370: 498
Case #371: 0
Case #372: 1
Case #373: 0
Case #374: 1
Case #375: 385
Case #376: 744
Case #377: 1
Case #378: 465
Case #379: 1
Case #380: 382
Case #381: 0
Case #382: 1
Case #383: 0
Case #384: 1
Case #385: 784
Case #386: 654
Case #387: 1
Case #388: 671
Case #389: 1
Case #390: 481
Case #391: 0
Case #392: 1
Case #393: 0
Case #394: 1
Case #395: 357
Case #396: 422
Case #397: 1
Case #398: 526
Case #399: 1
Case #400: 418
Case #401: 0
Case #402: 1
Case #403: 0
Case #404: 1
Case #405: 371
Case #406: 526
Case #407: 1
Case #408: 606
Case #409: 1
Case #410: 1045
Case #411: 0
Case #412: 1
Case #413: 0
Case #414: 1
Case #415: 495
Case #416: 496
Case #417: 1
Case #418: 540
Case #419: 1
Case #420: 506
Case #421: 0
Case #422: 1
Case #423: 0
Case #424: 1
Case #425: 372
Case #426: 601
Case #427: 1
Case #428: 575
Case #429: 1
Case #430: 450
Case #431: 0
Case #432: 1
Case #433: 0
Case #434: 1
Case #435: 450
Case #436: 507
Case #437: 1
Case #438: 589
Case #439: 1
Case #440: 390
Case #441: 0
Case #442: 1
Case #443: 0
Case #444: 1
Case #445: 441
Case #446: 447
Case #447: 1
Case #448: 397
Case #449: 1
Case #450: 296
Case #451: 0
Case #452: 1
Case #453: 0
Case #454: 1
Case #455: 226
Case #456: 407
Case #457: 1
Case #458: 509
Case #459: 1
Case #460: 619
Case #461: 0
Case #462: 1
Case #463: 0
Case #464: 1
Case #465: 517
Case #466: 467
Case #467: 1
Case #468: 483
Case #469: 1
Case #470: 569
Case #471: 0
Case #472: 1
Case #473: 0
Case #474: 1
Case #475: 481
Case #476: 509
Case #477: 1
Case #478: 451
Case #479: 1
Case #480: 348
Case #481: 0
Case #482: 1
Case #483: 0
Case #484: 1
Case #485: 713
Case #486: 424
Case #487: 1
Case #488: 391
Case #489: 1
Case #490: 640
Case #491: 0
Case #492: 1
Case #493: 0
Case #494: 1
Case #495: 650
Case #496: 479
Case #497: 1
Case #498: 470
Case #499: 1
Case #500: 826
--
Gerry
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2012-04-24 08:22 -0700 |
| Message-ID | <7xr4vdqhm7.fsf@ruckus.brouhaha.com> |
| In reply to | #11563 |
Gerry Jackson <gerry@jackson9000.fsnet.co.uk> writes: > Yet another solution using simple character comparisons. Very nice and compact. > Results for the large file - do others agree? I did a quick eyeball check of a dozen or so values and didn't spot any discrepancies with my own output.
[toc] | [prev] | [next] | [standalone]
| From | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| Date | 2012-04-24 22:28 +0200 |
| Message-ID | <00071311998435@frunobulax.edu> |
| In reply to | #11563 |
Gerry Jackson <gerry@jackson9000.fsnet.co.uk> writes Re: Google CodeJam? [..] > Yet another solution using simple character comparisons. Not a robust > solution as it expects perfectly formatted data, which is OK for the two > test files. Just stick the word alien as the first line of a test file > and include it. [..] Results for the large file - do others agree? [..] The results match mine, modulo spaces, tabs, and eol characters. Google has a checker that you could have used. -marcel
[toc] | [prev] | [next] | [standalone]
| From | Gerry Jackson <gerry@jackson9000.fsnet.co.uk> |
|---|---|
| Date | 2012-04-25 09:50 +0100 |
| Message-ID | <jn8dsa$c49$2@dont-email.me> |
| In reply to | #11581 |
On 24/04/2012 21:28, Marcel Hendrix wrote: > Gerry Jackson<gerry@jackson9000.fsnet.co.uk> writes Re: Google CodeJam? > [..] >> Yet another solution using simple character comparisons. Not a robust >> solution as it expects perfectly formatted data, which is OK for the two >> test files. Just stick the word alien as the first line of a test file >> and include it. > [..] > Results for the large file - do others agree? > [..] > > The results match mine, modulo spaces, tabs, and eol characters. Thanks > Google has a checker that you could have used. > Sorry, I'd overlooked that. -- Gerry
[toc] | [prev] | [next] | [standalone]
Page 3 of 4 — ← Prev page 1 2 [3] 4 Next page →
Back to top | Article view | comp.lang.forth
csiph-web