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 / avg_array.php
Created September 25, 2023 09:36
[PHP] average_array
<?php
// average value of array
// anda memiliki sebuah array 'arr' yang berisi : [1, 5, 6]
// buatlah program untuk menentukan nilai rata rata dari item di dalam array tersebut
// arr = [1, 5, 6], maka rata rata nya adalah 4, karena (1 + 5 + 6) / 3 = 4
$arr1 = [2, 2, 50];
$result1 = 0; // 18
@4RSIM3R
4RSIM3R / dry.dart
Created September 13, 2023 00:51
[OOP - Easy] DRY (Dont Repeat Yourself)
// please make this code more clean, and remember dont repeat your self (DRY)
class Book {
final String? table;
Book({this.table});
void create() {
print('Insert to table : ${table}');
@4RSIM3R
4RSIM3R / in_memory.dart
Created September 13, 2023 00:47
[OOP - Easy] Simple in memory 'database'
// complete this code, so whenever i call the class, the return value must be exactly same
// clue : https://refactoring.guru/design-patterns/singleton
import 'dart:math';
class InMemory {
String _value = '';
String get value => _value;
@4RSIM3R
4RSIM3R / roman_to_int.dart
Created September 12, 2023 00:33
[Medium] Soal Nomer 2
// Complete this function, that will implementing simple load balancer logic
var rules = {
"I": 1,
"V": 5,
"X": 10,
"L": 50,
};
int romanToInteger(String payload) {
@4RSIM3R
4RSIM3R / load_balancer.dart
Created September 12, 2023 00:28
[Medium] Soal Nomer 1
// Complete this function, that will implementing simple load balancer logic
int counter = 0;
String next(List<String> payload) {
return "";
}
main() {
List<String> servers = ["192.168.1.2", "192.168.1.3", "192.168.1.4"];
@4RSIM3R
4RSIM3R / is_root_number.dart
Created September 12, 2023 00:21
[Easy] Soal Nomer 3
// Complete this function, that determine is given number can be
// square rooted or not
// example :
// payload : 4
// the result is true, because 4 is 2 to the power of 2
bool isRootNumber(int payload) {
return false;
}
@4RSIM3R
4RSIM3R / count_unique.dart
Last active September 12, 2023 00:23
[Easy] Soal Nomer 2
// Complete this function, that determine is given number can be
// Complete this function, that count how much unique value in an array
// example :
// payload : ["a", "a", "b", "c", "a"]
// the result is 3, beccause there is just 3 unique value in array
// clue : https://www.darttutorial.org/dart-tutorial/dart-set/
int countUnique(List<String> payload) {
@4RSIM3R
4RSIM3R / two_sum.dart
Last active September 12, 2023 00:22
[Easy] Soal Nomer 1
// Complete this function, that determine is given number can be
// square rooted or not
// example :
// payload : 4
// the result is true, because 4 is 2 to the power of 2
// Complete this function, that will add up two item of a 'payload'
// that equal to 'target'
class ActivityTaskSigner {
final int userId;
final int order;
final String status;
ActivityTaskSigner(
{required this.userId, required this.order, required this.status});
}
bool isApproveDisable(int userId, List<ActivityTaskSigner> signers) {
@4RSIM3R
4RSIM3R / main.dart
Created September 8, 2023 06:54
fascinating-mirror-4837
class ActivityTaskSigner {
final int userId;
final int order;
final String status;
ActivityTaskSigner({required this.userId, required this.order, required this.status});
}
bool isApproveDisable(int userId, List<ActivityTaskSigner> signers) {
return signers.asMap().entries.any((entry) {