Hadi_Rastgele (Coding_challange)

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Uzman Üye
Katılım
19 Nis 2020
Mesajlar
298
Çözümler
6
Tepki puanı
38
Ödüller
4
6 HİZMET YILI
Özellikle yeni başlayan arkadaşlar için bir challenge. Ekte verilen dosyada 4 basamaklı yaklaşık 400.000 sayı bulunmakta. Cevap olarak belirli patternde bulunan sayıların toplamı istenmekte. Cevap veya yardım harici lütfen boş flood yapmayınız. İstediğiniz herhangi bir dil ile çalışabilirsiniz. Python'u hem yeni başlayanların çok kullandığı hemde yazması kolay bir dil olduğu için seçtim.

"random.txt" dosyasında her satırda 4 tane 4 haneli sayı olmak üzere 100.000 satır yer almaktadır. Bu dosyadaki 2000 ve onun katlarında yer alan tüm satırları kullanarak görseldeki örneğe benzer bir dönüştürme işlemi gerçekleştirmeniz istenmektedir.

İpucu: Cevap olarak 6 basamaklı bir tam sayı elde etmeniz gerekmekte.

Rastgele_soru.png
 

Ekli dosyalar

  • random.txt
    1.9 MB · Görüntüleme: 41
☆☆Her oyun bir gün hileyi tadacaktır☆☆
Griffin Premium
Katılım
12 Kas 2017
Mesajlar
13,726
Çözümler
240
Tepki puanı
5,132
Ödüller
23
8 HİZMET YILI
Çalısmalara başlayalım ozaman
 
Uzman Üye
Katılım
31 Tem 2017
Mesajlar
297
Tepki puanı
19
Ödüller
5
Yaş
28
8 HİZMET YILI
Udemy den öğrendiğim kadarıyla yardımcı olmaya çalışacağım
 
Onaylı Üye
Katılım
25 Nis 2020
Mesajlar
75
Çözümler
1
Tepki puanı
7
Yaş
29
6 HİZMET YILI
Eline Sağlık dostum güzel paylaşımlar forumda olması güzel oluyor +1
 
Süper Üye
Katılım
22 Mar 2020
Mesajlar
608
Çözümler
5
Tepki puanı
71
Ödüller
5
Yaş
26
6 HİZMET YILI
eline sağlık reis adamsın
 
ég ríf ykkur í bita
Süper Üye
Katılım
15 Tem 2019
Mesajlar
756
Çözümler
3
Tepki puanı
91
Ödüller
6
6 HİZMET YILI
burası ağır masaymış.
 
Rodß
Uzman Üye
Katılım
21 Kas 2017
Mesajlar
191
Tepki puanı
6
Ödüller
4
Yaş
25
8 HİZMET YILI
Eline sağlık güzel çalışma yapmayı deniyecem
 
Üye
Katılım
19 Şub 2017
Mesajlar
6
Tepki puanı
0
Ödüller
9
9 HİZMET YILI
Ben şöyle yaptım.

Python:
import pandas as pd

excel_file_name = 'Random.xlsx'
Excel = pd.ExcelFile(excel_file_name)
Sheets = Excel.sheet_names

for Sheet in Excel.sheet_names:
    print('Sheet Name: ' + Sheet)
    Current_Sheet = pd.read_excel(excel_file_name, sheet_name=Sheet)
    Current_Sheet.index = Current_Sheet.index + 1
    Ans = 0
    Cur_Row_Index = 2000
    multipl = 1
    Max_Row_Num = len(Current_Sheet)
    Cur_item_Index = 3
    print('Total row count : {}'.format(Max_Row_Num))
    for index, row in Current_Sheet.iterrows():
        if index == (Cur_Row_Index * multipl):
            print('Current index : {}'.format(index))
            multipl += 1
            if Cur_item_Index < 0:
                Cur_item_Index = 3
            old_row_item = row[Cur_item_Index]
            row[Cur_item_Index] = row[3]
            row[3] = old_row_item
            Curr_Item = row[Cur_item_Index]
            Curr_Ans = Ans
            Ans += Curr_Item
            print('Current : {} + {} = {}'.format(Curr_Ans, Curr_Item, Ans))
            Cur_item_Index -= 1
    print('Ans : {}'.format(Ans))

çıktı

Kod:
Sheet Name: Sayfa1
Total row count : 100000
Current index : 2000
Current : 0 + 7621 = 7621
Current index : 4000
Current : 7621 + 5845 = 13466
Current index : 6000
Current : 13466 + 2095 = 15561
Current index : 8000
Current : 15561 + 4781 = 20342
Current index : 10000
Current : 20342 + 8487 = 28829
Current index : 12000
Current : 28829 + 4607 = 33436
Current index : 14000
Current : 33436 + 7018 = 40454
Current index : 16000
Current : 40454 + 4166 = 44620
Current index : 18000
Current : 44620 + 7373 = 51993
Current index : 20000
Current : 51993 + 8519 = 60512
Current index : 22000
Current : 60512 + 5986 = 66498
Current index : 24000
Current : 66498 + 9766 = 76264
Current index : 26000
Current : 76264 + 1032 = 77296
Current index : 28000
Current : 77296 + 8688 = 85984
Current index : 30000
Current : 85984 + 1894 = 87878
Current index : 32000
Current : 87878 + 3558 = 91436
Current index : 34000
Current : 91436 + 8194 = 99630
Current index : 36000
Current : 99630 + 1670 = 101300
Current index : 38000
Current : 101300 + 2111 = 103411
Current index : 40000
Current : 103411 + 6742 = 110153
Current index : 42000
Current : 110153 + 7110 = 117263
Current index : 44000
Current : 117263 + 4639 = 121902
Current index : 46000
Current : 121902 + 8522 = 130424
Current index : 48000
Current : 130424 + 2159 = 132583
Current index : 50000
Current : 132583 + 1723 = 134306
Current index : 52000
Current : 134306 + 2629 = 136935
Current index : 54000
Current : 136935 + 5996 = 142931
Current index : 56000
Current : 142931 + 7405 = 150336
Current index : 58000
Current : 150336 + 6432 = 156768
Current index : 60000
Current : 156768 + 8289 = 165057
Current index : 62000
Current : 165057 + 3879 = 168936
Current index : 64000
Current : 168936 + 5202 = 174138
Current index : 66000
Current : 174138 + 3544 = 177682
Current index : 68000
Current : 177682 + 3855 = 181537
Current index : 70000
Current : 181537 + 5625 = 187162
Current index : 72000
Current : 187162 + 7836 = 194998
Current index : 74000
Current : 194998 + 4026 = 199024
Current index : 76000
Current : 199024 + 3553 = 202577
Current index : 78000
Current : 202577 + 8138 = 210715
Current index : 80000
Current : 210715 + 2064 = 212779
Current index : 82000
Current : 212779 + 2030 = 214809
Current index : 84000
Current : 214809 + 4873 = 219682
Current index : 86000
Current : 219682 + 3953 = 223635
Current index : 88000
Current : 223635 + 1032 = 224667
Current index : 90000
Current : 224667 + 6147 = 230814
Current index : 92000
Current : 230814 + 6049 = 236863
Current index : 94000
Current : 236863 + 1024 = 237887
Current index : 96000
Current : 237887 + 9576 = 247463
Current index : 98000
Current : 247463 + 8261 = 255724
Current index : 100000
Current : 255724 + 7358 = 263082
Ans : 263082
 
Son düzenleme:
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst