June Kim wrote:
> http://online-judge.uva.es/p/v7/706.html
Here's my first attempt:
segs=.'-||-||-'
unpack=. 5 3<@$"1 ' ',. 1j1#"1 ] {"0 1"1 2 ' ',.~ [
digs=.5 4{.L:0 segs unpack #:8 109 34 36 69 20 16 45 0 4
siz=:(0 1 0 0([<.^)~ [) #"1 ] #~ 0 1 0 1 0([<.^)~ [
form=:[EMAIL PROTECTED] siz L:0 ] {~ [: 10&#.^:_1 [: {: [
lcd1=:LF,~LF,@,.~_1}."1 [: ] 0 2 ,/"2@|: >@form~
out=:_2 }. [: ; [: <@(digs&lcd1)@(0&".);._2 [: ] 1!:1@<
For example, out'sample.file' will give the specified
sequence of characters, after building a sample file:
(0 :0)1!:2<'sample.file'
2 12345
3 67890
0 0
)
Notes:
The first three lines just build the list of digits.
I'm using boxing here where the contents have uniform shape.
This is so I could easily inspect my intermediate results.
My code might look simpler, if I abandoned boxing, and if
I represented the digits directly, perhaps starting from:
0 :0
- - - - - - - -
| | | | | | | | | | | | | |
- - - - - - -
| | | | | | | | | | | | |
- - - - - - -
)
However, I see that other people have already posted with
solutions which do that kind of thing, so I'll stop here.
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm