Skip to content

Instantly share code, notes, and snippets.

@marcogalluzzi
marcogalluzzi / hackerrank_cutting_metal_surplus.py
Last active August 17, 2024 18:25
Solution in Python to the HackerRank problem "Cutting metal surplus"
#
# HackerRank - Cutting Metal Surplus
#
# The owner of a metal rod factory has a surplus of rods of arbitrary lengths. A local contractor offers to buy any of the factory's
# surplus as long as all the rods have the same exact integer length, referred to as saleLength. The factory owner can increase the
# number of sellable rods by cutting each rod zero or more times, but each cut has a cost denoted by costPerCut. After all cuts have
# been made, any leftover rods having a length other than saleLength must be discarded for no profit. The factory owner's total profit
# for the sale is calculated as:
#
# totalProfit = totalUniformRods × saleLength × salePrice − totalCuts × costPerCut
@kevinkindom
kevinkindom / Python Socket 编程详细介绍.md
Last active April 18, 2025 06:52
Python Socket 编程详细介绍

Python Socket 编程详细介绍

Python 提供了两个基本的 socket 模块:

  • Socket 它提供了标准的BSD Socket API。
  • SocketServer 它提供了服务器重心,可以简化网络服务器的开发。

下面讲解下 Socket模块功能。

Socket 类型