Skip to content

Instantly share code, notes, and snippets.

View NimaGhaedsharafi's full-sized avatar

Nima Ghaedsharafi NimaGhaedsharafi

View GitHub Profile
<?php
/**
* @param $items
* @return int
*/
function ks($size, $items)
{
if ($size == 0 || count($items) == 0) {
return 0;
}
<?
function num($data, $i)
{
$c = strlen($data);
if ($c == 2 && $data > 26) {
return 0;
}
if ($c < 3) {
return $c;
function formingMagicSquare($s) {
if (checkMagic($s)) {
return 0;
}
$cost = 0;
if ($s[1][1] != 5) {
$cost = abs(5 - $s[1][1]);
$s[1][1] = 5;
}
<?php
$input = 10;
$last = "1";
for ($i = 0; $i < $input; $i++) {
echo $last . PHP_EOL;
$last = lookNSay($last);
}
<?php
$str0 = "at";
$str1 = "cat";
function oneEditApart($str0, $str1)
{
if (abs(strlen($str0) - strlen($str1)) > 1) {
return false;
}
<?php
$input = 9;
// 1x1 => 1
// 2x2 => 4
// 3x3 => 9
// 4x4 => 16
/*
//@version=3
study(title="EMA Ribbon [K]", shorttitle="EMA Ribbon", overlay=true)
dropn(src, n) =>
na(src[n]) ? na : src
length1 = input(20, title="MA-1 period", minval=1)
length2 = input(25, title="MA-2 period", minval=1)
length3 = input(30, title="MA-3 period", minval=1)
length4 = input(35, title="MA-4 period", minval=1)
panic(cpu 6 caller 0xffffff8014abfb71): assertion failed: ifp->if_sndbyte_total >= len, file: /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/xnu/xnu-7195.50.7/bsd/netinet/in_pcb.c, line: 3937
Backtrace (CPU 6), Frame : Return Address
0xffffffb0db9f3960 : 0xffffff80142bc66d
0xffffffb0db9f39b0 : 0xffffff80143ff073
0xffffffb0db9f39f0 : 0xffffff80143ef6aa
0xffffffb0db9f3a40 : 0xffffff8014261a2f
0xffffffb0db9f3a60 : 0xffffff80142bbf0d
0xffffffb0db9f3b80 : 0xffffff80142bc1f8
0xffffffb0db9f3bf0 : 0xffffff8014abee1a
0xffffffb0db9f3c60 : 0xffffff8014abfb71
<?php
function digitToWord($amount)
{
$one = [
'صفر',
'یک',
'دو',
'سه',
'چهار',
package cmd
import (
v10 "github.com/go-playground/validator/v10"
"github.com/labstack/echo/v4"
"log"
)
func Serve() {
e := echo.New()