willwac wrote:
Store
Code:
"H  He Li Be B  C  N  O  F  Ne Na Mg Al Si P  S  Cl Ar K  Ca Sc Ti V  Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Rb Sr Y  Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I  Xe Cs Ba La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu Hf Ta W  Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn Fr Ra Ac Th Pa U  Np Pu Am Cm Bk Cf Es Fm Md No Lr Rf Db Sg Bh Hs Mt Ds Rg Cn UutFl UupLv UusUuo"
in a string (i.e. Str2) and do
Code:
Output(2,8,sub(Str2,3V-2,3
I could, but if I'm not mistaken, then wouldn't the string just add another step in the code since I'm only using that data once, causing it to run slower? On small scale, wouldn't
Code:
:Output(1,1,"A"
be faster than
Code:
:"A"→Str1
:Output(1,1,Str1
?
If you're only using once, then use what you did.
Yeah, your code was better than what willwac wrote. I don't think he even bothered reading your post.

FrozenFire wrote:
How else would I be able to optimize the code?
You're well on your way and learning fast. Did you try turning that one remaining long set of comparisons into something more compact yet?
Jeez; way to make me not want to come back.
I did read the post; I didn't know that he was only using it once.
I don't think you even bothered reading my post, Kerm.
KermMartian wrote:
FrozenFire wrote:
How else would I be able to optimize the code?
You're well on your way and learning fast. Did you try turning that one remaining long set of comparisons into something more compact yet?
Do I know that it could probably be compacted to just a few lines? Yea. Do I have the current knowledge to do so with that many variables. No, unfortunately not. Sad

Edit:
I've had a few ideas, but they've all been discarded. The best one I've had was putting the entire thing into a single string and displaying each part separately, but that still doesn't solve the problem of all the comparisons, and that once again, essentially does

Code:
:"A"→Str1
:Output(1,1,Str1
compared to
Code:
:Output(1,1,"A"
willwac wrote:
I don't think you even bothered reading my post, Kerm.
Then please accept my apologies; I misunderstood what you were saying.

FrozenFire: How about something like this? You'll have to double-check that I didn't make an error transcribing the numbers, but this is the general idea:

Code:
:{24,27,41,42,44,45,46,47,57,58,64,78,79,89,90,91,92,93,96,103
:If max(V=Ans
:Then:Ans->X
:{6,6,9,9,9,9,9,9,13,13,13,12,12,17,17,17,17,17,18->L1
:1+6(V=64 or V=96)+(V=91)+2(V=92)+3(V=93)-(max(V={46,57,89,90,103->∟SHELL(L1(X
:{5,10,4,5,7,8,10,10,1,1,1,9,10,1,2,1,1,1,1,1
:Ans(X)->∟SHELL(L1(X)+1+(12=L1(X
:End
Ok, I'm glad that we don't have to fight over this anymore.
To check the errors, I have to try (and probably fail) to understand it
Code:
:{24,27,41,42,44,45,46,47,57,58,64,78,79,89,90,91,92,93,96,103 // the exceptions
:If max(V=Ans // if the element is an exception
:Then:Ans->X // set the exception to X
:{6,6,9,9,9,9,9,9,13,13,13,12,12,17,17,17,17,17,18->L1 // set ??? to a list
:1+6(V=64 or V=96)+(V=91)+2(V=92)+3(V=93)-(max(V={46,57,89,90,103->∟SHELL(L1(X // umm, weird math to describe the shells?
:{5,10,4,5,7,8,10,10,1,1,1,9,10,1,2,1,1,1,1,1 // how many electrons are in the shells
:Ans(X)->∟SHELL(L1(X)+1+(12=L1(X // set that string to the list somehow
:End
If I might make a suggestion, since you have access to a color screen, why not have color diagrams of an atom of each element, visually showing the number and configuration of protons neutrons and electrons? Seeing visually how many electrons are in the valence shell of an atom helps me see how they chemically bind with other atoms to form elements.
DShiznit wrote:
If I might make a suggestion, since you have access to a color screen, why not have color diagrams of an atom of each element, visually showing the number and configuration of protons neutrons and electrons? Seeing visually how many electrons are in the valence shell of an atom helps me see how they chemically bind with other atoms to form elements.
I was actually thinking about doing that after adding more text info about the elements. Without making it cluttered with all the sublevels' shapes as in the quantum theory, I'll only be limited to the Bohr Models and Lewis Structures, which I think you were describing, of the atom.

Edit:
Is it recommended that I put the element's names in one long string, with 13 characters reserved for each name (1534 characters total), and then do what I did for the element's symbols, or is there a better way to do it?
FrozenFire49 wrote:
To check the errors, I have to try (and probably fail) to understand it
:{24,27,41,42,44,45,46,47,57,58,64,78,79,89,90,91,92,93,96,103 // the exceptions
:If max(V=Ans // if the element is an exception
Specifically, this produces a list of 0s and 1s, 1s where V=the list element, 0s elsewhere. max(V=Ans) is 1 if there's at least one 1, or 0 if all 0s.
Quote:
:Then:Ans->X // set the exception to X
:{6,6,9,9,9,9,9,9,13,13,13,12,12,17,17,17,17,17,18->L1 // set ??? to a list
List elements of LSHELL for the first half of each exception.
Quote:
:1+6(V=64 or V=96)+(V=91)+2(V=92)+3(V=93)-(max(V={46,57,89,90,103->∟SHELL(L1(X // umm, weird math to describe the shells?
This should produce the same thing as all the first halves of the LSHELL stores in the original code. It products 7 if V=64 or V=96, 2 if V=91, 3 if V=92, 4 if V=93, 0 if V=46, 57, 89, 90, or 103, or 1 otherwise.
Quote:
:{5,10,4,5,7,8,10,10,1,1,1,9,10,1,2,1,1,1,1,1 // how many electrons are in the shells
:Ans(X)->∟SHELL(L1(X)+1+(12=L1(X // set that string to the list somehow
:End
For most of the LSHELL stores, the second list element is 1 more than the first list element (6 and 7, 13 and 14, 17 and 18, for example). The exception is 12 with 14.

Makes sense? Further questions?
That will take a few days to comprehend...

So if I would add the predicted exceptions to the program (which I will do soon), I would add Darmstadtium ([Rn] 7s1 5f14 6d9)
Code:
:If V=110
:Then
:1→ʟSHELL(16
:9→ʟSHELL(18
:End
and Roentgenium ([Rn] 7s1 5f14 6d10)
Code:
:If V=111
:Then
:1→ʟSHELL(16
:10→ʟSHELL(18
:End

How would this change the code you described so I can get a better feel for the mechanics and comprehend it a few days sooner
Here is some of version 0.3's code:

The beginning for the menus and searching:
Code:
:"H  He Li Be B  C  N  O  F  Ne Na Mg Al Si P  S  Cl Ar K  Ca Sc Ti V  Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr Rb Sr Y  Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I  Xe Cs Ba La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu Hf Ta W  Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn Fr Ra Ac Th Pa U  Np Pu Am Cm Bk Cf Es Fm Md No Lr Rf Db Sg Bh Hs Mt Ds Rg Cn UutFl UupLv UusUuo"→Str1
:"Hydrogen     Helium       Lithium      Berylium     Boron        Carbon       Nitrogen     Oxygen       Fluorine     Neon         Sodium       Magnesium    Aluminum     Silicon      Phosphorus   Sulfur       Chlorine     Argon        Potassium    Calcium      Scandium     Titanium     Vanadium     Chromium     Manganese    Iron         Cobalt       Nickel       Copper       Zinc         Gallium      Germanium    Arsenic      Selenium     Bromine      Krypton      Rubidium     Strontium    Yttrium      Zirconium    Niobium      Molybdenum   Technetium   Ruthenium    Rhodium      Palladium    Silver       Cadmium      Indium       Tin          Antimony     Tellurium    Iodine       Xenon        Cesium       Barium       Lanthanum    Cerium       Praseodymium Neodymium    Promethium   Samarium     Europium     Gadolinium   Terbium      Dysprosium   Holmium      Erbium       Thulium      Ytterbium    Lutetium     Hafnium      Tantalum     Tungsten     Rhenium      Osmium       Iridium      Platinum     Gold         Mercury      Thallium     Lead         Bismuth      Polonium     Astatine     Radon        Francium     Radium       Actinium     Thorium      Protactinium Uranium      Neptunium    Plutonium    Americium    Curium       Berkelium    Californium  Einsteinium  Fermium      Mendelevium  Nobilium     Lawrencium   RutherfordiumDubnium      Seaborgium   Bohrium      Hassium      Meltnerium   Darmstadtium Roentgenium  Copernicium  Ununtrium    Flerovium    Ununpentium  Livermorium  Ununseptium  Ununoctium   "→Str2
:DelVar B
:ClrHome
:Lbl 4
:Menu("Search By:","Atomic Number",5,"Name",6,"Symbol",7,"Quit",3
:Lbl 5
:Repeat A≥1 and A≤118 and A=int(A
:ClrHome
:Input "Atomic Number:",A
:End
:Goto 8
:Lbl 6
:Repeat inString(Str2,Str0)≠0
:Repeat length(Str0)≤13
:ClrHome
:Input "Name:",Str0
:End
:While length(Str0)<13
:Str0+" "→Str0
:End
:End
:(inString(Str2,Str0)+12)/13→A
:Goto 8
:Lbl 7
:Repeat inString(Str1,Str0)≠0
:Repeat length(Str0)≤3
:ClrHome
:Input "Symbol:",Str0
:End
:While length(Str0)<3
:Str0+" "→Str0
:End
:End
:(inString(Str1,Str0)+2)/3→A
:Lbl 8
:A→V
:Lbl 9
:ClrHome
:Menu("Go To:","Electron Configuration",10,"Basic Information",2,"Choose New Element",11,"Quit",3
:Lbl 11
:Menu("Seach By:","Atomic Number",5,"Name",6,"Symbol",7,"Back",9
:Lbl 10
:Menu("Noble Gas Notation?","Yes",1,"No",0,"Back",9
And the end for the element's info:
Code:
:Lbl 2
:Disp "Name:"
:Output(1,6,sub(Str2,13V-12,13
:Disp "Symbol:"
:Output(2,8,sub(Str1,3V-2,3
:Disp "Atomic Number:"
:Output(3,15,V
:Disp "Atomic Mass:"
:Output(4,13,sub("1.008   4.0026  6.94    9.0122  10.81   12.011  14.007  15.999  18.998  20.180  22.990  24.305  26.982  28.085  30.974  32.06   35.45   39.948  39.098  40.078  44.956  47.867  50.942  51.996  54.938  55.845  58.933  58.693  63.546  65.38   69.723  72.63   74.922  78.96   79.904  83.798  85.468  87.62   88.906  91.224  92.906  95.96   [97.91] 101.07  102.91  106.42  107.87  112.41  114.82  118.71  121.76  127.60  126.90  131.29  132.91  137.33  138.91  140.12  140.91  144.24  [144.91]150.36  151.96  157.25  158.93  162.50  164.93  167.26  168.93  173.05  174.97  178.49  180.95  183.84  186.21  190.23  192.22  195.08  196.97  200.59  204.38  207.2   208.98  [208.98][209.99][222.02][223.02][226.03][227.03]232.04  231.04  238.03  [237.05][244.06][243.06][247.07][247.07][251.08][252.08][257.10][258.10][259.10][262.11][265.12][268.13][271.13][270]   [277.15][276.15][281.16][280.16][285.17][284.18][289.19][288.19][293]   [294]   [294]   ",8V-7,8
:Disp "Group:"
:If V=1 or V=3 or V=11 or V=19 or V=37 or V=55 or V=87
:1→D
:If V=4 or V=12 or V=20 or V=38 or V=56 or V=88
:2→D
:If (V≥57 and V≤70) or (V≥89 and V≤102)
:0→D
:If V=21 or V=39 or V=71 or V=103
:3→D
:If V=22 or V=40 or V=72 or V=104
:4→D
:If V=23 or V=41 or V=73 or V=105
:5→D
:If V=24 or V=42 or V=74 or V=106
:6→D
:If V=25 or V=43 or V=75 or V=107
:7→D
:If V=26 or V=44 or V=76 or V=108
:8→D
:If V=27 or V=45 or V=77 or V=109
:9→D
:If V=28 or V=46 or V=78 or V=110
:10→D
:If V=29 or V=47 or V=79 or V=111
:11→D
:If V=30 or V=48 or V=80 or V=112
:12→D
:If V=5 or V=13 or V=31 or V=49 or V=81 or V=113
:13→D
:If V=6 or V=14 or V=32 or V=50 or V=82 or V=114
:14→D
:If V=7 or V=15 or V=33 or V=51 or V=83 or V=115
:15→D
:If V=8 or V=16 or V=34 or V=52 or V=84 or V=116
:16→D
:If V=9 or V=17 or V=35 or V=53 or V=85 or V=117
:17→D
:If V=10 or V=18 or V=36 or V=54 or V=86 or V=118
:18→D
:If D=0
:Then
:Output(5,7,"None
:Else
:Output(5,7,D
:End
:Disp "Period:"
:If V≤2
:1→E
:If V≥3 and V≤10
:2→E
:If V≥11 and V≤18
:3→E
:If V≥19 and V≤36
:4→E
:If V≥37 and V≤54
:5→E
:If V≥55 and V≤86
:6→E
:If V≥87
:7→E
:Output(6,8,E
:Output(7,8,"Press Enter"
:Pause
:Goto 9
:Lbl 3
:DelVar ADelVar BDelVar CDelVar DDelVar EDelVar VDelVar ∟LEVELDelVar ∟SHELLDelVar Str0DelVar Str1DelVar Str2

I fell like I optimized these parts of the code pretty well, even though the file is now over twice the size as v0.22.

To do list:
1. Farther compact the code, especially the part with the exceptions
2. Add element type in Basic Info, and add Advanced Info
3. Show location of an element on a text-based Periodic Table
4. Work on models of elements' atoms

Edit:
I've been working a little this morning on the periodic table. This is what I have so far:
Right now, the + is the selected element, and the * is the rest of the table.

What symbols do you think would work the best?

Edit:
Version 0.31 includes the periodic table above, each element's type, and a fixes to a few bugs and typos I've found. The periodic table is acceptable, but I'm still not satisfied with it.Neutral
Version 0.32 update:
    More info added
    Ability to move between elements with arrows
    Minor adjustments
Goals:
    Advanced info
    More optimization
    Atom models
Questions:
    How do I add the exceptions to this?
    Code:
    :{24,27,41,42,44,45,46,47,57,58,64,78,79,89,90,91,92,93,96,103
    :If max(V=Ans
    :Then:Ans->X
    :{6,6,9,9,9,9,9,9,13,13,13,12,12,17,17,17,17,17,18->L1
    :1+6(V=64 or V=96)+(V=91)+2(V=92)+3(V=93)-(max(V={46,57,89,90,103->∟SHELL(L1(X
    :{5,10,4,5,7,8,10,10,1,1,1,9,10,1,2,1,1,1,1,1
    :Ans(X)->∟SHELL(L1(X)+1+(12=L1(X
    :End

    What symbols would work the best on the periodic table?
I'll answer that soon, but first I just wanted to point out an optimization that I believe I also discuss in "Programming the TI-83 Plus/TI-84 Plus". This code can be optimized:
Code:
:If V=7 or V=15 or V=33 or V=51 or V=83 or V=115
:15→D
to something like this:
Code:
:If max(V={7,15,33,51,83,115
:15→D
Thanks for responding, but I have been looking at some other programs and I have actually done that with sum( instead of max( in one of the latest updates. Sorry for the onslaught of noobish questions, but what's the difference, if any, between the two commands?

KermMartian wrote:
Quote:
:Then:Ans->X // set the exception to X
:{6,6,9,9,9,9,9,9,13,13,13,12,12,17,17,17,17,17,18->L1 // set ??? to a list
List elements of LSHELL for the first half of each exception.
Also, what did you mean by "first half"?
FrozenFire49 wrote:
Thanks for responding, but I have been looking at some other programs and I have actually done that with sum( instead of max( in one of the latest updates. Sorry for the onslaught of noobish questions, but what's the difference, if any, between the two commands?
They do what it sounds like. sum() sums all the elements of the list, so the sum will be 0 if all the equality checks are zero and equal to the number of matches if any of the equality expressions are true. For example. sum(X={3,3,0,2}) will be 2 when X=3 and 0 when X=1. max(), on the other hand, just produces the maximum value in the list (1s for equality and 0 for inequality), so max(X={3,3,0,2}) will be 1 when X=3 and 0 when X=1. sum() and max() work equally well for the case when you have expression or expression or expression.... If you want to do expression and expression and expression, you will want to use sum() or min().

Quote:
KermMartian wrote:
Quote:
:Then:Ans->X // set the exception to X
:{6,6,9,9,9,9,9,9,13,13,13,12,12,17,17,17,17,17,18->L1 // set ??? to a list
List elements of LSHELL for the first half of each exception.
Also, what did you mean by "first half"?
Your exceptions set two elements of the SHELL list for each exception. By "the first half" I meant the first of the two list elements set in each exception's Then/End block.
After the contest, I can get back to work on this project.


Code:

:{24,27,41,42,44,45,46,47,57,58,64,78,79,89,90,91,92,93,96,103,110,111
:If max(V=Ans
:Then:Ans->X
:{6,6,9,9,9,9,9,9,13,13,13,12,12,17,17,17,17,17,18,16,16->L1
:1+6(V=64 or V=96)+(V=91)+2(V=92)+3(V=93)-(max(V={46,57,89,90,103->∟SHELL(L1(X
:{5,10,4,5,7,8,10,10,1,1,1,9,10,1,2,1,1,1,1,1,9,10
:Ans(X)->∟SHELL(L1(X)+1+({12,16}=L1(X
:End
This is what the code would look like after I add in the exceptions, right?
I copied the above code to replace the current code, and I got an overflow error, so I changed the second to last line to this:
Code:
:Ans(X)->∟SHELL(L1(X)+1+(12=L1(X) or 16=L1(X

It's giving me weird stuff. For example, element number 24 (Chromium) is displaying:

Code:
1s2  2s2  2p6  3s2  3p6 
4s2  3d4       5s1  4d5
and none of the exceptions are giving the correct configurations.

What did I do wrong?
Was the code that I had written working? If so, let me try to understand what you might have incorrectly modified. If not, then perhaps my original optimized code had an error.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 3
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement