Reading in string and printing in reverse order MIPS architecture

.data string1: .space 5 str2: .asciiz “\n The output string is: ” string2: .space 5 str1: .asciiz “\n Enter the string: ” .text li $ v0, 4 la $ a0, str1 syscall

li $ v0, 8 #read in string li $ a1, 5 #the size is 4 la $ a0, string1 syscall #lw $ t7, 0($ a0) lb $ t0, 0($ a0) #1st letter lb $ t1, 1($ a0) #2nd letter lb $ t2, 2($ a0) #3rd letter lb $ t3, 3($ a0) #4th letter

addi $ sp, $ sp, -4 #allocate 4 bytes for the string sb $ t0, 0($ sp) #4th letter sb $ t1, 1($ sp) #3rd letter sb $ t2, 2($ sp) #2nd letter sb $ t3, 3($ sp) #1st letter

lb $ s0, 3($ sp) #4th letter lb $ s1, 2($ sp) #3rd letter lb $ s2, 1($ sp) #2nd letter lb $ s3, 0($ sp) #1st letter addi $ sp, $ sp, 4

sll $ s4, $ s0, 8 add $ s4, $ s4, $ s1 sll $ s4, $ s4, 8 add $ s4, $ s4, $ s2 sll $ s4, $ s4, 8 add $ s4, $ s4, $ s3

la $ t0, string2 #lw $ s4, 0($ t0)

li $ v0, 4 la $ a0, str2 syscall

li $ v0, 4 #la $ a0, string2 #prints what’s in string2 move $ a0, $ s0
syscall

li $ v0, 10 syscall

It’s giving me an error that the address is out of range. How do I print what’s in $ s4?

Is checking if the length of a C program that can generate a string is less than a given number decidable?

I was given this question:

Komplexity(S) is the length of the smallest C program that generates the string S as an output. Is the question “Komplexity(S) < K” decidable?

With respect to decidability, I only know about the Halting Problem and just learned about Rice’s Theorem while searching online (though I don’t think it can be applied here?). I couldn’t reduce the problem to any undecidable problem I know about. Thanks in advance for any help

What’s the correct algorithm to filter accumulating string concatenations?

I have a function that is receiving messages with the following pattern:

Example of accumulating strings

(In this picture, “string” and “message” are synonymous.)

I’m only interested in the largest messages, such as these:

Largest filtered accumulated strings

over a particular window.

Is there an algorithm that can appropriately filter the messages in the desired manner over a specified window?

Phone Number inputs from 1 string to 3 inputs. Help!

My team is needing to change a phone number object within a form to 3 input fields instead of one string. This is turning out to potentially be slightly challenging for our team on the technical side so I thought I’d reach out to see if anyone has encountered this before or used a phone number widget in lieu of 3 separate inputs to handle country code, area code, and number? It’s clearly not a new problem but it is for my team 🙂

Counting the number of vowels and consonants in a string

I am creating a program that can count the number of vowels and consonants in a string. So far it has only been returning the number of characters in the string as a whole. Could you please tell me what I am doing wrong? Thank you

import java.util.Scanner; 

public class LanguageDriver { //your solution must include the practical use of these objects private CharacterCounter cc = new CharacterCounter(“Default phrase.”); private AlphaOnly trans = new AlphaOnly(“Default phrase.”);

private Scanner scan = new Scanner(System.in);  //this String might be helpful private String vowelStr = "AEIOUaeiou";   //surveys the user for information //controls execution public void userInput() {    System.out.println("Enter a sentence.");    String phrase = scan.nextLine();    cc.setWord(phrase);    trans.setWord(phrase);    int consonants = 0;    int vowels = 0;     for(int i = 0; i < phrase.length(); i++)    {    //checks if the letter at "i" is a vowel        if (phrase.substring(i, i+1) == "a" || phrase.substring(i,i+1) == "e" || phrase.substring(i,i+1) == "i" || phrase.substring(i,i+1) == "o" || phrase.substring(i,i+1) == "u")        {            vowels++;         }         else            {             consonants++;           }      }         System.out.println("There are " + consonants + " consonants " + " and " + vowels + " vowels." ); } 

}

Array to string conversion on array_map

I’m using array_map to sort out an array with all of my _octopud_id’s.

var_dump($ offices): Returns the following:

array (size=500)   0 =>      array (size=1)       'id' => string '1382' (length=4)   1 =>      array (size=1)       'id' => string '1330' (length=4) 

I need to input that array integer into the ’employees/’ section but I can’t figure out how – If I hardcode employees/6 I get the following result:

object(stdClass)[14592]   public 'id' => int 6 

What could I be doing wrong? I keep getting the Notice: Array to string conversion error on the $ results = line.

/* Return an array of _octopus_ids */ $  offices = array_map(     function($  post) {         return array(             'id' => get_post_meta($  post->ID, '_octopus_id', true),         );     },     $  query->posts );  var_dump($  offices);  $  results = $  octopus->get_all('employee/' . implode($  offices)); var_dump($  results);