Talk:Dutch national flag problem: Difference between revisions

m
corrected a misspelled section header title.
m (corrected a misspelled section header title.)
 
(5 intermediate revisions by 3 users not shown)
Line 2:
This task needs a picture of the Dutch national flag. --[[User:Paddy3118|Paddy3118]] 09:34, 1 July 2012 (UTC)
:http://en.wikipedia.org/wiki/Netherlands [[User:Fwend|Fwend]] 06:04, 2 July 2012 (UTC)
 
:: I've added an HTML rendition of the Dutch flag (immediately before the '''Cf.''').   I tried to use   ''style=float''   with right justification, but couldn't make that work without HTML forcing some (unwanted) inter-line spacing.   -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 02:19, 9 June 2015 (UTC)
 
::: Thanks Gerard, I think the task was missing it. I took the liberty of moving the flag text to a sub-heading so the text didn't dominate the task description area. What do you think? --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 05:57, 9 June 2015 (UTC)
 
:::: Looks great.   I was thinking along the lines of what you did, but I didn't want to utilize too much vertical space (in the Rosetta Code task preamble).   I spent quite a bit of time in doing something so simple;   I first tried to use a multicolored table (one color for each row, and with no text), but that wasn't good enough --- I couldn't get that square peg into a round hole.   So I ended up just rendering a "full" glyph character   █   with a color(ed) font.   -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 06:15, 9 June 2015 (UTC)
 
==Algorithms==
Line 44 ⟶ 50:
 
:: Perhaps the Haskell solution should also implement part 1 of the requirements? Or is acknowledging that a random list was already sorted sufficient? --[[User:Rdm|Rdm]] 09:17, 30 August 2012 (UTC)
 
:::Perhaps. Some effort has been made in a unique way and I did not want to discourage someone new to the site. I remain reluctant and wouldn't mind others chipping in (such as yourself). --[[User:Paddy3118|Paddy3118]] 10:23, 30 August 2012 (UTC)
 
== solved in BATCH/.BAT ==
 
i just solved the problem in batch or .bat, can someone post it in the section for me, i didnt understand all those html things yet.
i also am not sure if this is exactly what it is because in batch you dont have variables witch can contain more than one variable (arrays.
this is the script:
if you copy it and save it as "title".bat and click run it will start. you have to save it as all files and not as ".txt".
everything with REM is explaining, it wont bother in the script.
i hope that this solves the problem correctly and that my English isn't too bad
 
 
REM this part generates variables with the numbers 1-3
REM 1 means red
REM 2 means white
REM 3 means blue
REM variable ball a is the first in row and c is the last in row.
@echo off
cls
goto aset
:aset
cls
set /a R=%random%%% 3 +1
if %r% EQU 1 set a=1
if %r% EQU 2 set a=2
if %r% EQU 3 set a=3
goto bset
:bset
set /a R=%random%%% 3 +1
if %r% EQU 1 set b=1
if %r% EQU 2 set b=2
if %r% EQU 3 set b=3
goto cset
:cset
set /a R=%random%%% 3 +1
if %r% EQU 1 set c=1
if %r% EQU 2 set c=2
if %r% EQU 3 set c=3
goto acheck
REM this part checks if ball 1 is red, ball 2 is white and ball 3 is blue
REM and if they are in row of the dutch flag it will go to the begin again
:acheck
if %a% EQU 1 goto aset
goto bcheck
:bcheck
if %b% EQU 2 goto aset
goto ccheck
:ccheck
if %c% EQU 3 goto aset
goto color1
REM this part gives the numbers colors.
:color1
if %a% EQU 1 set a=red
if %b% EQU 1 set b=red
if %c% EQU 1 set c=red
goto color2
:color2
if %a% EQU 2 set a=white
if %b% EQU 2 set b=white
if %c% EQU 2 set c=white
goto color3
:color3
if %a% EQU 3 set a=blue
if %b% EQU 3 set b=blue
if %c% EQU 3 set c=blue
goto echoert
REM this part shows/echo/prints it, it shows the new dutch flag
REM that is the random generated flag
:echoert
echo the new dutch flag is...
echo %a%
echo %b%
echo %c%
pause
echo and the new dutch flag organised is...
goto posa
REM this part makes sure that variables will be setted when a equals 1/red and when it is red it will,
REM be standing in front of all the white/2 and blue/3 variables/balls/
:posa
if %a% EQU red set posa=1
if %a% EQU white set posa=2
if %a% EQU blue set posa=3
goto posb
:posb
if %b% EQU red set posb=1
if %b% EQU white set posb=2
if %b% EQU blue set posb=3
goto posc
:posc
if %c% EQU red set posc=1
if %c% EQU white set posc=2
if %c% EQU blue set posc=3
goto echopos1
REM this prints/echo/shows all the balls/colors/variables sorted
:echopos1
if %posa% EQU 1 echo %a%
if %posb% EQU 1 echo %b%
if %posc% EQU 1 echo %c%
goto echopos2
:echopos2
if %posa% EQU 2 echo %a%
if %posb% EQU 2 echo %b%
if %posc% EQU 2 echo %c%
goto echopos3
:echopos3
if %posa% EQU 3 echo %a%
if %posb% EQU 3 echo %b%
if %posc% EQU 3 echo %c%
pause
goto aset
REM this resets the script(it will go to top)