Skip to main content
Added a version from mazzy if we don't need to worry about negative numbers
Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell, 49 bytes

param($n)($n|?{$_-ge2*$l;$l=$_}).count-eq$n.count

Try it online!

Takes input $n then uses a Where-Object to pull out those elements that are -greaterthanorequal to 2 times the $last element. Those are left on the pipeline, and we set our $last element for the next iteration. We then take the .count of that collection and make sure it's -equal to the .count of our input array. That Boolean value is left on the pipeline and output is implicit.


If we don't need to worry about negative numbers, we can use the following instead, thanks to mazzy:

PowerShell, 27 bytes

!($args|?{$_-lt2*$l;$l=$_})

Try it online!

This again takes input $args, and pulls out those items where they're -lessthan 2 times the $last element (i.e., they're not "big enough" to make the doubling sequence). If there are any left, then the Boolean-not surrounding the collection results in False, otherwise if the collection is empty we get True. That's left on the pipeline and output is implicit.

PowerShell, 49 bytes

param($n)($n|?{$_-ge2*$l;$l=$_}).count-eq$n.count

Try it online!

Takes input $n then uses a Where-Object to pull out those elements that are -greaterthanorequal to 2 times the $last element. Those are left on the pipeline, and we set our $last element for the next iteration. We then take the .count of that collection and make sure it's -equal to the .count of our input array. That Boolean value is left on the pipeline and output is implicit.

PowerShell, 49 bytes

param($n)($n|?{$_-ge2*$l;$l=$_}).count-eq$n.count

Try it online!

Takes input $n then uses a Where-Object to pull out those elements that are -greaterthanorequal to 2 times the $last element. Those are left on the pipeline, and we set our $last element for the next iteration. We then take the .count of that collection and make sure it's -equal to the .count of our input array. That Boolean value is left on the pipeline and output is implicit.


If we don't need to worry about negative numbers, we can use the following instead, thanks to mazzy:

PowerShell, 27 bytes

!($args|?{$_-lt2*$l;$l=$_})

Try it online!

This again takes input $args, and pulls out those items where they're -lessthan 2 times the $last element (i.e., they're not "big enough" to make the doubling sequence). If there are any left, then the Boolean-not surrounding the collection results in False, otherwise if the collection is empty we get True. That's left on the pipeline and output is implicit.

Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell, 49 bytes

param($n)($n|?{$_-ge2*$l;$l=$_}).count-eq$n.count

Try it online!

Takes input $n then uses a Where-Object to pull out those elements that are -greaterthanorequal to 2 times the $last element. Those are left on the pipeline, and we set our $last element for the next iteration. We then take the .count of that collection and make sure it's -equal to the .count of our input array. That Boolean value is left on the pipeline and output is implicit.