Skip to main content
Trivial changes
Source Link
nutki
  • 3.7k
  • 12
  • 12

Perl, 170166 194170 194

A perfect task for a language created by Larry Wall.

#!perl -pa $_=(1x($x=2/($y=pop@F)*map{1..$_}@F)." ")x$y;sub f{my$l=$_;$-|=!@_;for$=(@_){$Z=_$Z=__ x~-$=;$f=0;s/1{$=}1(11){$=}/[$Z$Z][$Z]/&!/\]..{$x}\[/s&&f(grep$=ne$_||$f++,@_);$-or$_=$l;or$_=$l}}f@F 

Brute force, but quite fast on the test cases (<1s). Usage:

$ perl ~/wall.pl <<<"1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 5" [][__][__] [__][__][] [][__][__] [__][__][] [][__][__] 

Test me.

Perl, 170 194

A perfect task for a language created by Larry Wall.

#!perl -pa $_=(1x($x=2/($y=pop@F)*map{1..$_}@F)." ")x$y;sub f{my$l=$_;$-|=!@_;for$=(@_){$Z=_ x~-$=;$f=0;s/1{$=}1{$=}/[$Z$Z]/&!/\]..{$x}\[/s&&f(grep$=ne$_||$f++,@_);$-or$_=$l;}}f@F 

Brute force, but quite fast on the test cases (<1s). Usage:

$ perl ~/wall.pl <<<"1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 5" [][__][__] [__][__][] [][__][__] [__][__][] [][__][__] 

Test me.

Perl, 166 170 194

A perfect task for a language created by Larry Wall.

#!perl -pa $_=(1x($x=2/($y=pop@F)*map{1..$_}@F)." ")x$y;sub f{my$l=$_;$-|=!@_;for$=(@_){$Z=__ x~-$=;$f=0;s/(11){$=}/[$Z]/&!/\]..{$x}\[/s&&f(grep$=ne$_||$f++,@_);$-or$_=$l}}f@F 

Brute force, but quite fast on the test cases (<1s). Usage:

$ perl ~/wall.pl <<<"1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 5" [][__][__] [__][__][] [][__][__] [__][__][] [][__][__] 

Test me.

deleted 21 characters in body
Source Link
nutki
  • 3.7k
  • 12
  • 12

Perl, 194170 194

A perfect task for a language created by Larry Wall.

#!perl -napa $_=(1x($x=2/($y=pop@F)*map{1..$_}@F;$_=((1x$x--@F)." ")x$y;sub f{my$l=$_;/1/ or$s=print;$s|/\]\[.{$x}\]\[/s&&next;for$dmy$l=$_;$-|=!@_;for$=(@_){$Z=_ x(($z=$d*2)x~-2);$f=0;s$=;$f=0;s/\d1{$z$=}1{$=}/[$Z][$Z$Z]/&&f(grep&!/\]..{$_ ne$d||$f++$x}\[/s&&f(grep$=ne$_||$f++,@_);$_=$l;;$-or$_=$l;}}f@F 

Brute force, but quite fast on the test cases (<1s). Usage:

$ perl ~/wall.pl <<<"1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 5" [][__][__] [__][__][] [][__][__] [__][__][] [][__][__] 

Test me.

Perl, 194

A perfect task for a language created by Larry Wall.

#!perl -na $x=2/($y=pop@F)*map{1..$_}@F;$_=((1x$x--)." ")x$y;sub f{my$l=$_;/1/ or$s=print;$s|/\]\[.{$x}\]\[/s&&next;for$d(@_){$Z=_ x(($z=$d*2)-2);$f=0;s/\d{$z}/[$Z]/&&f(grep{$_ ne$d||$f++}@_);$_=$l;}}f@F 

Brute force, but quite fast on the test cases (<1s). Usage:

$ perl ~/wall.pl <<<"1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 5" [][__][__] [__][__][] [][__][__] [__][__][] [][__][__] 

Test me.

Perl, 170 194

A perfect task for a language created by Larry Wall.

#!perl -pa $_=(1x($x=2/($y=pop@F)*map{1..$_}@F)." ")x$y;sub f{my$l=$_;$-|=!@_;for$=(@_){$Z=_ x~-$=;$f=0;s/1{$=}1{$=}/[$Z$Z]/&!/\]..{$x}\[/s&&f(grep$=ne$_||$f++,@_);$-or$_=$l;}}f@F 

Brute force, but quite fast on the test cases (<1s). Usage:

$ perl ~/wall.pl <<<"1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 5" [][__][__] [__][__][] [][__][__] [__][__][] [][__][__] 

Test me.

added 50 characters in body
Source Link
nutki
  • 3.7k
  • 12
  • 12

Perl, 194

A perfect task for a language created by Larry Wall.

#!perl -na $x=2/($y=pop@F)*map{1..$_}@F;$_=((1x$x--)." ")x$y;sub f{my$l=$_;/1/ or$s=print;$s|/\]\[.{$x}\]\[/s&&next;for$d(@_){$Z=_ x(($z=$d*2)-2);$f=0;s/\d{$z}/[$Z]/&&f(grep{$_ ne$d||$f++}@_);$_=$l;}}f@F 

Brute force, but quite fast on the test cases (<1s). Usage:

$ perl ~/wall.pl <<<"1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 5" [][__][__] [__][__][] [][__][__] [__][__][] [][__][__] 

Test me.

Perl, 194

A perfect task for a language created by Larry Wall.

#!perl -na $x=2/($y=pop@F)*map{1..$_}@F;$_=((1x$x--)." ")x$y;sub f{my$l=$_;/1/ or$s=print;$s|/\]\[.{$x}\]\[/s&&next;for$d(@_){$Z=_ x(($z=$d*2)-2);$f=0;s/\d{$z}/[$Z]/&&f(grep{$_ ne$d||$f++}@_);$_=$l;}}f@F 

Brute force, but quite fast on the test cases (<1s). Usage:

$ perl ~/wall.pl <<<"1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 5" [][__][__] [__][__][] [][__][__] [__][__][] [][__][__] 

Perl, 194

A perfect task for a language created by Larry Wall.

#!perl -na $x=2/($y=pop@F)*map{1..$_}@F;$_=((1x$x--)." ")x$y;sub f{my$l=$_;/1/ or$s=print;$s|/\]\[.{$x}\]\[/s&&next;for$d(@_){$Z=_ x(($z=$d*2)-2);$f=0;s/\d{$z}/[$Z]/&&f(grep{$_ ne$d||$f++}@_);$_=$l;}}f@F 

Brute force, but quite fast on the test cases (<1s). Usage:

$ perl ~/wall.pl <<<"1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 5" [][__][__] [__][__][] [][__][__] [__][__][] [][__][__] 

Test me.

Source Link
nutki
  • 3.7k
  • 12
  • 12
Loading