Compare commits
9 commits
Author | SHA1 | Date | |
---|---|---|---|
6fa68b07b8 | |||
5fe83d7ee8 | |||
19dcae87c3 | |||
a52e81d6c8 | |||
897ef9bf4b | |||
6784d02b95 | |||
befd8c1e8b | |||
9429a39b3c | |||
6ba738d773 |
3 changed files with 14 additions and 112 deletions
16
README.md
16
README.md
|
@ -1,5 +1,17 @@
|
|||
# PPJ
|
||||
|
||||
This branch contains the solution for the **8th task**.
|
||||
This repository exists to archive PJATK tasks for the PPJ curriculum.
|
||||
|
||||
[Go back to main](/femsci/ppj/src/branch/nya)
|
||||
Each task can be found under its **corresponding branch**: `task/n`.
|
||||
|
||||
### Completed tasks:
|
||||
|
||||
- [Task 1](/femsci/ppj/src/branch/task/1)
|
||||
- [Task 2](/femsci/ppj/src/branch/task/2)
|
||||
- [Task 3](/femsci/ppj/src/branch/task/3)
|
||||
- [Task 4](/femsci/ppj/src/branch/task/4)
|
||||
- [Task 5](/femsci/ppj/src/branch/task/5)
|
||||
- [Task 6](/femsci/ppj/src/branch/task/6)
|
||||
- [Task 7](/femsci/ppj/src/branch/task/7)
|
||||
- [Task 8](/femsci/ppj/src/branch/task/8)
|
||||
- [Task 9](/femsci/ppj/src/branch/task/9)
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* TASK 8
|
||||
* archived at https://git.femboy.science/femsci/ppj/src/branch/task/8
|
||||
* by femsci
|
||||
*
|
||||
* written during a mental breakdown, vibing to The Cure - Disintegration
|
||||
*/
|
||||
|
||||
package dev.meowmeow;
|
||||
|
||||
import static dev.meowmeow.NamingUtils.*;
|
||||
|
||||
// :3
|
||||
public class CuteLemmas {
|
||||
public static void main(String[] args) {
|
||||
|
||||
// brace yourselves for a sysout frenzy
|
||||
|
||||
System.out.println(norm("caravaggio"));
|
||||
System.out.println(norm("VERMEER"));
|
||||
System.out.println(init("johann sebastian bach"));
|
||||
System.out.println(init("i. babeL"));
|
||||
System.out.println(init("jorge LUIS BORGES"));
|
||||
System.out.println(init("WOLFGANG a. mozart"));
|
||||
System.out.println(tr("Mississippi",
|
||||
"abcdefghijklmnopqrstuvwyz",
|
||||
"BCDEFGHIJKLMNOPQRSTUVWYZA"));
|
||||
System.out.println(tr("abcXYZ", "aZcX", "||Cx"));
|
||||
|
||||
System.out.println(norm(tr("haiii ", "h ", "pn")));
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* TASK 8
|
||||
* archived at https://git.femboy.science/femsci/ppj/src/branch/task/8
|
||||
* by femsci
|
||||
*/
|
||||
|
||||
package dev.meowmeow;
|
||||
|
||||
//cute atomic purely functional meows~
|
||||
|
||||
public class NamingUtils {
|
||||
// normeow
|
||||
public static String norm(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return String.format("%c%s", Character.toUpperCase(name.charAt(0)), name.substring(1).toLowerCase());
|
||||
}
|
||||
|
||||
// init 6
|
||||
public static String init(String name) {
|
||||
String[] sgmt = name.split(" ");
|
||||
|
||||
if (sgmt.length == 0) {
|
||||
throw new IllegalArgumentException("invalid data");
|
||||
}
|
||||
|
||||
int len = sgmt.length;
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
// alnamic names :3
|
||||
for (int c = 0; c < len - 1; ++c) {
|
||||
String silliname = sgmt[c];
|
||||
if (silliname.endsWith(".")) {
|
||||
if (silliname.length() != 2) {
|
||||
throw new IllegalArgumentException("only initials may end with a '.'");
|
||||
}
|
||||
|
||||
buf.append(silliname.toUpperCase()).append(' ');
|
||||
continue;
|
||||
}
|
||||
|
||||
buf.append(String.format("%c.", Character.toUpperCase(silliname.charAt(0)))).append(' ');
|
||||
}
|
||||
|
||||
// lname
|
||||
buf.append(norm(sgmt[len - 1]));
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
// trills
|
||||
public static String tr(String s, String assMapFrom, String assMapTo) {
|
||||
// hehe >:3c
|
||||
// Runtime.getRuntime().exec(new String[] {
|
||||
// "/usr/bin/bash",
|
||||
// String.format("-c \"echo '%s' | tr '%s' '%s'\"", s, from, to)
|
||||
// });
|
||||
|
||||
if (assMapFrom.length() != assMapTo.length()) {
|
||||
throw new IllegalArgumentException("mapping sets must have same len");
|
||||
}
|
||||
|
||||
StringBuffer buf = new StringBuffer(s.length());
|
||||
|
||||
for (int rcx = 0; rcx < s.length(); ++rcx) {
|
||||
char meow = s.charAt(rcx);
|
||||
int assIdx = assMapFrom.indexOf(meow);
|
||||
char meowie = assIdx == -1 ? meow : assMapTo.charAt(assIdx);
|
||||
|
||||
buf.append(meowie);
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue