Inscription / Connexion Nouveau Sujet
Niveau 2 *
Partager :

Joute n°184 : Pi Day +14

Posté par
godefroy_lehardi Posteur d'énigmes
28-03-15 à 09:26

Bonjour à tous,

J'ai découvert avec effroi que j'avais raté le Pi Day .
Pour les autres étourdis comme moi, c'était le 14 mars à 9h26 (mais les opinions divergent sur l'heure exacte Bon anniversaire de Pi).
Pour me rattraper, voici une petite joute utilisant les décimales de , que m'a proposée littleguy (merci à lui ).

Les quarante-cinq premières décimales de sont :
141592653589793238462643383279502884197169399

Si on les regroupe par trois, on obtient les quinze nombres suivants :
141-592-653-589-793-238-462-643-383-279-502-884-197-169-399

Parmi ceux-ci, quatre seulement sont premiers : 653, 643, 383 et 197.

Question : Comment ranger toutes ces décimales de sorte qu'en les regroupant par trois, on obtienne quinze nombres premiers tous distincts (ne commençant pas par 0), et que ce nouvel ordre donne un nombre de 45 chiffres le plus petit possible ?

Joute n°184 : Pi Day +14

Posté par
dpi
re : Joute n°184 : Pi Day +14 28-03-15 à 15:05

perduBonjour

c'est déjà dur d'en trouver 15...

Je donne:
101 113 223 227 233 389 449 463 569 599 647 659 859 887 983

Posté par
Nofutur2
re : Joute n°184 : Pi Day +14 28-03-15 à 17:11

gagnéEt tant , je réponds quand même ....
101-113-223-227-233-347-449-499-569-599-659-683-859-863-887
Merci pour l'énigme !!
  
  
  
  
  
  
  
  
  
  
  

  
  

Posté par
castoriginal
re : Joute n°184 : Pi Day +14 29-03-15 à 01:58

perduBonjour,

voici une solution

101 113 223 227 233 349 467 487 499 569 599 659 683 859 883

amitiés

Posté par
manitoba
re : Joute n°184 : Pi Day +14 29-03-15 à 12:07

perduBonjour Godefroy,

Pour le minimum:
101-113-223-227-233-347-389-449-499-569-659-683-859-887-233-

Pour le maximum (non demandé)
997-991-983-977-883-881-661-659-653-541-523-443-409-223-883-

Merci pour la joute

Posté par
rschoon
re : Joute n°184 : Pi Day +14 29-03-15 à 15:26

gagnéBonjour à tous.

Je propose la suite :
101, 113, 223, 227, 233, 347, 449, 499, 569, 599, 659, 683, 859, 863, 887.

Merci pour l'énigme.

Posté par
dpi
re : Joute n°184 : Pi Day +14 30-03-15 à 10:43

perduRE
Vu le nombre de réponses,et pour l'honneur
Je donne le plus petit:
101 113 223 227 233 389 449 463 569 599 647 659 859 887 983

Posté par
dpi
re : Joute n°184 : Pi Day +14 30-03-15 à 10:54

perduPARDON  

j'ai redonné le même (plusieurs clones)
il faut prendre 349 en 6ème position au lieu de 389

101 113 223 227 233 349 449 499 569 659 683 853 859 887 967

Posté par
manitoba
re : Joute n°184 : Pi Day +14 30-03-15 à 20:48

perduMerci pour le poisson Godefroy,
Et zut!
Un erreur idiote d'affichage le dernier nombre est fautif!
101-113-223-227-233-347-389-449-499-569-659-683-859-887-569- pour le minimum

Posté par
masab
re : Joute n°184 : Pi Day +14 31-03-15 à 10:01

gagnéBonjour godefroy,

On range les décimales comme suit :

101113223227233347449499569599659683859863887

La suite des nombres premiers obtenus est alors

[101, 113, 223, 227, 233, 347, 449, 499, 569, 599, 659, 683, 859, 863, 887]

Merci pour cette énigme difficile !

Posté par
torio
re : Joute n°184 : Pi Day +14 08-04-15 à 08:50

perdu101  113  223  227  233  449  463  499  563  569  599  769  859  883  887

Posté par
blumaise
re : Joute n°184 : Pi Day +14 10-04-15 à 15:38

gagnéJe tente :

101
113
223
227
233
347
449
499
569
599
659
683
859
863
887

Posté par
godefroy_lehardi Posteur d'énigmes
re : Joute n°184 : Pi Day +14 20-04-15 à 14:42

Clôture de l'énigme :

Pas beaucoup de réponses cette fois-ci.
Il faut dire qu'elle est moins facile qu'elle n'en avait l'air.

Merci encore à littleguy !

Posté par
godefroy_lehardi Posteur d'énigmes
re : Joute n°184 : Pi Day +14 20-04-15 à 14:45

Félicitations à Nofutur2 pour sa première victoire (de l'année).

Bravo également à masab et blumaise !

Posté par
manitoba
re : Joute n°184 : Pi Day +14 22-04-15 à 22:49

perduBravo à Nofutur2.
La solution pour le max est
997-991-983-977-883-881-661-659-643-541-523-503-443-229-223-
J'ai corrigé mes erreurs de programmation.


CONST PI = "141592653589793238462643383279502884197169399"
CONST NB_PRI = 143
CONST NB_NIV = 15
CONST Faux = (0 = 1)
CONST Vrai = NOT (Faux)



DATA 101,103,107,109,113,127,131,137,139,149
DATA 151,157,163,167,173,179,181,191,193,197
DATA 199,211,223,227,229,233,239,241,251,257
DATA 263,269,271,277,281,283,293,307,311,313
DATA 317,331,337,347,349,353,359,367,373,379
DATA 383,389,397,401,409,419,421,431,433,439
DATA 443,449,457,461,463,467,479,487,491,499
DATA 503,509,521,523,541,547,557,563,569,571
DATA 577,587,593,599,601,607,613,617,619,631
DATA 641,643,647,653,659,661,673,677,683,691
DATA 701,709,719,727,733,739,743,751,757,761
DATA 769,773,787,797,809,811,821,823,827,829
DATA 839,853,857,859,863,877,881,883,887,907
DATA 911,919,929,937,941,947,953,967,971,977
DATA 983,991,997
' compter les repetitions des chiffres de pi.

TYPE stPrime
    n AS STRING * 3
    r AS STRING * 10
END TYPE


DIM SHARED ch(9) AS INTEGER, prime(NB_PRI) AS stPrime, Lim AS STRING * 10, way AS STRING * 10, nbSol AS LONG
CALL Init_0
CALL Traiter
END


FUNCTION MayAdd% (p AS INTEGER)
SHARED Lim AS STRING * 10, way AS STRING * 10, prime() AS stPrime
DIM rep AS INTEGER, x AS INTEGER, y AS INTEGER, z AS INTEGER, t AS INTEGER, w AS STRING * 10
DIM a AS STRING * 3
CALL Pause

a = prime(p).n
w = way
rep = Vrai
FOR i = 1 TO 3
    t = ASC(MID$(a, i, 1)) - 48
    x = 1 + ASC(MID$(w, t + 1, 1)) - 48
    y = ASC(MID$(Lim, t + 1, 1)) - 48
    IF x > y THEN
        rep = Faux
        EXIT FOR
    ELSE
        MID$(w, t + 1, 1) = CHR$(x + 48)
    END IF
NEXT i
IF rep THEN
    way = w
END IF

MayAdd% = rep
END FUNCTION

SUB See (n1 AS INTEGER, n2 AS INTEGER, n3 AS INTEGER, n4 AS INTEGER, n5 AS INTEGER, n6 AS INTEGER, n7 AS INTEGER, n8 AS INTEGER, n9 AS INTEGER, n10 AS INTEGER, n11 AS INTEGER, n12 AS INTEGER, n13 AS INTEGER, n14 AS INTEGER, n15 AS INTEGER)
SHARED Lim AS STRING * 10, way AS STRING * 10, prime() AS stPrime, nbSol AS LONG
DIM rep AS STRING
rep = STR$(nbSol) + ":"
rep = rep + prime(n1).n + "-"
rep = rep + prime(n2).n + "-"
rep = rep + prime(n3).n + "-"
rep = rep + prime(n4).n + "-"
rep = rep + prime(n5).n + "-"
rep = rep + prime(n6).n + "-"
rep = rep + prime(n7).n + "-"
rep = rep + prime(n8).n + "-"
rep = rep + prime(n9).n + "-"
rep = rep + prime(n10).n + "-"
rep = rep + prime(n11).n + "-"
rep = rep + prime(n12).n + "-"
rep = rep + prime(n13).n + "-"
rep = rep + prime(n14).n + "-"
rep = rep + prime(n15).n + "-"
LOCATE 20, 1: PRINT rep
PRINT #1, rep
PRINT way
PRINT Lim
END SUB



SUB Traiter
SHARED way AS STRING * 10, nbSol AS LONG
DIM i1 AS INTEGER, i2 AS INTEGER, i3 AS INTEGER
DIM i4 AS INTEGER, i5 AS INTEGER, i6 AS INTEGER
DIM i7 AS INTEGER, i8 AS INTEGER, i9 AS INTEGER
DIM i10 AS INTEGER, i11 AS INTEGER, i12 AS INTEGER
DIM i13 AS INTEGER, i14 AS INTEGER, i15 AS INTEGER
DIM Push_way(NB_NIV) AS STRING * 10
OPEN "C:\_ile\184.sol" FOR OUTPUT AS #1
nbSol = 0
way = STRING$(10, "0")

FOR i1 = 1 TO NB_PRI - 14
    LOCATE 1, 1: PRINT USING "### \ \ "; i1; prime(i1).n
    Push_way(1) = way
    IF MayAdd%(i1) THEN
        FOR i2 = i1 + 1 TO NB_PRI - 13
            LOCATE 2, 1: PRINT USING "### \ \"; i2; prime(i2).n
            Push_way(2) = way
            IF MayAdd%(i2) THEN
                FOR i3 = i2 + 1 TO NB_PRI - 12
                    LOCATE 3, 1: PRINT USING "### \ \"; i3; prime(i3).n
                    Push_way(3) = way
                    IF MayAdd%(i3) THEN
                        FOR i4 = i3 + 1 TO NB_PRI - 11
                            LOCATE 4, 1: PRINT USING "### \ \"; i4; prime(i4).n
                            Push_way(4) = way
                            IF MayAdd%(i4) THEN
                                FOR i5 = i4 + 1 TO NB_PRI - 10
                                    LOCATE 5, 1: PRINT USING "### \ \"; i5; prime(i5).n
                                    Push_way(5) = way
                                    IF MayAdd%(i5) THEN
                                        FOR i6 = i5 + 1 TO NB_PRI - 9
                                            LOCATE 6, 1: PRINT USING "### \ \"; i6; prime(i6).n
                                            Push_way(6) = way
                                            IF MayAdd%(i6) THEN
                                                FOR i7 = i6 + 1 TO NB_PRI - 8
                                                    LOCATE 7, 1: PRINT USING "### \ \"; i7; prime(i7).n
                                                    Push_way(7) = way
                                                    IF MayAdd%(i7) THEN
                                                        FOR i8 = i7 + 1 TO NB_PRI - 7
                                                            LOCATE 8, 1: PRINT USING "### \ \"; i8; prime(i8).n
                                                            Push_way(8) = way
                                                            IF MayAdd%(i8) THEN
                                                                FOR i9 = i8 + 1 TO NB_PRI - 6
                                                                    LOCATE 9, 1: PRINT USING "### \ \"; i9; prime(i9).n
                                                                    Push_way(9) = way
                                                                    IF MayAdd%(i9) THEN
                                                                        FOR i10 = i9 + 1 TO NB_PRI - 5
                                                                            LOCATE 10, 1: PRINT USING "### \ \ "; i10; prime(i10).n
                                                                            Push_way(10) = way
                                                                            IF MayAdd%(i10) THEN
                                                                                FOR i11 = i10 + 1 TO NB_PRI - 4
                                                                                    Push_way(11) = way
                                                                                    IF MayAdd%(i11) THEN
                                                                                        FOR i12 = i11 + 1 TO NB_PRI - 3
                                                                                            Push_way(12) = way
                                                                                            IF MayAdd%(i12) THEN
                                                                                                FOR i13 = i12 + 1 TO NB_PRI - 2
                                                                                                    Push_way(13) = way
                                                                                                    IF MayAdd%(i13) THEN
                                                                                                        FOR i14 = i13 + 1 TO NB_PRI - 1
                                                                                                            Push_way(14) = way
                                                                                                            IF MayAdd%(i14) THEN
                                                                                                                FOR i15 = i14 + 1 TO NB_PRI
                                                                                                                    Push_way(15) = way
                                                                                                                    IF MayAdd%(i15) THEN
                                                                                                                        nbSol = nbSol + 1
                                                                                                                        PRINT nbSol; ":"
                                                                                                                        CALL See(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15)
                                                                                                                        END
                                                                                                                    END IF 'IF MayAdd%(i15) THEN
                                                                                                                    way = Push_way(15)
                                                                                                                NEXT i15
                                                                                                                way = Push_way(14)
                                                                                                            END IF 'IF MayAdd%(i14) THEN
                                                                                                        NEXT i14
                                                                                                        way = Push_way(13)
                                                                                                    END IF 'IF MayAdd%(i13) THEN
                                                                                                NEXT i13
                                                                                                way = Push_way(12)
                                                                                            END IF 'IF MayAdd%(i12) THEN
                                                                                        NEXT i12
                                                                                        way = Push_way(11)
                                                                                    END IF 'IF MayAdd%(i11) THEN
                                                                                NEXT i11
                                                                                way = Push_way(10)
                                                                            END IF 'IF MayAdd%(i10) THEN
                                                                        NEXT i10
                                                                        way = Push_way(9)
                                                                    END IF 'IF MayAdd%(i9) THEN
                                                                NEXT i9
                                                                way = Push_way(8)
                                                            END IF 'IF MayAdd%(i8) THEN
                                                        NEXT i8
                                                        way = Push_way(7)
                                                    END IF 'IF MayAdd%(i7) THEN
                                                NEXT i7
                                                way = Push_way(6)
                                            END IF 'IF MayAdd%(i6) THEN
                                        NEXT i6
                                        way = Push_way(5)
                                    END IF 'IF MayAdd%(i5) THEN
                                NEXT i5
                                way = Push_way(4)
                            END IF 'IF MayAdd%(i4) THEN
                        NEXT i4
                        way = Push_way(3)
                    END IF '                    IF MayAdd%(i3) THEN
                NEXT i3
                way = Push_way(2)
            END IF '            IF MayAdd%(i2) THEN
        NEXT i2
        way = Push_way(1)
    END IF '    IF MayAdd%(prime(i1).n) THEN
NEXT i1
CLOSE #1
END SUB

SUB Init_0
SHARED ch() AS INTEGER, prime() AS stPrime, Lim AS STRING * 10
DIM i AS INTEGER, j AS INTEGER, k AS INTEGER, a AS STRING * 3, b AS STRING * 10, x AS INTEGER
CALL Init
FOR i = 0 TO 9: ch(i) = 0: NEXT i
FOR i = 1 TO LEN(PI): x = VAL(MID$(PI, i, 1)): ch(x) = ch(x) + 1: NEXT i
Lim = STRING$(10, "0"): FOR i = 0 TO 9: MID$(Lim, i + 1, 1) = CHR$(48 + ch(i)): NEXT i
FOR i = 0 TO 9: PRINT i; " "; ch(i): NEXT i: PRINT Lim
RESTORE
FOR i = 1 TO NB_PRI
    READ a
    'j = i:
    j = NB_PRI + 1 - i

    prime(j).n = a
    prime(j).r = STRING$(10, "0")
    FOR k = 1 TO 3
        'ex 479
        'position 4+1  =5
        '0000000000
        '0000*00000
        ' 0+1=1
        '0000100000
        x = ASC(MID$(a, k, 1)) - 48
        y = ASC(MID$(prime(j).r, x + 1, 1)) - 48 + 1
        MID$(prime(j).r, x + 1, 1) = CHR$(y + 48)
    NEXT k
    'PRINT i; " "; prime(i).n; " "; prime(i).r
NEXT i
END SUB


SUB Init
SCREEN 0: WIDTH 150, 45: _FONT 16
CLS
END SUB

FUNCTION Maxy (p1, p2)
IF p1 > p2 THEN
    Maxy = p1
ELSE
    Maxy = p2
END IF
END FUNCTION

FUNCTION Miny (p1, p2)
IF p1 < p2 THEN
    Miny = p1
ELSE
    Miny = p2
END IF
END FUNCTION



SUB Pause
y$ = INKEY$
IF LEN(y$) > 0 THEN
    END
END IF
END SUB

FUNCTION NoSpace$ (p AS STRING)
NoSpace$ = LTRIM$(RTRIM$(p))
END FUNCTION


FUNCTION Net$ (p AS LONG, p1 AS LONG)
Net$ = RIGHT$(SPACE$(p1) + STR$(p), p1)
END FUNCTION

FUNCTION ToStr$ (p AS LONG)
ToStr$ = LTRIM$(STR$(p))
END FUNCTION

FUNCTION inArray% (p1 AS LONG, p2() AS LONG)
DIM i AS LONG, ret AS INTEGER
ret = Faux
FOR i = 1 TO p2(0)
    IF p2(i) = p1 THEN
        ret = Vrai
        EXIT FOR
    END IF
NEXT i
inArray% = ret
END FUNCTION


FUNCTION Pgcd& (p1 AS LONG, p2 AS LONG)
DIM a AS LONG, b AS LONG, q AS LONG, r AS LONG
a = Maxy(p1, p2)
b = Miny(p1, p2)
r = a MOD b
DO WHILE NOT (r = 0)
    a = b
    b = r
    r = a MOD b
LOOP
Pgcd& = b
END FUNCTION

Posté par
rschoon
re : Joute n°184 : Pi Day +14 23-04-15 à 12:07

gagnéIl me semble avoir donné la même réponse que Nofutur2. Pourquoi ce vilain poisson ?

Posté par
godefroy_lehardi Posteur d'énigmes
re : Joute n°184 : Pi Day +14 23-04-15 à 13:00

Oups ! Désolé.
C'est corrigé.

Challenge (énigme mathématique) terminé .
Nombre de participations : 0
:)0,00 %0,00 %:(
0 0

Temps de réponse moyen : 91:58:04.
Répondre à ce sujet

Seuls les membres peuvent poster sur le forum !

Vous devez être connecté pour poster :

Connexion / Inscription Poster un nouveau sujet
Une question ?
Besoin d'aide ?
(Gratuit)
Un modérateur est susceptible de supprimer toute contribution qui ne serait pas en relation avec le thème de discussion abordé, la ligne éditoriale du site, ou qui serait contraire à la loi.


Vous devez être membre accéder à ce service...

Pas encore inscrit ?

1 compte par personne, multi-compte interdit !

Ou identifiez-vous :


Rester sur la page

Désolé, votre version d'Internet Explorer est plus que périmée ! Merci de le mettre à jour ou de télécharger Firefox ou Google Chrome pour utiliser le site. Votre ordinateur vous remerciera !