Snippets
See what snippets have been added recently
1. no title author: eryk, created: 10:53 18-05-2018
Raw
				woman(ann).

woman(mary).

woman(dorothy).

woman(claudia).

woman(rose).



man(steve).

man(mark).

man(matt).

man(martin).



parent(steve,mary).

parent(steve,dorothy).

parent(ann,mary).

parent(ann,dorothy).

parent(mary,martin).

parent(mary,rose).

parent(mark,martin).

parent(mark,rose).

parent(dorothy,claudia).

parent(matt,claudia).


spouse(steve,ann).
spouse(ann,steve).
spouse(mary,mark).
spouse(mark,mary).
spouse(dorothy,matt).
spouse(matt,dorothy).


mother(X,Y) :- parent(X,Y), woman(X).

father(X,Y) :- parent(X,Y), man(X).



child(X,Y) :- parent(Y, X).



siblings(X,Y) :- parent(Z,X), parent(Z,Y).



husband(X,Y) :- spouse(X,Y), man(X).

wife(X,Y) :- spouse(X,Y), wife(X).



brother(X,Y) :- siblings(X, Y), man(X).

sister(X,Y) :- siblings(X, Y), woman(X).



daughter(X,Y) :- parent(Y, X), woman(X).

son(X,Y) :- parent(Y, X), man(X).



aunt(X,Y) :- parent(Y, X), siblings(Y, Z), woman(Z). 

uncle(X,Y) :- parent(Y, X), siblings(Y, Z), man(Z). 



granddaughter(X,Y) :- parent(X, Z), parent(Z, Y), woman(X).

grandson(X,Y) :- parent(X, Z), parent(Z, Y), man(X).



grandmother(X,Y) :- parent(Y, Z), parent(Z, X), woman(X).

grandfather(X,Y) :- parent(Y, Z), parent(Z, X), man(X).

grandparents(X,Y) :- parent(X, Z), parent(Z, Y).

	

ancestor(X,Y) :- parent(X, Y); grandparents(X,Y).

descendant(X,Y) :- parent(Y,X); grandparents(Y,X).



    
			
2. no title author: anonymous, created: 10:51 18-05-2018
Raw
				woman(ann).

woman(mary).

woman(dorothy).

woman(claudia).

woman(rose).



man(steve).

man(mark).

man(matt).

man(martin).



parent(steve,mary).

parent(steve,dorothy).

parent(ann,mary).

parent(ann,dorothy).

parent(mary,martin).

parent(mary,rose).

parent(mark,martin).

parent(mark,rose).

parent(dorothy,claudia).

parent(matt,claudia).


spouse(steve,ann).
spouse(ann,steve).
spouse(mary,mark).
spouse(mark,mary).
spouse(dorothy,matt).
spouse(matt,dorothy).


mother(X,Y) :- parent(X,Y), woman(X).

father(X,Y) :- parent(X,Y), man(X).



child(X,Y) :- parent(Y, X).



siblings(X,Y) :- parent(Z,X), parent(Z,Y).



husband(X,Y) :- spouse(X,Y), man(X).

wife(X,Y) :- spouse(X,Y), wife(X).



brother(X,Y) :- siblings(X, Y), man(X).

sister(X,Y) :- siblings(X, Y), woman(X).



daughter(X,Y) :- parent(Y, X), woman(X).

son(X,Y) :- parent(Y, X), man(X).



aunt(X,Y) :- parent(Y, X), siblings(Y, Z), woman(Z). 

uncle(X,Y) :- parent(Y, X), siblings(Y, Z), man(Z). 



granddaughter(X,Y) :- parent(X, Z), parent(Z, Y), woman(X).

grandson(X,Y) :- parent(X, Z), parent(Z, Y), man(X).



grandmother(X,Y) :- parent(Y, Z), parent(Z, X), woman(X).

grandfather(X,Y) :- parent(Y, Z), parent(Z, X), man(X).

grandparents(X,Y) :- parent(X, Z), parent(Z, Y).

	

ancestor(X,Y) :- parent(X, Y); grandparents(X,Y).

descendant(X,Y) :- parent(Y,X); grandparents(Y,X).



    
			
3. no title author: anonymous, created: 10:36 18-05-2018
Raw
				    	Ex. 1

=====



We have a family tree:





					Steve i Ann

                          |

            ------------------------------------

            |                                  |

   Mary and [Mark]               Dorothy and [Matt]

            |                                 |

        ---------------------                 |

        |                   |                 |

     Martin                Rose            Claudia

	

	

Lets define facts:



woman(ann).

woman(mary).

woman(dorothy).

woman(claudia).

woman(rose).



man(steve).

man(mark).

man(matt).

man(martin).



parent(steve,mary).

parent(steve,dorothy).

parent(ann,mary).

parent(ann,dorothy).

parent(mary,martin).

parent(mary,rose).

parent(mark,martin).

parent(mark,rose).

parent(dorothy,claudia).

parent(matt,claudia).


spouse(steve,ann).
spouse(ann,steve).
spouse(mary,mark).
spouse(mark,mary).
spouse(dorothy,matt).
spouse(matt,dorothy).


mother(X,Y) :- parent(X,Y), woman(X).

father(X,Y) :- parent(X,Y), man(X).



child(X,Y) :- parent(Y, X).



siblings(X,Y) :- parent(Z,X), parent(Z,Y).



husband(X,Y) :- spouse(X,Y), man(X).

wife(X,Y) :- spouse(X,Y), wife(X).



brother(X,Y) :- siblings(X, Y), man(X).

sister(X,Y) :- siblings(X, Y), woman(X).



daughter(X,Y) :- parent(Y, X), woman(X).

son(X,Y) :- parent(Y, X), man(X).



aunt(X,Y) :- parent(Y, X), siblings(Y, Z), woman(Z). 

uncle(X,Y) :- parent(Y, X), siblings(Y, Z), man(Z). 



granddaughter(X,Y) :- parent(X, Z), parent(Z, Y), woman(X).

grandson(X,Y) :- parent(X, Z), parent(Z, Y), man(X).



grandmother(X,Y) :- parent(Y, Z), parent(Z, X), woman(X).

grandfather(X,Y) :- parent(Y, Z), parent(Z, X), man(X).

grandparents(X,Y) :- parent(Y, Z), parent(Z, X).

	

%ancestor(X,Y) :- parent(X, Z) || grandparents(X,Y).

%descendant(X,Y) :- ...
			
4. prolog author: eryk, created: 9:31 18-05-2018
Raw
				Ex. 1
=====

We have a family tree:


					Steve i Ann
                          |
            ------------------------------------
            |                                  |
   Mary and [Mark]               Dorothy and [Matt]
            |                                 |
        ---------------------                 |
        |                   |                 |
     Martin                Rose            Claudia
	
	
Lets define facts:

woman(ann).
woman(mary).
woman(dorothy).
woman(claudia).
woman(rose).

man(steve).
man(mark).
man(matt).
man(martin).

parent(steve,mary).
parent(steve,dorothy).
parent(ann,mary).
parent(ann,dorothy).
parent(mary,martin).
parent(mary,rose).
parent(mark,martin).
parent(mark,rose).
parent(dorothy,claudia).
parent(matt,claudia).


Lets define rules:

mother(X,Y) :- ...
father(X,Y) :- ...

child(X,Y) :- ...

siblings(X,Y) :- ...

husband(X,Y) :- ...
wife(X,Y) :- ...

brother(X,Y) :- ...
sister(X,Y) :- ...

daughter(X,Y) :- ...
son(X,Y) :- ...

aunt(X,Y) :- ...
uncle(X,Y) :- ...

granddaughter(X,Y) :- ...
grandson(X,Y) :- ...

grandmother(X,Y) :- ...
grandfather(X,Y) :- ...
	
ancestor(X,Y) :- ...
descendant(X,Y) :- ...


Ex. 2
=====

We have ten cities:

huge, 4, 6, 4, 5

small, -3, -4, 1, 2

green, 10, 10, 4, 3

border, -5, 10, 4, 1

center, 2, 1, 4, 3

other, -7, 7, 5, 5

windy, -10, -8, 4, 5

sunny, 3, 5, 2, 1

good, 0, 1, 4, 2

bad, 0, 0, 2, 0 

where the parameters are:

- name
- X position
- Y position
- area
- population

Write the predicates:
 
       populationDensity(X,R)
	   
	   
	   taxiDistance(N1,N2,R)
	   
where taxiDistance between (X1,Y1) and (X2,Y2) is |X1-X2|+|Y1-Y2|

Let's view:

- cities with distance 7,
- cities with population <10,
- border cities (border city is city where |X|=10 or |Y|=10).	   



Ex. 3
=====

The knowledge base is given:

like(ann,jhon).
like(mary,frank).
like(kris,ann).
like(dorothy,ann).
like(george,jhon).
like(frank,iwo).

Add facts or rules to the knowledge base so that the operator like it is symmetrical.

Ex. 4
=====

The knowledge base is given

less(mysz,kot).
less(kot,czlowiek).
less(czlowiek,slon).
less(slon,dom).
less(dom,gora).

Add facts or rules to the knowledge base so that the less operator is transitive.


Ex. 5
=====

Write the predicate

			maximum2(A,B,W)

and

			maximum3(A,B,C,W)

which returns maximum two or three numbers.


Ex. 6
=====

Write the predicate

		ifPositive(X) ifNegative(X)
		
which returns true or false depending on X is positive or not.
			
5. Pyqt4 author: eryk, created: 16:58 21-04-2018
Raw
				import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt, SIGNAL, SLOT, QEvent
from PyQt4.QtGui import QFileDialog, QDialog, QLabel, QLineEdit, QMessageBox, QVBoxLayout, QBoxLayout, QHBoxLayout, \
    QPushButton


class NonModalDialog(QDialog):
    pressed_enter = False

    def __init__(self, parent):
        QDialog.__init__(self, parent)
        self.parent = parent
        self.setModal(0)
        self.setWindowTitle("Nonmodal Dialog")
        label = QLabel('Wpisz nazwe okna i ENTER', self)
        self.txt = QLineEdit(self)
        self.txt.move(0, 50)

        self.setGeometry(200, 300, 300, 200)
        # txt.textChanged.connect(self.set_title)
        # txt.keyPressEvent(self.set_title)
        self.connect(self, SIGNAL("textChanged(QString)"), self, SLOT("textChanged(QString)"))
        app.setWindowIcon(app_icon)
        self.show()

    def exit(self):
        self.close()

    def set_title(self, val=None):
        if val is None:
            val = self.txt.text()
        print('setting', val)
        self.parent.setWindowTitle(val)

    def keyPressEvent(self, event):
        # Did the user press the Escape key?
        print('keyPress', event.key())
        if event.key() == 16777220:
            print('enter')
            self.set_title()
            # super().close()
            # self.close
            self.pressed_enter = True
            self.close()

    def closeEvent(self, event):
        if self.pressed_enter:
            event.accept()
            self.pressed_enter = False
        else:
            event.ignore()


class Main(QtGui.QMainWindow):
    img_map = {
        'smutna': ['3.png', 10],
        'normalna': ['2.png', 50],
        'wesola': ['1.png', 90]
    }
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.initUI()
        self.cb = QtGui.QApplication.clipboard()
        self.opened_file = None
        self.choosen_radio_text = None
        self.img = None

    def initUI(self):
        # todo: need to restart at some point visited file
        # todo: log events
        # self.text_edit = QtGui.QTextEdit()
        # self.setCentralWidget(self.text_edit)
        self.menu_bar = self.menuBar()
        self.fill_menu_items(self.get_file_menu_actions(), 'Dialog')
        self.frm = QtGui.QFrame(self)
        self.bg_color = QtCore.Qt.white
        # self.frm.setStyleSheet("QWidget { background-color: %s }" % col.name())
        self.frm.setGeometry(130, 22, 100, 100)
        self.setCentralWidget(self.frm)
        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('Main window')
        self.show()

    def handler_open(self):
        dlg = QFileDialog()
        dlg.setFileMode(QFileDialog.AnyFile)
        dlg.setFilter("Text files (*.txt)")

        if dlg.exec_():
            filenames = dlg.selectedFiles()
            print('opened', filenames[0])
            self.opened_file = filenames[0]
            with open(filenames[0], 'r') as f:
                data = f.read()
                self.text_edit.setText(data)

    def fill_menu_items(self, q_actions, menu_name):
        menu = self.menu_bar.addMenu(menu_name)
        for action in q_actions:
            menu.addAction(action)

    def get_q_actions(self, actions):
        q_actions = []
        for a in actions:
            action = QtGui.QAction(QtGui.QIcon('icons/' + a['icon']), a['name'], self)
            if a.get('handler'):
                action.triggered.connect(a['handler'])
            q_actions.append(action)
        return q_actions

    def show_color_dialog(self):
        col = QtGui.QColorDialog.getColor(self.bg_color, self)
        if col.isValid():
            self.frm.setStyleSheet("QWidget { background-color: %s }" % col.name())
            self.bg_color = col

    def show_icon_dialog(self):
        self.d = QDialog()
        self.d.setGeometry(300*2, 300*2, 350*2, 250*2)
        # A vertical box layout
        layout = QHBoxLayout()

        # Add the widgets to the layout

        self.number_group1 = QtGui.QButtonGroup(self)  # Number group
        self.number_group1.buttonClicked.connect(self.radio_changed)
        r0 = QtGui.QRadioButton("wesola")
        self.number_group1.addButton(r0)
        r1 = QtGui.QRadioButton("normalna")
        self.number_group1.addButton(r1)
        r2 = QtGui.QRadioButton("smutna")
        self.number_group1.addButton(r2)
        layout.addWidget(QLabel('Wybierz', self.d))
        layout.addWidget(r0)
        layout.addWidget(r1)
        layout.addWidget(r2)

        self.number_group = QtGui.QButtonGroup(self)  # Number group
        self.number_group.buttonClicked.connect(self.checkbox_changed)
        # number_group.buttonClicked.connect(None)
        r0 = QtGui.QCheckBox("wesola")
        self.number_group.addButton(r0)
        r1 = QtGui.QCheckBox("normalna")
        self.number_group.addButton(r1)
        r2 = QtGui.QCheckBox("smutna")
        # r0.stateChanged()
        self.number_group.addButton(r2)
        layout.addWidget(QLabel('wybrano', self.d))
        layout.addWidget(r0)
        layout.addWidget(r1)
        layout.addWidget(r2)

        self.progress = QtGui.QProgressBar(self)
        self.progress.setGeometry(200, 200, 250, 100)
        self.progress.setOrientation(Qt.Vertical)
        layout.addWidget(self.progress)
        layout.addWidget(QLabel('<- Wskaznik zadowolenia'))

        self.pic = QtGui.QLabel(self)
        # pix = QtGui.QPixmap("1.png")
        # pix = pix.scaledToWidth(50)
        # self.pic.setPixmap(pix)
        layout.addWidget(self.pic)
        self.pic.show()  # You were missing this.

        b1 = QPushButton("Ok", self.d)
        b1.clicked.connect(self.ok)
        b2 = QPushButton("Anuluj", self.d)
        layout.addWidget(b1)
        layout.addWidget(b2)

        self.d.setLayout(layout)
        self.d.setWindowTitle("Dialog")
        self.d.setWindowModality(Qt.ApplicationModal)

        self.restore()
        self.d.exec_()

    def radio_changed(self, value):
        val = self.img_map[value.text()]
        self.radio_ch(val, value.text())
        self.choosen_radio_text = value.text()

    def restore(self):
        print(self.choosen_radio_text)
        if self.choosen_radio_text:
            val = self.img_map[self.choosen_radio_text]
            for btn in self.number_group1.buttons():
                if btn.text() == self.choosen_radio_text:
                    btn.setChecked(True)
                    break
            self.radio_ch(val, self.choosen_radio_text)

    def radio_ch(self, val, btn_text):
        print('radio ch', val, btn_text)
        pix = QtGui.QPixmap(val[0])
        pix = pix.scaledToWidth(50)
        self.pic.setPixmap(pix)
        self.img = val[0]
        self.progress.setValue(val[1])
        for btn in self.number_group.buttons():
            if btn.text() == btn_text:
                btn.setChecked(True)

    def checkbox_changed(self, value):
        print('checkbox', value.text(), value.isChecked())
        value.setChecked(False)
        checked_radio = None
        for btn in self.number_group1.buttons():
            if btn.isChecked():
                checked_radio = btn
                break

        if checked_radio:
            for btn in self.number_group.buttons():
                print(btn, btn.text())
                if btn.text() == checked_radio.text():
                    btn.setChecked(True)

    def show_non_modal(self):
        NonModalDialog(self)

    def ok(self):
        print(self.number_group.buttons())
        if self.img:
            self.setWindowIcon(QtGui.QIcon(self.img))
        self.d.close()
        print(self.number_group.buttons())

    def get_file_menu_actions(self):
        actions = [
            {
                'icon': 'new-file.png',
                'name': 'Nazwa okna głownego',
                'handler': self.show_non_modal
            },
            {
                'icon': 'open.png',
                'name': 'Ustaw kolor tla',
                'handler': self.show_color_dialog
            },
            {
                'icon': 'save.png',
                'name': 'Zmien ikone',
                'handler': self.show_icon_dialog
            }
        ]
        return self.get_q_actions(actions)


def main():
    app = QtGui.QApplication(sys.argv)
    main = Main()
    main.show()

    sys.exit(app.exec_())


main()
			
6. Pyx example author: eryk, created: 16:58 21-04-2018
Raw
				from pyx import *
from collections import Counter

words = ['1', '22', '333', '4444', '4444']
words_length = [len(word) for word in words]
letter_counts = Counter(words_length)

print(words_length)
print(letter_counts)

with open('data.txt', 'w+') as f:
    for word_len, word_occurrences in letter_counts.items():
        f.write('%s %s\n' % (word_len, word_occurrences))


g = graph.graphxy(width=8, x=graph.axis.bar())
g.plot(graph.data.file("data.txt", xname=0, y=2), [graph.style.bar()])
g.writeEPSfile("minimal")
g.writePDFfile("minimal")
g.writeSVGfile("minimal")
			
7. PyQt4 window author: eryk, created: 16:58 21-04-2018
Raw
				import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt, SIGNAL, SLOT, QEvent, QRegExp
from PyQt4.QtGui import QFileDialog, QDialog, QLabel, QLineEdit, QMessageBox, QVBoxLayout, QBoxLayout, QHBoxLayout, \
    QPushButton, QSlider, QRegExpValidator


class Main(QtGui.QMainWindow):

    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.initUI()

    def initUI(self):
        self.menu_bar = self.menuBar()
        self.fill_menu_items(self.get_file_menu_actions(), 'Dialog')
        self.frm = QtGui.QFrame(self)
        self.bg_color = QtCore.Qt.white
        self.setWindowIcon(QtGui.QIcon('face.jpg'))
        # self.frm.setStyleSheet("QWidget { background-color: %s }" % col.name())
        self.frm.setGeometry(130, 22, 100, 100)
        self.setCentralWidget(self.frm)
        self.setGeometry(300, 300, 350, 250)
        self.setWindowTitle('Dialogi')
        self.show()

    def fill_menu_items(self, q_actions, menu_name):
        menu = self.menu_bar.addMenu(menu_name)
        for action in q_actions:
            menu.addAction(action)

    def get_q_actions(self, actions):
        q_actions = []
        for a in actions:
            action = QtGui.QAction(QtGui.QIcon('icons/' + a['icon']), a['name'], self)
            if a.get('handler'):
                action.triggered.connect(a['handler'])
            q_actions.append(action)
        return q_actions

    def show_color_dialog(self):
        self.d = QDialog()
        self.d.setGeometry(300*2, 300*2, 350*2, 250)

        self.slider1 = QSlider(Qt.Horizontal)
        self.slider2 = QSlider(Qt.Horizontal)
        self.slider3 = QSlider(Qt.Horizontal)
        self.slider1.setMaximum(255)
        self.slider2.setMaximum(255)
        self.slider3.setMaximum(255)
        self.slider1.setMinimum(0)
        self.slider2.setMinimum(0)
        self.slider3.setMinimum(0)

        self.slider1_text = QLineEdit('0')
        self.slider2_text = QLineEdit('0')
        self.slider3_text = QLineEdit('0')
        reg_ex = QRegExp("\d+")
        slider1_validator = QRegExpValidator(reg_ex, self.slider1)
        objValidator = QtGui.QIntValidator(self)
        objValidator.setRange(0, 255)

        self.slider1_text.setValidator(objValidator)
        self.slider2_text.setValidator(objValidator)
        self.slider3_text.setValidator(objValidator)
        self.slider1_text.textChanged.connect(self.changed_1)
        self.slider2_text.textChanged.connect(self.changed_2)
        self.slider3_text.textChanged.connect(self.changed_3)
        self.pushButton = QtGui.QPushButton()
        self.pushButton.setGeometry(QtCore.QRect(0, 550, 150, 31))
        self.pushButton.setStyleSheet("background-color: red")

        self.slider1_text.resize(30, 30)

        self.slider1.valueChanged.connect(self.slider1_change)
        self.slider2.valueChanged.connect(self.slider2_change)
        self.slider3.valueChanged.connect(self.slider3_change)

        layout = QtGui.QGridLayout()
        btn_ok = QtGui.QPushButton('OK', self)
        btn_ok.clicked.connect(self.ok)
        btn_cancel = QtGui.QPushButton('Anuluj', self)
        btn_cancel.clicked.connect(self.cancel)

        layout.addWidget(self.slider1, 0, 1, 1, 3)
        layout.addWidget(self.slider1_text, 0, 4, 1, 3)
        layout.addWidget(self.slider2, 1, 1, 1, 3)
        layout.addWidget(self.slider2_text, 1, 4, 1, 3)
        layout.addWidget(self.slider3, 2, 1, 1, 3)
        layout.addWidget(self.slider3_text, 2, 4, 1, 3)
        layout.addWidget(btn_ok, 3, 3, 1, 2)
        layout.addWidget(btn_cancel, 3, 5, 1, 2)

        self.pushButton.setFixedSize(80, 80)
        layout.addWidget(self.pushButton, 1, 8, 2, 1)

        self.d.setLayout(layout)
        self.d.setWindowTitle("Ustaw kolor tla")
        self.d.setWindowModality(Qt.ApplicationModal)

        self.d.exec_()

    def cancel(self):
        self.d.close()

    def drawRectangles(self, qp):
        qp.setBrush(QtGui.QColor(000, 000, 255))
        qp.drawRect(0, 0, 90, 60)

    def slider1_change(self, value):
        self.slider1_text.setText(str(value))
        self.change_color()

    def slider2_change(self, value):
        self.slider2_text.setText(str(value))
        self.change_color()

    def slider3_change(self, value):
        self.slider3_text.setText(str(value))
        self.change_color()

    def changed_1(self, value):
        if not value:
            return
        print(value, type(value))
        self.slider1.setValue(int(value))

    def changed_2(self, value):
        if not value:
            return
        self.slider2.setValue(int(value))

    def changed_3(self, value):
        if not value:
            return
        self.slider3.setValue(int(value))

    def zmien_ikone(self):
        pass

    def change_color(self):
        r, g, b = self.slider1_text.text(), self.slider2_text.text(), self.slider3_text.text()
        self.pushButton.setStyleSheet("QWidget { background-color: rgb(%s, %s, %s) }" % (r, g, b))

    def ok(self):
        r, g, b = self.slider1_text.text(), self.slider2_text.text(), self.slider3_text.text()
        self.frm.setStyleSheet("QWidget { background-color: rgb(%s, %s, %s) }" % (r, g, b))
        # self.bg_color = col
        self.d.close()

    def get_file_menu_actions(self):
        actions = [
            {
                'icon': '',
                'name': 'Ustaw kolor tla',
                'handler': self.show_color_dialog
            },
            {
                'icon': '',
                'name': 'Zmien ikone',
                'handler': self.zmien_ikone
            }
        ]
        return self.get_q_actions(actions)


def main():
    app = QtGui.QApplication(sys.argv)
    main = Main()
    main.show()

    sys.exit(app.exec_())


main()
			
8. no title author: eryk, created: 16:57 21-04-2018
Raw
				using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // number of spaces
            const int n = 5;
            //DrawPiramid(n);
            //
            Console.WriteLine(IsSemiPrimeNumber(2));
            DrawL(9);
            Console.ReadKey();
        }

        static void DrawPiramid(int n)
        {
            int s = 2 * n - 2;
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j <= s; j++)
                {
                    Console.Write(" ");
                }
                s -= 1;
                for (int j = 0; j <= i; j++)
                {
                    Console.Write("* ");
                }
                Console.WriteLine();
            }
        }

        static bool IsDividedBy6(string value)
        {
            int number = Int32.Parse(value);
            return number % 6 == 0;
        }

        static bool IsSemiPrimeNumber(int value)
        {
            for (int i = 0; i < value + 1; i += 1)
            {
                if (IsPrime(i))
                {
                    for (int j = 0; j < value + 1; j += 1)
                    {
                        if (IsPrime(j) && j * i == value) {
                            return true;
                        }
                    }
                }
            }
            return false;
        }

        static bool IsPrime(int n)
        {
            if (n > 1)
            {
                return Enumerable.Range(1, n).Where(x => n % x == 0)
                                 .SequenceEqual(new[] { 1, n });
            }

            return false;
        }

        static void DrawL(int n)
        {
            int thinWidth = (int)n * 2 / 8;
            int thinHeight = (int)n * 6 / 9;
            Console.WriteLine(thinHeight);
            Console.WriteLine(thinWidth);
            for (int i = 0; i < n; i += 1)
            {
                for (int j = 0; j < n; j += 1)
                {
                    if (j < thinWidth || i >= thinHeight)
                    {
                        Console.Write("X");
                    }
                    else if (j < thinHeight)
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }
        }
    }
}