Skip to content

Instantly share code, notes, and snippets.

View mkeyno's full-sized avatar
🏠
Working from home

Mehrdad K mkeyno

🏠
Working from home
  • Smart Machine
  • New Zealand, Auckland
View GitHub Profile
@mkeyno
mkeyno / sorting.py
Last active November 11, 2021 05:57
# name, id , w, v
sample_string="(ba,100,1),(eng,320,2),(di,199,3),(kos,ss,1.2),(ri,188,.6),(fork,23,.8),(pis,210,11),(ert,137,.9),\
(omaa,186,1.8),(babel,156,1),(eng2,320,2),(diy,164.5,.48),(kos,196,1.2),(alfe,193,.6),(me,123,.8),(you,210,11),\
(thy,137,.9),(jer,192.7,1.8),(ba2,100,1),(eng2,320,2),(di2,199,3),(kos2,155,1.2),(ri2,188,.6),(fork2,23,.8),\
(pis2,210,11),(ert2,137,.9),(omaa2,186,1.8),(babel2,156,1),(eng21,320,2),(diy3,164.5,.48),(kos3,196,1.2),\
(alfe3,193,.6),(me3,123,.8),(you3,210,11),(thy3,137,.9),(jer3,192.7,1.8)"
#Max single cargo item weight 200kg
max_i_w=200
#Max single cargo item size is 2m^3

Dispensing package algorithm

Regards to the task description, there is a packaging machine that dispenses the product base of packet size and weight capacity. Number of the packed items should not exceed the packed size or weight capacity.

The algorithm is to first read this packed capacity information then dispense of product bath inside the packed in each iteration, the maximum item that can put in the packed will be defined by comparing the available index, available weight, and available items.
If remain item greater than the available space in the packet, then a new packed defined. For simplicity python script has been chosen for this algorithm. before printing each packet sorted base on item's length

@mkeyno
mkeyno / control.md
Last active April 13, 2021 19:45
control description

Objective

Design the primary firmware & features  for remote tank control system

Presumptions

With regards to the primary description, three identical devices bind together remotely to create an automatic tank control system, these parts includea liquid level gauge as a sensor, an electrical pump as an actuator, and an LCD unit as a main control node.

That information reveals , the sensor and actuator are not adjacent to each other and connected via wireless link.

@mkeyno
mkeyno / control.c
Created April 13, 2021 17:01
remote pump contoroller
#include "main.h"
#include "cmsis_os.h"
#include "usb_host.h"
#include "stdint.h"
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
#include "inttypes.h"