Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
import algorithm, strformat, strutils
|
||||
|
||||
let list = ["violet", "red", "green", "indigo", "blue", "yellow", "orange"]
|
||||
|
||||
var count = 0
|
||||
|
||||
proc comp(x, y: string): int =
|
||||
if x == y: return 0
|
||||
inc count
|
||||
while true:
|
||||
stdout.write &"{count:>2}) Is {x} less than {y} (y/n)? "
|
||||
let answer = stdin.readLine()[0]
|
||||
case answer
|
||||
of 'y': return -1
|
||||
of 'n': return 1
|
||||
else: echo "Incorrect answer."
|
||||
|
||||
var sortedList: seq[string]
|
||||
|
||||
for elem in list:
|
||||
sortedList.insert(elem, sortedList.upperBound(elem, comp))
|
||||
|
||||
echo "Sorted list: ", sortedList.join(", ")
|
||||
Loading…
Add table
Add a link
Reference in a new issue