Talk:Order two numerical lists: Difference between revisions
Content added Content deleted
No edit summary |
(test cases and draft) |
||
Line 7: | Line 7: | ||
Whatever is decided, some of the solutions will be incorrect and will need to be changed. --[[User:Spoon!|Spoon!]] 23:55, 29 November 2011 (UTC) |
Whatever is decided, some of the solutions will be incorrect and will need to be changed. --[[User:Spoon!|Spoon!]] 23:55, 29 November 2011 (UTC) |
||
: This probably should be marked draft until decided. --[[User:Dgamey|Dgamey]] 03:21, 30 November 2011 (UTC) |
|||
: Adding in extra conditions like stable sort when the task is NOT marked draft is rather bad form --[[User:Dgamey|Dgamey]] 03:21, 30 November 2011 (UTC) |
|||
==Test Cases== |
|||
I found the description a bit confusing at first. I used the following test cases where demo_list_llt was a wrapper to support my interpretation. |
|||
<pre> write() |
|||
demo_list_llt([-1],[0]) # << ok |
|||
demo_list_llt([0],[0]) # == fail |
|||
demo_list_llt([0],[-1]) # >> fail |
|||
write() |
|||
demo_list_llt([0],[0,-1]) # << ok |
|||
demo_list_llt([0],[0,0]) # << ok |
|||
demo_list_llt([0],[0,1]) # << ok |
|||
demo_list_llt([0,-1],[0]) # >> fail |
|||
demo_list_llt([0,0],[0]) # >> fail |
|||
demo_list_llt([0,0],[1]) # << ok</pre> |
|||
With the following output:<pre>[ 1 2 1 3 2 ] << [ 1 2 0 4 4 0 0 0 ] - FAILS |
|||
[ -1 ] << [ 0 ] |
|||
[ 0 ] << [ 0 ] - FAILS |
|||
[ 0 ] << [ -1 ] - FAILS |
|||
[ 0 ] << [ 0 -1 ] |
|||
[ 0 ] << [ 0 0 ] |
|||
[ 0 ] << [ 0 1 ] |
|||
[ 0 -1 ] << [ 0 ] - FAILS |
|||
[ 0 0 ] << [ 0 ] - FAILS |
|||
[ 0 0 ] << [ 1 ]</pre> |
|||
The wrapper and support routine in Icon was <pre> |
|||
procedure demo_list_llt(L1,L2) |
|||
write(list2string(L1)," << ",list2string(L2),if list_llt(L1,L2) then "" else " - FAILS") |
|||
end |
|||
procedure list2string(L1) |
|||
every (s := "[") ||:= " " || (!L1|"]") |
|||
return s |
|||
end</pre> |