





"""simple docstring"""
# Lint as: python3
import dataclasses
import re
from dataclasses import dataclass
from functools import total_ordering
from typing import Optional, Union


__UpperCamelCase     :						int						       =  re.compile(R'''^(?P<major>\d+)''' R'''\.(?P<minor>\d+)''' R'''\.(?P<patch>\d+)$''')







@total_ordering
@dataclass
class       a							:
 snake_case__             =       42
 snake_case__             =       None
 snake_case__             =       None
 snake_case__             =       None
 snake_case__             =       None



 def    UpperCamelCase__  (     self     ):







  """simple docstring"""






  lowerCAmelCase				,lowerCAmelCase				,lowerCAmelCase    				= _str_to_version_tuple(self.version_str     )



 def __repr__(     self     ):







  """simple docstring"""






  return F'{self.tuple[0]}.{self.tuple[1]}.{self.tuple[2]}'



 @property
 def    UpperCamelCase__  (     self     ):







  """simple docstring"""






  return self.major, self.minor, self.patch



 def    UpperCamelCase__  (     self				,       _snake_case     ):







  """simple docstring"""






  if isinstance(_snake_case				,       _snake_case     ):
   return Version(_snake_case     )
  elif isinstance(_snake_case				,       _snake_case     ):
   return other
  raise TypeError(F'{other} (type {type(_snake_case     )}) cannot be compared to version.'     )



 def __eq__(     self				,       _snake_case     ):







  """simple docstring"""






  try:
   lowerCAmelCase    				= self._validate_operand(_snake_case     )
  except (TypeError, ValueError):
   return False
  else:
   return self.tuple == other.tuple



 def __lt__(     self				,       _snake_case     ):







  """simple docstring"""






  lowerCAmelCase    				= self._validate_operand(_snake_case     )
  return self.tuple < other.tuple



 def __hash__(     self     ):







  """simple docstring"""






  return hash(_version_tuple_to_str(self.tuple     )     )



 @classmethod
 def    UpperCamelCase__  (     cls				,       _snake_case     ):







  """simple docstring"""






  lowerCAmelCase    				= {f.name for f in dataclasses.fields(cls     )}
  return cls(**{k: v for k, v in dic.items() if k in field_names}     )



 def    UpperCamelCase__  (     self     ):







  """simple docstring"""






  return self.version_str


def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    Union[str, Any]			):
 lowerCAmelCase    				= _VERSION_REG.match(_UpperCAmelCase			)
 if not res:
  raise ValueError(F'Invalid version \'{version_str}\'. Format should be x.y.z with {{x,y,z}} being digits.'			)
 return tuple(int(_UpperCAmelCase			) for v in [res.group('major'			), res.group('minor'			), res.group('patch'			)]			)




def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    Union[str, Any]			):
 return ".".join(str(_UpperCAmelCase			) for v in version_tuple			)












"""simple docstring"""
from __future__ import annotations

import requests

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    str			):
 lowerCAmelCase    				= F'https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty'
 return requests.get(_UpperCAmelCase			).json()

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    int = 10			):
 lowerCAmelCase    				= 'https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty'
 lowerCAmelCase    				= requests.get(_UpperCAmelCase			).json()[:max_stories]
 return [get_hackernews_story(_UpperCAmelCase			) for story_id in story_ids]

def 		_SCREAMING_SNAKE_CASE			(_UpperCAmelCase					:    int = 10			):
 lowerCAmelCase    				= hackernews_top_stories(_UpperCAmelCase			)
 return "\n".join('* [{title}]({url})'.format(**_UpperCAmelCase			) for story in stories			)


if __name__ == "__main__":
       print(hackernews_top_stories_as_markdown())





