Skip to content

Instantly share code, notes, and snippets.

View 4RSIM3R's full-sized avatar
💭
Make A New Journey

Cak Suku 4RSIM3R

💭
Make A New Journey
View GitHub Profile
@4RSIM3R
4RSIM3R / company_alias.php
Created February 20, 2024 13:35
Generate Company Alias
function shortenName(string $name): string
{
$words = explode(' ', $name);
$shortened = '';
foreach ($words as $word) {
// Take the first letter of each word and concatenate
$shortened .= strtoupper(substr($word, 0, 1));
}
<?php
// fix this error please
class DBConnection
{
private $connection;
public function __construct($connection)
<?php
// di berikan sebuah angka, cari posisi index angka tersebut dalam array
// input : arr = [1, 2, 3, 4, 5], i = 3
// output : 2
// input : arr = [1, 2, 3, 4, 5], i = 9
// output : -1
function findMe($arr, $i)
{
<?php
// hilangkan semua item yang duplikat dalam sebuah array
// contoh input : [1, 1, 2, 3, 4, 4, 5]
// maka output nya : [1, 2, 3, 4, 5]
function removeAllDuplicates($arr)
{
return $arr;
}
@4RSIM3R
4RSIM3R / mahasiswa_berpestasi.dart
Created October 2, 2023 06:57
mahasiswa_berpestasi.dart
void main() {
// Tugas 1
print("Hello world");
// Tugas 2
String name = 'joko anton jodo';
print(name);
// Tugas 3
@4RSIM3R
4RSIM3R / php_https.conf
Created September 26, 2023 09:33
[Nginx] Config
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
@4RSIM3R
4RSIM3R / count_odd.php
Created September 26, 2023 06:44
[PHP] Count Odd
<?php
// Complete this function, that count how much odd number in an array
// example :
// payload : [1, 2, 3, 4, 5, 6, 7]
// the result is 4
function countOdd($numbers) {
}
@4RSIM3R
4RSIM3R / manhattan_distance.php
Created September 26, 2023 06:38
[PHP] Manhattan Distance
<?php
// Manhattan Distance :
// Buatlah sebuah fungsi untuk menghitung 'manhattan distance' antara 2 titik koordinat, contoh:
//
// A = (2, 2)
// B = (3, 5)
//
// |x1 - x2| + |y1 - y2|
//
@4RSIM3R
4RSIM3R / altitude.php
Created September 25, 2023 09:46
[PHP] counting altitude
<?php
// counting the altitude
// 1. 'up' berarti naik 1 (+1)
// 2. 'down' berarti turun 1 (-1)
// 3. 'flat' berarti datar (+0)
// anda memiliki sebuah array 'arr' yang berisi : ['up', 'up', 'down', 'flat']
// buatlah program untuk menentukan ketinggian akhir berdasarkan aturan di atas
// arr = ['up', 'up', 'down', 'flat'], maka hasil nya adalah 1, karena naik 2 kali, turun 1 kali, dan datar 1 kali -> (2 * 1) - 1 + 0 = 1
@4RSIM3R
4RSIM3R / positive_negative_ratio.php
Created September 25, 2023 09:41
[PHP] positive negative ration
<?php
// negative positive ratio
// anda memiliki sebuah array 'arr' yang berisi : [-1, 1, 2]
// buatlah program untuk menentukan rasio (berupa bilangan pecahan) antara jumlah bilangan negatif dibandingkan bilangan positif
// arr = [-1, 1, 2], maka hasil nya adalah 0.5, karena jumlah bilangan negatif nya 1 dan bilangan positif nya 2 -> 1 / 2 = 0.5
$arr = [-1, -1, 1, 2];
$result1 = 0; // 1