Skip to content

Instantly share code, notes, and snippets.

View abdulhaq's full-sized avatar

Abdul haq abdulhaq

View GitHub Profile
{
"objects":{
"customer":{
"display_name":"Bobby S.",
"customer_id":"1",
"channels":[
{
"type":"sms",
"value":"+123456789"
}
@abdulhaq
abdulhaq / word_machine.php
Created December 18, 2022 14:52
A word machine is a system that performs a sequence of simple operations on a stack of integers.
<?php
function word_machine($operations)
{
// split the operations into an array
$ops = explode(' ', $operations);
// initialize the stack
$stack = [];
@abdulhaq
abdulhaq / tic_tac.php
Created December 18, 2022 14:18
Create a function that takes a Tic-tac-toe board and returns "X" if the X's are placed in a way that there are three X's in a row or returns "O" if there is three O's in a row
<?php
function get_winner($board) {
$x_count = 0;
$o_count = 0;
// Check rows
for ($i = 0; $i < 3; $i++) {
if ($board[$i][0] == $board[$i][1] && $board[$i][1] == $board[$i][2]) {
if ($board[$i][0] == "X") {