Last active
December 14, 2015 05:49
-
-
Save kunst1080/5038456 to your computer and use it in GitHub Desktop.
余剰計算なしのFizzBuzz ( ref: http://kunst1080.hatenablog.com/entry/2013/02/26/224615 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM dels | |
del Seq.txt Fizz.txt Buzz.txt FizzBuzz.txt | |
del merge.txt merge.pass.txt merge.pass.sort.txt | |
del out.txt | |
REM sequences | |
for /L %%i in (1,1,100) do @echo %%i 4 %%i>>Seq.txt | |
for /L %%i in (3,3,100) do @echo %%i 3 Fizz>>Fizz.txt | |
for /L %%i in (5,5,100) do @echo %%i 2 Buzz>>Buzz.txt | |
for /L %%i in (15,15,100) do @echo %%i 1 FizzBuzz>>FizzBuzz.txt | |
REM merge | |
copy Seq.txt+Fizz.txt+Buzz.txt+FizzBuzz.txt merge.txt /B | |
for /f "usebackq tokens=1,2,3" %%a in ("merge.txt") do @( | |
if %%a lss 10 (echo 00%%a %%b %%c) else if %%a lss 100 (echo 0%%a %%b %%c) else echo %%a %%b %%c) >>merge.pass.txt | |
sort merge.pass.txt /O merge.pass.sort.txt | |
REM uniq | |
for /f "usebackq tokens=1,2,3" %%a in ("merge.pass.sort.txt") do @( | |
call :uniq %%a %%c) >>out.txt | |
exit/b | |
REM subroutine | |
:uniq | |
rem %1 … key | |
rem %2 … data | |
if not "%PREV%"=="%1" ( | |
set PREV=%1 | |
echo %2 | |
) | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment