Skip to main content
added 88 characters in body
Source Link
Zylviij
  • 470
  • 2
  • 5

Haskell, 372

My first Haskell Program

(It's my first functional programming, too...)

w[]_=False w _[]=True w a b=if length j==0 then a>b else w (drop(d$head j)a++fst(head j))(drop(d$head j)b++snd(head j))where j=p a b d(a,b)=quot(maximum[length a,length b])2 f (Just a)=a p a b=map f$filter(/=Nothing)[t(a!!x,take(x+1)a,b!!x,take(x+1)b)|x<-[0,2..minimum[length a,length b]-1]] t(a,b,c,d)=if a==c then Nothing else if a>c then Just(d++b,[])else Just([],b++d) 

I'd love to have tips on how to improve.

Usage:

w "D58B35926B92C7C4C7E8D3DAA2" "8E47C38A2DEA43467EB9566B95" w "669D9D846D4B3BA52452C2EDEB" "E747CA988CC76723935A3B8EA5" w "5744B95ECDC6D325B28A782A72" "68394D9DA96EBBA8533EE7C6C4" w "87DB6C7EBC6C8D722389923DC6" "E28435DBEBEA543AA47956594A" w "589EAB9DCD43E9EC264A5726A8" "48DC2577BD68AB9335263B7EC4" w "E3698D7C46A739AE5BE2C49286" "BB54B7D78954ED526A83C3CDA2" w "32298B5E785DC394467D5C9CB2" "5ED6AAD93E873EA628B6A4BC47" w "B4AB985B34756C624C92DE5E97" "3EDD5BA2A68397C26CE837AD48" w "9A6D9A5457BB6ACBC5E8D7D4A9" "73E658CE2C3E289B837422D463" w "96E64D226BC8B7D6C5974BAE32" "58DC7A8C543E35978AEBA34D29" w "C2978A35E74D7652BA9762C458" "9A9BB332BE8C8DD44CE3DE66A5" w "BEDB44E947693CD284923CEA82" "8CC3B75756255A683A6AB9E7DD" w "EEDDCCBBAA8877665544332299" "EEDDCCBBAA9988776655443322" w "EEDDCCBBAA9988776655443322" "DDCCBBAA9988776655443E3E22" 

Haskell is quick... :)

real 0m0.039s user 0m0.022s sys 0m0.005s 

Haskell, 372

My first Haskell Program

(It's my first functional programming, too...)

w[]_=False w _[]=True w a b=if length j==0 then a>b else w (drop(d$head j)a++fst(head j))(drop(d$head j)b++snd(head j))where j=p a b d(a,b)=quot(maximum[length a,length b])2 f (Just a)=a p a b=map f$filter(/=Nothing)[t(a!!x,take(x+1)a,b!!x,take(x+1)b)|x<-[0,2..minimum[length a,length b]-1]] t(a,b,c,d)=if a==c then Nothing else if a>c then Just(d++b,[])else Just([],b++d) 

I'd love to have tips on how to improve.

Usage:

w "D58B35926B92C7C4C7E8D3DAA2" "8E47C38A2DEA43467EB9566B95" w "669D9D846D4B3BA52452C2EDEB" "E747CA988CC76723935A3B8EA5" w "5744B95ECDC6D325B28A782A72" "68394D9DA96EBBA8533EE7C6C4" w "87DB6C7EBC6C8D722389923DC6" "E28435DBEBEA543AA47956594A" w "589EAB9DCD43E9EC264A5726A8" "48DC2577BD68AB9335263B7EC4" w "E3698D7C46A739AE5BE2C49286" "BB54B7D78954ED526A83C3CDA2" w "32298B5E785DC394467D5C9CB2" "5ED6AAD93E873EA628B6A4BC47" w "B4AB985B34756C624C92DE5E97" "3EDD5BA2A68397C26CE837AD48" w "9A6D9A5457BB6ACBC5E8D7D4A9" "73E658CE2C3E289B837422D463" w "96E64D226BC8B7D6C5974BAE32" "58DC7A8C543E35978AEBA34D29" w "C2978A35E74D7652BA9762C458" "9A9BB332BE8C8DD44CE3DE66A5" w "BEDB44E947693CD284923CEA82" "8CC3B75756255A683A6AB9E7DD" w "EEDDCCBBAA8877665544332299" "EEDDCCBBAA9988776655443322" w "EEDDCCBBAA9988776655443322" "DDCCBBAA9988776655443E3E22" 

Haskell, 372

My first Haskell Program

(It's my first functional programming, too...)

w[]_=False w _[]=True w a b=if length j==0 then a>b else w (drop(d$head j)a++fst(head j))(drop(d$head j)b++snd(head j))where j=p a b d(a,b)=quot(maximum[length a,length b])2 f (Just a)=a p a b=map f$filter(/=Nothing)[t(a!!x,take(x+1)a,b!!x,take(x+1)b)|x<-[0,2..minimum[length a,length b]-1]] t(a,b,c,d)=if a==c then Nothing else if a>c then Just(d++b,[])else Just([],b++d) 

I'd love to have tips on how to improve.

Usage:

w "D58B35926B92C7C4C7E8D3DAA2" "8E47C38A2DEA43467EB9566B95" w "669D9D846D4B3BA52452C2EDEB" "E747CA988CC76723935A3B8EA5" w "5744B95ECDC6D325B28A782A72" "68394D9DA96EBBA8533EE7C6C4" w "87DB6C7EBC6C8D722389923DC6" "E28435DBEBEA543AA47956594A" w "589EAB9DCD43E9EC264A5726A8" "48DC2577BD68AB9335263B7EC4" w "E3698D7C46A739AE5BE2C49286" "BB54B7D78954ED526A83C3CDA2" w "32298B5E785DC394467D5C9CB2" "5ED6AAD93E873EA628B6A4BC47" w "B4AB985B34756C624C92DE5E97" "3EDD5BA2A68397C26CE837AD48" w "9A6D9A5457BB6ACBC5E8D7D4A9" "73E658CE2C3E289B837422D463" w "96E64D226BC8B7D6C5974BAE32" "58DC7A8C543E35978AEBA34D29" w "C2978A35E74D7652BA9762C458" "9A9BB332BE8C8DD44CE3DE66A5" w "BEDB44E947693CD284923CEA82" "8CC3B75756255A683A6AB9E7DD" w "EEDDCCBBAA8877665544332299" "EEDDCCBBAA9988776655443322" w "EEDDCCBBAA9988776655443322" "DDCCBBAA9988776655443E3E22" 

Haskell is quick... :)

real 0m0.039s user 0m0.022s sys 0m0.005s 
Source Link
Zylviij
  • 470
  • 2
  • 5

Haskell, 372

My first Haskell Program

(It's my first functional programming, too...)

w[]_=False w _[]=True w a b=if length j==0 then a>b else w (drop(d$head j)a++fst(head j))(drop(d$head j)b++snd(head j))where j=p a b d(a,b)=quot(maximum[length a,length b])2 f (Just a)=a p a b=map f$filter(/=Nothing)[t(a!!x,take(x+1)a,b!!x,take(x+1)b)|x<-[0,2..minimum[length a,length b]-1]] t(a,b,c,d)=if a==c then Nothing else if a>c then Just(d++b,[])else Just([],b++d) 

I'd love to have tips on how to improve.

Usage:

w "D58B35926B92C7C4C7E8D3DAA2" "8E47C38A2DEA43467EB9566B95" w "669D9D846D4B3BA52452C2EDEB" "E747CA988CC76723935A3B8EA5" w "5744B95ECDC6D325B28A782A72" "68394D9DA96EBBA8533EE7C6C4" w "87DB6C7EBC6C8D722389923DC6" "E28435DBEBEA543AA47956594A" w "589EAB9DCD43E9EC264A5726A8" "48DC2577BD68AB9335263B7EC4" w "E3698D7C46A739AE5BE2C49286" "BB54B7D78954ED526A83C3CDA2" w "32298B5E785DC394467D5C9CB2" "5ED6AAD93E873EA628B6A4BC47" w "B4AB985B34756C624C92DE5E97" "3EDD5BA2A68397C26CE837AD48" w "9A6D9A5457BB6ACBC5E8D7D4A9" "73E658CE2C3E289B837422D463" w "96E64D226BC8B7D6C5974BAE32" "58DC7A8C543E35978AEBA34D29" w "C2978A35E74D7652BA9762C458" "9A9BB332BE8C8DD44CE3DE66A5" w "BEDB44E947693CD284923CEA82" "8CC3B75756255A683A6AB9E7DD" w "EEDDCCBBAA8877665544332299" "EEDDCCBBAA9988776655443322" w "EEDDCCBBAA9988776655443322" "DDCCBBAA9988776655443E3E22"