Compare commits

..

5 Commits

Author SHA1 Message Date
io42630 ff20bf65fd Merge remote-tracking branch 'origin/master'
1 month ago
io42630 bcd16c6c64 bump sql
1 month ago
io42630 3743016a3c bump doc
1 month ago
io42630 81f70fccfe bump java-kit
1 month ago
io42630 1890db68dd add py-kit
1 month ago

@ -1,3 +1,4 @@
java temurin-21.0.3+9.0.LTS java temurin-21.0.3+9.0.LTS
maven 3.9.6 maven 3.9.6
pyton 3.13.3
ghc 9.8.4 ghc 9.8.4

@ -1,8 +1,10 @@
# Field Kit # Field Kit
* a collection of easy-to-use tools that cover common use cases. This repo has two purposes:
* also serves as workspace for exercises.
* those results should be migrated to their respective `about-foo` once some knowledge is consolidated. - Serve as a collection of easy-to-use tools that cover common use cases.
- Be a workspace for exercises.
- those results should be migrated to their respective `about-foo` once some knowledge is consolidated.
## List of Use Cases ## List of Use Cases
@ -19,10 +21,11 @@
## Setup ## Setup
* WIN #### Python
* pyenv win
* in IDEA, make sure to set SDK proj settings / module
### Haskell Kit #### Haskell
asdf plugin add ghc asdf plugin add ghc

@ -0,0 +1,11 @@
SELECT *
FROM CITY
WHERE COUNTRYCODE = 'USA'
AND POPULATION > 100000;
SELECT CITY, STATE
FROM STATION;
SELECT DISTINCT CITY FROM STATION WHERE ID % 2 = 0;

@ -0,0 +1,25 @@
package com.olexyn.field.kit.hacker.rank.problems;
public class CatMouseABC {
public static void main(String[] args) {
}
static String catAndMouse(int x, int y, int z) {
int dx = Math.abs(x - z);
int dy = Math.abs(y - z);
if (dx == dy) {
return "Mouse C";
}
if (dx < dy) {
return "Cat A";
}
return "Cat B";
}
}

@ -0,0 +1,30 @@
package com.olexyn.field.kit.hacker.rank.problems;
public class KeysBudget {
public static void main(String[] args) {
}
static int getMoneySpent(int[] keyboards, int[] drives, int b) {
int max = -1;
for (int k : keyboards) {
for (int d : drives) {
int sum = k + d;
if (sum <= b && sum > max) {
max = sum;
}
if (max == b) {
return max;
}
}
}
return max;
}
}

@ -5,26 +5,27 @@ public class Valleys {
public static void main(String[] args) { public static void main(String[] args) {
countingValleys( countingValleys(
8, 12,
"UDDDUDUU" "DDUUDDUDUUUD"
); );
System.out.println("hi");
} }
public static int countingValleys(int steps, String path) { public static int countingValleys(int steps, String path) {
// Write your code here // Write your code here
int prevLevel = 0;
int level = 0; int level = 0;
int valleys = 0; int valleys = 0;
String[] paths = path.split(""); for (String s : path.split("")) {
for (int i = 0; i < paths.length; i++) { if (s.equals("U")) {
if (paths[i].equals("U")) { prevLevel = level;
level++; level++;
} else { } else {
prevLevel = level;
level--; level--;
} }
if (i != 0 && level == 0 && paths[i - 1].equals("U")) { if (prevLevel == -1 && level == 0 && s.equals("U")) {
valleys++; valleys++;
} }
} }

@ -1,13 +0,0 @@
package org.example;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

@ -6,6 +6,7 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>java-kit</module> <module>java-kit</module>
<module>py-kit</module>
</modules> </modules>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

@ -0,0 +1,32 @@
def do_foo():
if n % 2 == 1:
print('Weird')
return
if 1 < n < 6:
print('Not Weird')
if 5 < n < 12:
print('Weird')
if 19 < n:
print('Not Weird')
def log_base_10(n):
if n == 0:
return float('-inf') # Logarithm of 0 is undefined
count = 0
while n >= 1:
n /= 10
count += 1
return count
if __name__ == '__main__':
n = 102
out = 0
for i in range(1, n + 1):
power = (i // 10 + 1)
# print(i, i / 10, log_base_10(i), pow(10, log_base_10(i) - 1), pow(10, power))
out = out * pow(10, log_base_10(i)) + i
print(out)

@ -0,0 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.olexyn</groupId>
<artifactId>field-kit</artifactId>
<version>1.0</version>
</parent>
<artifactId>py-kit</artifactId>
<packaging>jar</packaging>
<!-- dummy -->
</project>

@ -0,0 +1,20 @@
def log_base_10(n):
if n == 0:
return float('-inf') # Logarithm of 0 is undefined
count = 0
while n >= 1:
n /= 10
count += 1
return count
if __name__ == '__main__':
n = 102
out = 0
for i in range(1, n + 1):
power = (i // 10 + 1)
# print(i, i / 10, log_base_10(i), pow(10, log_base_10(i) - 1), pow(10, power))
out = out * pow(10, log_base_10(i)) + i
print(out)
Loading…
Cancel
Save