Typical - the definition of the LCD symbols looks
awful, and not what I saw on sending!
The numbers =: 0 : 0 definition should look
like the 6 lines of LCD characters including
column row blanks. I won't attempt to show it
again.
Mike
Mike Day wrote:
Not sure if this is more J-ish or not. The 1 0 2 transpose
could be removed at the expense of slightly more complicated
code.
(Haven't we discussed this in a J-forum previously?)
NB. this looks ok in Thunderbird with a fixed width font.
NB. ... apologies if not so good on receipt.
NB. set up size-1 LCD representations
numbers =: 0 : 0
- - - - - - - - | | | | | | | | | |
| | | |
- - - - - - - | | | | | | | | | |
| | |
- - - - - - - )
numbers =: 1 0 2 |: n =: 6 10 4$ 240{. LF -.~numbers
NB. including a blank column and row as part of each shape
2 { numbers NB. eg...
- |
- | -
NB. verb to adjust the "size" of the LC display
resize =: 3 : 0
:
NB. get vertical and horizontal replicate counts v, h
'v h' =. (0 1 0 1 0 0 ; 0 1 0 0) (1: >. *) each x
h #"1 v # y
)
show =: 3 : 0
:
units =. 10&#.^:_1 y size1 =. 1 0 2|: units { numbers ,"2 x
resize size1
)
NB. I haven't bothered with doing more than one in/output.
2 show 12345 NB. eg ...
-- -- -- | | | | | | | | | | | |
-- -- -- -- | | | | |
| | | | |
-- -- --
Mike
June Kim wrote:
First, have a look at the problem at
http://online-judge.uva.es/p/v7/706.html
Here is my first attempt at the solution:
dl=:<@}.;._1 (0 : 0)
~
-
| |
| |
-
~
|
|
~
-
|
-
|
-
~
-
|
-
|
-
~
| |
-
|
~
-
|
-
|
-
~
-
|
-
| |
-
~
-
|
|
~
-
| |
-
| |
-
~
-
| |
-
|
-
)
ss=:[: > <;._2
sep=:10&#.^:_1
sdl=: ss each dl
hm=:] #"1~ 1 , 1 ,~ [
vb=:[: >: (5$0 1) * <:
vm=:(#~ vb)~
mm=: [ hm vm
con=:[ ,. ' ' ,. ]
ds=: sdl {~ sep
lcd=: [:>con&.>/@(mm&.> ds)
2 lcd 12345
I wonder if mine is J-ish or not, and how you would solve this problem
in more J-ish way(if any). I am excited to learn from your solutions!
p.s. I happened upon rubyists solution at
http://rubyquiz.com/quiz14.html Have a look at it for comparison.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm