Problem 1

A mathematician was going home along the creek with the speed, which was one and half times higher, than the speed of the creek flow and kept in his hands a stick and a hat. At some moment he threw a hat, confusing it with the stick, in the creek and continued to go along the creek with the same speed. After some time he noticed his mistake, threw a stick in the creek and ran back with the speed, which was two time higher, than his initial speed. After he caught up with the floating hat, he immediately procured it from the water and went along the creek with the initial speed. After \(10\) minutes he passed a stick, which was floating in the creek. How much earlier he would came home, if he did not confuse a stick with a hat?

Solution

\(u\) - the creek flow linear speed;

\(1.5u\) - the speed of the walking mathematician;

\(3u\) - the speed of the running mathematician;

\(s\) - distance which mathematician ran;

\(s_1\) - distance which mathematician walk after collecting the hat and met a stick;

\(s_2\) - distance which the stick traveled after mathematician throw a hat and passed mathematician;

\[s = s_1+s_2\]

\[3ut = 1.5u + u (t + 10)\] \[3t = 15 + t + 10\]

\[2t = 25\] \[t = 12.5\]

Total time: \[ t_{total} = t + 2t = 37.5\]

Problem 2

Does for any triangle \(ABC\) exist some point \(P\) , that all three points, symmetric to point \(P\) relatively the lines \(AB\), \(BC\) and \(AC\), located on the circle circumscribed around the triangle \(ABC\).

Solutions

  1. Any triangle has an orthocenter.

  2. The distance point which is symmetric relatevely to orthocenter through the triangle side is located on the circumscribed circle.

Problem 3

For what values of \(a\) the difference between roots of the equations \(ax^2+x-2=0\) equals \(3\)?

Solution

from sympy.solvers import solve
from sympy import Symbol
x = Symbol('x')
a = Symbol('a')
dx = Symbol('dx')

roots = solve(a * x**2 + x - 2, x)
dx = roots[0] - roots[1]
solve(dx - 3, a)
## [-1/9]

Problem 4.

A student for five years of educations passed \(31\) exams. Each next year he passed more exams than previous one. On the fifth year he passed three times more exams than in the first year. How many exams he passed during the fourth year?

Solution

library(rolog)
## Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.11)
## SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
## Please run ?- license. for legal details.
## 
## For online help and background, visit https://www.swi-prolog.org
## For built-in help, use ?- help(Topic). or ?- apropos(Word).
text1 = "
:- use_module(library(clpfd)).
solution1([A, B, C, D, E]) :-
A + B+ C + D + E #= 31, 
A #< B, B #< C, C #< D, D #< E, 
E #= 3 * A, 
A #> 0,
labeling([],[A, B, C, D, E]) .
"

txtPath <- tempfile(fileext = ".pl")
writeLines(text1, 
           con = txtPath)

consult(txtPath)
z <- (findall(call("solution1", expression(A))))
z1 <- sapply(1:length(z), function(y) unlist(z[y]))
unique(z1[4, ])
## [1] 8
clear()
unlink(txtPath)

Problem 5

The isosceles trapezoid bases are \(4 \space cm\) cm and \(8 \space cm\), and the area is \(21 \space cm^2\). Which side is intersected by the angle bisector of the angle which lies at the bigger basis - the lesser basis or the trapezoid’s leg?

Solution

library(ggplot2)  
df <- data.frame(x = c(0, 8, 6, 2, 0),
                 y = c(0, 0, 3.5, 3.5, 0),
                 lbl = LETTERS[c(1:4, 1)])

df <- data.frame(x = c(0, 8, 6, 2, 0),
                 y = c(0, 0, 3.5, 3.5, 0),
                 lbl = LETTERS[c(1:4, 1)])

df2 <- data.frame(x = c(2, 2), y = c(3.5, 0), lbl = c('D', 'H1'))
df3 <- data.frame(x = c(6, 6), y = c(3.5, 0), lbl = c('C', 'H2'))

gg <- ggplot(df, aes(x, y, label = lbl)) +
  geom_path() +
  geom_label() +
  geom_path(data = df2, aes(x, y)) +
  geom_label(data = df2, aes(x, y, label = lbl)) +
  geom_path(data = df3, aes(x, y)) +
  geom_label(data = df3, aes(x, y, label = lbl))
print(gg)

S <- 21
AB <- 4
CD <- 8
AH1 <- 2*S / (AB + CD)
CH1 <- (CD - AB) / 2
H1H2 <- AB
CH2 <- CH1 + H1H2
BH2 <- AH1
ACH1 <- atan(AH1/CH1) / pi * 180
bisection <- ACH1 / 2
BCH2 <- atan(BH2/CH2) / pi * 180
bisection
## [1] 30.12756
BCH2
## [1] 30.25644
ifelse(bisection < BCH2, "cross side", "cross top")
## [1] "cross side"

Problem 6

All digits of some four digit number, being the full square, can be reduced to the same digit number in such a way, that the resulting four digit number is four digit as well. Find all such numbers.

Solution

for(i in 1:99){
  for(j in 1:99) { 
    for(k in 1:9) {
      if(i * i - 1111 * k == j * j & log10(i * i) > 3 & log10(j *j) > 3) {
        cat(i, j, k, "\n")
      }
    }
  }
}
## 56 45 1 
## 67 34 3

Problem 7

A point is located inside a convex quadrilateral. Can the sum of distances from the point to all of the vertices be greater than the perimeter?

Solution

  library(geometry)
  set.seed(123)
  
  a <- 1
  b <- 0
  four_in <- function() {
    n <- 3
    while(n < 4) {
      ps <-matrix(rnorm(6), , 2)
      ch <- convhulln(ps, options="FA")
      x <- matrix(rnorm(2), ncol = 2)
      while(inhulln(ch, x) == TRUE) {
        x <- matrix(rnorm(2), ncol = 2)
      }
      ps <- rbind(ps, x)
      ch <- convhulln(ps, options="FA")
      
      x <- matrix(rnorm(2), ncol = 2)
      while(inhulln(ch, x) == FALSE) {
        x <- matrix(rnorm(2), ncol = 2)
      }
      ps <- rbind(ps, x)
      ch <- convhulln(ps, options="FA")
      n <- nrow(ch$hull)
    }
    ch
  }
  
  
  while (a > b) {
    ch <- four_in()
    xx <- as.data.frame(ch$p)
    xx$text <- 1:5
    z <- as.matrix(dist(ch$p))
    (a <- sum(z[ch$hull]))
    (b <- sum(z[5, ]))
    plot(ch) 
    break
    text(xx$V1, xx$V2, xx$text)
  }

Answer: yes, it’s possible see above.

Problem 8

One of three thieves, known in City C called Archie, Boss and Wesley, stole the suitcase with money. During the interrogation each of them made three statements.

Archie:

  1. I did not take a suitcase;
  2. At the day of the theft I left City C.
  3. Wesley stole a suitcase.

Boss:

  1. Wesley stole the suitcase.
  2. If I took it I would not confess.
  3. I have enough money.

Wesley:

  1. I did not take the suitcase.
  2. I have been looking for a good suitcase for a long time.
  3. Archie is right saying he left City C.

During investigation it was understood that three of two statements by each gangsters is true and one if false. Who stole the suitcase.

Solution

library(rolog)
text1 = "
:- use_module(library(clpb)).

solution1([A, B, W]) :- 
sat(card([2],[A =:= ~A, T, A =:= W])),
sat(card([2], [B =:= W, X1, X2])),
sat(card([2], [W =:= ~W, X3, T])),
sat(card([1], [A, B, W])).
"

txtPath <- tempfile(fileext = ".pl")
writeLines(text1, 
           con = txtPath)

consult(txtPath)
query(call("solution1", expression(A)))
## [1] TRUE
## attr(,"query")
## [1] "solution1(A)"
submit()
## $A
## $A[[1]]
## [1] 0
## 
## $A[[2]]
## [1] 1
## 
## $A[[3]]
## [1] 0
clear()
unlink(txtPath)

Problem 9

Find integers \(x\) and \(y\), such that \[x>y>0 \land x^3+7y=y^3+7x\]

Solution

\[x^3+7y = y^3 +7x \implies x^3-y^3=7(x-y) \implies (x-y)(x^2+xy+y^2) = 7(x-y) = 0 \implies x=y \land x^2+xy+y^2=7 \]

but \(x>y\) in accordance to the conditions to the problem than \(x=y\) is excluded. then you need to solve only \(x^2+xy+y^2=7\)

from sympy import *
x, y = symbols('x y')

factor(x**3-y**3)
## (x - y)*(x**2 + x*y + y**2)
r = diophantine((x**2 + x*y + y**2) - 7)
#plot_implicit((x**2 + x*y + y**2) - 7)
p = list(r)

[i for i in p if i[0] > 0 and i[1] > 0 and i[0] > i[1]]
## [(2, 1)]

Problem 10

Square area size \(100\space m\times100\space m\) paved with squares \(1\space m\times 1\space m\) in four colours: white, red, black and grey - so, that no two square of the same colour touch each other (i.e. they have no common side or vertex). How many red squares are there?

Solution

n <- 10
k <- 1:(n-1)
z <- apply(expand.grid(k, k), 1, function(x){
    i <- x[1]
    j <- x[2]
    s1 <- paste0("maplist(#\\=(X", i, j,"),[X", i, j +1, 
           ",X", i + 1, j, ",X", i + 1, j + 1, "]),")
    
    s2 <- paste0("maplist(#\\=(X", i, j + 1,"),[X", i, j, 
           ",X", i + 1, j, ",X", i + 1, j + 1, "]),")
    
    s3 <- paste0("maplist(#\\=(X", i + 1, j + 1,"),[X", i, j, 
           ",X", i + 1, j, ",X", i, j + 1, "]),")
    
    s4 <- paste0("maplist(#\\=(X", i + 1, j ,"),[X", i, j, 
                 ",X", i + 1, j + 1, ",X", i, j + 1, "]),\n")
    
    paste0(s1, s2, s3, s4)
  }
)

df <- data.frame(expand.grid(1:n, 1:n))
df$Var3 <- paste0("X", df$Var1, df$Var2)
x <- paste0(df$Var3, collapse = ",")


a <- ":- use_module(library(clpfd)).
regions(Rs):-
  Rs = ["

b <- "], Rs ins 0..3,"

c <- "label(Rs)."

library(rolog)
text1 = paste0(c(a, x, b, z, c))
#cat(text1)

txtPath <- tempfile(fileext = ".pl")
writeLines(text1, 
           con = txtPath)

consult(txtPath)
(query(call("regions", expression(A))))
## [1] TRUE
## attr(,"query")
## [1] "regions(A)"
res <- unlist(submit())
matrix(res, nrow = n, byrow = TRUE)
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
##  [1,]    0    1    0    1    0    1    0    1    0     1
##  [2,]    2    3    2    3    2    3    2    3    2     3
##  [3,]    0    1    0    1    0    1    0    1    0     1
##  [4,]    2    3    2    3    2    3    2    3    2     3
##  [5,]    0    1    0    1    0    1    0    1    0     1
##  [6,]    2    3    2    3    2    3    2    3    2     3
##  [7,]    0    1    0    1    0    1    0    1    0     1
##  [8,]    2    3    2    3    2    3    2    3    2     3
##  [9,]    0    1    0    1    0    1    0    1    0     1
## [10,]    2    3    2    3    2    3    2    3    2     3
table(res)
## res
##  0  1  2  3 
## 25 25 25 25
clear()
unlink(txtPath)

So it is seen that combination (0/2, 1/3) is paving all the area without intersection then the formula is \(n^2 / 4\) or for \(100\times100\) it is \(2500\).

Problem 11

Solve the equation: \[(x^2 + 6x - 4)(x^2+6x-3)=12 \]

Solution

from sympy.solvers import solve
from sympy import Symbol
x = Symbol('x')
solve((x**2 + 6 * x - 4) * (x**2 + 6 * x - 3) - 12, x)
## [-7, -6, 0, 1]

Problem 12

There is Triangle \(ABC\). Find points \(K\) and \(H\), respectively on the sides \(AB\) and \(BC\), such as: \[BK=KH=HC\].

Solutions

Triangle ABC Answer: H and K lays at the center of two equal circles which are located at radius between each other.

Problem 13

Find all primes \(p\), which satisfy \(p^2+13\) else prime.

Solution

Only \(2\), as all other prime are odd and sum of two odds is even, i.e. non-prime.

Answer: \(2\).