Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: February 22, 2025, 10:58 am

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My maturity test
#4
RE: My maturity test
(January 9, 2018 at 2:08 pm)FlatAssembler Wrote: Hey, guys! I am from Croatia, and, when I finish my high school, which will be in around 6 months, I will have to go to the maturity test. I have to choose the subjects I will take with respect to the university I am planning to attend. I am planning to study informatics, so I have to take informatics at my maturity test. However, I didn't have informatics as a subject at all in my high-school. In the maturity test in informatics, there are some tasks about programming, but they have little to do with what I happen to know about programming.

Here is an example from the last-year maturity test in informatics:
25. What will the following program (in pseudocode) output if a=14 and b=17?
Code:
m := 0;
p := 0;
for i := a to b do
{
    t := i;
    s := 0;
    while t > 0 do
    {
        z := t mod 2;
        s := s + z;
        t := t div 2;
    }
    if s > m then
    {
        m := s;
        p := i;
    }

}
print (p);

Do you have any idea how to solve that task? I don't. Last year, there were around ten of such tasks (plus the tasks from Word, Excel and the binary-system-related things) and they had only 90 minutes to solve that all.

Can you please explain me how to solve that task (and similar ones) in reasonable time? Calculators aren't allowed (and, as far as I can see, wouldn't help much).

The output of this will depend on the specifics of the rules in your pseudocode. Since a=14 and b=1, the for statement will either 1. not run at all (since a>b) or run with i starting at 14 and decreasing down to b=1. My guess is that the first is intended. If so, then the whole for loop is skipped, leaving p=0, which is printed.

Otherwise, the internal while loop counts the number of initial 1s in the binary representation of i and the following if statement finds the number with the largest such sequence. The number with that sequence (between 14 and 1) is 7, so p=7, which is printed.

So, the answer depends on the grammar for your for statements.
Reply



Messages In This Thread
My maturity test - by FlatAssembler - January 9, 2018 at 2:08 pm
RE: My maturity test - by rado84 - January 9, 2018 at 8:59 pm
RE: My maturity test - by RoadRunner79 - January 9, 2018 at 9:18 pm
RE: My maturity test - by polymath257 - January 9, 2018 at 9:23 pm
RE: My maturity test - by SteelCurtain - January 9, 2018 at 10:27 pm
RE: My maturity test - by chimp3 - January 9, 2018 at 10:37 pm
RE: My maturity test - by FlatAssembler - January 10, 2018 at 12:13 am
RE: My maturity test - by SteelCurtain - January 10, 2018 at 8:43 am
RE: My maturity test - by Grandizer - January 10, 2018 at 9:19 am
RE: My maturity test - by polymath257 - January 10, 2018 at 12:43 am
RE: My maturity test - by Brian37 - January 10, 2018 at 8:59 am
RE: My maturity test - by FlatAssembler - January 10, 2018 at 9:12 am
RE: My maturity test - by polymath257 - January 10, 2018 at 10:13 am
RE: My maturity test - by I_am_not_mafia - January 10, 2018 at 10:01 am
RE: My maturity test - by SteelCurtain - January 10, 2018 at 3:05 pm

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Serious] Anyone here use ECU Test? Jehanne 2 668 September 1, 2022 at 7:20 pm
Last Post: Jehanne
  Test if a ZIP is infected FlatAssembler 21 3166 June 11, 2020 at 10:05 am
Last Post: FlatAssembler
  Google's Mobile-Friendly Test Driving Me Batty: What am I Doing Wrong? Rhondazvous 10 3253 August 14, 2015 at 12:05 pm
Last Post: Longhorn
  Broadband speed test Darwinian 3 1985 April 18, 2014 at 6:23 am
Last Post: Sejanus
  Can anyone help beta test my webcam app? Tiberius 2 1903 April 26, 2013 at 9:20 am
Last Post: panda bear
  Hypercube Beta Test Darwinian 16 6261 June 24, 2012 at 6:50 am
Last Post: Darwinian
  Reliable internet speed test? Oldandeasilyconfused 8 5613 April 17, 2012 at 11:30 am
Last Post: venmalathy



Users browsing this thread: 1 Guest(s)