Skip to content

Instantly share code, notes, and snippets.

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

Maged Ahmed MagedAhmad

🏠
Working from home
View GitHub Profile
<?php
namespace MagedAhmad\LaraPayment;
use GuzzleHttp\Client;
use MagedAhmad\LaraPayment\Paymob;
use MagedAhmad\LaraPayment\Models\Balance_summary;
class LaraPayment
<?php
namespace MagedAhmad\LaraPayment;
use GuzzleHttp\Client;
use MagedAhmad\LaraPayment\Paymob;
use MagedAhmad\LaraPayment\Models\Balance_summary;
class LaraPayment
{
@MagedAhmad
MagedAhmad / minimumSwaps.php
Created April 19, 2020 16:23
Hackerrank minimum Swaps
<?php
function minimumSwaps($arr) {
$swaps = 0;
for($i = 0; $i < count($arr); $i++) {
while($arr[$i] != $i + 1) {
$temp = $arr[$i];
$arr[$i] = $arr[$temp-1];
$arr[$temp-1] = $temp;
$swaps++;
@MagedAhmad
MagedAhmad / minimumBribes.php
Created April 18, 2020 23:29
Hacker rank new year chaos
<?php
function minimumBribes($q) {
$count = 0;
for($i = count($q) -1 ; $i >= 0; $i--) {
if($q[$i] - ($i+1) > 2) {
print "Too chaotic" . "\n";
return;
}
@MagedAhmad
MagedAhmad / rotLeft.php
Created April 15, 2020 17:27
Hackerrank Arrays left rotation
<?php
function rotLeft($a, $d) {
$temp = [];
for($i = 0; $i < $d; $i++) {
$temp[$i] = $a[$i];
}
$a = array_slice($a, $d);
$result = array_merge($a, $temp);
return $result;
@MagedAhmad
MagedAhmad / hourglassSum.php
Created April 15, 2020 17:10
Hackerrank 2D Array DS
<?php
function hourglassSum($arr) {
for($i = 0; $i < count($arr) - 2; $i++) {
for($j = 0; $j < count($arr[$i]) - 2; $j++) {
$results[] = $arr[$i][$j] + $arr[$i][$j+1] + $arr[$i][$j+2]
+ $arr[$i+1][$j+1]
+ $arr[$i+2][$j] + $arr[$i+2][$j+1] + $arr[$i+2][$j+2];
}
}
@MagedAhmad
MagedAhmad / repeatedString.php
Created April 15, 2020 15:24
Hackerrank repeated String
<?php
// Complete the repeatedString function below.
function repeatedString($s, $n) {
$i = 0;
$count = 0;
while($i < strlen($s)){
if ($s[$i] == 'a') {
$count++;
}
@MagedAhmad
MagedAhmad / JumpingClounds.php
Created April 15, 2020 14:40
Hackerrank Jumping on the Clouds
<?php
// 0 0 0 0 1 0
function jumpingOnClouds($c) {
$start = 0;
$counts = 0;
while($start < count($c) - 1) {
if( ($start + 2) < count($c) && $c[$start + 2] != 1) {
$counts++;
$start = $start + 2;
@MagedAhmad
MagedAhmad / CountingValleys.php
Created April 15, 2020 14:07
Hackerrank Counting Valleys challenge
<?php
function countingValleys($n, $s) {
$count = 0;
$track = 0;
for($i = 0; $i < $n; $i++) {
if($s[$i] == 'U') {
$track++;
}else {
if($track == 0) {
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{THE_REQUEST} /public/([^\s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]