Can I draw a pascal triangle with for loop?

Can I also write the pascal triangle i got with the

Column[Table[Binomial[n, k], {n, 0, 8}, {k, 0, n}], Center]

enter image description here

using for loop and the if command?

can you help me create the code?

thanks

pascal – max() without arithmetics or so

so i have a plan to make something to solve this stuff: you have 7 chips that are on the run. each has some cargo loaded. And also there’s where record on each.Latter could be either track means running(or gone offroad) or tobeauty means it reaches its finish. Where .cargo = -1 means it’s gone . And finally i need one of three : all is gone, at least one is on finish and others either are on finish or gone , and show is in progress so neither of these two. Only first two will be checked so thrd will be just anything else. I’ve done it like this finally

uses crt;

type 
    trail_type = (blue ,desert ,white ,green ,violet ,wood ,coldgreen) ;
    palmtree = (none ,apple ,appricot ,grape ,pineapple ,lemon);
    catchinon  = (track, tobeauty);
type
    ontherun = Record
    trail : trail_type;
    cargo : Currency;
    miles : Integer;
    where : catchinon;
end;

Var 
    rec_b : array(1..7) of ontherun;
    fruit : palmtree;
    k  : Integer;

Function Ternary(x : Boolean ; b : palmtree ; c  : palmtree ) : palmtree;
begin
    if x then
        Ternary := b
    else
        Ternary := c;
end;
begin
    {testing part}

{       rec_b(4).cargo := -1;
        rec_b(5).where := tobeauty;
        rec_b(7).where := tobeauty;
        rec_b(1).cargo := -1;
        rec_b(3).where := tobeauty;
        fruit := none;}

    {for k := 1 to 7 do
                        rec_b(k).where := tobeauty;}
    for k := 1 to 7 do
        rec_b(k).cargo := -1;
    rec_b(7).where := tobeauty;
    rec_b(7).cargo := 20;

    {testing part ended}

    fruit := none;

    for k := 1 to 7 do
    begin
        fruit := Ternary((rec_b(k).where = tobeauty) and ( fruit in (none , pineapple)), appricot , fruit );
        fruit := Ternary((rec_b(k).cargo = -1) and ( not (fruit in  (grape))), lemon ,  fruit); 
        fruit := Ternary((rec_b(k).where = track) and ( fruit in ( none , appricot , apple , pineapple)), grape , fruit);
        fruit := Ternary((rec_b(k).cargo = -1) and ( fruit  in  (lemon )), pineapple ,  fruit); 
        fruit := Ternary((rec_b(k).where = tobeauty) and ( fruit in (pineapple, appricot)), apple , fruit );
    end;
    Writeln(fruit); 
end.

Is there some tricks on that do you know?

python – Pascal Triangle type Problem – Find number in top layer by adding each pair of adjacent numbers in the lower layer

omg I don’t even know how to start on this ūüôĀ I’m supposed to create a function. The question is as follows:

A pyramid of size n is formed with a base consisting of n numbers, given as a list

Next layer contains (n-1) numbers, and following contains (n-2) numbers, etc. Each number is obtained from adding each pair of adjacent numbers in the lower layer and process is repeated until top layer has 1 number.

Problem: Create a function that takes in a list of numbers in the bottom layer and returns the top layer

E.g.

8

5 3

3 2 1

test cases:

pyramid((1, 2))

3

pyramid((3, 2, 1))

8

pyramid((2, 0, 2, 1))

9

Any help would be appreciated!

matem√°tica – Como ocultar decimais em pascal?

Estou fazendo um conversor de moeda e estou tendo problemas com os decimais, por ex: “$1.0 √© igual a R$ 0.18248175182481752”

Gostaria de saber como ocultar os decimais a partir da segunda casa.

O código é o seguinte:

uses crt, Graph;
var valorA, valorB, op:Real;

Procedure dolarToReal;
begin

ClrScr;
WriteLn('Digite o valor em dólares: ');
ReadLn(valorA);

valorB := (valorA * 5.48 );
ClrScr;

WriteLn('R$ ', valorA, ' é igual à $ ', valorB);
readln();


end;


Procedure realToDolar;
begin

ClrScr;
WriteLn('Digite o valor em reais: ');
ReadLn(valorA);

valorB := (valorA / 5.48 );
ClrScr;

WriteLn('$', valorA, ' é igual a R$ ', valorB);
readln();

end;


Procedure menu;
begin


WriteLn('1 - Real > Dólar');
WriteLn('2 - Dólar > Real');
ReadLn(op);

if op = 1 
 then
  begin 
  
  realToDolar
  
  end;
if op = 2 
 then
  begin
  
  dolarToReal
  
  end;



end;

begin
  
  textColor(Black);
  textBackground(White);
  ClrScr;

  menu
  
 
end.

pascal – Simular pressionamento de tecla – Delphi

Ol√°,
estou com problemas em enviar o pressionamento de tecla em um jogo,

estou usando o delphi, testei fun√ß√Ķes como:

  SendMessage(hdle_do_game, WM_KEYDOWN , ord('a'), 0);
   keybd_event(65,0,0,0);
SendMessage(hdle_do_game, WM_CHAR, ord('a'), 0);

e o jogo simplesmente n√£o reconhece em sua interface, apenas em √°reas de chatbox, entretanto, o teclado virtual do windows funciona em todo o jogo

alguma sugest√£o? Grato!

co.combinatorics – Combinatorics and geometry underlying a refined Pascal matrix/Newton identities

The partition polynomials of OEIS A263633 give the coefficients of the power series/o.g.f of the multiplicative inverse (reciprocal) of a power series/o.g.f. and so give the Newton identities for transforming between complete homogeneous symmetric polynomials/functions and elementary symmetric polynomials/functions. Certain Koszul duals are related to this.

The algebraic combinatorics of the complementary reciprocal of a Taylor series/e.g.f. is governed by the antipode/refined Euler characteristic classes of the permutahedra or, equivalently, by surjective mappings, so I have an indirect geometric combinatorial interpretation of ‘scaled’ versions of the Newton identities, but I’m looking for more direct interpretations.

What combinatoric/geometric structures are enumerated by the integer coefficients of these partition polynomials for conversion of an o.g.f. into a reciprocal o.g.f.?

Error with conditional on pascal

The error I have in my program is the following, I want to create a program in which the user digits numbers from 1 to 7 but I also need to establish a condition, which is that if the user digits a number less than 1 and greater than 7 The program does not run. This condition is what is giving me problems since it is not fulfilling any of the possibilities.

program dias;
 USES CRT;
 var num:integer;
 begin

 writeln('Digite un numero del 1 al 7');
 num:=2;

 if ((num>=7) and (num<=1) ) then
 begin
 writeln('LUNES');
 end

 else
 begin
writeln('ERROR');
end;


readkey;

 end.

Create ChatBot in Pascal

Hi, I need to create a chat bot in pascal, lazarus but I have no idea how to start.
What kind of method is necessary or procedures / functions.

Element repeated within the matrix – Pascal

I have tried for a long time to produce code that identifies and informs the user if there are repeated elements in a 5×5 random number matrix in pascal. I tried searching the matrix using one or two variables and also with a complete matrix to search, but it didn't work.
Some people have told me that it is not necessary to have a code too large or complex for the task. Then my despair increases.

I ask if anyone has any solution to the problem.

PasteBin link for failed attempt (and the busiest) – https://pastebin.com/uzPLACXe

Dijkstra Algorithm in Pascal — OBI Question

Hi I am practicing for OBI Phase 2 and I need help with the following link problem:
https://olimpiada.ic.unicamp.br/pratique/p1/2018/f2/relogios/

How would the implementation of Dijkstra be in this problem in Pascal?