Easy Live

Simple Programming

30 points

3940 Solves

Programming

Easy

intelagent moderator badge ctflearn++ badge

Community Rating: 4.46 / 5

Can you help me? I need to know how many lines there are where the number of 0's is a multiple of 3 or the numbers of 1s is a multiple of 2. Please! Here is the file: https://mega.nz/#!7aoVEKhK!BAohJ0tfnP7bISIkbADK3qe1yNEkzjHXLKoJoKmqLys

First 10 Solvers

Rank Username
1 koshi
2 jowls
3 ross3102
4 emperorlepone
5 aboudster

  • Formadill

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • KappaDetective

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

    • wannabehacker1234

      Protected

      [REDACTED] This comment is only shown to users who have solved this challenge.

      • Lindaine

        Protected

        [REDACTED] This comment is only shown to users who have solved this challenge.

  • k4at3034

    excellent programming CTF for beginners

  • mo999

    its simple program write script to read the file an count that line which is its one divisible by 2 OR its zeros divisible by 3 simple use mod

  • mo999

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • mo999

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • NorthLake

    I know how I can solve the problem, but what is the flag exactly? It's not explained how the flag should be formulated.

    • intelagent moderator badge ctflearn++ badge

      The flag is just the number. If you were to wrap it in CTFlearn{} it would also work! We have a pretty robust flag checking system!

        • meganuke

          me too! I have the number but I just can't enter the flag

  • A23187

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

    • chobs

      nice... I need to learn awk.

  • NullString

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • yohji

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • IronLarreh_

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • rickdeckard

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • Fl4Gg3R

    I got the answer but what format am i supposed to submit it in????

  • Fl4Gg3R

    This is a really great challenge in my opinion.

  • gosobog

    I used c++ and the hardest part was to put space int the end of every line.

  • gosobog

    I used c++ and the hardest part was to put space int the end of every line.

    • Xavii

      Could you show me the code cause i dont know whats wrong with mine.

  • quido18

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • maroo

    dobra nie chwalcie się tak zjeby że rozwiązaliście łatwe zadanie

  • xyuru

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

    • Lriend

      Protected

      [REDACTED] This comment is only shown to users who have solved this challenge.

  • doteq

    I used regex with node.js ```const fs = require('fs') var text = fs.readFileSync('./data.dat','utf8')

    function count0(bin){ var arr = bin.match(/(0)/g); return arr ? arr.length : 0; } function count1(bin){ var arr = bin.match(/(1)/g); return arr ? arr.length : 0; }

    var binArray = text.split('\n') var succArray = []

    binArray.forEach((bin) => { var zeros = count0(bin); var ones = count1(bin); if(ones % 2 == 0){ succArray.push(bin); } else if(zeros % 3 == 0){ succArray.push(bin); } }); console.log(succArray.length)```

  • makoteq

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • seishin

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • maxk05

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • Kasza

    v cool. needed to remind myself how to read files in py, because i didn't want to do it in bash

  • Mossi13

    Yeah! Excellent task for the beginner. I'm pleased :D

  • cardynlsyn ctflearn++ badge

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • Sidpatchy

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • Nn00b0

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

    • Nn00b0

      Protected

      [REDACTED] This comment is only shown to users who have solved this challenge.

  • xmatar

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • steve_samue

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • Borthwick

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • Theriphunters

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • monkPL

    simple, but first you need to understand the quest

  • chobs

    ``` print(Test Markdown

    ```

  • chobs

    ''' print("Markdown Test")

    '''

  • ImYawn

    TIP for people who are stuck:

    I didn't read the question carefully so I took a lot of time figuring out what was wrong with my answer when I didn't read the question properly. It's asking if the 0 is a multiple of 3 OR if its a multiple 2

  • ImYawn

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • Bnkn

    I did it with Java and the code is a bit longer, but it does the work

  • gugliver

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • TheSourceCoder

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

    • judith

      Cool solution. Here's mine

      x = 0 with open('data.dat', "r") as f: for i in f: if not i: break if (i.count('0') % 3 == 0) | (i.count('1') % 2 == 0): x = x + 1 print("Answer is:", x)

      • judith

        Protected

        [REDACTED] This comment is only shown to users who have solved this challenge.

        • judith

          Protected

          [REDACTED] This comment is only shown to users who have solved this challenge.

  • judith

    You can solve this with a quick python script. Don't forget the OR

  • iSkLz

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • Pems

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • Panics

    User nodejs help const fs = require('fs'); fs.readFile('C:/Users/ASUS/desktop/data.dat', "utf8", (err, data) => { data = data.split("\n") <br /> var x = 0 for(var i = 0 ; i < data.length ; i ++){ if( data[i] % 3 == 0 || data[i] %2 == 0){ x = x+1 } } console.log(x); }); result : 7644 Howww

  • Panics

    Yess i can do it with NODE.JS xD ----> const fs = require('fs'); fs.readFile('C:/Users/ASUS/desktop/data.dat', "utf8", (err, data) => { data = data.split("\n") <br /> var x = 0 <br /> for(var i = 0 ; i < data.length ; i ++){ <br /> var dalam1Line = data[i] , angka0 = 0 , angka1 = 0; for (var z=0; z < dalam1Line.length; z++){ if (dalam1Line[z] == 0) angka0++; } for (var z=0; z < dalam1Line.length; z++){ if (dalam1Line[z] == 1) angka1++; } <br /> if( angka0 % 3 == 0 || angka1 % 2 == 0){ x++ } } console.log(x); });

  • UfaiX04

    without knowing literally anything abount hacking/in this case programming, this took me 3 days straight, really fun challange!

  • pspice2000

    cannot download the file. MegaGay is making me wait 45 minutes

  • pspice2000

    with open('data.dat') as f: lines = [line.rstrip() for line in f] cnt = 0 for line in lines: if line.count("0") % 3 == 0 or line.count("1") % 2 == 0: cnt += 1 print(cnt)

  • pspice2000

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • pjrox

    Lol I dont know how to code in python, It took me so long XD

  • yukselemirhan

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • becktech

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

    • becktech

      Protected

      [REDACTED] This comment is only shown to users who have solved this challenge.

  • blackghost

    If anyone want to get my solution then it is here ""https://github.com/root-ji218at/ctflearn.com/tree/master/Easy/Programming/Simple%20Programming"

  • AtharvParlikar

    here's my solution python count = 0; for line in open("data.dat", "r").readlines(): zero = 0 one = 0 for i in line: if i == '0': zero += 1 elif i == '1': one += 1 if zero % 3 == 0 or one % 2 == 0: count += 1 print(count)

  • Qdoit12

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • psr67

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • NoNaim

    validline = 0 with open("./data.dat","r")as f: for line in f: ocounter = 0 icounter = 0 for char in line: if char == "0": ocounter += 1 elif char == "1": icounter += 1 if ocounter %3 == 0 or icounter % 2 == 0: validline +=1 print(validline)

  • SHaNTuDe

    Protected

    [REDACTED] This comment is only shown to users who have solved this challenge.

  • V1L3N

    Hey @intelagent, I can't do it! Please help me out. Either script isn't working or giving an error :(

  • http263

    fun item made me wind back my python knowledge