Created
May 24, 2011 15:21
-
-
Save miau/988908 to your computer and use it in GitHub Desktop.
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 | |
setlocal enabledelayedexpansion | |
set LINE=1 | |
for /f "tokens=1*" %%I in (A-small.in) do ( | |
if "%%J" neq "" ( | |
rem echo !LINE! %%I %%J | |
set /a STATE="(1 << (%%I - 1)) & %%J" | |
if !STATE! == 0 ( | |
set STR=OFF | |
) else ( | |
set STR=ON | |
) | |
echo Case #!LINE!: !STR! | |
set /a LINE+=1 | |
) | |
) | |
endlocal |
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
load 'files' | |
dat=: 'm' fread 'A-small.in' | |
dat=: 0 ". dat | |
main=: 3 : 0 | |
result=. '' | |
for_line. }. y do. | |
'a b'=. line | |
state=. * (2 ^ (a - 1)) (17 b.) b | |
if. state = 1 do. | |
str=. 'ON' | |
else. | |
str=. 'OFF' | |
end. | |
result=. result , 'Case #' , (": line_index + 1) , ': ' , str , LF | |
end. | |
result | |
) | |
dat2=: (main dat) | |
dat2 fwrites 'A-small.out' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment