AA 折れ線グラフクイズ
http://oss.timedia.co.jp/index.fcgi/kahua-web/show/ossz/oneline/2006-03-14
http://oss.timedia.co.jp/index.fcgi/kahua-web/show/ossz/oneline/2006-03-15
歪 経由で。
an Array2D にマップされた平面へ1文字ずつプロットする版
| series value min max pairs height result | series := 'RCRFCRFFCCRFFRRCRRCCFRFRFF'. value := min := max := 0. pairs := Array streamContents: [:ss | series do: [:each | each caseOf: { [$R] -> [ss nextPut: {value. $/}. max := max max: (value := value + 1)]. [$F] -> [ss nextPut: {value := value - 1. $\}. min := min min: value]. [$C] -> [ss nextPut: {value. $_}]}]]. height := max - min + 1. result := Array2D width: series size + 1 height: height type: String. result atAllPut: Character space. (1 to: height) do: [:yy | result at: series size + 1 at: yy put: Character cr]. pairs doWithIndex: [:pair :xx | result at: xx at: height - (pair first - min) put: pair last]. ^ result asArray
=> ' __ / \/\/\ _/\_/\ _/ \ / \__/\ / \/ '
行を変えずに連続する文字の列の抽出を行なった後、それをスキャンする版
| series assocs add currv nextv wstrm | series := 'RCRFCRFFCCRFFRRCRRCCFRFRFF'. currv := nextv := 0. wstrm := '' writeStream. assocs := OrderedCollection new. add := [assocs add: currv -> wstrm contents. wstrm := '' writeStream. currv := nextv]. series do: [:each | each caseOf: { [$R] -> [nextv > currv ifTrue: [add value]. wstrm nextPut: $/. nextv := nextv + 1]. [$F] -> [(nextv := nextv - 1) < currv ifTrue: [add value]. wstrm nextPut: $\]. [$C] -> [nextv > currv ifTrue: [add value]. wstrm nextPut: $_]}]. wstrm size > 0 ifTrue: [add value]. ^ String streamContents: [:ss | (assocs max key to: assocs min key by: -1) do: [:rowidx | assocs do: [:assoc | assoc key = rowidx ifTrue: [ss nextPutAll: assoc value] ifFalse: [assoc value size timesRepeat: [ss space]]]. ss cr]]
=> ' __ / \/\/\ _/\_/\ _/ \ / \__/\ / \/ '