Solving HackerRank HARD Problems with Codestral.

Поделиться
HTML-код
  • Опубликовано: 3 июн 2024
  • Codestral is a really good model and i wanted to see if It can solving coding problems efficiently!
    I used Mistral's codestral a really powerful (22B coding expert model) with 32K context window to solve hard python hackerrank problems!
    🔗 Links 🔗
    Codestral - mistral.ai/news/codestral/
    Codestral on HF mode hub - huggingface.co/mistralai/Code...
    ❤️ If you want to support the channel ❤️
    Support here:
    Patreon - / 1littlecoder
    Ko-Fi - ko-fi.com/1littlecoder
    🧭 Follow me on 🧭
    Twitter - / 1littlecoder
    Linkedin - / amrrs
  • НаукаНаука

Комментарии • 26

  • @shivamkumarz
    @shivamkumarz Месяц назад +10

    I think these types of problems are surely part of the training dataset.

  • @jhaddixP
    @jhaddixP Месяц назад +2

    codestral vs claude opus?

  • @yadav-r
    @yadav-r Месяц назад +1

    I really hope AI masters all that DSA, in next 2-3 years. Just prompt your problem and AI comes up with proper DS , Algo and system design.

  • @jmirodg7094
    @jmirodg7094 Месяц назад +1

    impressive I'm keen to see how it would go in Aider

  • @alex_smallet
    @alex_smallet Месяц назад +2

    How do you know that the model was not trained on problems like this? It could have memorized the solution, couldn’t it?

    • @JohnDoe-zx8bu
      @JohnDoe-zx8bu Месяц назад +2

      I tried Codestral many times last days to solve not standard problems and it was failed. I couldn't get any suitable response (Python and Typescript) so I guess it can solve popular tasks but can't do anything good with specific things

  • @elibar4148
    @elibar4148 Месяц назад +1

    Thank you for the great video! I did try a one shot test of making a Snake game, and a Tetris game (very hard, only top models like gpt 4 and claude opus can do) and it did a great Snake game but the Tetris did not work. However for the 22B size I think it's a very good model and it's great there is some competition to the closed source (which probably will always be better due to their huge training and parameters)

    • @1littlecoder
      @1littlecoder  Месяц назад +1

      Thanks for testing. Did you try to make Tetris in Python? Was it supposed to use Pygame?

    • @elibar4148
      @elibar4148 Месяц назад +1

      @@1littlecoder Yes it was all in Python, I test all the models in Python because this is usually the language they are best at, and also most useful for ai and machine learning. I don't remember which library it used specifically I will check

    • @elibar4148
      @elibar4148 Месяц назад

      Ok, I see it used Pygame library for both. Btw all the requests are via the Mistral official API.
      Here is the complete response that I got for a snake game, containing a nice working snake game (you need to press the arrows to start). The Tetris is not functioning so I won't add it but it also tried to use the Pygame.
      Everything from here until the end of the comment is Codestral response nothing I wrote-
      -------------------------------
      Headline: "Creating a Simple Snake Game in Python: A Step-by-Step Guide"
      Introduction:
      Python, with its simplicity and readability, is an excellent language for beginners to learn programming. One of the most popular projects for beginners is creating a snake game. This article will guide you through the process of creating a simple snake game in Python using the Pygame library.
      Step 1: Install Pygame
      Before we start, make sure you have Pygame installed on your computer. If not, you can install it using pip:
      ```python
      pip install pygame
      ```
      Step 2: Import Necessary Libraries
      In your Python script, import the necessary libraries:
      ```python
      import pygame
      import time
      import random
      ```
      Step 3: Initialize Pygame
      Initialize Pygame and create a game window:
      ```python
      pygame.init()
      white = (255, 255, 255)
      yellow = (255, 255, 102)
      black = (0, 0, 0)
      red = (213, 50, 80)
      green = (0, 255, 0)
      blue = (50, 153, 213)
      dis_width = 800
      dis_height = 600
      dis = pygame.display.set_mode((dis_width, dis_height))
      pygame.display.set_caption('Snake Game')
      clock = pygame.time.Clock()
      snake_block = 10
      snake_speed = 30
      ```
      Step 4: Create the Snake Function
      Define a function to draw the snake:
      ```python
      def our_snake(snake_block, snake_List):
      for x in snake_List:
      pygame.draw.rect(dis, white, [x[0], x[1], snake_block, snake_block])
      ```
      Step 5: Create the Game Loop
      Create the main game loop:
      ```python
      def gameLoop():
      game_over = False
      game_close = False
      x1 = dis_width / 2
      y1 = dis_height / 2
      x1_change = 0
      y1_change = 0
      snake_List = []
      Length_of_snake = 1
      foodx = round(random.randrange(0, dis_width - snake_block) / 10.0) * 10.0
      foody = round(random.randrange(0, dis_height - snake_block) / 10.0) * 10.0
      while not game_over:
      while game_close == True:
      dis.fill(blue)
      font_style = pygame.font.SysFont(None, 50)
      message = font_style.render("You Lost! Press Q-Quit or C-Play Again", True, red)
      dis.blit(message, [dis_width / 2, dis_height / 2])
      pygame.display.update()
      for event in pygame.event.get():
      if event.type == pygame.KEYDOWN:
      if event.key == pygame.K_q:
      game_over = True
      game_close = False
      if event.key == pygame.K_c:
      gameLoop()
      for event in pygame.event.get():
      if event.type == pygame.QUIT:
      game_over = True
      game_close = False
      if event.type == pygame.KEYDOWN:
      if event.key == pygame.K_UP:
      y1_change = -snake_block
      x1_change = 0
      elif event.key == pygame.K_DOWN:
      y1_change = snake_block
      x1_change = 0
      elif event.key == pygame.K_LEFT:
      x1_change = -snake_block
      y1_change = 0
      elif event.key == pygame.K_RIGHT:
      x1_change = snake_block
      y1_change = 0
      if x1 >= dis_width or x1 < 0 or y1 >= dis_height or y1 < 0:
      game_close = True
      x1 += x1_change
      y1 += y1_change
      dis.fill(blue)
      pygame.draw.rect(dis, green, [foodx, foody, snake_block, snake_block])
      snake_Head = []
      snake_Head.append(x1)
      snake_Head.append(y1)
      snake_List.append(snake_Head)
      if len(snake_List) > Length_of_snake:
      del snake_List[0]
      for x in snake_List[:-1]:
      if x == snake_Head:
      game_close = True
      our_snake(snake_block, snake_List)
      pygame.display.update()
      if x1 == foodx and y1 == foody:
      foodx = round(random.randrange(0, dis_width - snake_block) / 10.0) * 10.0
      foody = round(random.randrange(0, dis_height - snake_block) / 10.0) * 10.0
      Length_of_snake += 1
      clock.tick(snake_speed)
      pygame.quit()
      quit()
      gameLoop()
      ```
      Conclusion:
      Creating a snake game in Python is a fun and educational project for beginners. By following this guide, you can create a simple yet engaging snake game using the Pygame library. Remember to experiment with the code and customize it to your liking. Happy coding!

    • @elibar4148
      @elibar4148 Месяц назад

      Ok, I see it used Pygame library for both. Btw all the requests are via the Mistral official API.
      Here is the complete response that I got for a snake game, containing a nice working snake game (you need to press the arrows to start). The Tetris is not functioning so I won't add it but it also tried to use the Pygame.
      Everything from here until the end of the comment is Codestral response nothing I wrote-
      ------------------------------------
      Headline: "Creating a Simple Snake Game in Python: A Step-by-Step Guide"
      Introduction:
      Python, with its simplicity and readability, is an excellent language for beginners to learn programming. One of the most popular projects for beginners is creating a snake game. This article will guide you through the process of creating a simple snake game in Python using the Pygame library.
      Step 1: Install Pygame
      Before we start, make sure you have Pygame installed on your computer. If not, you can install it using pip:
      ```python
      pip install pygame
      ```
      Step 2: Import Necessary Libraries
      In your Python script, import the necessary libraries:
      ```python
      import pygame
      import time
      import random
      ```
      Step 3: Initialize Pygame
      Initialize Pygame and create a game window:
      ```python
      pygame.init()
      white = (255, 255, 255)
      yellow = (255, 255, 102)
      black = (0, 0, 0)
      red = (213, 50, 80)
      green = (0, 255, 0)
      blue = (50, 153, 213)
      dis_width = 800
      dis_height = 600
      dis = pygame.display.set_mode((dis_width, dis_height))
      pygame.display.set_caption('Snake Game')
      clock = pygame.time.Clock()
      snake_block = 10
      snake_speed = 30
      ```
      Step 4: Create the Snake Function
      Define a function to draw the snake:
      ```python
      def our_snake(snake_block, snake_List):
      for x in snake_List:
      pygame.draw.rect(dis, white, [x[0], x[1], snake_block, snake_block])
      ```
      Step 5: Create the Game Loop
      Create the main game loop:
      ```python
      def gameLoop():
      game_over = False
      game_close = False
      x1 = dis_width / 2
      y1 = dis_height / 2
      x1_change = 0
      y1_change = 0
      snake_List = []
      Length_of_snake = 1
      foodx = round(random.randrange(0, dis_width - snake_block) / 10.0) * 10.0
      foody = round(random.randrange(0, dis_height - snake_block) / 10.0) * 10.0
      while not game_over:
      while game_close == True:
      dis.fill(blue)
      font_style = pygame.font.SysFont(None, 50)
      message = font_style.render("You Lost! Press Q-Quit or C-Play Again", True, red)
      dis.blit(message, [dis_width / 2, dis_height / 2])
      pygame.display.update()
      for event in pygame.event.get():
      if event.type == pygame.KEYDOWN:
      if event.key == pygame.K_q:
      game_over = True
      game_close = False
      if event.key == pygame.K_c:
      gameLoop()
      for event in pygame.event.get():
      if event.type == pygame.QUIT:
      game_over = True
      game_close = False
      if event.type == pygame.KEYDOWN:
      if event.key == pygame.K_UP:
      y1_change = -snake_block
      x1_change = 0
      elif event.key == pygame.K_DOWN:
      y1_change = snake_block
      x1_change = 0
      elif event.key == pygame.K_LEFT:
      x1_change = -snake_block
      y1_change = 0
      elif event.key == pygame.K_RIGHT:
      x1_change = snake_block
      y1_change = 0
      if x1 >= dis_width or x1 < 0 or y1 >= dis_height or y1 < 0:
      game_close = True
      x1 += x1_change
      y1 += y1_change
      dis.fill(blue)
      pygame.draw.rect(dis, green, [foodx, foody, snake_block, snake_block])
      snake_Head = []
      snake_Head.append(x1)
      snake_Head.append(y1)
      snake_List.append(snake_Head)
      if len(snake_List) > Length_of_snake:
      del snake_List[0]
      for x in snake_List[:-1]:
      if x == snake_Head:
      game_close = True
      our_snake(snake_block, snake_List)
      pygame.display.update()
      if x1 == foodx and y1 == foody:
      foodx = round(random.randrange(0, dis_width - snake_block) / 10.0) * 10.0
      foody = round(random.randrange(0, dis_height - snake_block) / 10.0) * 10.0
      Length_of_snake += 1
      clock.tick(snake_speed)
      pygame.quit()
      quit()
      gameLoop()
      ```
      Conclusion:
      Creating a snake game in Python is a fun and educational project for beginners. By following this guide, you can create a simple yet engaging snake game using the Pygame library. Remember to experiment with the code and customize it to your liking. Happy coding!

    • @elibar4148
      @elibar4148 Месяц назад

      Yes both used Pygame-
      import pygame
      import time
      import random
      these are the imports for the snake, and for the tetris (which didnt work) without the time..
      Btw all was tested via Mistral official API

  • @TheRealHassan789
    @TheRealHassan789 Месяц назад +5

    What OCR extension is that!? I need that in my life

    • @1littlecoder
      @1littlecoder  Месяц назад

      the one i'm using is a mac specific one, but i heard windows might have this inbuilt.
      The mac one is Shottr. I'm using their free version!

    • @BOSS_1417
      @BOSS_1417 Месяц назад

      Try copy fish

  • @WatchNoah
    @WatchNoah Месяц назад +1

    question is if this model was trained on these problems

  • @gunasekhar8440
    @gunasekhar8440 Месяц назад

    Hi 1littlecode, I'm also a mac user. Yesterday I was surprised by the tool that you are using for the image to text by clipping the screen. May i know that tool please?
    Thank you
    Guna Sekhar

    • @1littlecoder
      @1littlecoder  Месяц назад

      Hey it's Shottr.

    • @gunasekhar8440
      @gunasekhar8440 Месяц назад

      @@1littlecoder Thankyou. Also in so many days back I have asked you one question that how to build a embedding model from scratch for llm training instead of converting the original text into desired text using any language translators... If possible Could you make any video on that by chance!
      Thank you
      Guna Sekhar

  • @aviral339
    @aviral339 16 дней назад

    I don't agree the problem difficulty, first problem is just maximum all possible sum of square of elements. there more harder problems In hackerrank itself

  • @DLBrawlStars
    @DLBrawlStars Месяц назад

    Why didn't you compare it with GPT 4o?

    • @1littlecoder
      @1littlecoder  Месяц назад +4

      I did internally but I decided to not publish it thinking it's an unfair comparison. for context, this is a 22B open model. gpt-4o could be a trillion paramter or in the hundreds of billion closed model. I just felt maybe I'd be doing a disservice by doing that comparison. what do you think?

    • @DLBrawlStars
      @DLBrawlStars Месяц назад +3

      @@1littlecoder I think it makes sense to compare several models at once, after all, many of them are free and the end user is interested in the result, and not the number of parameters in the model

    • @Cingku
      @Cingku Месяц назад

      @@DLBrawlStars That's right, people interested in model performance not the parameter size. In fact, Codestral beats gpt4o for mere 22 B param! I tested the model locally with my peasant RTX 3060 12 GB and cpu intel i5 12400 with the below prompt and using Ollama and Page Assist chrome extension and it give me the working code with only one freaking shot! GPT4o cannot give the working code even after vigorous chat back and forth, until I ask it to better rephrase my broken English prompt and then use the provided better prompt and with another couple of back and forth chatting, finally it solved it. But codestral give the working script with only one shot. How amazing is it for only 22 B param that can be run locally:
      I am using Windows 11 and ffmpeg binary already in path. So make me simple python script with GUI using tkinter and make it responsive using threading..to speed up mp4 video using ffmpeg with value of x speed time which I can slide the value from 1x to 5x..and increment for each is 0.1x. Display the value too when I slide the slider in the little box beside the slider. And use crf value of 29. And I can browse and select multiple mp4 videos. Put a button called "Speed up now" too when I clicked, it will start process..and when finish it will beep like 3 second using ffplay which also on path already..and I can browse what folder I want to put the output videos too..

    • @therobotocracy
      @therobotocracy Месяц назад

      Wow, nice idea for a test.