From e35e3cdf1e2faa89085410070a1af5b99ddfb661 Mon Sep 17 00:00:00 2001 From: meron469 <56836344+Meron469@users.noreply.github.com> Date: Wed, 10 Jun 2020 19:50:07 -0500 Subject: [PATCH 1/2] python Finished the code in python. I made a mistake and was looking at the wrong link . But it is done --- week-2/Python/Meron-Solomon.py | 58 ++++++++++++++++++++++++++++++++++ week-2/Python/READ_ME.txt | 19 +++++++++++ 2 files changed, 77 insertions(+) create mode 100644 week-2/Python/Meron-Solomon.py create mode 100644 week-2/Python/READ_ME.txt diff --git a/week-2/Python/Meron-Solomon.py b/week-2/Python/Meron-Solomon.py new file mode 100644 index 0000000..2483fd3 --- /dev/null +++ b/week-2/Python/Meron-Solomon.py @@ -0,0 +1,58 @@ +#Meron Solomon +from itertools import permutations + +#this function prints out the permutation from string input +def printPermutation(My_String): + lst=[] + Hold_perm = permutations(My_String)#useing the Permutation library + for i in list(Hold_perm):#loop will go through the size of the string until it finishes plugginf in the permutation + hold_prem_2=(''.join(i)) + lst.append(hold_prem_2) + print("\nOutput:\n") + print(lst)#printing out the permutation + +#this function takes in a string and +def Palindrome_Machine(My_String): + #this if statement checks the string + if not My_String: + return My_String + String_length, a, b = len(My_String), 0, 0 + # + String_Hold = [[True]*String_length, [False]*String_length] + #This loop goes through the given string and appends it + for c in range(String_length-1): + if My_String[c] == My_String[c+1]: + String_Hold[1][c] = True + a, b = c, c+1 + #This loop takes in the string and converts it into the permuatation + for d in range(2, String_length): + for c in range(String_length-d): + Hold_return = c+d + y, z = d%2, c+d//2 + String_Hold[y][z] = String_Hold[y][z] and My_String[c] == My_String[Hold_return] + if String_Hold[y][z] and Hold_return-c > b-a: + a, b = c, Hold_return + return My_String[a:b+1] + + +# this while loop runs endlessely until you press the number 3 +#Enter 1 to turn string into Palindrome +#Enter 2 for string permutation +#First enter a number then you enter a string that you want to turn into a palindrome or permutations +while True: + i=input("\nEnter 1 to turn string into Palindrome\nEnter 2 for string permutation\n3 to exit\n") + i=int(i) + if i==1: + String_1 = input("\nEnter String-Palindrome\n") + print("\nOutput:\n") + print(Palindrome_Machine(String_1)) + + elif i==2: + String_2 = input("\nEnter String-Permutation\n") + printPermutation(String_2) + + elif i==3: + break + else: + print("\nwrong") + diff --git a/week-2/Python/READ_ME.txt b/week-2/Python/READ_ME.txt new file mode 100644 index 0000000..c5f34c0 --- /dev/null +++ b/week-2/Python/READ_ME.txt @@ -0,0 +1,19 @@ +Palindrome and Permutation README + +Enter 1 to type in a String you want to turn into Palindrome: +EX: + +Enter String-Palindrome +ababad +Output: +ababa + +Enter 2 to type in a String you want to turn into Permutation: +EX: + +Enter String-Permutation +abb +Output: +['abb', 'abb', 'bab', 'bba', 'bab', 'bba'] + +Enter 3 to exit: From 48f565e94f11dd6b1803dd85446860caff73b74d Mon Sep 17 00:00:00 2001 From: meron469 <56836344+Meron469@users.noreply.github.com> Date: Wed, 24 Jun 2020 21:37:34 -0500 Subject: [PATCH 2/2] Add files via upload --- .../Meron-Solomon/bin/Function_check.class | Bin 0 -> 1824 bytes .../Meron-Solomon/bin/Link_list$Take_n.class | Bin 0 -> 474 bytes week-4/Java/Meron-Solomon/bin/Link_list.class | Bin 0 -> 2916 bytes week-4/Java/Meron-Solomon/bin/Reverse.class | Bin 0 -> 380 bytes week-4/Java/Meron-Solomon/src/Link_list.java | 178 ++++++++++++++++++ week-4/Java/Meron-Solomon/src/Reverse.java | 119 ++++++++++++ 6 files changed, 297 insertions(+) create mode 100644 week-4/Java/Meron-Solomon/bin/Function_check.class create mode 100644 week-4/Java/Meron-Solomon/bin/Link_list$Take_n.class create mode 100644 week-4/Java/Meron-Solomon/bin/Link_list.class create mode 100644 week-4/Java/Meron-Solomon/bin/Reverse.class create mode 100644 week-4/Java/Meron-Solomon/src/Link_list.java create mode 100644 week-4/Java/Meron-Solomon/src/Reverse.java diff --git a/week-4/Java/Meron-Solomon/bin/Function_check.class b/week-4/Java/Meron-Solomon/bin/Function_check.class new file mode 100644 index 0000000000000000000000000000000000000000..03ee9202e3f9a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s(Z0<13aP15+a9&NLk-vc_Q^&iQu~1qIqqwh{|XWF2@SC4iVy73zu7xb AKL7v# literal 0 HcmV?d00001 diff --git a/week-4/Java/Meron-Solomon/bin/Link_list$Take_n.class b/week-4/Java/Meron-Solomon/bin/Link_list$Take_n.class new file mode 100644 index 0000000000000000000000000000000000000000..6f867e44a4e5750fa6c0d67419bf8e9c9e6a83cc GIT binary patch literal 474 zcmZ8dO;5r=5Pe%JrKLhe#Sc(CZ~#oitI>ENF_I8CNVt*(H@Z-^Nw*mPmIq?u!5`p{ zGR{_m#%y+W=DqoNJ0G8K?*J}Pb6_z9J*np7Q0k;U3d?l4kt{IArKX|t}qHdk&UbrC2hYQa` z23tPzDACA9b7Ytu9~;P01`QPbdv^aA~4OzfJ4hRCHnGsKPQZ#^-<`!G0D->F<2wK$@wqJ;{uuHZCo2*C8TsnCasI*K-nRuXxJ<~k(%sA6* VpCStfIHcE0$5n7d{&9*|z5r~aSCaq$ literal 0 HcmV?d00001 diff --git a/week-4/Java/Meron-Solomon/bin/Link_list.class b/week-4/Java/Meron-Solomon/bin/Link_list.class new file mode 100644 index 0000000000000000000000000000000000000000..0289e6543e8c9c8c748a4dbe8ef830c81fc16f68 GIT binary patch literal 2916 zcmZ`*`%fI_6+PeX><%nrLwUJ|bs!F|_rW7}sFRpS97qWe9u81aOk)^!r!cV0Zgyv} z^K{}kQld6erK+tWSxM|RrIM|xuHto6SNXA)`bXqnh?HNdN=fOtv%`X8S7N^Rckj99 zp8GBT`tRSr1n@L2>j)@RPuR}JQpPU0Iy8m4b#u$?$(YV+&-BW=m2wrrGgiS}I-yWM zQ90W&XKq+aPT%hCNrlje?U)$_-P_7K3TlkzFRaV zD}o^E3>Y||P)qaHRB>~~%FmfA8Q!R$$fnH9yqULU?k{TYnq5$+*+WAZ`izya%mVK; z#r8IKVaDgH@k6xeIDB7(v#%ChYtuk0q6C#KGT5dGj{rN{b2e`~?yQ@)%*{R>k0>14 zqlU}2vpQ6?GifVdjdmQ>@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{X)tzs;Dmz`=3GLfSmheiF z@*6Lquver*q!##?n)`$SGUK>LqObG0`2)58N0#e0p2wd_>^6zLL22D&*f)^JU$BM0 z;w{|TN8lx(i&mC+gAIt*=x&O$m~ j*FpZ?;GY6&4%G0{n>-MpyG!gPGwuA|=J*|cn#}(PbL}cF literal 0 HcmV?d00001 diff --git a/week-4/Java/Meron-Solomon/bin/Reverse.class b/week-4/Java/Meron-Solomon/bin/Reverse.class new file mode 100644 index 0000000000000000000000000000000000000000..1d1b330b39ad043af1976970b7ecb66a8ffbdbc7 GIT binary patch literal 380 zcmX|6O-sX25S&fYrm1P8^;<7`Ym3;kD1sC`6$LE?Px4xy`f8d$n)ZKrD1rxnfImu{ z7lW7mnBAG#{r>s<0&s={ACADk(@UMrwGU6QK2=NAi&gT{yB$yUBo}x?^`-^V7gVmE zbDar-LCHB6R4+_o@=HOZ-T#L>Bl7y`ldi)>BSe6vz-@O%0q7B;f~u`rA$-&X(ZD47 zW-%M= 0) + { + which_one = check; + check = check.next; + } + + + compare_size(which_one, Rest_2); + + + take_on_C(Rest_1); + } + + if (Take_on > 0) + input_var(Take_on, 3); + + } + + + public static void main(String args[]) + { + Link_list Test_Hold = new Link_list(); + Test_Hold.Rest_1 = null; + Test_Hold.Rest_2 = null; + Test_Hold.Final = null; + Test_Hold.Take_on = 0; + int Case_1[] = { 5, 6, 3 }; + int Case_2[] = { 8, 4, 2 }; + + + for (int i = Case_1.length - 1; i >= 0; --i) + Test_Hold.input_var(Case_1[i], 1); + + + for (int i = Case_2.length - 1; i >= 0; --i) + Test_Hold.input_var(Case_2[i], 2); + + Test_Hold.add_on_there(); + + Test_Hold.Release(Test_Hold.Final); + } +} \ No newline at end of file diff --git a/week-4/Java/Meron-Solomon/src/Reverse.java b/week-4/Java/Meron-Solomon/src/Reverse.java new file mode 100644 index 0000000..918d66e --- /dev/null +++ b/week-4/Java/Meron-Solomon/src/Reverse.java @@ -0,0 +1,119 @@ + +public class Reverse { + public Reverse(char Take_in, Reverse After_in) + { + Take = Take_in; + After = After_in; + } + public char Take; + public Reverse After; +} +class Function_check { + + + private static Reverse Switch_string(String hold_string) + { + Reverse top_on = null; + Reverse tester = null; + + for (int i = 0; i < hold_string.length(); i++) { + char charact = hold_string.charAt(i); + Reverse node = new Reverse(charact, null); + + if (top_on == null) { + top_on = node; + tester = top_on; + } + else { + tester.After = node; + tester = tester.After; + } + } + return top_on; + } + + + private static Reverse Reverse(Reverse top_on) + { + if (top_on == null) + return top_on; + + Reverse Start_on = null; + Reverse last = null; + Reverse start_p = null; + + + Start_on = top_on; + + while (top_on != null && top_on.Take != ' ') { + + last = top_on; + + top_on = top_on.After; + } + + if (top_on == null) { + top_on = Start_on; + return top_on; + } + + do { + + + Reverse tester = top_on.After; + top_on.After = Start_on; + Start_on = top_on; + top_on = tester; + + Reverse prev = null; + + start_p = top_on; + + + while (top_on != null && top_on.Take != ' ') { + prev = top_on; + top_on = top_on.After; + } + + + prev.After = Start_on; + + + Start_on = start_p; + if (top_on == null) + break; + + + } while (top_on != null); + + top_on = start_p; + + + last.After = null; + return top_on; + } + + + private static void show_off(Reverse Header) + { + Reverse tester = Header; + + while (tester != null) { + System.out.print(tester.Take); + tester = tester.After; + } + } + + + public static void main(String[] args) + { + String hold_string = "I love Geeks for Geeks"; + + Reverse top_on = Switch_string(hold_string); + + top_on = Reverse(top_on); + + System.out.println("\nAfter:"); + show_off(top_on); + } +} \ No newline at end of file