Created
April 13, 2014 02:54
-
-
Save 123jimin/10567042 to your computer and use it in GitHub Desktop.
A failed attempt
This file contains hidden or 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
| #!/usr/bin/env beef | |
| :: This only handles the case when (R or C is 1) or M is 0 | |
| ::::: Memory Map ::::: | |
| >X >Y >Z >T >_ >R >C >_ >_ >M >N >P >E >_ >_ >_ | |
| ::::: Init Literals ::::: | |
| +++++ +++++ [ | |
| >0 +++++ | |
| >C +++++ ++ | |
| >a +++++ +++++ | |
| >s +++++ +++++ + | |
| >e +++++ +++++ | |
| >_ +++ | |
| >H +++ | |
| >: +++++ + | |
| >N + | |
| >I +++++ ++ | |
| >m +++++ +++++ + | |
| >p +++++ +++++ + | |
| >o +++++ +++++ + | |
| >i +++++ +++++ | |
| >b +++++ +++++ | |
| >l +++++ +++++ + | |
| >^ +++++ | |
| >* ++++ | |
| >c +++++ +++++ | |
| <<<<< <<<<< <<<<< <<<<-] | |
| >0 -- | |
| >C --- | |
| >a --- | |
| >s +++++ | |
| >e + | |
| >_ ++ | |
| >H +++++ | |
| >: -- | |
| >N | |
| >I +++ | |
| >m - | |
| >p ++ | |
| >o + | |
| >i +++++ | |
| >b -- | |
| >l -- | |
| >^ ---- | |
| >* ++ | |
| >c - | |
| <<<<< <<<<< <<<<< <<< 0 | |
| <<<<< <<<<< <<< T | |
| ::::: Read Number Of Cases ::::: | |
| ,>>,>C, | |
| >>>>> >>>>>0 | |
| :: Subtract T R C by 48 | |
| [-<+<<<<<<<<<C-<-<<->>>>>>>>>>>>>0]<[>+<-],[-] | |
| <<<<< <<<<C | |
| :: Init XYZ | |
| <<<<< <X[-] >Y[-] >Z[-]+ | |
| >T [->+++++ +++++<]>[-<T+++++ +++++>] | |
| >R[-<<T+++++ +++++>>]>C[-<<<T+>>>] | |
| ::::: Main Loop ::::: | |
| <<<T [ | |
| :: Print case | |
| >>>>> >>>>> >>>>'C' .>.>.>.>.>'H'. | |
| <<<<< <<<<< <<<<< <<<<< <<X | |
| :: if(x) | |
| <[-]>X>>>>[-] | |
| <<<<X[<+>>>>>+<<<<-]<[>+<-]+ | |
| >>>>>[ | |
| :: if(x) body | |
| >>>>> >>>>> >>'0' | |
| [-<+<<<<< <<<<< <<<<Y+<X+ >>>>> >>>>> >>>>> >] | |
| <<<<< <<<<< <<<<< <X .>. | |
| >>>>> >>>>> >>>>[->'0'+<<<<< <<<<< <<<<<Y-<- >>>>> >>>>> >>>>>] | |
| <<<<< <<<<< <<<<< <- | |
| >>>>>[-] | |
| ]<<<<<[ | |
| :: else body | |
| :: if(y) body | |
| [-]>>>>>[-] | |
| <<<Y[<<+>>>>>+<<<-]<<[>>+<<-]>>>>>[ | |
| :: if(y) body | |
| :: Lazy way to print a number | |
| <<<Y ++++++ ++++++ ++++++ ++++++ ++++++ ++++++ ++++++ ++++++. | |
| ------ ------ ------ ------ ------ ------ ------ ------ >>>[-] | |
| ] | |
| <<<<<[-] | |
| ] | |
| :: Again; lazy way to print a number | |
| >>>Z ++++++ ++++++ ++++++ ++++++ ++++++ ++++++ ++++++ ++++++. | |
| ------ ------ ------ ------ ------ ------ ------ ------ | |
| >>>>> >>>>> >>>>> >>>>> >':'.>. | |
| <<<<< <<<<< <<<<< <<<<R | |
| R,>C,,>>>M,,>N, | |
| >>>>> >'0'[-<+<<<<<<M-<<<C-<R->>>>> >>>>> >] <[->+<] | |
| <<<<<N ----- ----- | |
| :: if(N) | |
| <<<[-]>[-]>>N | |
| [<<+<+>>-]<<<[>>>N+<<<-] | |
| >[ | |
| :: if(N) body | |
| >>N ----- ----- ----- ----- ----- ----- ----- --- | |
| <M [->N+++++ +++++<] | |
| >N [-<M+>] | |
| <<,[-] | |
| ] | |
| :: if(M) (main) | |
| <[-]>+>M[ | |
| :: then | |
| ::::: MAIN PROCESS ::::: | |
| >[-]<<<<<R[<+>-]<[>R+>C[<<<<< <<+>>>>> >>-]<<<<< <<[>>>>> >>C+>>>>N+<<<<< <<<<< <-]>>>>>-]>R :: N=R*C | |
| ->C-[<<+>>-]<<[>>C+<R[<<<<< <+>>>>> >-]<<<<< <[>>>>> >R+ >>>>> >P+ <<<<< <<<<< <<-]>>>>>-]>>C :: Rmm Cmm P=R*C | |
| :: if(P) | |
| >>>>>P>>[-]+>>[-]<<<<P[ | |
| :: if(P) then | |
| <<<<<C+ <R+ | |
| >>>>> >>E[-]<<N[->>>+<<<]>>>[-<E+<<N+>>>] | |
| <<<<M[->>>E-<<<]>>>E>[-]<<P | |
| P>>[-]>>[-]<<]>>[<<P | |
| :: else | |
| <<<<<C+<R+<[-]+>R[ | |
| >C[>+<-]>[-<C+ | |
| :: Meh I AM lazy | |
| >>[-] | |
| +++++ +++++ +++++ +++++ | |
| +++++ +++++ +++++ +++++ ++ | |
| >M | |
| >>>>[-]>[-]<<<<<M | |
| [>>>>+>+<<<<<-]>>>>[<<<<M+>>>>-] | |
| >[ | |
| <<<<<M- <++++>>>>> > | |
| [-]]<<<<<M | |
| <<<<<[[-] | |
| >>>>++[-<<<<+>>>>] | |
| <<<<[->>>>++<<<<] | |
| >>>>+<<<< | |
| [-]]>>>>. | |
| <] | |
| +++++ +++++.[-] | |
| <<-] | |
| >>>>> >>>->>]<<<<P | |
| ::::: END MAIN PROCESS ::::: | |
| <<<<[-]>[-]]<[>M | |
| :: else | |
| <<<<<[-]+ | |
| >R [ | |
| >C [-<<<<< <<+>>>>> >>]C | |
| <<<<< <<[ | |
| ->>>>> >>C+ | |
| >>>>> >>>>> >>>>> >>>>> >>>>> >'^' | |
| [-<<<<< <<<<< <<<<< <<+>>>>> >>>>> >>>>> >>] | |
| <<<<< <<<<< <<<<< << | |
| [->>>>> >>>>> >>>>> >>+ <<<<< <<<<< <<<<< <<<<+ >>] | |
| << | |
| <<<<< <<<< [ | |
| >>>>> >>>> | |
| ++++++++++ ++++++++++ ++++++++++ | |
| ++++++++++ ++++++++++ +++ | |
| <<<<< <<<<[-] | |
| ] | |
| >>>>> >>>>.[-] | |
| <<<<< <<<<< <<<< | |
| ] | |
| >>>>> >>>>> >>>>> >>>>> >>>>>. | |
| <<<<< <<<<< <<<<< <<<<R | |
| -] | |
| R>C>>(LM)-<]<<<< | |
| :: if(Z) (plus) | |
| <Z----- ---- | |
| <Y----- ---- | |
| <<[-]+>>>>>[-]<<Z[ | |
| +<<<->>>[>>+<<-] | |
| ]Z>>[<<+>>-]<<Z<<<[ | |
| :: Z=0 | if(Y) | |
| [-]+>>>Z[-]----- ---- | |
| >>[-]<<<Y[+<<->>[>>>+<<<-]] | |
| >>>[<<<+>>>-]<<<<<[ | |
| >>Y[-]----- ---- | |
| <X+ <- | |
| ] | |
| [-]]>X | |
| >Y+++++ ++++ | |
| >Z+++++ ++++ | |
| >T- | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment