Hello everybody,
I'd like to introduce you to some rather interesting examples
proposed by teachers S.Gorlitskaya and I.Kuznetsova from
St.Petersburg and posted in Russian newspaper "Informatics".
I think these examples are in time for our "word games".
Here are the first ones.
The main procedure reads a number as a word.
how_digits? counts the "sensible" digits of the number.
Then invert calls inverty, which returns the inverted number.
I've slightly changed the initial code, and if there is something
wrong here, it's my fault.
---------------------------------
to how_digits? :n
;counts the "sensible"(?) digits of the number
if emptyp :n [op 0]
ifelse not (first :n)=0[op count :n]~
[op how_digits? butfirst :n]
end
to invert :n
op inverty how_digits? :n :n 0
end
to inverty :k :n :new_n
; inverts the initial number :n and returnes it as :new_n
if :k=0 [op :new_n]
op inverty :k-1 int :n/10 10*:new_n+remainder :n 10
end
to main
pr [input any number, it may begin with 0 ==>]
pr invert rw
end
------------------------------------------------------
Regards,
Olga.
---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org. Mail
questions about the list administration to logofdn@gsn.org. To
unsubscribe send unsubscribe logo-l to majordomo@gsn.org.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home