Skip to content

Instantly share code, notes, and snippets.

@miau
Created May 24, 2011 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miau/988908 to your computer and use it in GitHub Desktop.
Save miau/988908 to your computer and use it in GitHub Desktop.
@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
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