






from __future__ import annotations

from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any




class        _lowerCAmelCase:





							"""simple docstring"""







							a       :	Dict								=('''_front''', '''_back''', '''_len''')




							@dataclass
							class        _lowerCAmelCase:





														"""simple docstring"""







														a       :	Any								=None
														a       :	Deque._Node | None								=None
														a       :	Deque._Node | None								=None







							class        _lowerCAmelCase:





														"""simple docstring"""







														a       :	Dict								=('''_cur''',)





														def __init__(      self						,    _lowerCamelCase							):
																UpperCamelCase_:      List[Any]					   =       cur





														def __iter__(      self							):
																return self





														def     _a					(      self							):
																if self._cur is None:
																		# finished iterating
																		raise StopIteration
																UpperCamelCase_:      List[Any]					   =       self._cur.val
																UpperCamelCase_:      int					   =       self._cur.next_node

																return val







							def __init__(      self						,    _lowerCamelCase = None							):
									UpperCamelCase_:      Any					   =       None
									UpperCamelCase_:      Any					   =       None
									UpperCamelCase_:      int					   =       0

									if iterable is not None:
											# append every value to the deque
											for val in iterable:
													self.append(_lowerCamelCase							)





							def     _a					(      self						,    _lowerCamelCase							):
									UpperCamelCase_:      Dict					   =       self._Node(_lowerCamelCase						,    _lowerCamelCase						,    _lowerCamelCase							)
									if self.is_empty():
											# front = back
											UpperCamelCase_:      Dict					   =       node
											UpperCamelCase_:      List[str]					   =       1
									else:
											# connect nodes
											UpperCamelCase_:      List[str]					   =       node
											UpperCamelCase_:      List[str]					   =       self._back
											UpperCamelCase_:      Optional[Any]					   =       node  # assign new back to the new node

											self._len += 1

											# make sure there were no errors
											assert not self.is_empty(), "Error on appending value."





							def     _a					(      self						,    _lowerCamelCase							):
									UpperCamelCase_:      Tuple					   =       self._Node(_lowerCamelCase						,    _lowerCamelCase						,    _lowerCamelCase							)
									if self.is_empty():
											# front = back
											UpperCamelCase_:      Union[str, Any]					   =       node
											UpperCamelCase_:      Optional[Any]					   =       1
									else:
											# connect nodes
											UpperCamelCase_:      Optional[Any]					   =       self._front
											UpperCamelCase_:      Optional[Any]					   =       node
											UpperCamelCase_:      int					   =       node  # assign new front to the new node

											self._len += 1

											# make sure there were no errors
											assert not self.is_empty(), "Error on appending value."





							def     _a					(      self						,    _lowerCamelCase							):
									for val in iterable:
											self.append(_lowerCamelCase							)





							def     _a					(      self						,    _lowerCamelCase							):
									for val in iterable:
											self.appendleft(_lowerCamelCase							)





							def     _a					(      self							):
									assert not self.is_empty(), "Deque is empty."

									UpperCamelCase_:      Optional[int]					   =       self._back
									UpperCamelCase_:      int					   =       self._back.prev_node  # set new back
									# drop the last node - python will deallocate memory automatically
									UpperCamelCase_:      List[str]					   =       None

									self._len -= 1

									return topop.val





							def     _a					(      self							):
									assert not self.is_empty(), "Deque is empty."

									UpperCamelCase_:      List[Any]					   =       self._front
									UpperCamelCase_:      Tuple					   =       self._front.next_node  # set new front and drop the first node
									UpperCamelCase_:      str					   =       None

									self._len -= 1

									return topop.val





							def     _a					(      self							):
									return self._front is None





							def __len__(      self							):
									return self._len





							def __eq__(      self						,    _lowerCamelCase							):

									if not isinstance(_lowerCamelCase						,    _lowerCamelCase							):
											return NotImplemented

									UpperCamelCase_:      Union[str, Any]					   =       self._front
									UpperCamelCase_:      Optional[Any]					   =       other._front

									# if the length of the dequeues are not the same, they are not equal
									if len(self							) != len(_lowerCamelCase							):
											return False

									while me is not None and oth is not None:
											# compare every value
											if me.val != oth.val:
													return False
											UpperCamelCase_:      Optional[Any]					   =       me.next_node
											UpperCamelCase_:      Union[str, Any]					   =       oth.next_node

									return True





							def __iter__(      self							):
									return Deque._Iterator(self._front							)





							def __repr__(      self							):
									UpperCamelCase_:      str					   =       []
									UpperCamelCase_:      Dict					   =       self._front
									while aux is not None:
											# append the values in a list to display
											values_list.append(aux.val							)
											UpperCamelCase_:      Optional[Any]					   =       aux.next_node

									return f'''[{', '.join(repr(_lowerCamelCase							) for val in values_list							)}]'''


if __name__ == "__main__":
			import doctest

			doctest.testmod()







from datetime import date

import requests

A_	:	Any				=				'https://api.carbonintensity.org.uk/intensity'

def 						snake_case      () ->       str:
  UpperCamelCase_:      Any					   =       requests.get(UpperCAmelCase__						).json()['data'][0]
  return last_half_hour["intensity"]["actual"]

def 						snake_case      (UpperCAmelCase__			,					UpperCAmelCase__						) ->       list:
  return requests.get(F'''{BASE_URL}/{start}/{end}'''						).json()["data"]


if __name__ == "__main__":
   for entry in fetch_from_to(start=date(2020, 10, 1), end=date(2020, 10, 3)):
      print('from {from} to {to}: {intensity[actual]}'.format(**entry))
   print(F'''{fetch_last_half_hour() = }''')