Dutch national flag problem: Difference between revisions
Content added Content deleted
(→{{header|Lua}}: added Lua solution) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 23: | Line 23: | ||
* [https://www.google.co.uk/search?rlz=1C1DSGK_enGB472GB472&sugexp=chrome,mod=8&sourceid=chrome&ie=UTF-8&q=Dutch+national+flag+problem#hl=en&rlz=1C1DSGK_enGB472GB472&sclient=psy-ab&q=Probabilistic+analysis+of+algorithms+for+the+Dutch+national+flag+problem&oq=Probabilistic+analysis+of+algorithms+for+the+Dutch+national+flag+problem&gs_l=serp.3...60754.61818.1.62736.1.1.0.0.0.0.72.72.1.1.0...0.0.Pw3RGungndU&psj=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=c33d18147f5082cc&biw=1395&bih=951 Probabilistic analysis of algorithms for the Dutch national flag problem] by Wei-Mei Chen. (pdf) |
* [https://www.google.co.uk/search?rlz=1C1DSGK_enGB472GB472&sugexp=chrome,mod=8&sourceid=chrome&ie=UTF-8&q=Dutch+national+flag+problem#hl=en&rlz=1C1DSGK_enGB472GB472&sclient=psy-ab&q=Probabilistic+analysis+of+algorithms+for+the+Dutch+national+flag+problem&oq=Probabilistic+analysis+of+algorithms+for+the+Dutch+national+flag+problem&gs_l=serp.3...60754.61818.1.62736.1.1.0.0.0.0.72.72.1.1.0...0.0.Pw3RGungndU&psj=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.,cf.osb&fp=c33d18147f5082cc&biw=1395&bih=951 Probabilistic analysis of algorithms for the Dutch national flag problem] by Wei-Mei Chen. (pdf) |
||
<br><br> |
<br><br> |
||
=={{header|11l}}== |
|||
{{trans|Python: Construct from ball counts}} |
|||
<lang 11l>V colours_in_order = ‘Red White Blue’.split(‘ ’) |
|||
F dutch_flag_sort3(items) |
|||
[String] r |
|||
L(colour) :colours_in_order |
|||
r.extend([colour] * items.count(colour)) |
|||
R r |
|||
V balls = [‘Red’, ‘Red’, ‘Blue’, ‘Blue’, ‘Blue’, ‘Red’, ‘Red’, ‘Red’, ‘White’, ‘Blue’] |
|||
print(‘Original Ball order: ’balls) |
|||
V sorted_balls = dutch_flag_sort3(balls) |
|||
print(‘Sorted Ball Order: ’sorted_balls)</lang> |
|||
{{out}} |
|||
<pre> |
|||
Original Ball order: [Red, Red, Blue, Blue, Blue, Red, Red, Red, White, Blue] |
|||
Sorted Ball Order: [Red, Red, Red, Red, Red, White, Blue, Blue, Blue, Blue] |
|||
</pre> |
|||
=={{header|ABAP}}== |
=={{header|ABAP}}== |