Several Cases for Angels: Bug Problems Fixed

I spent a little time on the Greek nouns.  I think that I have the o-micron declension down pretty pat, now.  It’s the same for masculine and feminine, slightly different for neutral nouns because the nominative, and accusative, and vocative are the same both in the singular and plural (the singular is different from the plural).  Also the endings are different in neutral for these cases biblion vs. helios.  I think it is also called the 2nd declension in Greek.  I’m sure I’ve made a couple of mistakes just by doing the noun quiz on the unit 3 nouns, I can see that there are some differences from the paradigm.  Still, I think the most important thing is to learn the paradigm well.  Also, I kind of passed on the accents and consequently the pronunciation – they will be for another round of analysis.  Not really sure why ἄγγελος seems to be pronounced “angelos” – hard g, and not “aggelos”.  Happy that I got one set of 19 nouns down – gender and all.  There may be 3 gender cases (Spanish, French, and Hebrew have 2, German also has 3, English has only 1), but there are other kinds of nouns, so it doesn’t cover all nouns.  Also different in Greek, is the presence of a “dual person with 2 cases”.  This needs more elaboration.

Spent an entire day debugging the randomize code.  The astute observer will have noticed (future perfect 🙂 or “habrá advertido” in Spanish) that everything was not quite random in the program – there were end effects, in particular the first number after randomization was always either the first or last number in the list of numbers. 

The bug ended up being an array that was reversed.  This was corrected, and 2 new programs were generated random_order 3 6 2 3 6 2 (for example), and random_set 8 2 12 (for example).  The first program takes the input numbers and rearranges them, the second program puts out a list of 8 numbers between 2 and 12.  These programs were used to modify my bash script setup program to the 2012 agenda, accommodating my need for intense focus and also to break focus with this program.  At some point, I will want to make the plunge into a gui (graphical user interface).  Not there yet.  The program still has some bugs in it.  When it randomizes the list at any given time, it should only randomize the remainder of the list, not anything that has already been done.  Also, it does not work right when the reorder (small r) option is used.  It breaks.  If I comment out the break, it does not reassign the i of the for loop that it is in.  It is a problem of scope I think, but tricky to debug.

Also, the classical_work program (now called classical_retry was really! debugged.  I had fixed (past perfect! or “hube reparado” in Spanish) the 2 bugs that were making it crash before, but had put in a new section of code that had the original bug in it.  So, that bug had to be fixed too.  Now it really! doesn’t crash anymore.  You can play it all night if you want.

Painted the bed. 

Cleaned while using the housecleaning mode of my program classical_retry.  Parents came to visit. We went to church together.  The priest talked about “ethos” or ἔθος .  It looks like an o-micron Greek word, but it’s not.  It’s a 3rd declension neutral noun that means character, but can also mean habit. 

So the reflection was that these are the rules that are required to keep a society together.  Different societies have different rules.  The Jewish tradition – that in which Jesus was raised – had the 10 commandments. Some of them were more important to Jesus than others were.   Although it might be nice if we all had the same biorhythms, some of us find it very difficult not to do anything 1 day a week, or even to not have an emergency requiring others to work.  I think it is easier to honor God a little every day, rather than focussing a whole day on this effort.   That is just between me and God.  All of the 10 commandments have equivalents in Islamic tradition.

The leaf-cutter ant problem is really quite a problem, not just here, but all over central america apparently.  Although I have 3 tender little squashes, 1 broccoli, 1 bean, 4 collard greens, 1 cauliflower, 3 carrots, and 2 tomatoes growing, some of them in pots.  I fear that the ants will attack.   They are somewhat slower with the potted plants, but they eventually get them.  The plant is destroyed in less than 12 hours. 

I don’t think I will get a cauliflower.  That plant is damaged but not destroyed by the ants.  They don’t eat the grass, but I wonder about the flowers, and the row of potatoes, swiss chard, and carrots that is just starting to come up.  I have 6 potato plants that have sprouted. 

It is a problem of great urgency.

Hurt my foot working on the bed. 

I think I used the foot to brace the leg of the bed while I put in a nail.  I wasn’t wearing shoes and maybe the impact broke the first metatarsal.  It hurts when I walk without shoes.  Bike has a fixable flat, but old patches got wet, and pull off like paper.  Need new patches.

Fixed the tire, but had subsequently had a blow out and blew the sidewall on the tire.  It apparently was damaged from the flat.  Now I need both a tire and an innertube.  I guess it is kind of like an aneurism.  Foot feels better today, though.

I also had to resolder the lead on my computer adapter.  Repairs are rarely permanent.  Planted a 20 square foot bed. 

Working on trying to come up with a ride into town for the bike marathon this Sunday.  It will mean leaving here around 4:30 am.

The computer picked my agenda for the day using my new program with 5 events:

environmental work:  planting flowers

exercise: 5 mile bike ride into town

world improvement work: connected with several people who needed assistance: 

1) East Texas family – now back together, but without food stamps and desperate for food.

2) Cousin who has been sick.  Invited cousin over for tea on the back porch when she feels better.

3) Visited my friend who had his catheterization done, and walked his dog.  They put in another stent.  It only took about 1 1/2 hours.  He can’t drive for a bit, because they don’t want any intense activity on his leg (like putting on the brakes).  He was eating fish and vegetables for dinner, but otherwise seemed to be doing well. 

4) Texted and called my friend who is staying with her mother who has Alzheimer’s.  She texted back, but could not get through with phone.  I’m out of phone minutes.

studying: reviewed the past perfect tense in Spanish well.  Also called the pluperfect.  Found a text section that uses this tense in Don Quixote and noted the examples.

cleaning:  picked up room.

——————————————————————————————-

The new programs:

Setup 2012_randopt2.sh

#!/bin/bash

# Setup 2012_randopt2.sh A bash script that helps to organize a day according to a set of goals, and implements both

# random selection of events and random reordering of events. Dependencies: needs random_order

# and random_set compiled c programs in the /mnt/home directory.

# Known bugs: “To do list does not work.” “r option is not working”. “R works, but does the whole list, instead of just

# what needs to be done. It’s still a neat program.

#

# submitted by livedoggb on 3/12/2012

#

function print_choice {

echo ” ”

echo “You chose to proceed in the following order: $choice”

echo ” ”

for i in ${choice}

do

echo “${event_array[$i]}”

done

return

}

#

function random_reassign {

echo ” ”

echo “Would you like the computer to randomly reorder the events? (y or n)”

read reorder

if [ $reorder == “y” ]

then

count=0

trimmed_choice=””

# for j in ${choice}

# do

# count =($count + 1)

# if ($count > $current_pos)

# then

# trimmed_choice=echo $trimmed_choice ${choice[$j]} ” ”

# fi

# done

echo $trimmed_choice

new_choice=$(/mnt/home/random_order $choice)

echo new_choice is “$new_choice”

choice=$new_choice

echo “The new order is:”

print_choice

fi

return

}

#

#

function neworder {

echo “Please take a few minutes to identify urgent matters that can be solved today.”

read urgent

echo $urgent “is urgent and can be solved today.”

echo ” ”

echo “Please take a few minutes to identify urgent matters that will require more time.”

read urgentneedingtime

echo $urgentneedingtime “is urgent and needs priority time over the next few days.”

echo ” ”

echo ” ”

echo “Please enter numbers in the order you would like to proceed separated”

echo “by spaces. Simply enter 0 to ignore. Enter r at anytime in the describe activity space to redefine order of day. Enter e at anytime in the describe activity space to exit gracefully and end program.”

echo ” ”

echo ” ”

echo ” ”

local i=1

while [ $i -lt $num_events ]

do

echo “$i. ${event_array[$i]}.”

i=$(( $i + 1 ))

done

echo ” ”

echo ” ”

echo “Do you have a list of things that HAVE to get done today? (y or n)”

read to_do_list

if [ $to_do_list == “y” ]

then

echo “enter items separated by commas using category numbers from above to start.”

echo “i.e. 1. Walk Petey, 8. Ask an elderly person if there is anything I can do for them, 9. Fix bicycle, 7. Sweep and Mop floors”

real_to_do_list=”1) Walk Petey, 9) Fix bicycle, 6) Do situps,”

echo $real_to_do_list

remainder=$real_to_do_list

remainder=$(echo $remainder | sed -e “s/^/,/”)

echo “remainder starts out as:” $remainder

while [ -n “$remainder” ]

do

num=$(echo $remainder | sed ‘s/,\([0-9]*\).*,/\1/1’)

remainder=$(echo $remainder)

remainder=$(echo $remainder | sed ‘s/,[0-9].*,/,/1’)

echo “num is:” $num “, and remainder is: ” $remainder

read c

done

fi

if [ $to_do_list == “n” ]

then

let_comp_pick=”y”

echo “Would you like the computer to randomly pick some activities for the day? (y or n)”

read let_comp_pick

if [ $let_comp_pick == “y” ]

then

echo “Enter the number of events the computer should schedule:”

read num_ev

real_num_events=$(( $num_events-1 ))

choice=$(/mnt/home/random_set $num_ev 1 $real_num_events)

print_choice

else

echo “Choices?”

read choice

fi

else

echo “Choices?”

read choice

fi

# print_choice

#for i in ${choice}

#do

# echo “${event_array[$i]}”

#done

random_reassign

#print_choice

return

}

#

#

function execute_events {

count=””

i=””

for i in ${choice}

do

finished=””

eventbgn=””

description=””

echo ” ”

echo ” ”

echo “${event_array[$i]]} anticipated.”

echo “Describe your activity.”

echo “Some more options if you aren’t ready for this activity:”

echo “e to exit.”

echo “r to personally reorder items on list.”

echo “R to have the computer randomly reorder items on list.”

read description

case “$description” in

r)

echo “Time to redefine your day. The old order was:”

for j in ${choice}

do

echo “${event_array[$j]}”

done

neworder

echo ” ”

# echo “The new order is:”

# for j in ${choice}

# do

# echo “${event_array[$j]}”

# done

finished=”not”

echo “Program is continuing with a new order.”

choice=$new_choice

# break

;;

e)

echo “Ending gracefully. Bye.”

break 10

;;

R)

echo “Randomly reassigning.”

random_reassign

execute_events

break

;;

esac

echo “Please press enter when you begin to ${event_array[$i]}.”

read bgn

date

# eventbgn=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+

# expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”

eventbgn=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+

expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”

# echo $eventbgn

echo “Please press enter when you have finished to ${event_array[$i]]}.”

read finished

while [ -n “$finished” ];

do

break

done

date

eventend=”$(expr $(”date | awk ‘{print $4}”’|sed “s/:.*//”)*60+

expr $(”date | awk ‘{print $4}”’|sed “s/^..:\(..\).*/\1/”))”

echo

echo “You spent $(($((eventend))-$((eventbgn)))) minutes to $description ”

echo “thereby accomplishing your ${event_array[$i]]} activity.”

echo “Comments on success in achieving goal?”

read goalmet

echo $goalmet

count=$(expr $((count+1)))

echo -n $count “. ”

case “$i” in

0)

echo “It’s ok. We all have bad days.”

;;

1)

echo “Dog Walk done. Your dogs say: “I love you””.

;;

2)

echo “It feels good to be smarter.”

;;

3)

echo “Mother Nature embraces you! Thank you for doing your part to care for her.”

;;

4)

echo “Good job telling the computer what to do!”

;;

5)

echo “Find people that treat you well, and try to care for those who don’t.”

;;

6)

echo “Work out done. Your body says thank you for caring!”

;;

7)

echo “Clean up done. Good job!!!!!”

;;

8)

echo “You are making a positive difference in the world.”

;;

9)

echo “Building challenges your relationship with reality. Do it with excellence, pride, and attention to detail. Rest.”

;;

10)

echo “Write to remember. Write to explore. Write to be the master of your own universe.”

;;

11)

echo “Music and art can make the world beautiful.”

;;

12)

echo “There is always something new to explore.”

;;

esac

done

finished=”done”

return

}

description = “”

event_array=(“nothing” “dog work” “studying” “environmental work” “computer” “personal relationships” “exercise” “clean up” “world improvement” “building work” “writing” “music/art” “exploration”)

num_events=13

date

echo “Today is a brand new day. How would you like to start?”

echo ” ”

choice=(1 2 3 4 5 6 7 8 9 10 11 12)

neworder

execute_events

# while [ -n $finished -o $description == “r” ];

#while [ “$description” != “” ]

# do

# case “$description” in

# r)

# echo “Working on events.”

# execute_events

# ;;

# R)

#

# esac

# done

echo “Program completed. Goals for the day achieved. VERY WELL DONE.”

#

#

#

#

——————————————————————————————-

random_order.c program

#include<stdio.h>

#include<stdlib.h>

MAX_ALLOWED=10000;

/* “random_order.c” a program to take as input a list of integers and permute them using a mapping

algorithm ———– submitted by livedoggb 3/9/2012 */

main(int argc, char *argv[MAX_ALLOWED], char *envp[]){

int num, sd, a,c, counter, missing_value_index, n, junk, max, ar[MAX_ALLOWED], orig_array[MAX_ALLOWED], init_values[MAX_ALLOWED], count[MAX_ALLOWED], temp1[MAX_ALLOWED], temp2[MAX_ALLOWED], values[MAX_ALLOWED];

int randomize(int num_values, int max_value, int *count, int *init_values);

int bin_analyze(int max_value, int num, int *init_values, int *count);

int map(int *temp1, int *temp2, int n, int missing_value_index);

int permute(int *count);

/* printf(“Enter the number of random numbers you want “);

scanf(“%d”,&n);*/

n=argc-1;

/* printf(“The number of values needing randomization is: %d\n”, n);*/

/* printf(“Enter the maximum value of random number (up to %d)”, MAX_ALLOWED);

scanf(“%d”,&max);*/

max=MAX_ALLOWED;

/* printf(“Enter the values of the 5 numbers you want to randomize:\n”);*/

for (c=1; c<=n; c++) {

ar[c]=atoi(argv[c]);

/* printf(“init_values[%d]=%d”, c, ar[c]);*/

};

/* printf(“\n”);

scanf(“%d %d %d %d %d”, &ar[1], &ar[2], &ar[3], &ar[4], &ar[5]);

printf(“The 5 numbers are: %d %d %d %d %d”, ar[1], ar[2], ar[3], ar[4], ar[5]);*/

num=n;

srand(sd);

/* randomize(n, max, count, init_values); */

for (c=1; c<=num; c++) {

init_values[c]=ar[c];

};

for (c=1; c<=num; c++){

orig_array[c]=init_values[c];

};

/* bin_analyze(max, num, init_values, count);*/

/* randomize picks n numbers between 0 and max, */

a=num;

counter=1;

while (a>0){

missing_value_index=randomize(1,n, count, temp2); /*pick 1 # between 0 and n from a set of init_values*/

/* randomize picks 1 number between 0 and n, and returns

the value of that position in the array init_values*/

if (missing_value_index==0){missing_value_index++;};

/* printf(“\n %d is missing value index before map.\n”, missing_value_index);*/

map(temp1, init_values, n, missing_value_index); /*take missing_value out of set*/

values[counter]=init_values[missing_value_index];

/* printf(“picked value is values[%d]=%d \n”, counter, values[counter]);*/

counter++;

/* printf(“The rest of the numbers are:\n”);*/

/* for (c=1; c<n; c++) {

printf(“%d “,temp1[c]);

};

scanf(“%d”,&junk);*/

/* printf(“Init_values array after reassignment should be temp1: “); */

for (c=1;c<n; c++) {

init_values[c]=temp1[c];

/* printf(“%d “, init_values[c]); */

};

n–;

a–;

};

/* printf(“\n The original array was:”);

for (c=1;c <= num; c++) {

printf(“%d “, orig_array[c]);

};*/

/* bin_analyze(max, num, orig_array, count);*/

/* printf(“\n The array after randomization is:”);*/

for (c=1;c <= num;c++) {

printf(“%d “, values[c]);

};

/* bin_analyze(max, num, values, count);*/

printf(“\n”);

return 0;

};

 

int randomize(int n, int max, int *count, int *init_values)

{

int r, x, c=0, sd;

float r_real, rmax=2100598400.0*1.022400;

srand(sd);

for (c=0; c <=max; c++)

{

count[c]=0;

};

c=1;

while (c<=n)

/* for ( c = 1 ; c <= n ; c++ ) */

{

r = random();

r_real=r;

x = ((r_real / rmax)*(max+1));

init_values[c]=x;

/*count[x]++;*/

/* printf(“%d “,init_values[c]);*/

c++;

/* continue;*/

};

/* printf(“\n”);*/

return init_values[1];

};

int bin_analyze(int max, int num, int * init_values, int * count)

{

int decision=1, c, sum=0;

printf(“\n Bin analysis? Type 1 for yes, 0 for no.”);

scanf(“%d”,&decision);

if (decision == 0) { printf(“no analysis desired.”);}

else

{

for (c=0;c<=max;c++) {

count[c]=0;

};

for (c=1; c <=num; c++) {

count[init_values[c]]++;

};

sum=0;

for (c=0; c <=max; c++)

{

printf(“number of random numbers of type %d:”, c);

printf(“%d\n”, count[c]);

sum = sum + count[c];

};

printf(“total number of numbers is %d”, sum);

};

return 0;

};

int map(int *temp1, int *temp2, int n, int missing_value_index)

{

int c;

for (c=1;c<missing_value_index;c++){

temp1[c]=temp2[c];

/* printf(“c, temp1, temp2 are %d, %d, %d \n”, c, temp1[c], temp2[c]); */

};

for (c=missing_value_index;c<=n;c++){

temp1[c]=temp2[c+1];

/* printf(“c, temp1, temp2 are %d, %d, %d, \n”, c, temp1[c], temp2[c]); */

};

/*working array is now temp1*/

return 0;

};

——————————————————————————————-

random_set.c program

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

MAX_ALLOWED=10000;

/*”random_set.c a program to pick n random integers between two integers*/

/*entered as parameters submitted by livedoggb 3/03/2011 */

main(int argc, char *argv[4], char *envp[]){

/* parameters to the program are # of random integers desired, low int range inclusive, high int range inclusive */

/* command should be “random_set 5 1 12” for 5 random numbers between 1 and 12.*/

int i, num_ran, min=1, max=12, rn[MAX_ALLOWED], sd;

int random1(int min_value, int max_value);

srand(sd);

/* printf(“Enter the maximum value of random number (up to %d)”, MAX_ALLOWED);

scanf(“%d”,&max);*/

num_ran = atoi(argv[1]);

min = atoi(argv[2]);

max = atoi(argv[3]);

for (i=0; i<num_ran;i++) {

rn[i]=random1(min, max);

printf(“%d “, rn[i]);}

printf(“\n”);

return 0;

};

 

int random1(int lowint, int highint)

{

int r, x;

float r_real, rmax=2100598400.0*1.022400;

r = random();

r_real=r;

highint=highint-lowint;

x = ((r_real / rmax)*(highint+1)+lowint);

return x;

};

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s