How to apply dynamic block layout depending upon number of nodes in it (Drupal 8)? I have very challenging task. Can any expert guide me?

(NOTE: This is for Drupal 8)

There is a requirement to show nodes in a block in a way that block must adopt style automatically depending upon the number of nodes in it.

For Example:
If there is only node published under news content type then block must adopt single news article layout in teaser mode, And
If there are published 2 nodes under news content type then block must now adopt the layout of 2 nodes and so on.

and this continues to 10 nodes

I know we can create views but how to apply conditions to check how many nodes are there under any content type and apply block layout accordingly?

Can anybody help?

Thanks
Mithow
Not everything is clear in your question, but there are some approaches for that task.
For example if you are using views module you can count number of views rows in twig template: 

{% if rows|length == 2 %}
   {% for row in rows %} 
//Here some staff for two rows
   {% endfor %} 
{% endif %}


About twig, about views templates

Also you can use jquery $('.some-class-for-every-row').length and add some style using js.